Skip to content

Commit

Permalink
docs: Migrate Fixed bottom navigation demo to emotion
Browse files Browse the repository at this point in the history
  • Loading branch information
vicasas committed Mar 3, 2021
1 parent 85466e5 commit b248fba
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 34 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/no-use-before-define */
import * as React from 'react';
import { makeStyles } from '@material-ui/core/styles';
import Box from '@material-ui/core/Box';
import CssBaseline from '@material-ui/core/CssBaseline';
import BottomNavigation from '@material-ui/core/BottomNavigation';
import BottomNavigationAction from '@material-ui/core/BottomNavigationAction';
Expand All @@ -14,18 +14,6 @@ import ListItemAvatar from '@material-ui/core/ListItemAvatar';
import ListItemText from '@material-ui/core/ListItemText';
import Avatar from '@material-ui/core/Avatar';

const useStyles = makeStyles({
root: {
paddingBottom: 56,
},
bottomNav: {
position: 'fixed',
bottom: 0,
left: 0,
right: 0,
},
});

function refreshMessages() {
const getRandomInt = (max) => Math.floor(Math.random() * Math.floor(max));

Expand All @@ -35,7 +23,6 @@ function refreshMessages() {
}

export default function FixedBottomNavigation() {
const classes = useStyles();
const [value, setValue] = React.useState(0);
const ref = React.useRef(null);
const [messages, setMessages] = React.useState(() => refreshMessages());
Expand All @@ -46,7 +33,7 @@ export default function FixedBottomNavigation() {
}, [value, setMessages]);

return (
<div className={classes.root} ref={ref}>
<Box sx={{ pb: 7 }} ref={ref}>
<CssBaseline />
<List>
{messages.map(({ primary, secondary, person }, index) => (
Expand All @@ -58,7 +45,7 @@ export default function FixedBottomNavigation() {
</ListItem>
))}
</List>
<Paper elevation={3} className={classes.bottomNav}>
<Paper sx={{ position: 'fixed', bottom: 0, left: 0, right: 0 }} elevation={3}>
<BottomNavigation
showLabels
value={value}
Expand All @@ -71,7 +58,7 @@ export default function FixedBottomNavigation() {
<BottomNavigationAction label="Archive" icon={<ArchiveIcon />} />
</BottomNavigation>
</Paper>
</div>
</Box>
);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/no-use-before-define */
import * as React from 'react';
import { makeStyles } from '@material-ui/core/styles';
import Box from '@material-ui/core/Box';
import CssBaseline from '@material-ui/core/CssBaseline';
import BottomNavigation from '@material-ui/core/BottomNavigation';
import BottomNavigationAction from '@material-ui/core/BottomNavigationAction';
Expand All @@ -14,18 +14,6 @@ import ListItemAvatar from '@material-ui/core/ListItemAvatar';
import ListItemText from '@material-ui/core/ListItemText';
import Avatar from '@material-ui/core/Avatar';

const useStyles = makeStyles({
root: {
paddingBottom: 56,
},
bottomNav: {
position: 'fixed',
bottom: 0,
left: 0,
right: 0,
},
});

function refreshMessages(): MessageExample[] {
const getRandomInt = (max: number) => Math.floor(Math.random() * Math.floor(max));

Expand All @@ -35,7 +23,6 @@ function refreshMessages(): MessageExample[] {
}

export default function FixedBottomNavigation() {
const classes = useStyles();
const [value, setValue] = React.useState(0);
const ref = React.useRef<HTMLDivElement>(null);
const [messages, setMessages] = React.useState(() => refreshMessages());
Expand All @@ -46,7 +33,7 @@ export default function FixedBottomNavigation() {
}, [value, setMessages]);

return (
<div className={classes.root} ref={ref}>
<Box sx={{ pb: 7 }} ref={ref}>
<CssBaseline />
<List>
{messages.map(({ primary, secondary, person }, index) => (
Expand All @@ -58,7 +45,7 @@ export default function FixedBottomNavigation() {
</ListItem>
))}
</List>
<Paper elevation={3} className={classes.bottomNav}>
<Paper sx={{ position: 'fixed', bottom: 0, left: 0, right: 0 }} elevation={3}>
<BottomNavigation
showLabels
value={value}
Expand All @@ -71,7 +58,7 @@ export default function FixedBottomNavigation() {
<BottomNavigationAction label="Archive" icon={<ArchiveIcon />} />
</BottomNavigation>
</Paper>
</div>
</Box>
);
}

Expand Down

0 comments on commit b248fba

Please sign in to comment.