mirror of
https://github.com/sergeyyarkov/todo-app.git
synced 2026-10-11 02:19:04 +03:00
refactor styles
This commit is contained in:
parent
2aa914ea4a
commit
437b18536d
@ -1,6 +1,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import Nav from '../Nav/Nav'
|
import Nav from '../Nav/Nav'
|
||||||
import { AppBar, IconButton, Toolbar, Typography, makeStyles } from '@material-ui/core'
|
import useStyles from './styles'
|
||||||
|
import { AppBar, IconButton, Toolbar, Typography } from '@material-ui/core'
|
||||||
|
|
||||||
import MenuIcon from '@material-ui/icons/Menu';
|
import MenuIcon from '@material-ui/icons/Menu';
|
||||||
import CategoryIcon from '@material-ui/icons/Category';
|
import CategoryIcon from '@material-ui/icons/Category';
|
||||||
@ -8,28 +9,6 @@ import DeleteIcon from '@material-ui/icons/Delete';
|
|||||||
import ErrorIcon from '@material-ui/icons/Error';
|
import ErrorIcon from '@material-ui/icons/Error';
|
||||||
import FormatListBulletedIcon from '@material-ui/icons/FormatListBulleted';
|
import FormatListBulletedIcon from '@material-ui/icons/FormatListBulleted';
|
||||||
|
|
||||||
const useStyles = makeStyles((theme) => ({
|
|
||||||
pageHeading: {
|
|
||||||
display: 'flex',
|
|
||||||
alignItems: 'center',
|
|
||||||
},
|
|
||||||
pageHeadingImg: {
|
|
||||||
marginRight: 10
|
|
||||||
},
|
|
||||||
appBar: {
|
|
||||||
[theme.breakpoints.up('sm')]: {
|
|
||||||
width: `calc(100% - 240px)`,
|
|
||||||
marginLeft: 240,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
menuButton: {
|
|
||||||
marginRight: theme.spacing(2),
|
|
||||||
[theme.breakpoints.up('sm')]: {
|
|
||||||
display: 'none',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}));
|
|
||||||
|
|
||||||
const renderHeading = (history, classes) => {
|
const renderHeading = (history, classes) => {
|
||||||
const { pathname } = history.location
|
const { pathname } = history.location
|
||||||
|
|
||||||
@ -48,7 +27,7 @@ const renderHeading = (history, classes) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const Header = ({ history }) => {
|
const Header = ({ history }) => {
|
||||||
const classes = useStyles();
|
const classes = useStyles()
|
||||||
const [mobileOpen, setMobileOpen] = React.useState(false);
|
const [mobileOpen, setMobileOpen] = React.useState(false);
|
||||||
|
|
||||||
const handleDrawerToggle = () => {
|
const handleDrawerToggle = () => {
|
||||||
|
|||||||
25
client/src/components/Header/styles.js
Normal file
25
client/src/components/Header/styles.js
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
import { makeStyles } from '@material-ui/core';
|
||||||
|
|
||||||
|
const useStyles = makeStyles((theme) => ({
|
||||||
|
pageHeading: {
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
},
|
||||||
|
pageHeadingImg: {
|
||||||
|
marginRight: 10
|
||||||
|
},
|
||||||
|
appBar: {
|
||||||
|
[theme.breakpoints.up('sm')]: {
|
||||||
|
width: `calc(100% - 240px)`,
|
||||||
|
marginLeft: 240,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
menuButton: {
|
||||||
|
marginRight: theme.spacing(2),
|
||||||
|
[theme.breakpoints.up('sm')]: {
|
||||||
|
display: 'none',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
export default useStyles
|
||||||
@ -1,21 +1,9 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import Header from '../Header/Header';
|
import Header from '../Header/Header';
|
||||||
import { makeStyles } from '@material-ui/core/styles'
|
import useStyles from './styles'
|
||||||
|
|
||||||
const useStyles = makeStyles((theme) => ({
|
|
||||||
layout: {
|
|
||||||
display: 'flex'
|
|
||||||
},
|
|
||||||
toolbar: theme.mixins.toolbar,
|
|
||||||
content: {
|
|
||||||
flexGrow: 1,
|
|
||||||
padding: theme.spacing(3),
|
|
||||||
},
|
|
||||||
}))
|
|
||||||
|
|
||||||
const Layout = ({ children, history }) => {
|
const Layout = ({ children, history }) => {
|
||||||
const classes = useStyles()
|
const classes = useStyles()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classes.layout}>
|
<div className={classes.layout}>
|
||||||
<Header history={history} />
|
<Header history={history} />
|
||||||
|
|||||||
14
client/src/components/Layout/styles.js
Normal file
14
client/src/components/Layout/styles.js
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import { makeStyles } from '@material-ui/core/styles'
|
||||||
|
|
||||||
|
const useStyles = makeStyles((theme) => ({
|
||||||
|
layout: {
|
||||||
|
display: 'flex'
|
||||||
|
},
|
||||||
|
toolbar: theme.mixins.toolbar,
|
||||||
|
content: {
|
||||||
|
flexGrow: 1,
|
||||||
|
padding: theme.spacing(3),
|
||||||
|
},
|
||||||
|
}))
|
||||||
|
|
||||||
|
export default useStyles
|
||||||
@ -1,26 +1,16 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
|
import useStyles from './styles'
|
||||||
import NavContent from './NavContent/NavContent'
|
import NavContent from './NavContent/NavContent'
|
||||||
import CreateCategoryModal from '../Modals/Category/CreateCategoryModal'
|
import CreateCategoryModal from '../Modals/Category/CreateCategoryModal'
|
||||||
import { Drawer, Hidden, makeStyles, useTheme } from '@material-ui/core';
|
import { Drawer, Hidden, useTheme } from '@material-ui/core';
|
||||||
|
|
||||||
const useStyles = makeStyles((theme) => ({
|
|
||||||
drawer: {
|
|
||||||
[theme.breakpoints.up('sm')]: {
|
|
||||||
width: 240,
|
|
||||||
flexShrink: 0,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
drawerPaper: {
|
|
||||||
width: 240,
|
|
||||||
},
|
|
||||||
}));
|
|
||||||
|
|
||||||
const Nav = ({ window, mobileOpen, handleDrawerToggle, history }) => {
|
const Nav = ({ window, mobileOpen, handleDrawerToggle, history }) => {
|
||||||
const classes = useStyles();
|
const classes = useStyles()
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const container = window !== undefined ? () => window().document.body : undefined;
|
const container = window !== undefined ? () => window().document.body : undefined;
|
||||||
|
|
||||||
const [isModalOpen, setIsModalOpen] = React.useState(false)
|
const [isModalOpen, setIsModalOpen] = React.useState(false)
|
||||||
|
|
||||||
const handleCloseModal = () => setIsModalOpen(false)
|
const handleCloseModal = () => setIsModalOpen(false)
|
||||||
const handleOpenModal = () => setIsModalOpen(true)
|
const handleOpenModal = () => setIsModalOpen(true)
|
||||||
|
|
||||||
@ -46,13 +36,7 @@ const Nav = ({ window, mobileOpen, handleDrawerToggle, history }) => {
|
|||||||
</Drawer>
|
</Drawer>
|
||||||
</Hidden>
|
</Hidden>
|
||||||
<Hidden xsDown implementation="css">
|
<Hidden xsDown implementation="css">
|
||||||
<Drawer
|
<Drawer classes={{paper: classes.drawerPaper}} variant="permanent" open>
|
||||||
classes={{
|
|
||||||
paper: classes.drawerPaper,
|
|
||||||
}}
|
|
||||||
variant="permanent"
|
|
||||||
open
|
|
||||||
>
|
|
||||||
<NavContent handleOpenModal={handleOpenModal} history={history} />
|
<NavContent handleOpenModal={handleOpenModal} history={history} />
|
||||||
</Drawer>
|
</Drawer>
|
||||||
</Hidden>
|
</Hidden>
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import useStyles from '../styles'
|
||||||
import Categories from '../../Categories/Categories'
|
import Categories from '../../Categories/Categories'
|
||||||
import { Link } from 'react-router-dom'
|
import { Link } from 'react-router-dom'
|
||||||
|
import { Divider, List, ListItemIcon, ListItemText, Collapse, ListItem, IconButton, Typography } from '@material-ui/core'
|
||||||
import MuiLink from '@material-ui/core/Link';
|
import MuiLink from '@material-ui/core/Link';
|
||||||
import { Divider, List, ListItemIcon, ListItemText, Collapse, ListItem, IconButton, Typography, makeStyles } from '@material-ui/core'
|
|
||||||
|
|
||||||
import FormatListBulletedIcon from '@material-ui/icons/FormatListBulleted';
|
import FormatListBulletedIcon from '@material-ui/icons/FormatListBulleted';
|
||||||
import CategoryIcon from '@material-ui/icons/Category';
|
import CategoryIcon from '@material-ui/icons/Category';
|
||||||
@ -14,49 +15,12 @@ import ExpandMore from '@material-ui/icons/ExpandMore'
|
|||||||
|
|
||||||
import categories from '../../../db/categories.json'
|
import categories from '../../../db/categories.json'
|
||||||
|
|
||||||
const useStyles = makeStyles((theme) => ({
|
|
||||||
navHeading: {
|
|
||||||
padding: '10px 0px 10px 16px',
|
|
||||||
minHeight: 64,
|
|
||||||
display: 'flex',
|
|
||||||
alignItems: 'center',
|
|
||||||
color: 'rgba(255, 255, 255, 0.7)'
|
|
||||||
},
|
|
||||||
githubIcon: {
|
|
||||||
marginLeft: 10
|
|
||||||
},
|
|
||||||
author: {
|
|
||||||
display: 'flex',
|
|
||||||
alignItems: 'center',
|
|
||||||
marginTop: 10
|
|
||||||
},
|
|
||||||
nested: {
|
|
||||||
paddingLeft: theme.spacing(4)
|
|
||||||
},
|
|
||||||
addCategoryItem: {
|
|
||||||
display: 'flex',
|
|
||||||
justifyContent: 'center'
|
|
||||||
},
|
|
||||||
link: {
|
|
||||||
textDecoration: 'none',
|
|
||||||
color: '#fff'
|
|
||||||
}
|
|
||||||
}))
|
|
||||||
|
|
||||||
const NavContent = ({ history, handleOpenModal }) => {
|
const NavContent = ({ history, handleOpenModal }) => {
|
||||||
const classes = useStyles()
|
const classes = useStyles()
|
||||||
const [collapseInfo, setCollapseInfo] = React.useState({
|
const [collapseInfo, setCollapseInfo] = React.useState({ idCollapse: 0, isCollapseOpen: false, })
|
||||||
idCollapse: 0,
|
|
||||||
isCollapseOpen: false,
|
const listItemSelectedHandler = (e, index) => setCollapseInfo({ idCollapse: index, isCollapseOpen: !collapseInfo.isCollapseOpen })
|
||||||
})
|
|
||||||
|
|
||||||
const listItemSelectedHandler = (e, index) => {
|
|
||||||
setCollapseInfo({
|
|
||||||
idCollapse: index,
|
|
||||||
isCollapseOpen: !collapseInfo.isCollapseOpen
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className={classes.navHeading}>
|
<div className={classes.navHeading}>
|
||||||
|
|||||||
41
client/src/components/Nav/styles.js
Normal file
41
client/src/components/Nav/styles.js
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
import { makeStyles } from '@material-ui/core';
|
||||||
|
|
||||||
|
const useStyles = makeStyles((theme) => ({
|
||||||
|
drawer: {
|
||||||
|
[theme.breakpoints.up('sm')]: {
|
||||||
|
width: 240,
|
||||||
|
flexShrink: 0,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
drawerPaper: {
|
||||||
|
width: 240,
|
||||||
|
},
|
||||||
|
navHeading: {
|
||||||
|
padding: '10px 0px 10px 16px',
|
||||||
|
minHeight: 64,
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
color: 'rgba(255, 255, 255, 0.7)'
|
||||||
|
},
|
||||||
|
githubIcon: {
|
||||||
|
marginLeft: 10
|
||||||
|
},
|
||||||
|
author: {
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
marginTop: 10
|
||||||
|
},
|
||||||
|
nested: {
|
||||||
|
paddingLeft: theme.spacing(4)
|
||||||
|
},
|
||||||
|
addCategoryItem: {
|
||||||
|
display: 'flex',
|
||||||
|
justifyContent: 'center'
|
||||||
|
},
|
||||||
|
link: {
|
||||||
|
textDecoration: 'none',
|
||||||
|
color: '#fff'
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
export default useStyles
|
||||||
@ -1,45 +1,18 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import useStyles from './styles'
|
||||||
import UpdateTodoModal from '../Modals/Todo/UpdateTodoModal'
|
import UpdateTodoModal from '../Modals/Todo/UpdateTodoModal'
|
||||||
import DeleteTodoDialog from '../Dialogs/Todo/DeleteTodoDialog'
|
import DeleteTodoDialog from '../Dialogs/Todo/DeleteTodoDialog'
|
||||||
import DeleteTodoСompletelyDialog from '../Dialogs/Todo/DeleteTodoСompletelyDialog'
|
import DeleteTodoСompletelyDialog from '../Dialogs/Todo/DeleteTodoСompletelyDialog'
|
||||||
import RestoreTodoDialog from '../Dialogs/Todo/RestoreTodoDialog'
|
import RestoreTodoDialog from '../Dialogs/Todo/RestoreTodoDialog'
|
||||||
import { Card, CardActions, CardContent, Typography, Grid, IconButton, makeStyles } from '@material-ui/core'
|
import { Card, CardActions, CardContent, Typography, Grid, IconButton } from '@material-ui/core'
|
||||||
|
|
||||||
import RestoreIcon from '@material-ui/icons/Restore';
|
import RestoreIcon from '@material-ui/icons/Restore';
|
||||||
import DeleteIcon from '@material-ui/icons/Delete'
|
import DeleteIcon from '@material-ui/icons/Delete'
|
||||||
import AlarmIcon from '@material-ui/icons/Alarm';
|
import AlarmIcon from '@material-ui/icons/Alarm';
|
||||||
import EditIcon from '@material-ui/icons/Edit';
|
import EditIcon from '@material-ui/icons/Edit';
|
||||||
|
|
||||||
|
|
||||||
import categories from '../../db/categories.json'
|
import categories from '../../db/categories.json'
|
||||||
|
|
||||||
const useStyles = makeStyles((theme) => ({
|
|
||||||
alarmIcon: {
|
|
||||||
marginRight: 10
|
|
||||||
},
|
|
||||||
cardActions: {
|
|
||||||
justifyContent: 'flex-end'
|
|
||||||
},
|
|
||||||
cardHeading: {
|
|
||||||
marginBottom: 10
|
|
||||||
},
|
|
||||||
cardCategoryHeading: {
|
|
||||||
display: 'flex',
|
|
||||||
justifyContent: 'space-between',
|
|
||||||
fontSize: 14
|
|
||||||
},
|
|
||||||
cardAlarm: {
|
|
||||||
display: 'flex',
|
|
||||||
alignItems: 'center'
|
|
||||||
},
|
|
||||||
fab: {
|
|
||||||
position: 'fixed',
|
|
||||||
margin: 30,
|
|
||||||
bottom: theme.spacing(2),
|
|
||||||
right: theme.spacing(2),
|
|
||||||
},
|
|
||||||
}))
|
|
||||||
|
|
||||||
const Todos = ({ data, fromTrashContainer }) => {
|
const Todos = ({ data, fromTrashContainer }) => {
|
||||||
const classes = useStyles()
|
const classes = useStyles()
|
||||||
const [selectedTodo, setSelectedTodo] = React.useState({
|
const [selectedTodo, setSelectedTodo] = React.useState({
|
||||||
@ -93,10 +66,16 @@ const Todos = ({ data, fromTrashContainer }) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{!fromTrashContainer ? <UpdateTodoModal isModalOpen={isModalOpen} handleOpenModal={handleOpenModal} handleCloseModal={handleCloseModal} selectedTodo={selectedTodo} setSelectedTodo={setSelectedTodo} /> : null}
|
{!fromTrashContainer
|
||||||
{!fromTrashContainer ? <DeleteTodoDialog isOpenDialog={isOpenDialog} handleCloseDialog={handleCloseDialog} selectedTodo={selectedTodo} /> : null}
|
? <>
|
||||||
{fromTrashContainer ? <DeleteTodoСompletelyDialog isOpenDialog={isOpenDialog} handleCloseDialog={handleCloseDialog} selectedTodo={selectedTodo} /> : null}
|
<UpdateTodoModal isModalOpen={isModalOpen} handleOpenModal={handleOpenModal} handleCloseModal={handleCloseModal} selectedTodo={selectedTodo} setSelectedTodo={setSelectedTodo} />
|
||||||
{fromTrashContainer ? <RestoreTodoDialog isOpenDialog={isOpenRestoreDialog} handleCloseDialog={handleCloseRestoreDialog} selectedTodo={selectedTodo} /> : null}
|
<DeleteTodoDialog isOpenDialog={isOpenDialog} handleCloseDialog={handleCloseDialog} selectedTodo={selectedTodo} />
|
||||||
|
</>
|
||||||
|
: <>
|
||||||
|
<DeleteTodoСompletelyDialog isOpenDialog={isOpenDialog} handleCloseDialog={handleCloseDialog} selectedTodo={selectedTodo} />
|
||||||
|
<RestoreTodoDialog isOpenDialog={isOpenRestoreDialog} handleCloseDialog={handleCloseRestoreDialog} selectedTodo={selectedTodo} />
|
||||||
|
</>
|
||||||
|
}
|
||||||
{data.map((todo, i) =>
|
{data.map((todo, i) =>
|
||||||
<Grid key={i} item xs={12} md={4} lg={3}>
|
<Grid key={i} item xs={12} md={4} lg={3}>
|
||||||
<Card>
|
<Card>
|
||||||
|
|||||||
30
client/src/components/Todos/styles.js
Normal file
30
client/src/components/Todos/styles.js
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
import { makeStyles } from '@material-ui/core'
|
||||||
|
|
||||||
|
const useStyles = makeStyles((theme) => ({
|
||||||
|
alarmIcon: {
|
||||||
|
marginRight: 10
|
||||||
|
},
|
||||||
|
cardActions: {
|
||||||
|
justifyContent: 'flex-end'
|
||||||
|
},
|
||||||
|
cardHeading: {
|
||||||
|
marginBottom: 10
|
||||||
|
},
|
||||||
|
cardCategoryHeading: {
|
||||||
|
display: 'flex',
|
||||||
|
justifyContent: 'space-between',
|
||||||
|
fontSize: 14
|
||||||
|
},
|
||||||
|
cardAlarm: {
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center'
|
||||||
|
},
|
||||||
|
fab: {
|
||||||
|
position: 'fixed',
|
||||||
|
margin: 30,
|
||||||
|
bottom: theme.spacing(2),
|
||||||
|
right: theme.spacing(2),
|
||||||
|
},
|
||||||
|
}))
|
||||||
|
|
||||||
|
export default useStyles
|
||||||
Loading…
x
Reference in New Issue
Block a user