-
Notifications
You must be signed in to change notification settings - Fork 26
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
feat: make text-input theme-able
#563
Conversation
materials/design-tokens.js
Outdated
@@ -0,0 +1,18 @@ | |||
export default { | |||
backgroundColorForInput: 'colorWhite', |
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.
this file would need to be autogenerated
const getInputStyles = (props, theme) => { | ||
const overwrittenVars = { | ||
...vars, | ||
...theme, |
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.
basically how it works, is in your theme, you overwrite one of our choices. So for "colorGreen", you can specify "pink".
background-color: ${vars.backgroundColorForInput}; | ||
border: 1px solid ${vars.borderColorForInput}; | ||
border-radius: ${vars.borderRadiusForInput}; | ||
background-color: ${overwrittenVars[designTokens.backgroundColorForInput]}; |
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.
we use design tokens, but the design tokens variables contain "choices"
Nice. Can you maybe, for us on the outside, give a set of use cases we need theming fir? |
We wanted to look into it to see if/how we can use the ui-kit components/design tokens for other use cases other than the MC (e.g. documentation websites). However, I feel like having a "theme-like" structure, will help/force us to keep the design system/tokens more consistent. For example, the color names as we have them now don't make much sense. Instead of |
Yes, that's my main concern. We would need more generic/semantic colour names. Like
Do we have designs or colour palettes for those? Feels a bit hard to anticipate what we need without. Even though this exploration is obviously great. Sorry for clicking the wrong button |
We can support theming without actually coming up with other colour palettes. As you can see from this PR, the code changes are very minimal 😇. The blocker right now is renaming the choices. |
I like the names! |
theme-able
f5db7e3
to
4327dd3
Compare
in the design-team, we had a closer look at the naming and changed three proposals to make it more generic. (bold=new) green = Primary sorry for mention it so late.. could these one be updated? |
Thanks. I am a bit worried about these
White is not the surface whenever a theme is inverted. Just saying. |
I agree with @tdeekens . Think about if you would have a dark theme, what would the color names map to. Why not keeping black/white as dark/light? |
Yeah dark/light names for the inverted colors is a bit weird. I think we all want the same thing eventually, solid/surface for me also feels a bit weird but maybe we just need to get used to it. At least I can't think of any better name... Thanks |
Thanks. Agreed. Maybe it's just we're not used to it but eventually the smallest evil name :) |
Okay I updated the color names 👍 |
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.
Looks good to give it a shot I think. Curious to see where this leads and how it may be used. I presume we consider theming a beta
feature for now?
--color-primary-25: hsl(172.9608938547486, 100%, 25%); | ||
--color-primary-40: hsl(172.9608938547486, 100%, 40%); | ||
--color-primary-85: hsl(172.9608938547486, 100%, 85%); | ||
--color-primary-95: hsl(172.9608938547486, 100%, 95%); |
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.
172.9608938547486
👀
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.
AFAIK these values haven't changed 😆. They are just copy pasted of color-green-25
, etc. But yeah, the weird 172.9608938547486
value comes because before we were using some postcss plugin to generate the value. Might make sense to round these 🤔
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 guess rounding them would be a separate task but it would make sense.
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 maybe use rgba instead of hsl?
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.
Cool, looking forward to see the first results! 🚀
const darkTheme = { | ||
colorLight: 'black', | ||
colorDark: 'white', | ||
colorDarkAccent98: 'white', |
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.
Shouldn't those be solid/surface?
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.
oh yeah true, thanks!
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.
🤦♂️
Making UI-Kit
Themeable
This PR contains two major changes.
New choices
The first change introduces new choices. These choices have more semantically meaningful names that the old choices. For example,
color-green
, becomescolor-primary
. For now, this is a non breaking change. The choices are duplicated, and the old choices remain. At some point in the future, we will remove these now deprecated choices. See the table below for the new (and old) names.#00b39e
hsl(172.9608938547486, 100%, 25%)
hsl(172.9608938547486, 100%, 40%)
hsl(172.9608938547486, 100%, 85%)
hsl(172.9608938547486, 100%, 95%)
#213c45
hsl(195, 35.2941176471%, 30)
hsl(195, 35.2941176471%, 40)
hsl(195, 35.2941176471%, 95)
hsl(195, 35.2941176471%, 98)
#cccccc
hsl(0, 0%, 60%)
hsl(0, 0%, 90%)
hsl(0, 0%, 95%)
#078cdf
hsl(203.05555555555554, 93.9130434783%, 85%)
hsl(203.05555555555554, 93.9130434783%, 95%)
#f16d0e
hsl(25.110132158590307, 89.0196078431%, 95%)
#e60050
hsl(339.1304347826087, 100%, 95%)
#1a1a1a
#ffffff
Internally we now use these new choices for our design tokens.
Introducing the concept of a
theme
By default, we can think about UI-Kit's theme as being the relationship between a
choice
and adecision
. For example, in our (default) theme, we set thecolor-surface
choice to the decision#FFF
.Overriding the default theme for a specific component.
In this PR, the ability to override the default theme for the component
text-input
has been added. A user can set a custom theme to the component as follows.Overriding the default theme for an entire application.
ThemeProvider
supports nested themes, so once we have added theming to more components, users will be able to override the theme once in their app, and have it propagated everywhere UI-Kit is used.What's next?
Once this PR has been merged, we can go about supporting themeing in the other components.