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

Add DashboardLayout component to @toolpad/core #3343

Closed
wants to merge 73 commits into from
Closed
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
bebb82e
Improve bundling, try to fix MUI/Next integration bugs
apedroferreira Mar 28, 2024
03786bd
Fix import in template
apedroferreira Mar 28, 2024
fd68ff0
fix it more
apedroferreira Mar 28, 2024
4d04649
Re-add icon imports
apedroferreira Mar 28, 2024
8630f2a
Always clean or it gets messy
apedroferreira Mar 28, 2024
235116a
Basic layout - a start
apedroferreira Mar 29, 2024
1311f6f
Remove unused icon
apedroferreira Apr 1, 2024
8f6c9db
Basic header, sidebar in progress
apedroferreira Apr 2, 2024
e6d436b
Header with branding + navigation with nesting
apedroferreira Apr 3, 2024
4807db7
Grammar
apedroferreira Apr 3, 2024
926102f
Much better test
apedroferreira Apr 3, 2024
f0c6180
Update created app files
apedroferreira Apr 4, 2024
4175348
Scaffolding fixes
apedroferreira Apr 4, 2024
8f19dde
Add DashboardLayout tests
apedroferreira Apr 4, 2024
f44f5a0
Remove this thing I guess
apedroferreira Apr 4, 2024
d250929
Nevermind
apedroferreira Apr 4, 2024
06da40c
Fix dependencies if they're broken
apedroferreira Apr 4, 2024
f0a17e4
Merge remote-tracking branch 'upstream/master' into add-layout-component
apedroferreira Apr 4, 2024
3dab0a8
Review fixes, make everything more generic, use playground folder
apedroferreira Apr 16, 2024
eb8a6f1
Build with babel, create development tools
apedroferreira Apr 18, 2024
b8fdf8d
Merge remote-tracking branch 'upstream/master' into add-layout-component
apedroferreira Apr 18, 2024
229dffc
Update create-toolpad-app for core
apedroferreira Apr 18, 2024
1c777d3
Review suggestions and add DashboardLayout demo to docs
apedroferreira Apr 23, 2024
9efd2f5
Merge remote-tracking branch 'upstream/master' into add-layout-component
apedroferreira Apr 23, 2024
c31fe20
Fix this example
apedroferreira Apr 23, 2024
7fd54d4
Dedupe
apedroferreira Apr 23, 2024
c6819a5
Use new navigation system
apedroferreira Apr 26, 2024
c4da025
Better component name
apedroferreira Apr 26, 2024
e105c15
DashboardLayout docs, missing API reference
apedroferreira Apr 30, 2024
0327c4f
Update
apedroferreira May 2, 2024
4b59fc0
Merge remote-tracking branch 'upstream/master' into add-layout-component
apedroferreira May 2, 2024
cbc3045
Reuse theme in docs
apedroferreira May 2, 2024
6508899
Fix core publish
apedroferreira May 2, 2024
34e9255
Rerun install
apedroferreira May 2, 2024
fa9b64f
Fix tests and other errors
apedroferreira May 3, 2024
c21a36e
Set exports too
apedroferreira May 3, 2024
83e99e2
whoops
apedroferreira May 3, 2024
effcabf
Merge branch 'master' into add-layout-component
apedroferreira May 3, 2024
0de2030
Try Netlify deploy with imports from root
apedroferreira May 3, 2024
dd39264
Stupid VSCode setting
apedroferreira May 3, 2024
65acf1d
Linters
apedroferreira May 3, 2024
67f724b
Attempt to fix netlify build
apedroferreira May 6, 2024
4b033f7
Merge remote-tracking branch 'upstream/master' into add-layout-component
apedroferreira May 6, 2024
6da38cb
Try to fix OOM in Circle CI
apedroferreira May 6, 2024
1c4f46b
Another attempt to fix OOM in CI
apedroferreira May 6, 2024
a154f6f
Add Toolpad Core contributing instructions
apedroferreira May 6, 2024
c939d98
Try Jan's changes and some other but keep playground
apedroferreira May 7, 2024
b56c288
Merge remote-tracking branch 'upstream/master' into add-layout-component
apedroferreira May 7, 2024
69f2db0
Another attempt
apedroferreira May 7, 2024
661c6ad
More cleanup before trying to remove playground
apedroferreira May 7, 2024
291c78f
Update lockfile
apedroferreira May 7, 2024
c355188
Retry filter option to try to keep playground alive
apedroferreira May 7, 2024
701187e
Try with correct option
apedroferreira May 7, 2024
fef1864
Dedupe again
apedroferreira May 7, 2024
deb85ea
ugh
apedroferreira May 7, 2024
b3346b9
Maybe this
apedroferreira May 7, 2024
f7a9cbb
Revert last failed attempts
apedroferreira May 8, 2024
31a4af8
Try older pnpm patch version
apedroferreira May 8, 2024
1c996a7
Try latest pnpm minor version
apedroferreira May 8, 2024
631afc1
Try pnpm 9
apedroferreira May 8, 2024
5682085
Properly try previous minor version
apedroferreira May 8, 2024
ce8102e
Try latesg pnpm commit ( I think)
apedroferreira May 8, 2024
22cfa4f
gh
apedroferreira May 8, 2024
8fa6300
Fix mismatched packages
apedroferreira May 8, 2024
8ac56cb
Playing around with pnpm had somehow broken the lockfile permanently
apedroferreira May 8, 2024
09a4741
Final cleanup
apedroferreira May 8, 2024
4e7d81c
Many review improvements, provide some themes too
apedroferreira May 13, 2024
dbc0e1b
Merge remote-tracking branch 'upstream/master' into add-layout-component
apedroferreira May 14, 2024
59e4121
Remove more leftovers
apedroferreira May 14, 2024
9e26e6e
Review fixes, prep to split into another PR
apedroferreira May 14, 2024
6277b31
Add TODO comments
apedroferreira May 14, 2024
3718162
Merge remote-tracking branch 'upstream/master' into add-layout-component
apedroferreira May 24, 2024
136ba8a
Merge remote-tracking branch 'upstream/master' into add-layout-component
apedroferreira May 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
60 changes: 2 additions & 58 deletions packages/create-toolpad-app/src/generateProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,69 +24,13 @@ export default function generateProject(
`;

const dashboardLayoutContent = `
import {
AppBar,
Badge,
Box,
Container,
Divider,
Drawer,
IconButton,
List,
ListItemButton,
ListItemIcon,
Toolbar,
} from "@mui/material";

import HomeIcon from "@mui/icons-material/Home";
import SettingsIcon from "@mui/icons-material/Settings";
import NotificationsIcon from "@mui/icons-material/Notifications";
import { DashboardLayout } from '@toolpad/core/layout';

export default function Layout({
children,
}: Readonly<{ children: React.ReactNode }>) {
return (
<Box sx={{ display: "flex" }}>
<AppBar position="absolute">
<Toolbar sx={{ justifyContent: "flex-end" }}>
<IconButton color="inherit">
<Badge badgeContent={4} color="secondary">
<NotificationsIcon />
</Badge>
</IconButton>
</Toolbar>
</AppBar>
<Drawer variant="permanent" anchor="left">
<Toolbar
sx={{
display: "flex",
alignItems: "center",
justifyContent: "flex-end",
px: [1],
}}
></Toolbar>
<Divider />
<List component="nav">
<ListItemButton LinkComponent={"a"} href="/">
<ListItemIcon>
<HomeIcon />
</ListItemIcon>
</ListItemButton>
<ListItemButton>
<ListItemIcon>
<SettingsIcon />
</ListItemIcon>
</ListItemButton>
</List>
</Drawer>
<Box
component={"main"}
sx={{ flexGrow: 1, height: "100vh", overflow: "auto" }}
>
<Toolbar />
<Container maxWidth="lg">{children}</Container>
</Box>
</Box>
<DashboardLayout>{children}</DashboardLayout>
);
}
`;
Expand Down
27 changes: 14 additions & 13 deletions packages/toolpad-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"author": "Toolpad Team",
"homepage": "https://github.com/mui/mui-toolpad#readme",
"license": "MIT",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"type": "module",
Expand All @@ -27,9 +26,8 @@
"import": "./dist/index.js"
},
"./*": {
"types": "./dist/*.d.ts",
"require": "./dist/*.cjs",
"default": "./dist/*.js"
"types": "./dist/*/index.d.ts",
"import": "./dist/*/index.js"
}
},
"files": [
Expand All @@ -48,22 +46,25 @@
"@mui/icons-material": "5.15.14",
"@mui/material": "5.15.14",
"@mui/material-nextjs": "5.15.11",
"next": "13.5.6",
"@mui/system": "5.15.14",
"next": "14.1.4",
"react": "18.2.0",
"react-dom": "18.2.0"
},
"devDependencies": {
"@types/react": "18.2.67",
"@types/react": "18.2.72",
"@types/react-dom": "18.2.22"
},
"peerDependencies": {
"@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.0",
"@mui/material": "^5.15.14",
"@types/react": "^18.2.67",
"next": "^13.5.6",
"react": "^18.2.0",
"react-dom": "^18.2.0"
"@emotion/react": "^11",
"@emotion/styled": "^11",
"@mui/icons-material": "^5",
"@mui/material": "^5",
"@mui/system": "^5",
"@types/react": "^18",
"next": "^14",
"react": "^18",
"react-dom": "^18"
},
"publishConfig": {
"access": "public"
Expand Down
23 changes: 0 additions & 23 deletions packages/toolpad-core/src/AppProvider/AppProvider.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ describe('AppProvider', () => {
test('renders content correctly', async () => {
const theme = createTheme();

render(<AppProvider theme={theme}>hello</AppProvider>);
render(
<AppProvider theme={theme} navigation={[]}>
Hello world
</AppProvider>,
);

expect(screen.getByText('hello')).toBeTruthy();
});
Expand Down
38 changes: 38 additions & 0 deletions packages/toolpad-core/src/client/AppProvider/AppProvider.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import * as React from 'react';
import { AppRouterCacheProvider } from '@mui/material-nextjs/v14-appRouter';
import { NoSsr } from '@mui/material';
import { ThemeProvider } from '@mui/material/styles';
import CssBaseline from '@mui/material/CssBaseline';
import type { Theme } from '@emotion/react';
import BrandingContext from '../context/BrandingContext';
import NavigationContext from '../context/NavigationContext';
import { Branding, Navigation } from '../../types';

interface AppProviderProps {
children: React.ReactNode;
theme: Theme;
branding?: Branding | null;
navigation: Navigation;
}

export default function AppProvider({
children,
theme,
branding = null,
navigation,
}: AppProviderProps) {
return (
<AppRouterCacheProvider options={{ enableCssLayer: true }}>
<ThemeProvider theme={theme}>
{/* CssBaseline kickstarts an elegant, consistent, and simple baseline to build upon. */}
<CssBaseline />
<BrandingContext.Provider value={branding}>
<NavigationContext.Provider value={navigation}>
{/* @TODO: Can probably remove NoSsr once we have non CSS-in-JS solution. */}
apedroferreira marked this conversation as resolved.
Show resolved Hide resolved
<NoSsr>{children}</NoSsr>
</NavigationContext.Provider>
</BrandingContext.Provider>
</ThemeProvider>
</AppRouterCacheProvider>
);
}
6 changes: 6 additions & 0 deletions packages/toolpad-core/src/client/context/BrandingContext.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import * as React from 'react';
import type { Branding } from '../../types/Branding';

const BrandingContext = React.createContext<Branding | null>(null);

export default BrandingContext;
6 changes: 6 additions & 0 deletions packages/toolpad-core/src/client/context/NavigationContext.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import * as React from 'react';
import type { Navigation } from '../../types/Navigation';

const NavigationContext = React.createContext<Navigation>([]);

export default NavigationContext;
3 changes: 3 additions & 0 deletions packages/toolpad-core/src/client/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export { default as AppProvider } from './AppProvider';

export * from './layout';