Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
225ac70
fix: package.json pretty print Closes #4643
rkristelijn Jan 31, 2025
2628997
Merge branch 'master' into master
bharatkashyap Feb 3, 2025
9d0d2e3
Merge branch 'master' into master
bharatkashyap Feb 11, 2025
d9e28ea
Merge branch 'mui:master' into master
rkristelijn Feb 14, 2025
4769295
Merge branch 'mui:master' into master
rkristelijn Mar 14, 2025
5a2a52d
Merge branch 'mui:master' into master
rkristelijn Mar 19, 2025
982a79b
chore(dashboard-layout): add custom toolbar
rkristelijn Mar 28, 2025
e26102d
feat(dashboard-layout): add cart and custom toolbar
rkristelijn Mar 31, 2025
32ae5b6
chore: add example
rkristelijn Mar 31, 2025
434c893
fix: searchbar layout:
rkristelijn Mar 31, 2025
5f45f01
chore(dashboard-layout): applied comments
rkristelijn Apr 2, 2025
7723447
chore(playground): reverts changes
rkristelijn Apr 2, 2025
6ad6279
refactor(dashboard-layout): add properties
rkristelijn Apr 2, 2025
3062c81
refactor(dashboard-layout): removes extensive docs
rkristelijn Apr 2, 2025
be5fc8e
docs(dashboard-layout): Add custom toolbar
rkristelijn Apr 3, 2025
f0e8805
refactor(dashboard-layout): improve layout
rkristelijn Apr 3, 2025
be2f8e5
Merge branch 'mui:master' into master
rkristelijn Apr 7, 2025
cf9f2b4
chore: merge master
rkristelijn Apr 7, 2025
d37db35
chore: revert playground
rkristelijn Apr 7, 2025
92bbc8d
Merge branch 'mui:master' into master
rkristelijn Apr 14, 2025
0aa845e
Merge branch 'mui:master' into master
rkristelijn Apr 19, 2025
fd67d8b
refactor(dashboard-layout): reduced documentation, cleanup comments
rkristelijn Apr 19, 2025
1cd788e
docs: cleanup
rkristelijn Apr 19, 2025
53a3507
Merge branch 'mui:master' into master
rkristelijn Apr 22, 2025
50ae1a0
Merge branch 'mui:master' into master
rkristelijn Apr 24, 2025
602cda9
Merge remote-tracking branch 'origin/master' into feat/custom-toolbar
rkristelijn Apr 24, 2025
48213a4
fix(dashboard-layout): apply suggested comments
rkristelijn Apr 24, 2025
12b6770
chore: revert playground
rkristelijn Apr 24, 2025
b765060
fix(dashboard-layout): wrap the full appbar
rkristelijn Apr 24, 2025
283e31b
Merge branch 'mui:master' into master
rkristelijn Apr 26, 2025
695b23f
chore: revert accidantally toolbarActions property rename
rkristelijn Apr 26, 2025
675c984
Merge branch 'master' into feat/custom-toolbar
rkristelijn Apr 26, 2025
201a17b
Apply suggestions from code review
rkristelijn May 2, 2025
2753405
feat(dashboard-layout): add default example
rkristelijn May 6, 2025
bb6a3ad
feat(playground): ooops, that playground again
rkristelijn May 6, 2025
28bf06c
Review, add fixes and improvements, refactor DashboardHeader as separ…
apedroferreira May 7, 2025
9af5372
Add fixes
apedroferreira May 7, 2025
c639580
More updates
apedroferreira May 7, 2025
a930295
Update docs
apedroferreira May 7, 2025
fd56d94
Fix tests
apedroferreira May 7, 2025
0bd0cfa
Merge remote-tracking branch 'upstream/master' into feat/custom-toolbar
apedroferreira May 7, 2025
5235275
Test solution was wrong
apedroferreira May 7, 2025
742853e
Update docs demo
apedroferreira May 7, 2025
ceb06cd
Fix header slot props override
apedroferreira May 7, 2025
bb73107
Adjust one more docs demo
apedroferreira May 7, 2025
89fcb59
Add todo comment
apedroferreira May 7, 2025
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
Expand Up @@ -13,7 +13,7 @@ import { createTheme } from '@mui/material/styles';
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 { DashboardLayout, ThemeSwitcher } from '@toolpad/core/DashboardLayout';
import {
Account,
AccountPreview,
Expand Down Expand Up @@ -56,6 +56,14 @@ const demoTheme = createTheme({
},
});

function CustomToolbarActions() {
return (
<Stack direction="row" alignItems="center">
<ThemeSwitcher />
</Stack>
);
}

function DemoPageContent({ pathname }) {
return (
<Box
Expand Down Expand Up @@ -281,7 +289,10 @@ function DashboardLayoutAccountSidebar(props) {
>
{/* preview-start */}
<DashboardLayout
slots={{ toolbarAccount: () => null, sidebarFooter: SidebarFooterAccount }}
slots={{
toolbarActions: CustomToolbarActions,
sidebarFooter: SidebarFooterAccount,
}}
>
<DemoPageContent pathname={pathname} />
</DashboardLayout>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ import { createTheme } from '@mui/material/styles';
import DashboardIcon from '@mui/icons-material/Dashboard';
import ShoppingCartIcon from '@mui/icons-material/ShoppingCart';
import { AppProvider } from '@toolpad/core/AppProvider';
import { DashboardLayout, SidebarFooterProps } from '@toolpad/core/DashboardLayout';
import {
DashboardLayout,
SidebarFooterProps,
ThemeSwitcher,
} from '@toolpad/core/DashboardLayout';
import {
Account,
AccountPreview,
Expand Down Expand Up @@ -56,6 +60,14 @@ const demoTheme = createTheme({
},
});

function CustomToolbarActions() {
return (
<Stack direction="row" alignItems="center">
<ThemeSwitcher />
</Stack>
);
}

function DemoPageContent({ pathname }: { pathname: string }) {
return (
<Box
Expand Down Expand Up @@ -267,7 +279,10 @@ export default function DashboardLayoutAccountSidebar(props: DemoProps) {
>
{/* preview-start */}
<DashboardLayout
slots={{ toolbarAccount: () => null, sidebarFooter: SidebarFooterAccount }}
slots={{
toolbarActions: CustomToolbarActions,
sidebarFooter: SidebarFooterAccount,
}}
>
<DemoPageContent pathname={pathname} />
</DashboardLayout>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<DashboardLayout
slots={{ toolbarAccount: () => null, sidebarFooter: SidebarFooterAccount }}
slots={{
toolbarActions: CustomToolbarActions,
sidebarFooter: SidebarFooterAccount,
}}
>
<DemoPageContent pathname={pathname} />
</DashboardLayout>
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import IconButton from '@mui/material/IconButton';
import Popover from '@mui/material/Popover';
import Radio from '@mui/material/Radio';
import RadioGroup from '@mui/material/RadioGroup';
import Stack from '@mui/material/Stack';
import Tooltip from '@mui/material/Tooltip';
import Typography from '@mui/material/Typography';
import { createTheme, useColorScheme } from '@mui/material/styles';
Expand All @@ -16,6 +17,7 @@ import ShoppingCartIcon from '@mui/icons-material/ShoppingCart';
import SettingsIcon from '@mui/icons-material/Settings';
import { AppProvider } from '@toolpad/core/AppProvider';
import { DashboardLayout } from '@toolpad/core/DashboardLayout';
import { Account } from '@toolpad/core/Account';
import { DemoProvider, useDemoRouter } from '@toolpad/core/internal';

const NAVIGATION = [
Expand Down Expand Up @@ -131,6 +133,15 @@ function CustomThemeSwitcher() {
);
}

function CustomToolbarActions() {
return (
<Stack direction="row" alignItems="center">
<CustomThemeSwitcher />
<Account />
</Stack>
);
}

function DashboardLayoutCustomThemeSwitcher(props) {
const { window } = props;

Expand All @@ -151,7 +162,7 @@ function DashboardLayoutCustomThemeSwitcher(props) {
{/* preview-start */}
<DashboardLayout
slots={{
toolbarActions: CustomThemeSwitcher,
toolbarActions: CustomToolbarActions,
}}
>
<DemoPageContent pathname={router.pathname} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import IconButton from '@mui/material/IconButton';
import Popover from '@mui/material/Popover';
import Radio from '@mui/material/Radio';
import RadioGroup from '@mui/material/RadioGroup';
import Stack from '@mui/material/Stack';
import Tooltip from '@mui/material/Tooltip';
import Typography from '@mui/material/Typography';
import { createTheme, useColorScheme } from '@mui/material/styles';
Expand All @@ -15,6 +16,7 @@ import ShoppingCartIcon from '@mui/icons-material/ShoppingCart';
import SettingsIcon from '@mui/icons-material/Settings';
import { AppProvider, type Navigation } from '@toolpad/core/AppProvider';
import { DashboardLayout } from '@toolpad/core/DashboardLayout';
import { Account } from '@toolpad/core/Account';
import { DemoProvider, useDemoRouter } from '@toolpad/core/internal';

const NAVIGATION: Navigation = [
Expand Down Expand Up @@ -126,6 +128,15 @@ function CustomThemeSwitcher() {
);
}

function CustomToolbarActions() {
return (
<Stack direction="row" alignItems="center">
<CustomThemeSwitcher />
<Account />
</Stack>
);
}

interface DemoProps {
/**
* Injected by the documentation to work in an iframe.
Expand Down Expand Up @@ -154,7 +165,7 @@ export default function DashboardLayoutCustomThemeSwitcher(props: DemoProps) {
{/* preview-start */}
<DashboardLayout
slots={{
toolbarActions: CustomThemeSwitcher,
toolbarActions: CustomToolbarActions,
}}
>
<DemoPageContent pathname={router.pathname} />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<DashboardLayout
slots={{
toolbarActions: CustomThemeSwitcher,
toolbarActions: CustomToolbarActions,
}}
>
<DemoPageContent pathname={router.pathname} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import CheckCircleIcon from '@mui/icons-material/CheckCircle';
import SearchIcon from '@mui/icons-material/Search';
import { AppProvider } from '@toolpad/core/AppProvider';
import { DashboardLayout, ThemeSwitcher } from '@toolpad/core/DashboardLayout';
import { Account } from '@toolpad/core/Account';
import { DemoProvider, useDemoRouter } from '@toolpad/core/internal';

const NAVIGATION = [
Expand Down Expand Up @@ -103,6 +104,7 @@ function ToolbarActionsSearch() {
sx={{ display: { xs: 'none', md: 'inline-block' }, mr: 1 }}
/>
<ThemeSwitcher />
<Account />
</Stack>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
ThemeSwitcher,
type SidebarFooterProps,
} from '@toolpad/core/DashboardLayout';
import { Account } from '@toolpad/core/Account';
import { DemoProvider, useDemoRouter } from '@toolpad/core/internal';

const NAVIGATION: Navigation = [
Expand Down Expand Up @@ -102,6 +103,7 @@ function ToolbarActionsSearch() {
sx={{ display: { xs: 'none', md: 'inline-block' }, mr: 1 }}
/>
<ThemeSwitcher />
<Account />
</Stack>
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
productId: toolpad-core
title: Dashboard Layout
components: AppProvider, DashboardLayout, ToolbarActions, ThemeSwitcher, Account, DashboardSidebarPageItem
components: AppProvider, DashboardLayout, DashboardHeader, ToolbarActions, ThemeSwitcher, Account, DashboardSidebarPageItem
---

# Dashboard Layout
Expand Down Expand Up @@ -164,9 +164,11 @@ Some possibly useful slots:

- `appTitle`: allows you to customize the app title section in the layout header.

- `toolbarActions`: allows you to add new items to the toolbar in the header, such as a search bar or button. The default `ThemeSwitcher` component can be imported and used if you wish to do so, as shown in the example below.
- `toolbarActions`: allows you to add new items to the toolbar in the header, such as a search bar or button. The default `ThemeSwitcher` and `Account` components can be imported and used if you wish to do so, as shown in the example below.

- `sidebarFooter`: allows you to add footer content in the sidebar.
- `header`: allows you to fully replace and customize the layout header.

- `sidebarFooter`: allows you to add a footer to the sidebar.

{{"demo": "DashboardLayoutSlots.js", "height": 400, "iframe": true}}

Expand Down
1 change: 1 addition & 0 deletions docs/data/toolpad/core/pagesApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export default [
{ pathname: '/toolpad/core/api/crud' },
{ pathname: '/toolpad/core/api/crud-form' },
{ pathname: '/toolpad/core/api/crud-provider' },
{ pathname: '/toolpad/core/api/dashboard-header' },
{ pathname: '/toolpad/core/api/dashboard-layout' },
{ pathname: '/toolpad/core/api/dashboard-sidebar-page-item' },
{ pathname: '/toolpad/core/api/dialogs-provider' },
Expand Down
23 changes: 23 additions & 0 deletions docs/pages/toolpad/core/api/dashboard-header.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import * as React from 'react';
import ApiPage from 'docs/src/modules/components/ApiPage';
import mapApiPageTranslations from 'docs/src/modules/utils/mapApiPageTranslations';
import jsonPageContent from './dashboard-header.json';

export default function Page(props) {
const { descriptions, pageContent } = props;
return <ApiPage descriptions={descriptions} pageContent={pageContent} />;
}

Page.getInitialProps = () => {
const req = require.context(
'docs-toolpad/translations/api-docs/dashboard-header',
false,
/\.\/dashboard-header.*.json$/,
);
const descriptions = mapApiPageTranslations(req);

return {
descriptions,
pageContent: jsonPageContent,
};
};
57 changes: 57 additions & 0 deletions docs/pages/toolpad/core/api/dashboard-header.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"props": {
"menuOpen": { "type": { "name": "bool" }, "required": true },
"onToggleMenu": { "type": { "name": "func" }, "required": true },
"branding": {
"type": {
"name": "shape",
"description": "{ homeUrl?: string, logo?: node, title?: string }"
},
"default": "null"
},
"hideMenuButton": { "type": { "name": "bool" }, "default": "false" },
"slotProps": {
"type": {
"name": "shape",
"description": "{ appTitle?: { branding?: { homeUrl?: string, logo?: node, title?: string } }, toolbarAccount?: { localeText?: object, slotProps?: { popover?: object, popoverContent?: object, preview?: object, signInButton?: object, signOutButton?: object }, slots?: { popover?: elementType, popoverContent?: elementType, preview?: elementType, signInButton?: elementType, signOutButton?: elementType } }, toolbarActions?: object }"
},
"default": "{}"
},
"slots": {
"type": {
"name": "shape",
"description": "{ appTitle?: elementType, toolbarAccount?: elementType, toolbarActions?: elementType }"
},
"default": "{}",
"additionalInfo": { "slotsApi": true }
}
},
"name": "DashboardHeader",
"imports": ["import { DashboardHeader } from '@toolpad/core/DashboardLayout';"],
"slots": [
{
"name": "appTitle",
"description": "The component used for the app title section.",
"default": "Link",
"class": null
},
{
"name": "toolbarActions",
"description": "The toolbar actions component to be used.",
"default": "ToolbarActions",
"class": null
},
{
"name": "toolbarAccount",
"description": "The toolbar account component to be used.",
"default": "Account",
"class": null
}
],
"classes": [],
"muiName": "DashboardHeader",
"filename": "/packages/toolpad-core/src/DashboardLayout/DashboardHeader.tsx",
"inheritance": null,
"demos": "<ul><li><a href=\"/toolpad/core/react-dashboard-layout/\">Dashboard Layout</a></li></ul>",
"cssComponent": false
}
10 changes: 8 additions & 2 deletions docs/pages/toolpad/core/api/dashboard-layout.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@
"slotProps": {
"type": {
"name": "shape",
"description": "{ appTitle?: { branding?: { homeUrl?: string, logo?: node, title?: string } }, sidebarFooter?: { mini: bool }, toolbarAccount?: { localeText?: object, slotProps?: { popover?: object, popoverContent?: object, preview?: object, signInButton?: object, signOutButton?: object }, slots?: { popover?: elementType, popoverContent?: elementType, preview?: elementType, signInButton?: elementType, signOutButton?: elementType } }, toolbarActions?: object }"
"description": "{ appTitle?: { branding?: { homeUrl?: string, logo?: node, title?: string } }, header?: { branding?: { homeUrl?: string, logo?: node, title?: string }, hideMenuButton?: bool, menuOpen: bool, onToggleMenu: func, slotProps?: { appTitle?: object, toolbarAccount?: object, toolbarActions?: object }, slots?: { appTitle?: elementType, toolbarAccount?: elementType, toolbarActions?: elementType } }, sidebarFooter?: { mini: bool }, toolbarAccount?: { localeText?: object, slotProps?: { popover?: object, popoverContent?: object, preview?: object, signInButton?: object, signOutButton?: object }, slots?: { popover?: elementType, popoverContent?: elementType, preview?: elementType, signInButton?: elementType, signOutButton?: elementType } }, toolbarActions?: object }"
},
"default": "{}"
},
"slots": {
"type": {
"name": "shape",
"description": "{ appTitle?: elementType, sidebarFooter?: elementType, toolbarAccount?: elementType, toolbarActions?: elementType }"
"description": "{ appTitle?: elementType, header?: elementType, sidebarFooter?: elementType, toolbarAccount?: elementType, toolbarActions?: elementType }"
},
"default": "{}",
"additionalInfo": { "slotsApi": true }
Expand Down Expand Up @@ -78,6 +78,12 @@
"default": "Account",
"class": null
},
{
"name": "header",
"description": "The component used for the layout header.",
"default": "DashboardHeader",
"class": null
},
{
"name": "sidebarFooter",
"description": "Optional footer component used in the layout sidebar.",
Expand Down
19 changes: 19 additions & 0 deletions docs/translations/api-docs/dashboard-header/dashboard-header.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"componentDescription": "",
"propDescriptions": {
"branding": { "description": "Branding options for the header." },
"hideMenuButton": { "description": "Whether the menu icon should always be hidden." },
"menuOpen": {
"description": "If <code>true</code>, show menu button as if menu is expanded, otherwise show it as if menu is collapsed."
},
"onToggleMenu": { "description": "Callback fired when the menu button is clicked." },
"slotProps": { "description": "The props used for each slot inside." },
"slots": { "description": "The components used for each slot inside." }
},
"classDescriptions": {},
"slotDescriptions": {
"appTitle": "The component used for the app title section.",
"toolbarAccount": "The toolbar account component to be used.",
"toolbarActions": "The toolbar actions component to be used."
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"classDescriptions": {},
"slotDescriptions": {
"appTitle": "The component used for the app title section in the layout header.",
"header": "The component used for the layout header.",
"sidebarFooter": "Optional footer component used in the layout sidebar.",
"toolbarAccount": "The toolbar account component used in the layout header.",
"toolbarActions": "The toolbar actions component used in the layout header."
Expand Down
Loading