feat(notes/nui): Notes initial commit

This commit is contained in:
chip committed 2020-10-29 00:07:56 +01:00
1 parent 3f6600c28c
commit f1aea97cc4
12 files changed
+228

No files matched your search

+3
View File
@@ -0,0 +1,3 @@
#notes-app.Mui-Selected:focus {
border-bottom: 2px solid #f9a825;
}
+46
View File
@@ -0,0 +1,46 @@
import React from 'react'
import { AppWrapper } from '../../ui/components/AppWrapper';
import { AppContent } from '../../ui/components/AppContent';
import NotesTitle from './NotesTitle';
import NoteList from './list/NoteList';
import { useNotes } from './hooks/useNotes';
import { AddNoteModal } from './modal/AddNoteModal';
import { Button, Fab } from '@material-ui/core';
import AddIcon from '@material-ui/icons/Add';
import { useNoteModal } from './hooks/useNoteModal';
import useStyles from './notes.styles';
export const NotesApp = () => {
const { noteModal, setNoteModal } = useNoteModal();
const notes = useNotes();
const classes = useStyles();
const handleModal = () => {
setNoteModal(true)
}
return (
<AppWrapper id="notes-app">
<NotesTitle />
<AddNoteModal />
<div className={ noteModal ? classes.backgroundModal : undefined} />
<AppContent>
<NoteList notes={notes}/>
<Fab
onClick={handleModal}
style={{
background: '#f9a825',
color: '#fff'
}}
>
<AddIcon />
</Fab>
</AppContent>
</AppWrapper>
)
}
+18
View File
@@ -0,0 +1,18 @@
import React from 'react'
import useStyles from './notes.styles';
import { Paper } from "@material-ui/core";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faStickyNote } from "@fortawesome/free-solid-svg-icons";
const NotesTitle = () => {
const classes = useStyles()
return (
<Paper elevation={24} square variant="outlined" className={classes.header}>
<FontAwesomeIcon icon={faStickyNote} style={{ }} size="lg" />
</Paper>
)
}
export default NotesTitle;
+12
View File
@@ -0,0 +1,12 @@
import { atom } from 'recoil';
export const noteStates = {
noteItems: atom({
key: 'noteItem',
default: []
}),
noteModal: atom({
key: 'noteModal',
default: true
})
}
@@ -0,0 +1,7 @@
import { useRecoilState } from 'recoil';
import { noteStates } from './state';
export const useNoteModal = () => {
const [noteModal, setNoteModal] = useRecoilState(noteStates.noteModal);
return { noteModal, setNoteModal };
}
+7
View File
@@ -0,0 +1,7 @@
import { useRecoilValue } from 'recoil';
import { noteStates } from './state';
export const useNotes = () => {
const notes = useRecoilValue(noteStates.noteItems);
return notes;
}
@@ -0,0 +1,10 @@
import { useSetRecoilState } from 'recoil'
import { useNuiEvent } from '../../../os/nui-events/hooks/useNuiEvent';
import { useNotes } from './useNotes';
import { noteStates } from './state';
export const useNotesService = () => {
const setNotes = useSetRecoilState(noteStates.noteItems);
useNuiEvent('NOTES', 'setNotes', setNotes);
return useNotes();
}
+10
View File
@@ -0,0 +1,10 @@
import { ListItem, ListItemText } from '@material-ui/core'
import React from 'react'
export const NoteItem = (note) => {
return (
<ListItem button divider>
<ListItemText>{note.title}</ListItemText>
</ListItem>
)
}
+16
View File
@@ -0,0 +1,16 @@
import { List } from '@material-ui/core';
import React from 'react'
import { NoteItem } from './NoteItem';
// add search bar later
const NoteList = ({notes}) => {
return (
<List>
{notes.map((note) => (
<NoteItem key={note.id} {...note} />
))}
</List>
)
}
export default NoteList;
@@ -0,0 +1,57 @@
import { Button, List, ListItem, TextField } from '@material-ui/core';
import React, { useState } from 'react'
import Modal from '../../../ui/components/Modal';
import ClearIcon from "@material-ui/icons/Clear";
import { useNoteModal } from '../hooks/useNoteModal';
import useStyles from './modal.styles';
import '../NotesApp.css'
export const AddNoteModal = () => {
const [title, setTitle] = useState('');
const [content, setContent] = useState('');
const classes = useStyles();
const {noteModal, setNoteModal} = useNoteModal();
const _handleClose = () => {
setNoteModal(false);
}
return (
<Modal visible={noteModal} handleClose={_handleClose}>
<Button onClick={_handleClose} className={classes.closeButton}><ClearIcon /></Button>
<List style={{ marginTop: 20 }}>
<ListItem>
<TextField
fullWidth
className={classes.input}
placeholder="Title"
inputProps={{
className: classes.inputStyles
}}
value={title}
variant="standard"
onChange={e => setTitle(e.target.value)}
/>
</ListItem>
<ListItem>
<TextField
fullWidth
className={classes.input}
placeholder="Some shit"
value={content}
onChange={e => setContent(e.target.value)}
variant="outlined"
multiline
inputProps={{
className: classes.inputStyles
}}
/>
</ListItem>
</List>
</Modal>
)
}
@@ -0,0 +1,17 @@
import { makeStyles } from '@material-ui/core';
const useStyles = makeStyles((theme) => ({
closeButton: {
width: '10%',
position: 'absolute',
right: 0
},
input: {
},
inputStyles: {
}
}))
export default useStyles;
+25
View File
@@ -0,0 +1,25 @@
import { makeStyles } from '@material-ui/core';
const useStyles = makeStyles((theme) => ({
header: {
width: '100%',
display: 'flex',
flexFlow: 'row nowrap',
justifyContent: 'center',
alignItems: 'center',
textAlign: 'center',
height: '60px'
},
backgroundModal: {
background: "black",
opacity: "0.6",
position: "absolute",
top: 0,
left: 0,
right: 0,
bottom: 0,
zIndex: 5,
},
}))
export default useStyles;