Add: MUI theme support for react-select#15
Open
wongyiuhang wants to merge 1 commit intoCollegeAI:masterfrom
Open
Add: MUI theme support for react-select#15wongyiuhang wants to merge 1 commit intoCollegeAI:masterfrom
wongyiuhang wants to merge 1 commit intoCollegeAI:masterfrom
Conversation
Contributor
|
thanks @wongyiuhang! reviewing now... |
seveibar
requested changes
Mar 18, 2021
| neutral80: MUItheme.palette.grey['800'], | ||
| neutral90: MUItheme.palette.grey['900'] | ||
| } | ||
| })} |
Contributor
There was a problem hiding this comment.
this should be part of a global context or in a single file, in react when you define objects in component props it causes a lot of rerenders- it COULD be a problem from a performance perspective and it's a problem from a DRY perspective.
Author
There was a problem hiding this comment.
I understand your concern, however, the theme really would change on some rare occasions, for example, switching between light mode and dark mode.
Is that okay, if I somehow "memorise" the colors object, therefore reduces the re-rendering of the object?
Author
There was a problem hiding this comment.
const themeColors = useMemo(() => ({
primary: MUItheme.palette.primary.main,
primary75: MUItheme.palette.primary.light,
primary50: MUItheme.palette.primary.light,
primary25: MUItheme.palette.primary.light,
neutral0: MUItheme.palette.background.paper,
neutral5: MUItheme.palette.grey['50'],
neutral10: MUItheme.palette.grey['100'],
neutral20: MUItheme.palette.grey['200'],
neutral30: MUItheme.palette.grey['300'],
neutral40: MUItheme.palette.grey['400'],
neutral50: MUItheme.palette.grey['500'],
neutral60: MUItheme.palette.grey['600'],
neutral70: MUItheme.palette.grey['700'],
neutral80: MUItheme.palette.grey['800'],
neutral90: MUItheme.palette.grey['900']
}), [MUItheme])
<AsyncSelect
...
theme={theme => ({
...theme,
colors: {
...theme.colors,
...themeColors
}
})}
...
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR is trying to pass
Material-UItheme context toreact-select, in order to support dark theme.Closes #14