-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Styling for mobile devices #16
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import React from 'react'; | ||
import { makeStyles, useTheme } from '@material-ui/core/styles'; | ||
import useMediaQuery from "@material-ui/core/useMediaQuery"; | ||
import MenuIcon from "@material-ui/icons/Menu"; | ||
import { Button, IconButton } from '@material-ui/core'; | ||
import Link from '@material-ui/core/Link'; | ||
import { IMenuProps } from '../../../types/IMenuProps'; | ||
|
||
|
||
const useStyles = makeStyles((theme) => ({ | ||
toolbar: { | ||
borderBottom: `1px solid ${theme.palette.divider}`, | ||
}, | ||
toolbarTitle: { | ||
flex: 1, | ||
}, | ||
toolbarSecondary: { | ||
justifyContent: 'space-between', | ||
overflowX: 'auto', | ||
}, | ||
toolbarLink: { | ||
padding: theme.spacing(1), | ||
flexShrink: 0, | ||
}, | ||
menuButton: { | ||
marginRight: theme.spacing(2) | ||
}, | ||
})); | ||
|
||
|
||
export default function MobileMenu(props: IMenuProps): JSX.Element { | ||
const classes = useStyles(); | ||
const theme = useTheme(); | ||
|
||
return (<>{ | ||
props.sections.map(section => <> | ||
<Button href={section.url}>{section.title}</Button> | ||
</>) | ||
}</>) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ import { Toolbar, Typography, Link, AppBar } from "@material-ui/core"; | |
import useStyles from "./Header.styles"; | ||
import Section from "../../../types/section"; | ||
import { StaticImage } from "gatsby-plugin-image"; | ||
import MainMenu from "../../organisms/MainMenu/MainMenu"; | ||
|
||
// TODO add storybook | ||
|
||
|
@@ -31,43 +32,8 @@ const Header: FC<HeaderProps> = ({ sections, title }) => { | |
src="../../../images/codestar_logo_dark.svg" | ||
/> | ||
</Typography> | ||
{/* <IconButton> | ||
<SearchIcon /> | ||
</IconButton> | ||
<Button variant="outlined" size="small"> | ||
Sign up | ||
</Button> */} | ||
{sections.map((section) => ( | ||
<Link | ||
color="inherit" | ||
noWrap | ||
key={section.title} | ||
variant="body2" | ||
href={section.url} | ||
className={classes.toolbarLink} | ||
> | ||
{section.title} | ||
</Link> | ||
))} | ||
<MainMenu sections={sections}></MainMenu> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice to have this extracted! 👍🏻 |
||
</Toolbar> | ||
{/* <Toolbar | ||
component="nav" | ||
variant="dense" | ||
className={classes.toolbarSecondary} | ||
> | ||
{sections.map((section) => ( | ||
<Link | ||
color="inherit" | ||
noWrap | ||
key={section.title} | ||
variant="body2" | ||
href={section.url} | ||
className={classes.toolbarLink} | ||
> | ||
{section.title} | ||
</Link> | ||
))} | ||
</Toolbar> */} | ||
</AppBar> | ||
); | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import React from 'react'; | ||
import { makeStyles } from '@material-ui/core/styles'; | ||
import MenuIcon from "@material-ui/icons/Menu"; | ||
import { IconButton } from '@material-ui/core'; | ||
|
||
//interfaces | ||
import { IMenuProps } from '../../../../types/IMenuProps'; | ||
|
||
|
||
const useStyles = makeStyles((theme) => ({ | ||
menuButton: { | ||
marginRight: theme.spacing(2) | ||
}, | ||
})); | ||
|
||
export interface IMobileMenuProps { | ||
sections: IMenuProps[]; | ||
} | ||
|
||
export default function MobileMenu(props: IMobileMenuProps): JSX.Element { | ||
const classes = useStyles(); | ||
|
||
return (<>{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think you need to wrap it with |
||
<IconButton | ||
edge="start" | ||
className={classes.menuButton} | ||
color="inherit" | ||
aria-label="menu" | ||
//onClick={handleMenu} | ||
> | ||
<MenuIcon /> | ||
</IconButton> | ||
}</>) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import React from 'react'; | ||
import MenuIcon from "@material-ui/icons/Menu"; | ||
import { Button, IconButton, List, ListItem, Typography } from '@material-ui/core'; | ||
import { StaticImage } from "gatsby-plugin-image"; | ||
|
||
//interfaces | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure if this comment adds much 😜 |
||
import Section from '../../../types/section'; | ||
import { Drawer } from '@material-ui/core'; | ||
import { ListItemText } from '@material-ui/core'; | ||
import useStyles from '../Header/Header.styles'; | ||
|
||
export interface IMobileMenuProps { | ||
sections: Section[]; | ||
} | ||
|
||
export default function MobileMenu(props: IMobileMenuProps): JSX.Element { | ||
|
||
const [state, setState] = React.useState(false); | ||
|
||
const toggleDrawer = (open: boolean) => ( | ||
event: React.KeyboardEvent | React.MouseEvent, | ||
) => { | ||
if ( | ||
event.type === 'keydown' && | ||
((event as React.KeyboardEvent).key === 'Tab' || | ||
(event as React.KeyboardEvent).key === 'Shift') | ||
) { | ||
return; | ||
} | ||
|
||
setState(open); | ||
}; | ||
|
||
const classes = useStyles(); | ||
|
||
return ( | ||
<div> | ||
<Drawer anchor="top" open={state} onClose={() => setState(false)}> | ||
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }}> | ||
<Typography | ||
component="h2" | ||
variant="h5" | ||
color="inherit" | ||
style={{ padding: '10px' }} | ||
noWrap | ||
className={classes.toolbarTitle} | ||
> | ||
<StaticImage | ||
alt={`Mobile menu Logo`} | ||
src="../../../images/codestar_logo_dark.svg" | ||
/> | ||
</Typography> | ||
<List component="nav" aria-label="secondary mailbox folders" > | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need for |
||
<>{ | ||
props.sections.map(section => <> | ||
<ListItem button> | ||
<Button href={section.url}>{section.title}</Button> | ||
</ListItem> | ||
</>) | ||
}</> | ||
|
||
</List> | ||
</div> | ||
</Drawer> | ||
<IconButton | ||
key="iconButton" | ||
edge="start" | ||
color="inherit" | ||
aria-label="menu" | ||
onClick={toggleDrawer(true)} | ||
> | ||
<MenuIcon key="menuIButton" /> | ||
</IconButton> | ||
</div> | ||
) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import React from 'react'; | ||
import { useTheme } from '@material-ui/core/styles'; | ||
import useMediaQuery from "@material-ui/core/useMediaQuery"; | ||
|
||
// local imports | ||
import BrowserMenu from '../../molecules/BrowserMenu/BrowserMenu'; | ||
import MobileMenu from '../../molecules/MobileMenu/MobileMenu'; | ||
|
||
//interfaces | ||
import { IMenuProps } from '../../../types/IMenuProps'; | ||
|
||
export default function MainMenu(props: IMenuProps): JSX.Element { | ||
const theme = useTheme(); | ||
const isMobile = useMediaQuery(theme.breakpoints.down("xs")); | ||
|
||
return (<> | ||
{ | ||
isMobile ? | ||
<MobileMenu sections={props.sections} /> | ||
: | ||
<BrowserMenu sections={props.sections} /> | ||
} | ||
</>) | ||
Comment on lines
+16
to
+23
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think
should also work! |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import Section from './section'; | ||
|
||
|
||
export interface IMenuProps { | ||
sections: Section[]; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe these can be removed?