-
-
Notifications
You must be signed in to change notification settings - Fork 274
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
[AppProvider] Create basic router adapters #3638
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
048b4fb
Create router adapter
Janpot a2fb58a
unify
Janpot 09b993e
lint
Janpot 09d6375
yep
Janpot cdcf922
api docs
Janpot 47d7ca5
Update AppProvider.test.tsx
Janpot 4f43d68
TimelineIcon
Janpot b498778
Update AppProvider.tsx
Janpot 38e588d
hdt
Janpot 5aa765d
frwf
Janpot 241b3e8
Update AppProvider.test.tsx
Janpot 6d15f29
test
Janpot af0c002
Update AppProvider.test.tsx
Janpot 1830803
gety
Janpot 1111069
Update pnpm-lock.yaml
Janpot 100f442
fwefew
Janpot 74e9109
Merge branch 'master' into router-adapter
Janpot 5c090e9
fdsg
Janpot d0ce1f0
Merge branch 'master' into router-adapter
Janpot 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
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import * as React from 'react'; | ||
import Box from '@mui/material/Box'; | ||
import Typography from '@mui/material/Typography'; | ||
import DashboardIcon from '@mui/icons-material/Dashboard'; | ||
import { AppProvider, Navigation } from '@toolpad/core/AppProvider'; | ||
import { DashboardLayout } from '@toolpad/core/DashboardLayout'; | ||
|
||
const NAVIGATION: Navigation = [ | ||
{ | ||
title: 'Page', | ||
icon: <DashboardIcon />, | ||
}, | ||
]; | ||
|
||
export default function TutorialDefault() { | ||
return ( | ||
<AppProvider navigation={NAVIGATION}> | ||
<DashboardLayout> | ||
<Box | ||
sx={{ | ||
py: 4, | ||
display: 'flex', | ||
flexDirection: 'column', | ||
alignItems: 'center', | ||
}} | ||
> | ||
<Typography>Dashboard content</Typography> | ||
</Box> | ||
</DashboardLayout> | ||
</AppProvider> | ||
); | ||
} |
12 changes: 12 additions & 0 deletions
12
docs/data/toolpad/core/introduction/TutorialDefault.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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<DashboardLayout> | ||
<Box | ||
sx={{ | ||
py: 4, | ||
display: 'flex', | ||
flexDirection: 'column', | ||
alignItems: 'center', | ||
}} | ||
> | ||
<Typography>Dashboard content</Typography> | ||
</Box> | ||
</DashboardLayout> |
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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import * as React from 'react'; | ||
import Box from '@mui/material/Box'; | ||
import Typography from '@mui/material/Typography'; | ||
import DashboardIcon from '@mui/icons-material/Dashboard'; | ||
import TimelineIcon from '@mui/icons-material/Timeline'; | ||
import { AppProvider } from '@toolpad/core/AppProvider'; | ||
import { DashboardLayout } from '@toolpad/core/DashboardLayout'; | ||
|
||
const NAVIGATION = [ | ||
{ | ||
kind: 'header', | ||
title: 'Main items', | ||
}, | ||
{ | ||
slug: '/page', | ||
title: 'Page', | ||
icon: <DashboardIcon />, | ||
}, | ||
// Add the following new item: | ||
{ | ||
slug: '/page-2', | ||
title: 'Page 2', | ||
icon: <TimelineIcon />, | ||
}, | ||
]; | ||
|
||
export default function TutorialPages() { | ||
const [pathname, setPathname] = React.useState('/page'); | ||
|
||
const router = React.useMemo(() => { | ||
return { | ||
pathname, | ||
searchParams: new URLSearchParams(), | ||
navigate: (path) => setPathname(String(path)), | ||
}; | ||
}, [pathname]); | ||
|
||
return ( | ||
<AppProvider router={router} navigation={NAVIGATION}> | ||
<DashboardLayout> | ||
<Box | ||
sx={{ | ||
py: 4, | ||
display: 'flex', | ||
flexDirection: 'column', | ||
alignItems: 'center', | ||
}} | ||
> | ||
<Typography>Dashboard content for {pathname}</Typography> | ||
</Box> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import * as React from 'react'; | ||
import Box from '@mui/material/Box'; | ||
import Typography from '@mui/material/Typography'; | ||
import DashboardIcon from '@mui/icons-material/Dashboard'; | ||
import TimelineIcon from '@mui/icons-material/Timeline'; | ||
import { AppProvider, Navigation, Router } from '@toolpad/core/AppProvider'; | ||
import { DashboardLayout } from '@toolpad/core/DashboardLayout'; | ||
|
||
const NAVIGATION: Navigation = [ | ||
{ | ||
kind: 'header', | ||
title: 'Main items', | ||
}, | ||
{ | ||
slug: '/page', | ||
title: 'Page', | ||
icon: <DashboardIcon />, | ||
}, | ||
// Add the following new item: | ||
{ | ||
slug: '/page-2', | ||
title: 'Page 2', | ||
icon: <TimelineIcon />, | ||
}, | ||
]; | ||
|
||
export default function TutorialPages() { | ||
const [pathname, setPathname] = React.useState('/page'); | ||
|
||
const router = React.useMemo<Router>(() => { | ||
return { | ||
pathname, | ||
searchParams: new URLSearchParams(), | ||
navigate: (path) => setPathname(String(path)), | ||
}; | ||
}, [pathname]); | ||
|
||
return ( | ||
<AppProvider router={router} navigation={NAVIGATION}> | ||
<DashboardLayout> | ||
<Box | ||
sx={{ | ||
py: 4, | ||
display: 'flex', | ||
flexDirection: 'column', | ||
alignItems: 'center', | ||
}} | ||
> | ||
<Typography>Dashboard content for {pathname}</Typography> | ||
</Box> | ||
</DashboardLayout> | ||
</AppProvider> | ||
); | ||
} |
12 changes: 12 additions & 0 deletions
12
docs/data/toolpad/core/introduction/TutorialPages.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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<DashboardLayout> | ||
<Box | ||
sx={{ | ||
py: 4, | ||
display: 'flex', | ||
flexDirection: 'column', | ||
alignItems: 'center', | ||
}} | ||
> | ||
<Typography>Dashboard content for {pathname}</Typography> | ||
</Box> | ||
</DashboardLayout> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1 @@ | ||
{ | ||
"componentDescription": "", | ||
"propDescriptions": { | ||
"branding": { "description": "Branding options for the app." }, | ||
"children": { "description": "The content of the app provider." }, | ||
"navigation": { "description": "Navigation definition for the app." }, | ||
"theme": { | ||
"description": "<a href=\"https://mui.com/material-ui/customization/theming/\">Theme</a> used by the app." | ||
} | ||
}, | ||
"classDescriptions": {} | ||
} | ||
{ "componentDescription": "", "propDescriptions": {}, "classDescriptions": {} } |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
'use client'; | ||
export * from './AppProvider'; |
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.
I don't think we need to export the contexts in
AppProvider/index
, if was probably just an oversight from me.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.
Or we can just move the to their own file.