-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Frontend app page without target styles (#23)
* Add css * Add sidebar * Format * Add AppBar * Add AppMain * delete non-used import * delete non-used code lines
- Loading branch information
1 parent
1352dae
commit 2aebc7c
Showing
6 changed files
with
228 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export const MIN_CARD_COMPONENT_WIDTH : string = "300px"; | ||
export const MIN_CARD_COMPONENT_WIDTH : string = "300px"; | ||
export const DRAWER_WIDTH = 240; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { createContext } from 'react'; | ||
|
||
export const defaultObject = { | ||
isOpenDrawer: false, | ||
handleDrawerOpen: () => { | ||
}, | ||
handleDrawerClose: () => { | ||
}, | ||
}; | ||
|
||
export const AppContext = createContext(defaultObject); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { Badge, makeStyles, Typography } from '@material-ui/core'; | ||
import clsx from 'clsx'; | ||
import IconButton from '@material-ui/core/IconButton'; | ||
import React, { useContext } from 'react'; | ||
import { AppContext } from '../../atoms/hooks/AppContext'; | ||
import { DRAWER_WIDTH } from '../../atoms/constants/sizes'; | ||
import Toolbar from '@material-ui/core/Toolbar'; | ||
import MenuIcon from '@material-ui/icons/Menu'; | ||
import NotificationsIcon from '@material-ui/icons/Notifications'; | ||
import { AppBar as AppBarFromSigma } from '@material-ui/core'; | ||
|
||
export function AppBar() { | ||
const classes = useStyles(); | ||
const { handleDrawerOpen } = useContext(AppContext); | ||
const { isOpenDrawer } = useContext(AppContext); | ||
|
||
return ( | ||
<AppBarFromSigma position='absolute' className={clsx(classes.appBar, isOpenDrawer && classes.appBarShift)}> | ||
<Toolbar className={classes.toolbar}> | ||
<IconButton | ||
edge='start' | ||
color='inherit' | ||
aria-label='open drawer' | ||
onClick={handleDrawerOpen} | ||
className={clsx(classes.menuButton, isOpenDrawer && classes.menuButtonHidden)} | ||
> | ||
<MenuIcon /> | ||
</IconButton> | ||
<Typography component='h1' variant='h6' color='inherit' noWrap className={classes.title}> | ||
Dashboard | ||
</Typography> | ||
<IconButton color='inherit'> | ||
<Badge badgeContent={4} color='secondary'> | ||
<NotificationsIcon /> | ||
</Badge> | ||
</IconButton> | ||
</Toolbar> | ||
</AppBarFromSigma> | ||
); | ||
} | ||
|
||
const useStyles = makeStyles((theme) => ({ | ||
toolbar: { | ||
paddingRight: 24, // keep right padding when drawer closed | ||
}, | ||
appBar: { | ||
zIndex: theme.zIndex.drawer + 1, | ||
transition: theme.transitions.create(['width', 'margin'], { | ||
easing: theme.transitions.easing.sharp, | ||
duration: theme.transitions.duration.leavingScreen, | ||
}), | ||
}, | ||
appBarShift: { | ||
marginLeft: DRAWER_WIDTH, | ||
width: `calc(100% - ${DRAWER_WIDTH}px)`, | ||
transition: theme.transitions.create(['width', 'margin'], { | ||
easing: theme.transitions.easing.sharp, | ||
duration: theme.transitions.duration.enteringScreen, | ||
}), | ||
}, | ||
menuButton: { | ||
marginRight: 36, | ||
}, | ||
menuButtonHidden: { | ||
display: 'none', | ||
}, | ||
title: { | ||
flexGrow: 1, | ||
}, | ||
})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { makeStyles, Typography } from '@material-ui/core'; | ||
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom'; | ||
import { PATH_FOR_MAIN_VIEW } from '../../atoms/constants/routerPaths'; | ||
import ClickButton from '../../atoms/Button/ClickButton'; | ||
|
||
const onClick = () => { | ||
}; | ||
|
||
export function AppMain() { | ||
const classes = useStyles(); | ||
|
||
return ( | ||
<main className={classes.content}> | ||
<Router> | ||
|
||
<Switch> | ||
|
||
<Route path={PATH_FOR_MAIN_VIEW} exact> | ||
|
||
<Typography variant='h2'>Responsive h3</Typography> | ||
|
||
<ClickButton text={'ZADAJ PYTANIE'} onClick={() => onClick()} /> | ||
|
||
</Route> | ||
|
||
</Switch> | ||
|
||
</Router> | ||
|
||
</main> | ||
); | ||
} | ||
|
||
const useStyles = makeStyles((theme) => ({ | ||
content: { | ||
overflow: 'auto', | ||
position: 'relative', | ||
flexGrow: 1, | ||
height: '100vh', | ||
}, | ||
})); |
61 changes: 61 additions & 0 deletions
61
frontend/src/components/organisms/AppSidebar/AppSidebar.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { Divider, Drawer, makeStyles } from '@material-ui/core'; | ||
import clsx from 'clsx'; | ||
import IconButton from '@material-ui/core/IconButton'; | ||
import ChevronLeftIcon from '@material-ui/icons/ChevronLeft'; | ||
import React, { useContext } from 'react'; | ||
import { AppContext } from '../../atoms/hooks/AppContext'; | ||
import { DRAWER_WIDTH } from '../../atoms/constants/sizes'; | ||
|
||
export function AppSidebar() { | ||
const classes = useStyles(); | ||
const { handleDrawerClose } = useContext(AppContext); | ||
const { isOpenDrawer } = useContext(AppContext); | ||
|
||
return ( | ||
<Drawer | ||
variant='permanent' | ||
classes={{ | ||
paper: clsx(classes.drawerPaper, !isOpenDrawer && classes.drawerPaperClose), | ||
}} | ||
open={isOpenDrawer} | ||
> | ||
<div className={classes.toolbarIcon}> | ||
<IconButton onClick={handleDrawerClose}> | ||
<ChevronLeftIcon /> | ||
</IconButton> | ||
</div> | ||
<Divider /> | ||
<Divider /> | ||
</Drawer> | ||
); | ||
} | ||
|
||
const useStyles = makeStyles((theme) => ({ | ||
toolbarIcon: { | ||
display: 'flex', | ||
alignItems: 'center', | ||
justifyContent: 'flex-end', | ||
padding: '0 8px', | ||
...theme.mixins.toolbar, | ||
}, | ||
drawerPaper: { | ||
position: 'relative', | ||
whiteSpace: 'nowrap', | ||
width: DRAWER_WIDTH, | ||
transition: theme.transitions.create('width', { | ||
easing: theme.transitions.easing.sharp, | ||
duration: theme.transitions.duration.enteringScreen, | ||
}), | ||
}, | ||
drawerPaperClose: { | ||
overflowX: 'hidden', | ||
transition: theme.transitions.create('width', { | ||
easing: theme.transitions.easing.sharp, | ||
duration: theme.transitions.duration.leavingScreen, | ||
}), | ||
width: theme.spacing(7), | ||
[theme.breakpoints.up('sm')]: { | ||
width: theme.spacing(9), | ||
}, | ||
}, | ||
})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters