-
Notifications
You must be signed in to change notification settings - Fork 32
feat: Change selectedOptionColorPalette
values pulled from the theme
#364
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
Conversation
|
Open in Stackblitz • chakra-react-select-demo
commit: |
📊 Package size report -0.55%↓
Unchanged files
🤖 This report was automatically generated by pkg-size-action |
{ value: "gray", label: "Gray" }, | ||
{ value: "red", label: "Red" }, | ||
{ value: "pink", label: "Pink" }, | ||
{ value: "purple", label: "Purple" }, | ||
{ value: "cyan", label: "Cyan" }, | ||
{ value: "blue", label: "Blue" }, | ||
{ value: "teal", label: "Teal" }, | ||
{ value: "green", label: "Green" }, | ||
{ value: "yellow", label: "Yellow" }, | ||
{ value: "orange", label: "Orange" }, | ||
{ value: "brand", label: "Brand" }, |
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 added the remaining default color palettes from the "Design Tokens" > "Colors" section of the docs: https://www.chakra-ui.com/docs/theming/colors
As well as one custom palette, brand
.
selectedOptionColorPalette
selected valuesselectedOptionColorPalette
values pulled from the theme
This PR changes the values that the
selectedOptionColorPalette
prop pulls from the theme from specific numeric color values to semantic tokens. Specifically, it is now usingcolorPalette.solid
for the background color andcolorPalette.contrast
for the text color. This change does somewhat change the styling for the selected option, but it falls more in line with how the chakra theming system works.This was originally inspired by some thoughts I had around this comment (with my original response). This doesn't actually remove the default value of
blue
for theselectedOptionColorPalette
as suggested, but it does provide a more correct path towards doing so if that's what I end up deciding to do with it. Thanks for bringing it up @saalto-it!This change also allows for the removal of the
useColorModeValue
anduseColorMode
hooks which were essentially copied in from the Chakra template files. Removing the reliance on those styling approaches definitely makes the new approach feel much closer to the way the color tokens were intended to be used.One other change I implemented along with this is adding a new example for demonstrating all of the built-in
selectetOptionColorPalette
options that are available. This was done by updating thecolorOptions
array to include all of the built-in Chakra color palettes. As a bonus, I also added a custom color palette to the demo's theme to give an example for how that can be done. Here's a quick demo of all of the new styles in light and dark mode:Screen.Recording.2025-03-24.at.10.17.02.PM.mov