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

[material-ui][docs] Add improvements to Dashboard template #42445

Open
wants to merge 63 commits into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 45 commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
656f5ae
Stray design tweaks
zanivan May 29, 2024
4ed55c1
Improve a11y
zanivan May 29, 2024
a691f09
Run scripts
zanivan May 29, 2024
6658704
Danilo's feedback
zanivan May 29, 2024
214aee7
More design tweaks
zanivan May 29, 2024
d3ad0bc
Remove even background color from data grid
zanivan Jun 4, 2024
325b002
Replace tabs for sidemenu
zanivan Jun 4, 2024
c6f3c1e
More visual tweaks
zanivan Jun 4, 2024
1f22e2b
Merge remote-tracking branch 'upstream/next' into dashboard-template-…
zanivan Jun 5, 2024
0a7b7c1
Stray design tweaks
zanivan Jun 5, 2024
3e6ab9b
Stray tweaks
zanivan Jun 6, 2024
860d0b3
fix CardAlert
danilo-leal Jun 6, 2024
31e188f
Add visual tweaks to the select
zanivan Jun 7, 2024
5103c11
Run docs:typescript:formatted
zanivan Jun 7, 2024
18ab029
Replace outlined icons for the rounded
zanivan Jun 7, 2024
8676bbb
fix linting errors
noraleonte Jun 10, 2024
d7c16f9
split theme file
noraleonte Jun 10, 2024
53e6212
tweak
noraleonte Jun 10, 2024
0de4e7d
styling tweaks
noraleonte Jun 10, 2024
4d63484
menus consistency
noraleonte Jun 10, 2024
04fcc09
alignment tweaks
noraleonte Jun 10, 2024
0bc0f82
fix scrollbar origin
noraleonte Jun 10, 2024
717d432
oopsie
noraleonte Jun 10, 2024
2b332cb
Merge remote-tracking branch 'upstream/next' into dashboard-template-…
zanivan Jun 10, 2024
0081f89
tweaks
noraleonte Jun 11, 2024
12ec8b1
Tweaks to mobile breakpoint
zanivan Jun 11, 2024
70ae5ae
fix select focus
noraleonte Jun 13, 2024
3693bb9
Merge branch 'next' into dashboard-template-polishing
zanivan Jun 18, 2024
ec7746d
Some of danilo's feedback
zanivan Jun 18, 2024
2c8cade
tweaks
noraleonte Jun 19, 2024
7050775
update packages
noraleonte Jun 19, 2024
855b89b
fix
noraleonte Jun 19, 2024
27980a9
fix sidenav spacing
noraleonte Jun 19, 2024
301fb72
fix menu focus
noraleonte Jun 19, 2024
97a09a1
Small fix to drawer style
zanivan Jun 19, 2024
98f6a67
Merge branch 'next' into pr/42445
zanivan Jun 24, 2024
c1de6f6
Fix eslint
zanivan Jun 24, 2024
918b7fb
Update preview images
zanivan Jun 24, 2024
fe6b572
Fix regression test
zanivan Jun 24, 2024
a9a3dd5
Stray visual improvements
zanivan Jun 25, 2024
d03b845
Stray tweaks
zanivan Jun 26, 2024
a406e79
Stray polishing
zanivan Jun 28, 2024
54906f0
Run scripts
zanivan Jun 28, 2024
522fdf1
Fix tests
zanivan Jun 28, 2024
4b4d4a6
Simplify chart colors
zanivan Jun 28, 2024
8f37414
Remove sx-like props
zanivan Jul 1, 2024
0e4641e
Merge branch 'next' into pr/42445
zanivan Jul 1, 2024
d7a29e4
Remove unused items on navbar
zanivan Jul 1, 2024
f64168d
Fix grid changes
zanivan Jul 1, 2024
7bbf911
Remove hardcoded classes
zanivan Jul 1, 2024
70033a5
Fix lint
zanivan Jul 1, 2024
6469a01
Trigger CI
zanivan Jul 2, 2024
3dddf23
Bump contrast
zanivan Jul 2, 2024
7dd8ecd
add little round of polish
danilo-leal Jul 2, 2024
f8a2401
Stray tweaks to data grid
zanivan Jul 2, 2024
593b429
Merge branch 'dashboard-template-polishing' of https://github.com/zan…
zanivan Jul 2, 2024
f6d6b95
Round of polishing
zanivan Jul 3, 2024
088d812
Remove 'Mui-'
zanivan Jul 4, 2024
9c558c8
Run docs:typescript:formatted
zanivan Jul 4, 2024
1722d3c
Fix typo on datePickers
zanivan Jul 4, 2024
8b6165c
Remove whitespace
zanivan Jul 4, 2024
cfe1afd
fix tree view and grid pagination
noraleonte Jul 9, 2024
6eb9198
wip
noraleonte Jul 9, 2024
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
38 changes: 20 additions & 18 deletions docs/data/material/getting-started/templates/dashboard/Dashboard.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import * as React from 'react';

import { createTheme, ThemeProvider } from '@mui/material/styles';
import { createTheme, ThemeProvider, alpha } from '@mui/material/styles';
import CssBaseline from '@mui/material/CssBaseline';
import Box from '@mui/material/Box';
import Container from '@mui/material/Container';
import getDashboardTheme from './getDashboardTheme';
import Stack from '@mui/material/Stack';
import getDashboardTheme from './theme/getDashboardTheme';
import ToggleCustomTheme from './internals/components/ToggleCustomTheme';
import Copyright from './internals/components/Copyright';
import Navbar from './components/Navbar';
import Header from './components/Header';
import MainGrid from './components/MainGrid';
import SideMenu from './components/SideMenu';

export default function Dashboard() {
const [mode, setMode] = React.useState('light');
Expand All @@ -29,30 +29,32 @@ export default function Dashboard() {
<ThemeProvider theme={showCustomTheme ? dashboardTheme : defaultTheme}>
<CssBaseline />
<Box sx={{ display: 'flex' }}>
<SideMenu />
<Navbar mode={mode} toggleColorMode={toggleColorMode} />
{/* Main content */}
<Box
component="main"
sx={{
backgroundColor: 'background.default',
sx={(theme) => ({
position: { sm: 'relative', md: '' },
top: { sm: '48px', md: '0' },
height: { sm: 'calc(100vh - 48px)', md: '100vh' },
flexGrow: 1,
height: '100vh',
pt: 2,
backgroundColor: alpha(theme.palette.background.default, 1),
overflow: 'auto',
}}
})}
>
{/* Main content */}
<Container
maxWidth="xl"
<Stack
spacing={2}
sx={{
display: 'flex',
flexDirection: 'column',
py: { xs: 14, sm: 16 },
gap: 2,
alignItems: 'center',
mx: 3,
pb: 10,
}}
>
<Header />
<Header mode={mode} toggleColorMode={toggleColorMode} />
<MainGrid />
<Copyright sx={{ my: 4 }} />
</Container>
</Stack>
</Box>
<ToggleCustomTheme
showCustomTheme={showCustomTheme}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import * as React from 'react';
import { PaletteMode } from '@mui/material';
import { createTheme, ThemeProvider } from '@mui/material/styles';
import { createTheme, ThemeProvider, alpha } from '@mui/material/styles';
import CssBaseline from '@mui/material/CssBaseline';
import Box from '@mui/material/Box';
import Container from '@mui/material/Container';
import getDashboardTheme from './getDashboardTheme';
import Stack from '@mui/material/Stack';
import getDashboardTheme from './theme/getDashboardTheme';
import ToggleCustomTheme from './internals/components/ToggleCustomTheme';
import Copyright from './internals/components/Copyright';
import Navbar from './components/Navbar';
import Header from './components/Header';
import MainGrid from './components/MainGrid';
import SideMenu from './components/SideMenu';

export default function Dashboard() {
const [mode, setMode] = React.useState<PaletteMode>('light');
Expand All @@ -29,30 +29,32 @@ export default function Dashboard() {
<ThemeProvider theme={showCustomTheme ? dashboardTheme : defaultTheme}>
<CssBaseline />
<Box sx={{ display: 'flex' }}>
<SideMenu />
<Navbar mode={mode} toggleColorMode={toggleColorMode} />
{/* Main content */}
<Box
component="main"
sx={{
backgroundColor: 'background.default',
sx={(theme) => ({
position: { sm: 'relative', md: '' },
top: { sm: '48px', md: '0' },
height: { sm: 'calc(100vh - 48px)', md: '100vh' },
flexGrow: 1,
height: '100vh',
pt: 2,
backgroundColor: alpha(theme.palette.background.default, 1),
overflow: 'auto',
}}
})}
>
{/* Main content */}
<Container
zanivan marked this conversation as resolved.
Show resolved Hide resolved
maxWidth="xl"
<Stack
spacing={2}
sx={{
display: 'flex',
flexDirection: 'column',
py: { xs: 14, sm: 16 },
gap: 2,
alignItems: 'center',
mx: 3,
pb: 10,
}}
>
<Header />
<Header mode={mode} toggleColorMode={toggleColorMode} />
<MainGrid />
<Copyright sx={{ my: 4 }} />
</Container>
</Stack>
</Box>
<ToggleCustomTheme
showCustomTheme={showCustomTheme}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import * as React from 'react';
import Card from '@mui/material/Card';
import CardContent from '@mui/material/CardContent';
import Button from '@mui/material/Button';
import Typography from '@mui/material/Typography';
import AutoAwesomeRoundedIcon from '@mui/icons-material/AutoAwesomeRounded';

export default function CardAlert() {
return (
<Card variant="outlined" sx={{ m: 1.5, p: 1.5 }}>
<CardContent>
<AutoAwesomeRoundedIcon fontSize="small" />
<Typography fontWeight="600" gutterBottom>
Plan about to expire
</Typography>
<Typography color="text.secondary" variant="body2" sx={{ mb: 2 }}>
Enjoy 10% off when renewing your plan today.
</Typography>
<Button variant="contained" size="small" fullWidth>
Get the discount
</Button>
</CardContent>
</Card>
);
}
zanivan marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import * as React from 'react';
import Card from '@mui/material/Card';
import CardContent from '@mui/material/CardContent';
import Button from '@mui/material/Button';
import Typography from '@mui/material/Typography';
import AutoAwesomeRoundedIcon from '@mui/icons-material/AutoAwesomeRounded';

export default function CardAlert() {
return (
<Card variant="outlined" sx={{ m: 1.5, p: 1.5 }}>
<CardContent>
<AutoAwesomeRoundedIcon fontSize="small" />
<Typography fontWeight="600" gutterBottom>
zanivan marked this conversation as resolved.
Show resolved Hide resolved
Plan about to expire
</Typography>
<Typography color="text.secondary" variant="body2" sx={{ mb: 2 }}>
Enjoy 10% off when renewing your plan today.
</Typography>
<Button variant="contained" size="small" fullWidth>
Get the discount
</Button>
</CardContent>
</Card>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,18 @@ PieCenterLabel.propTypes = {
};

const colors = [
'hsl(220, 25%, 65%)',
'hsl(220, 25%, 45%)',
'hsl(220, 25%, 30%)',
'hsl(220, 25%, 20%)',
'hsl(220, 20%, 65%)',
'hsl(220, 20%, 42%)',
'hsl(220, 20%, 35%)',
'hsl(220, 20%, 25%)',
];

export default function ChartUserByCountry() {
return (
<Card variant="outlined" sx={{ pb: '8px' }}>
<Card
variant="outlined"
sx={{ display: 'flex', flexDirection: 'column', gap: '8px', flexGrow: 1 }}
>
<CardContent>
<Typography component="h2" variant="subtitle2">
Users by country
Expand Down Expand Up @@ -177,6 +180,7 @@ export default function ChartUserByCountry() {
</Stack>
<LinearProgress
variant="determinate"
aria-label="Number of users by country"
value={country.value}
sx={{
[`& .${linearProgressClasses.bar}`]: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,18 @@ function PieCenterLabel({ primaryText, secondaryText }: PieCenterLabelProps) {
}

const colors = [
'hsl(220, 25%, 65%)',
'hsl(220, 25%, 45%)',
'hsl(220, 25%, 30%)',
'hsl(220, 25%, 20%)',
'hsl(220, 20%, 65%)',
'hsl(220, 20%, 42%)',
'hsl(220, 20%, 35%)',
'hsl(220, 20%, 25%)',
];

export default function ChartUserByCountry() {
return (
<Card variant="outlined" sx={{ pb: '8px' }}>
<Card
variant="outlined"
sx={{ display: 'flex', flexDirection: 'column', gap: '8px', flexGrow: 1 }}
>
<CardContent>
<Typography component="h2" variant="subtitle2">
Users by country
Expand Down Expand Up @@ -180,6 +183,7 @@ export default function ChartUserByCountry() {
</Stack>
<LinearProgress
variant="determinate"
aria-label="Number of users by country"
value={country.value}
sx={{
[`& .${linearProgressClasses.bar}`]: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,19 @@ import { columns, rows } from '../internals/data/gridData';
export default function CustomizedDataGrid() {
return (
<DataGrid
autoHeight
checkboxSelection
rows={rows}
columns={columns}
rowHeight={40}
columnHeaderHeight={40}
getRowClassName={(params) =>
params.indexRelativeToCurrentPage % 2 === 0 ? 'even' : 'odd'
}
initialState={{
pagination: { paginationModel: { pageSize: 10 } },
pagination: { paginationModel: { pageSize: 20 } },
}}
pageSizeOptions={[10, 25, 50]}
pageSizeOptions={[10, 20, 50]}
disableColumnResize
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,19 @@ import { columns, rows } from '../internals/data/gridData';
export default function CustomizedDataGrid() {
return (
<DataGrid
autoHeight
checkboxSelection
rows={rows}
columns={columns}
rowHeight={40}
columnHeaderHeight={40}
getRowClassName={(params) =>
params.indexRelativeToCurrentPage % 2 === 0 ? 'even' : 'odd'
}
initialState={{
pagination: { paginationModel: { pageSize: 10 } },
pagination: { paginationModel: { pageSize: 20 } },
}}
pageSizeOptions={[10, 25, 50]}
pageSizeOptions={[10, 20, 50]}
disableColumnResize
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,12 @@ export default function CustomizedTreeView() {
return (
<Card
variant="outlined"
sx={{ display: 'flex', flexDirection: 'column', gap: '8px' }}
sx={{ display: 'flex', flexDirection: 'column', gap: '8px', flexGrow: 1 }}
>
<CardContent>
<Typography variant="subtitle2">Product tree</Typography>
<Typography component="h2" variant="subtitle2">
Product tree
</Typography>
<RichTreeView
items={ITEMS}
aria-label="pages"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,12 @@ export default function CustomizedTreeView() {
return (
<Card
variant="outlined"
sx={{ display: 'flex', flexDirection: 'column', gap: '8px' }}
sx={{ display: 'flex', flexDirection: 'column', gap: '8px', flexGrow: 1 }}
>
<CardContent>
<Typography variant="subtitle2">Product tree</Typography>
<Typography component="h2" variant="subtitle2">
Product tree
</Typography>
<RichTreeView
items={ITEMS}
aria-label="pages"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,32 +1,45 @@
import * as React from 'react';
import PropTypes from 'prop-types';

import Stack from '@mui/material/Stack';
import Typography from '@mui/material/Typography';
import Search from './Search';
import NotificationsRoundedIcon from '@mui/icons-material/NotificationsRounded';
import CustomDatePicker from './CustomDatePicker';
import NavbarBreadcrumbs from './NavbarBreadcrumbs';
import ToggleColorMode from './ToggleColorMode';
import MenuButton from './MenuButton';

import Search from './Search';

export default function Header() {
function Header({ mode, toggleColorMode }) {
return (
<Stack
direction={{ xs: 'column', md: 'row' }}
direction="row"
sx={{
alignItems: { xs: 'flex-start', md: 'flex-end' },
display: { xs: 'none', md: 'flex' },
width: '100%',
alignItems: { xs: 'flex-start', md: 'center' },
justifyContent: 'space-between',
gap: 2,
my: 2,
maxWidth: { sm: '100%', md: '1700px' },
}}
spacing={2}
>
<Stack sx={{ maxWidth: 500 }}>
<Typography variant="h4" component="h1">
Dashboard
</Typography>
<Typography sx={{ color: 'text.secondary' }}>
Real-time analytics to improve user engagement and guide strategy.
</Typography>
</Stack>
<Stack direction="row" sx={{ gap: 1, width: { xs: '100%', sm: 'auto' } }}>
<NavbarBreadcrumbs />
<Stack direction="row" sx={{ gap: 1 }}>
<Search />
<CustomDatePicker />
<MenuButton showBadge aria-label="Open notifications">
<NotificationsRoundedIcon />
</MenuButton>

<ToggleColorMode mode={mode} toggleColorMode={toggleColorMode} />
</Stack>
</Stack>
);
}

Header.propTypes = {
mode: PropTypes.oneOf(['dark', 'light']).isRequired,
toggleColorMode: PropTypes.func.isRequired,
};

export default Header;
Loading