@@ -2,33 +2,14 @@ import * as React from 'react';
22
33import { Resource , testDataProvider } from 'ra-core' ;
44import { defaultTheme , Admin } from 'react-admin' ;
5- import { AppBar , Typography , Box } from '@mui/material' ;
6- import { createTheme } from '@mui/material/styles' ;
7- import { ToggleThemeButton } from '../button' ;
8- import { Layout , Menu , SidebarToggleButton , Title } from '.' ;
5+ import { Typography , ThemeOptions } from '@mui/material' ;
6+ import { Layout , Menu , Title } from '.' ;
97
108export default { title : 'ra-ui-materialui/layout/Menu' } ;
119
1210const resources = [ 'Posts' , 'Comments' , 'Tags' , 'Users' , 'Orders' , 'Reviews' ] ;
1311
14- const DemoAppBar = ( ) => {
15- const darkTheme = createTheme ( {
16- palette : { mode : 'dark' } ,
17- } ) ;
18- return (
19- < AppBar elevation = { 1 } sx = { { flexDirection : 'row' , flexWrap : 'nowrap' } } >
20- < Box sx = { { flex : '1 1 100%' } } >
21- < SidebarToggleButton />
22- </ Box >
23- < Box sx = { { flex : '0 0 auto' } } >
24- < ToggleThemeButton
25- lightTheme = { defaultTheme }
26- darkTheme = { darkTheme }
27- />
28- </ Box >
29- </ AppBar >
30- ) ;
31- } ;
12+ const darkTheme : ThemeOptions = { ...defaultTheme , palette : { mode : 'dark' } } ;
3213
3314const DemoList = ( { name } ) => (
3415 < >
@@ -38,47 +19,43 @@ const DemoList = ({ name }) => (
3819) ;
3920
4021export const Default = ( ) => {
41- const DefaultLayout = props => (
42- < Layout { ...props } menu = { MenuDefault } appBar = { DemoAppBar } />
43- ) ;
44- const MenuDefault = ( ) => {
45- return < Menu hasDashboard = { true } dense = { false } /> ;
46- } ;
22+ const MenuDefault = ( ) => < Menu hasDashboard = { true } dense = { false } /> ;
23+ const DefaultLayout = props => < Layout { ...props } menu = { MenuDefault } /> ;
4724
4825 return (
49- < Admin dataProvider = { testDataProvider ( ) } layout = { DefaultLayout } >
50- { resources . map ( ( resource , index ) => {
51- return (
52- < Resource
53- name = { resource }
54- key = { `resource_${ index } ` }
55- list = { < DemoList name = { resource } /> }
56- />
57- ) ;
58- } ) }
26+ < Admin
27+ dataProvider = { testDataProvider ( ) }
28+ layout = { DefaultLayout }
29+ darkTheme = { darkTheme }
30+ >
31+ { resources . map ( ( resource , index ) => (
32+ < Resource
33+ name = { resource }
34+ key = { `resource_${ index } ` }
35+ list = { < DemoList name = { resource } /> }
36+ />
37+ ) ) }
5938 </ Admin >
6039 ) ;
6140} ;
6241
6342export const Dense = ( ) => {
64- const LayoutDense = props => (
65- < Layout { ...props } menu = { MenuDense } appBar = { DemoAppBar } />
66- ) ;
67- const MenuDense = props => {
68- return < Menu { ...props } hasDashboard = { true } dense = { true } /> ;
69- } ;
43+ const MenuDense = props => < Menu hasDashboard = { true } dense = { true } /> ;
44+ const LayoutDense = props => < Layout { ...props } menu = { MenuDense } /> ;
7045
7146 return (
72- < Admin dataProvider = { testDataProvider ( ) } layout = { LayoutDense } >
73- { resources . map ( ( resource , index ) => {
74- return (
75- < Resource
76- name = { resource }
77- key = { `resource_${ index } ` }
78- list = { < DemoList name = { resource } /> }
79- />
80- ) ;
81- } ) }
47+ < Admin
48+ dataProvider = { testDataProvider ( ) }
49+ layout = { LayoutDense }
50+ darkTheme = { darkTheme }
51+ >
52+ { resources . map ( ( resource , index ) => (
53+ < Resource
54+ name = { resource }
55+ key = { `resource_${ index } ` }
56+ list = { < DemoList name = { resource } /> }
57+ />
58+ ) ) }
8259 </ Admin >
8360 ) ;
8461} ;
0 commit comments