Repository navigation
feat: add tailwind theme support - #43616
Conversation
| display: inline-block; | ||
| line-height: 1; | ||
| } | ||
| .storybook-button--primary { |
There was a problem hiding this comment.
The aim is to completely get rid of custom css as much as possible. Here I cleaned what was relevant to the theme support for now.
| <div | ||
| className={`flex h-screen justify-center items-center ${ | ||
| args.theme === 'dark' | ||
| ? 'dark bg-dark-theme-background' | ||
| : 'light bg-light-theme-background' | ||
| }`} | ||
| > | ||
| <Button {...args} /> | ||
| </div> |
There was a problem hiding this comment.
This is the hack that is mentioned in the pr description.
| export interface ButtonProps { | ||
| primary?: boolean; | ||
| size?: ButtonSize; | ||
| backgroundColor?: string; |
There was a problem hiding this comment.
No longer needed since the color change logic will depend inside the button and will depend on the other props.
| label: string; | ||
| customKey?: string; | ||
| onClick: () => void; | ||
| theme?: 'light' | 'dark'; |
There was a problem hiding this comment.
Theme was added to accommodate the component wrapper in button story.
There was a problem hiding this comment.
Just a quick question - our database uses "default" and "night" for the theme settings on the user profile. Does this need to match those values?
There was a problem hiding this comment.
It should not be an issue since when we receive the user info, we can conditionally attach the relevant class to the html element.
Although it pays off to be consistent with naming all across, 'light'/'dark' seem to be the convention.
| --green10: var(--green10); | ||
| --green90: var(--green90); | ||
| html, | ||
| div.light { |
There was a problem hiding this comment.
div.light and div.dark selectors are added so we could change the wrapper's class conditionally and have the color variable change based on the selected theme.
| --default-foreground-primary: var(--gray90); | ||
| --default-foreground-secondary: var(--gray85); | ||
| --default-foreground-tertiary: var(--gray80); | ||
| --default-foreground-quaternary: var(--gray75); | ||
| --default-background-primary: var(--gray00); | ||
| --default-background-secondary: var(--gray05); | ||
| --default-background-tertiary: var(--gray10); | ||
| --default-background-quaternary: var(--gray15); |
There was a problem hiding this comment.
Only the default variables are added. The rest will be added upon use.
huyenltnguyen
left a comment
There was a problem hiding this comment.
@ahmadabdolsaheb Thanks for taking this over!
Checklist:
Update index.md)mainbranch of freeCodeCamp.Closes #42186
This pull request adds theme support as described in #42186 by setting a list of colors variables that change based on the class of the html element.
Note: Since color variables change based on the class of the HTML, I added a small hack and wrapped components in a div whose classes changes based on the theme argument. Once we find a better way to add theme controls, we could remove the wrapper.