Skip to content
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

[docs] Migrate Bottom Navigation demos to emotion #25180

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number Diff line number Diff line change
@@ -1,28 +1,20 @@
import * as React from 'react';
import { makeStyles } from '@material-ui/core/styles';
import BottomNavigation from '@material-ui/core/BottomNavigation';
import BottomNavigationAction from '@material-ui/core/BottomNavigationAction';
import FolderIcon from '@material-ui/icons/Folder';
import RestoreIcon from '@material-ui/icons/Restore';
import FavoriteIcon from '@material-ui/icons/Favorite';
import LocationOnIcon from '@material-ui/icons/LocationOn';

const useStyles = makeStyles({
root: {
width: 500,
},
});

export default function LabelBottomNavigation() {
const classes = useStyles();
const [value, setValue] = React.useState('recents');

const handleChange = (event, newValue) => {
setValue(newValue);
};

return (
<BottomNavigation value={value} onChange={handleChange} className={classes.root}>
<BottomNavigation sx={{ width: 500 }} value={value} onChange={handleChange}>
<BottomNavigationAction
label="Recents"
value="recents"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,20 @@
import * as React from 'react';
import { makeStyles } from '@material-ui/core/styles';
import BottomNavigation from '@material-ui/core/BottomNavigation';
import BottomNavigationAction from '@material-ui/core/BottomNavigationAction';
import FolderIcon from '@material-ui/icons/Folder';
import RestoreIcon from '@material-ui/icons/Restore';
import FavoriteIcon from '@material-ui/icons/Favorite';
import LocationOnIcon from '@material-ui/icons/LocationOn';

const useStyles = makeStyles({
root: {
width: 500,
},
});

export default function LabelBottomNavigation() {
const classes = useStyles();
const [value, setValue] = React.useState('recents');

const handleChange = (event: React.SyntheticEvent, newValue: string) => {
setValue(newValue);
};

return (
<BottomNavigation value={value} onChange={handleChange} className={classes.root}>
<BottomNavigation sx={{ width: 500 }} value={value} onChange={handleChange}>
<BottomNavigationAction
label="Recents"
value="recents"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,16 @@
import * as React from 'react';
import { makeStyles } from '@material-ui/core/styles';
import Box from '@material-ui/core/Box';
import BottomNavigation from '@material-ui/core/BottomNavigation';
import BottomNavigationAction from '@material-ui/core/BottomNavigationAction';
import RestoreIcon from '@material-ui/icons/Restore';
import FavoriteIcon from '@material-ui/icons/Favorite';
import LocationOnIcon from '@material-ui/icons/LocationOn';

const useStyles = makeStyles({
root: {
width: 500,
},
});

export default function SimpleBottomNavigation() {
const classes = useStyles();
const [value, setValue] = React.useState(0);

return (
<div className={classes.root}>
<Box sx={{ width: 500 }}>
<BottomNavigation
showLabels
value={value}
Expand All @@ -29,6 +22,6 @@ export default function SimpleBottomNavigation() {
<BottomNavigationAction label="Favorites" icon={<FavoriteIcon />} />
<BottomNavigationAction label="Nearby" icon={<LocationOnIcon />} />
</BottomNavigation>
</div>
</Box>
);
}
Original file line number Diff line number Diff line change
@@ -1,23 +1,16 @@
import * as React from 'react';
import { makeStyles } from '@material-ui/core/styles';
import Box from '@material-ui/core/Box';
import BottomNavigation from '@material-ui/core/BottomNavigation';
import BottomNavigationAction from '@material-ui/core/BottomNavigationAction';
import RestoreIcon from '@material-ui/icons/Restore';
import FavoriteIcon from '@material-ui/icons/Favorite';
import LocationOnIcon from '@material-ui/icons/LocationOn';

const useStyles = makeStyles({
root: {
width: 500,
},
});

export default function SimpleBottomNavigation() {
const classes = useStyles();
const [value, setValue] = React.useState(0);

return (
<div className={classes.root}>
<Box sx={{ width: 500 }}>
<BottomNavigation
showLabels
value={value}
Expand All @@ -29,6 +22,6 @@ export default function SimpleBottomNavigation() {
<BottomNavigationAction label="Favorites" icon={<FavoriteIcon />} />
<BottomNavigationAction label="Nearby" icon={<LocationOnIcon />} />
</BottomNavigation>
</div>
</Box>
);
}