-
-
Notifications
You must be signed in to change notification settings - Fork 355
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
[core] Fix some DashboardLayout bugs and make some docs examples more consis… #3905
Merged
Merged
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
cd5ce4b
Fix some DashboardLayout bugs and make some docs examples more consis…
apedroferreira e82b611
Merge remote-tracking branch 'upstream/master' into core-docs-fixes
apedroferreira 33fe7c0
Merge remote-tracking branch 'upstream/master' into core-docs-fixes
apedroferreira 126661a
Move example
apedroferreira b682fb5
Merge branch 'master' into core-docs-fixes
Janpot 5658dc0
Add todos
apedroferreira 412a7b8
ugh
apedroferreira cdc45a6
Make it clearer
apedroferreira 634b330
Merge branch 'master' into core-docs-fixes
apedroferreira 0cd37ed
Remove unneeded check
apedroferreira b93880f
Simplify more
apedroferreira b426317
More nit simplifications I have to stop
apedroferreira File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
Fix some DashboardLayout bugs and make some docs examples more consis…
…tent
- Loading branch information
commit cd5ce4bee001f0851ff6356ddcc195a5cde549f0
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,63 @@ | ||
import * as React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import Box from '@mui/material/Box'; | ||
import { AppProvider, DashboardLayout } from '@toolpad/core'; | ||
import Typography from '@mui/material/Typography'; | ||
import { extendTheme } from '@mui/material/styles'; | ||
import DashboardIcon from '@mui/icons-material/Dashboard'; | ||
import { AppProvider } from '@toolpad/core/AppProvider'; | ||
import { DashboardLayout } from '@toolpad/core/DashboardLayout'; | ||
|
||
const NAVIGATION = [ | ||
{ | ||
segment: 'dashboard', | ||
title: 'Dashboard', | ||
icon: <DashboardIcon />, | ||
}, | ||
]; | ||
|
||
const demoTheme = extendTheme({ | ||
breakpoints: { | ||
values: { | ||
xs: 0, | ||
sm: 600, | ||
md: 600, | ||
lg: 1200, | ||
xl: 1536, | ||
}, | ||
}, | ||
}); | ||
|
||
function DemoPageContent({ pathname }) { | ||
return ( | ||
<Box | ||
sx={{ | ||
py: 4, | ||
display: 'flex', | ||
flexDirection: 'column', | ||
alignItems: 'center', | ||
textAlign: 'center', | ||
}} | ||
> | ||
<Typography>Dashboard content for {pathname}</Typography> | ||
</Box> | ||
); | ||
} | ||
|
||
DemoPageContent.propTypes = { | ||
pathname: PropTypes.string.isRequired, | ||
}; | ||
|
||
function AccountWithDashboard(props) { | ||
const { window } = props; | ||
|
||
export default function AccountWithDashboard() { | ||
const [session, setSession] = React.useState({ | ||
user: { | ||
name: 'Bharat Kashyap', | ||
email: '[email protected]', | ||
image: 'https://avatars.githubusercontent.com/u/19550456', | ||
}, | ||
}); | ||
|
||
const authentication = React.useMemo(() => { | ||
return { | ||
signIn: () => { | ||
|
@@ -27,11 +75,43 @@ export default function AccountWithDashboard() { | |
}; | ||
}, []); | ||
|
||
const [pathname, setPathname] = React.useState('/dashboard'); | ||
|
||
const router = React.useMemo(() => { | ||
return { | ||
pathname, | ||
searchParams: new URLSearchParams(), | ||
navigate: (path) => setPathname(String(path)), | ||
}; | ||
}, [pathname]); | ||
|
||
// Remove this const when copying and pasting into your project. | ||
const demoWindow = window !== undefined ? window() : undefined; | ||
|
||
return ( | ||
<AppProvider session={session} authentication={authentication}> | ||
// preview-start | ||
<AppProvider | ||
session={session} | ||
authentication={authentication} | ||
navigation={NAVIGATION} | ||
router={router} | ||
theme={demoTheme} | ||
window={demoWindow} | ||
> | ||
<DashboardLayout> | ||
<Box sx={{ px: 6, py: 2 }}>Dashboard content</Box> | ||
<DemoPageContent pathname={pathname} /> | ||
</DashboardLayout> | ||
</AppProvider> | ||
// preview-end | ||
); | ||
} | ||
|
||
AccountWithDashboard.propTypes = { | ||
/** | ||
* Injected by the documentation to work in an iframe. | ||
* Remove this when copying and pasting into your project. | ||
*/ | ||
window: PropTypes.func, | ||
}; | ||
|
||
export default AccountWithDashboard; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,67 @@ | ||
import * as React from 'react'; | ||
import Box from '@mui/material/Box'; | ||
import { Session, AppProvider, DashboardLayout } from '@toolpad/core'; | ||
import Typography from '@mui/material/Typography'; | ||
import { extendTheme } from '@mui/material/styles'; | ||
import DashboardIcon from '@mui/icons-material/Dashboard'; | ||
import { AppProvider } from '@toolpad/core/AppProvider'; | ||
import { DashboardLayout } from '@toolpad/core/DashboardLayout'; | ||
import type { Session, Router, Navigation } from '@toolpad/core'; | ||
|
||
const NAVIGATION: Navigation = [ | ||
{ | ||
segment: 'dashboard', | ||
title: 'Dashboard', | ||
icon: <DashboardIcon />, | ||
}, | ||
]; | ||
|
||
const demoTheme = extendTheme({ | ||
breakpoints: { | ||
values: { | ||
xs: 0, | ||
sm: 600, | ||
md: 600, | ||
lg: 1200, | ||
xl: 1536, | ||
}, | ||
}, | ||
}); | ||
|
||
function DemoPageContent({ pathname }: { pathname: string }) { | ||
return ( | ||
<Box | ||
sx={{ | ||
py: 4, | ||
display: 'flex', | ||
flexDirection: 'column', | ||
alignItems: 'center', | ||
textAlign: 'center', | ||
}} | ||
> | ||
<Typography>Dashboard content for {pathname}</Typography> | ||
</Box> | ||
); | ||
} | ||
|
||
interface DemoProps { | ||
/** | ||
* Injected by the documentation to work in an iframe. | ||
* Remove this when copying and pasting into your project. | ||
*/ | ||
window?: () => Window; | ||
} | ||
|
||
export default function AccountWithDashboard(props: DemoProps) { | ||
const { window } = props; | ||
|
||
export default function AccountWithDashboard() { | ||
const [session, setSession] = React.useState<Session | null>({ | ||
user: { | ||
name: 'Bharat Kashyap', | ||
email: '[email protected]', | ||
image: 'https://avatars.githubusercontent.com/u/19550456', | ||
}, | ||
}); | ||
|
||
const authentication = React.useMemo(() => { | ||
return { | ||
signIn: () => { | ||
|
@@ -27,11 +79,33 @@ export default function AccountWithDashboard() { | |
}; | ||
}, []); | ||
|
||
const [pathname, setPathname] = React.useState('/dashboard'); | ||
|
||
const router = React.useMemo<Router>(() => { | ||
return { | ||
pathname, | ||
searchParams: new URLSearchParams(), | ||
navigate: (path) => setPathname(String(path)), | ||
}; | ||
}, [pathname]); | ||
|
||
// Remove this const when copying and pasting into your project. | ||
const demoWindow = window !== undefined ? window() : undefined; | ||
|
||
return ( | ||
<AppProvider session={session} authentication={authentication}> | ||
// preview-start | ||
<AppProvider | ||
session={session} | ||
authentication={authentication} | ||
navigation={NAVIGATION} | ||
router={router} | ||
theme={demoTheme} | ||
window={demoWindow} | ||
> | ||
<DashboardLayout> | ||
<Box sx={{ px: 6, py: 2 }}>Dashboard content</Box> | ||
<DemoPageContent pathname={pathname} /> | ||
</DashboardLayout> | ||
</AppProvider> | ||
// preview-end | ||
); | ||
} |
15 changes: 12 additions & 3 deletions
15
docs/data/toolpad/core/components/account/AccountWithDashboard.tsx.preview
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,12 @@ | ||
<DashboardLayout> | ||
<Box sx={{ px: 6, py: 2 }}>Dashboard content</Box> | ||
</DashboardLayout> | ||
<AppProvider | ||
session={session} | ||
authentication={authentication} | ||
navigation={NAVIGATION} | ||
router={router} | ||
theme={demoTheme} | ||
window={demoWindow} | ||
> | ||
<DashboardLayout> | ||
<DemoPageContent pathname={pathname} /> | ||
</DashboardLayout> | ||
</AppProvider> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah it's adding all this boilerplate here too but this way it matches the other examples...