|
| 1 | +import { |
| 2 | + Box, |
| 3 | + ListItemIcon, |
| 4 | + ListItemText, |
| 5 | + MenuItem, |
| 6 | + MenuList, |
| 7 | + Skeleton, |
| 8 | + ThemeProvider, |
| 9 | + createTheme, |
| 10 | +} from '@mui/material'; |
| 11 | +import DashboardIcon from '@mui/icons-material/Dashboard'; |
| 12 | +import ShoppingCartIcon from '@mui/icons-material/ShoppingCart'; |
| 13 | +import PeopleIcon from '@mui/icons-material/People'; |
| 14 | +import { |
| 15 | + AuthContext, |
| 16 | + PreferencesEditorContextProvider, |
| 17 | + StoreContextProvider, |
| 18 | + memoryStore, |
| 19 | +} from 'ra-core'; |
| 20 | +import * as React from 'react'; |
| 21 | +import { QueryClient, QueryClientProvider } from 'react-query'; |
| 22 | +import { MemoryRouter } from 'react-router'; |
| 23 | + |
| 24 | +import { defaultTheme } from '../defaultTheme'; |
| 25 | +import { Layout } from './Layout'; |
| 26 | +import { Title } from './Title'; |
| 27 | + |
| 28 | +export default { |
| 29 | + title: 'ra-ui-materialui/layout/Layout', |
| 30 | +}; |
| 31 | + |
| 32 | +const Content = () => ( |
| 33 | + <Box> |
| 34 | + <Skeleton |
| 35 | + variant="text" |
| 36 | + width="auto" |
| 37 | + sx={{ fontSize: '2rem', mx: 2 }} |
| 38 | + animation={false} |
| 39 | + /> |
| 40 | + <Skeleton |
| 41 | + variant="rectangular" |
| 42 | + width="auto" |
| 43 | + height={1500} |
| 44 | + sx={{ mx: 2 }} |
| 45 | + animation={false} |
| 46 | + /> |
| 47 | + </Box> |
| 48 | +); |
| 49 | + |
| 50 | +const Wrapper = ({ |
| 51 | + children = <Content />, |
| 52 | + theme = createTheme(defaultTheme), |
| 53 | + layout: LayoutProp = Layout, |
| 54 | +}) => ( |
| 55 | + <MemoryRouter> |
| 56 | + <QueryClientProvider client={new QueryClient()}> |
| 57 | + <ThemeProvider theme={theme}> |
| 58 | + <StoreContextProvider value={memoryStore()}> |
| 59 | + <PreferencesEditorContextProvider> |
| 60 | + <AuthContext.Provider value={undefined as any}> |
| 61 | + <LayoutProp> |
| 62 | + {children} |
| 63 | + <Title title="React Admin" /> |
| 64 | + </LayoutProp> |
| 65 | + </AuthContext.Provider> |
| 66 | + </PreferencesEditorContextProvider> |
| 67 | + </StoreContextProvider> |
| 68 | + </ThemeProvider> |
| 69 | + </QueryClientProvider> |
| 70 | + </MemoryRouter> |
| 71 | +); |
| 72 | + |
| 73 | +const Menu = () => ( |
| 74 | + <MenuList> |
| 75 | + <MenuItem> |
| 76 | + <ListItemIcon> |
| 77 | + <DashboardIcon /> |
| 78 | + </ListItemIcon> |
| 79 | + <ListItemText>Dashboard</ListItemText> |
| 80 | + </MenuItem> |
| 81 | + <MenuItem> |
| 82 | + <ListItemIcon> |
| 83 | + <ShoppingCartIcon /> |
| 84 | + </ListItemIcon> |
| 85 | + <ListItemText>Orders</ListItemText> |
| 86 | + </MenuItem> |
| 87 | + <MenuItem> |
| 88 | + <ListItemIcon> |
| 89 | + <PeopleIcon /> |
| 90 | + </ListItemIcon> |
| 91 | + <ListItemText>Customers</ListItemText> |
| 92 | + </MenuItem> |
| 93 | + </MenuList> |
| 94 | +); |
| 95 | + |
| 96 | +const BasicLayout = props => <Layout menu={Menu} {...props} />; |
| 97 | +export const Basic = () => <Wrapper layout={BasicLayout} />; |
| 98 | + |
| 99 | +const AppBarAlwaysOnLayout = props => <BasicLayout appBarAlwaysOn {...props} />; |
| 100 | +export const AppBarAlwaysOn = () => <Wrapper layout={AppBarAlwaysOnLayout} />; |
0 commit comments