-
-
Notifications
You must be signed in to change notification settings - Fork 293
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] Agnostic DashboardLayout component #3831
Draft
apedroferreira
wants to merge
7
commits into
mui:master
Choose a base branch
from
apedroferreira:agnostic-dashboard-layout
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e6908fd
Agnostic DashboardLayout with props for overrides
apedroferreira 125cf5e
what the
apedroferreira 8cc02ce
Merge remote-tracking branch 'upstream/master' into agnostic-dashboar…
apedroferreira 3e449b6
Fix merge
apedroferreira eafe98f
Rename props as per review
apedroferreira 7e1c541
Merge remote-tracking branch 'upstream/master' into agnostic-dashboar…
apedroferreira 5a59c7b
Incomplete work so far
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
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
11 changes: 10 additions & 1 deletion
11
docs/translations/api-docs/dashboard-layout/dashboard-layout.json
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,5 +1,14 @@ | ||
{ | ||
"componentDescription": "", | ||
"propDescriptions": { "children": { "description": "The content of the dashboard." } }, | ||
"propDescriptions": { | ||
"branding": { "description": "Branding options for the layout." }, | ||
"children": { "description": "The content of the dashboard." }, | ||
"navigation": { "description": "Navigation definition for the layout." }, | ||
"paletteMode": { "description": "Active palette mode in theme." }, | ||
"setPaletteMode": { "description": "Function to run when the theme switcher is toggled." }, | ||
"window": { | ||
"description": "The window where the layout is rendered. This is needed when rendering the layout inside an iframe, for example." | ||
} | ||
}, | ||
"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
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 believe the state for
paletteMode
andsetPaletteMode
(we use a different naming convention for controlled props anyway) should be owned byDashboardLayout
. It's owned by the theme and if the user wants to manipulate ituseColorScheme
should be used. For the classic theme, I believe we should create auseColorScheme
shim (i.e. rewriteuseStandardPaletteMode
with the same signature asuseColorScheme
and export from the library).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.
Ok, it was just a first idea and I wasn't sure about the names for these 2 props either.
We can go with that,
the only disadvantage I guess is that it will only work with MUI theming(nevermind, the theme is strongly connected to the component anyway so this should be more automatic, sounds good!)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 was looking a bit more into this and not sure about the approach to take.
DashboardLayout
inside anAppProvider
with any of the 3 theming methods we support (https://mui.com/toolpad/core/react-app-provider/#theming) => theme switcher already worksDashboardLayout
withoutAppProvider
around it => we can make things work automatically if they're using a CSS vars theme by simply using the methods fromuseColorScheme
, otherwise if they're using a standard theme it can only have one mode unless they're managing the active theme state themselves somehow, in which case we can't support it automatically?About the shim, what scenario are we trying to solve with it? For internal components we have this context https://github.com/mui/mui-toolpad/blob/ad9bddb719a81cd113b73e82d304ae5ead1a0e8c/packages/toolpad-core/src/DashboardLayout/DashboardLayout.tsx#L81
Should I make an abstraction around the context as a hook that users can import called
useColorScheme
?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.
Ok, we could make it a dumb controlled property. But name it
colorScheme
,onColorSchemeChange
to match naming of the cssvar theme, and also we always useonXyzChange
for controlled propxyz
, notsetXyz