Skip to content

Commit

Permalink
Add DashboardLayout component to @toolpad/core (#3554)
Browse files Browse the repository at this point in the history
  • Loading branch information
apedroferreira authored May 21, 2024
1 parent 282d1b7 commit 6174b03
Show file tree
Hide file tree
Showing 27 changed files with 1,181 additions and 105 deletions.
3 changes: 3 additions & 0 deletions docs/data/toolpad/core/api/components/dashboard-layout.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Dashboard Layout API

<p class="description">DashboardLayout API reference</p>
3 changes: 0 additions & 3 deletions docs/data/toolpad/core/api/components/dashboard.md

This file was deleted.

2 changes: 1 addition & 1 deletion docs/data/toolpad/core/api/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## Components

- [Dashboard](/toolpad/core/api/dashboard/)
- [Dashboard Layout](/toolpad/core/api/dashboard-layout/)
- [Data Grid](/toolpad/core/api/data-grid/)
- [Line Chart](/toolpad/core/api/line-chart/)
- [Select Filter](/toolpad/core/api/select-filter/)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import * as React from 'react';
import Box from '@mui/material/Box';
import Typography from '@mui/material/Typography';
import DashboardIcon from '@mui/icons-material/Dashboard';
import ShoppingCartIcon from '@mui/icons-material/ShoppingCart';
import BarChartIcon from '@mui/icons-material/BarChart';
import DescriptionIcon from '@mui/icons-material/Description';
import LayersIcon from '@mui/icons-material/Layers';
import { AppProvider } from '@toolpad/core/AppProvider';
import { DashboardLayout } from '@toolpad/core/DashboardLayout';

const NAVIGATION = [
{
kind: 'header',
title: 'Main items',
},
{
title: 'Dashboard',
icon: <DashboardIcon />,
},
{
title: 'Orders',
icon: <ShoppingCartIcon />,
},
{
kind: 'divider',
},
{
kind: 'header',
title: 'Analytics',
},
{
title: 'Reports',
icon: <BarChartIcon />,
children: [
{
title: 'Sales',
icon: <DescriptionIcon />,
},
{
title: 'Traffic',
icon: <DescriptionIcon />,
},
],
},
{
title: 'Integrations',
icon: <LayersIcon />,
},
];

export default function DashboardLayoutBasic() {
return (
<AppProvider navigation={NAVIGATION}>
<DashboardLayout>
<Box
sx={{
py: 4,
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
}}
>
<Typography>Dashboard content goes here.</Typography>
</Box>
</DashboardLayout>
</AppProvider>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import * as React from 'react';
import Box from '@mui/material/Box';
import Typography from '@mui/material/Typography';
import DashboardIcon from '@mui/icons-material/Dashboard';
import ShoppingCartIcon from '@mui/icons-material/ShoppingCart';
import BarChartIcon from '@mui/icons-material/BarChart';
import DescriptionIcon from '@mui/icons-material/Description';
import LayersIcon from '@mui/icons-material/Layers';
import { AppProvider } from '@toolpad/core/AppProvider';
import { DashboardLayout } from '@toolpad/core/DashboardLayout';
import type { Navigation } from '@toolpad/core';

const NAVIGATION: Navigation = [
{
kind: 'header',
title: 'Main items',
},
{
title: 'Dashboard',
icon: <DashboardIcon />,
},
{
title: 'Orders',
icon: <ShoppingCartIcon />,
},
{
kind: 'divider',
},
{
kind: 'header',
title: 'Analytics',
},
{
title: 'Reports',
icon: <BarChartIcon />,
children: [
{
title: 'Sales',
icon: <DescriptionIcon />,
},
{
title: 'Traffic',
icon: <DescriptionIcon />,
},
],
},
{
title: 'Integrations',
icon: <LayersIcon />,
},
];

export default function DashboardLayoutBasic() {
return (
<AppProvider navigation={NAVIGATION}>
<DashboardLayout>
<Box
sx={{
py: 4,
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
}}
>
<Typography>Dashboard content goes here.</Typography>
</Box>
</DashboardLayout>
</AppProvider>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import * as React from 'react';
import Box from '@mui/material/Box';
import Typography from '@mui/material/Typography';
import DashboardIcon from '@mui/icons-material/Dashboard';
import ShoppingCartIcon from '@mui/icons-material/ShoppingCart';
import { AppProvider } from '@toolpad/core/AppProvider';
import { DashboardLayout } from '@toolpad/core/DashboardLayout';

const NAVIGATION = [
{
title: 'Dashboard',
icon: <DashboardIcon />,
},
{
title: 'Orders',
icon: <ShoppingCartIcon />,
},
];

const BRANDING = {
logo: <img src="https://mui.com/static/logo.png" alt="MUI logo" />,
title: 'MUI',
};

export default function DashboardLayoutBranding() {
return (
<AppProvider navigation={NAVIGATION} branding={BRANDING}>
<DashboardLayout>
<Box
sx={{
py: 4,
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
}}
>
<Typography>Dashboard content goes here.</Typography>
</Box>
</DashboardLayout>
</AppProvider>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import * as React from 'react';
import Box from '@mui/material/Box';
import Typography from '@mui/material/Typography';
import DashboardIcon from '@mui/icons-material/Dashboard';
import ShoppingCartIcon from '@mui/icons-material/ShoppingCart';
import { AppProvider } from '@toolpad/core/AppProvider';
import { DashboardLayout } from '@toolpad/core/DashboardLayout';
import type { Navigation, Branding } from '@toolpad/core';

const NAVIGATION: Navigation = [
{
title: 'Dashboard',
icon: <DashboardIcon />,
},
{
title: 'Orders',
icon: <ShoppingCartIcon />,
},
];

const BRANDING: Branding = {
logo: <img src="https://mui.com/static/logo.png" alt="MUI logo" />,
title: 'MUI',
};

export default function DashboardLayoutBranding() {
return (
<AppProvider navigation={NAVIGATION} branding={BRANDING}>
<DashboardLayout>
<Box
sx={{
py: 4,
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
}}
>
<Typography>Dashboard content goes here.</Typography>
</Box>
</DashboardLayout>
</AppProvider>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
import * as React from 'react';
import Box from '@mui/material/Box';
import Typography from '@mui/material/Typography';
import DescriptionIcon from '@mui/icons-material/Description';
import FolderIcon from '@mui/icons-material/Folder';
import { AppProvider } from '@toolpad/core/AppProvider';
import { DashboardLayout } from '@toolpad/core/DashboardLayout';

const NAVIGATION = [
{
title: 'Item 1',
icon: <DescriptionIcon />,
},
{
title: 'Item 2',
icon: <DescriptionIcon />,
},
{
title: 'Folder 1',
icon: <FolderIcon />,
children: [
{
title: 'Item A1',
icon: <DescriptionIcon />,
},
{
title: 'Item A2',
icon: <DescriptionIcon />,
},
{
title: 'Folder A1',
icon: <FolderIcon />,
children: [
{
title: 'Item B1',
icon: <DescriptionIcon />,
},
{
title: 'Item B2',
icon: <DescriptionIcon />,
},
],
},
],
},
{ kind: 'divider' },
{
kind: 'header',
title: 'Header 1',
},
{
title: 'Item A',
icon: <DescriptionIcon />,
},
{
kind: 'header',
title: 'Header 2',
},
{
title: 'Item B',
icon: <DescriptionIcon />,
},
{
title: 'Folder 2',
icon: <FolderIcon />,
children: [
{
kind: 'header',
title: 'Header A1',
},
{
title: 'Item C1',
icon: <DescriptionIcon />,
},
{
title: 'Item C2',
icon: <DescriptionIcon />,
},
{ kind: 'divider' },
{
kind: 'header',
title: 'Header A2',
},
{
title: 'Item C3',
icon: <DescriptionIcon />,
},
],
},
];

export default function DashboardLayoutNavigation() {
return (
<AppProvider navigation={NAVIGATION}>
<DashboardLayout>
<Box
sx={{
py: 4,
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
}}
>
<Typography>Dashboard content goes here.</Typography>
</Box>
</DashboardLayout>
</AppProvider>
);
}
Loading

0 comments on commit 6174b03

Please sign in to comment.