You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
scope: tools/scriptsScripts for supporting dev work, generating config and build artifacts, etc.status: discussingUnder discussion threads. Closed as stale after 60 days of inactivity.
We are in the progress of building a component library, and TailwindCSS is what we use for component theming.
The config file has been created, and further configurations will be added in the future. For now, we need to add color tokens to the file, in the colors object.
Tokens for dark theme colors are suffixed with the word dark. Tokens for light theme can stay as is. For example: primaryColor and primaryColorDark, secondaryColor and secondaryColorDark, etc.
@ahmadabdolsaheb I'm using the color palette in the style guide as the starting point, but do you think we need other colors in /client's variables.css as well?
Yes we should add variables.css in addition to the design style guide colors. The whole dark mode, layout, and accent colors might need another review, but that will come later.
I have updated the issue description to lay out the requirements. I might need to discuss with you on the token naming (I'm considering using foreground and background), but that is just a minor thing that came into my mind. We can leave it for later since the color palette will be reviewed.
I'm going to open this issue up for first-time contributor. If you are interested in helping us with this issue, please add a comment here to let us know.
Please also make sure you read our guidelines for contributing, we prioritize contributors following the instructions in our guides. Join us in our chat room or the forum if you need help contributing, our moderators will guide you through this.
Sometimes we may get more than one pull requests. We typically accept the most quality contribution followed by the one that is made first.
@huyenltnguyen I know there are different ways to setup the night mode.
How about adjusting global.css (or adding another .css file) in our tailwind setup to include all of our variables.
Then we could set tailwind config colors to CSS variables similar to this, but while having our root colors intact.
Do you see any pros or cons for this setup?
We could build on @ChrisPrzR's pr if necessary.
Yeah I was looking for a way to keep the colors in a variable CSS file instead of porting them to the config file as well. The article I read suggested the same approach as the one you shared.
With that approach, we would need to maintain a file with CSS variables and map the variables to a corresponding color property in the tailwind config. That extra mapping step makes me hesitant to keep a CSS file, and I wasn't sure how complex the palette would eventually be, so I opted for a simpler approach.
However, I guess we could consider having two layers for our colors (this is what I said I would discuss with you more):
One is for color names, which describes what the colors are. For example: lightGreen, darkGreen, gray05, gray90, etc.
One is for semantic names, which describes what the colors are used for. For example: primaryText, primaryTextDark, secondaryText, secondaryTextDark, etc.
To be honest, I haven't put much thoughts into the dark theme support. I have added an item for this in the main issue, but the traditional .dark {} way is what I have at the moment. However, I'm afraid that it might not work well with the CSS purging that Tailwind offers.
I skimmed the Tailwind doc yesterday and found that it provides a darkMode option in the config. I think I would try out and see if I can use the tokens I proposed with it.
I think we can still use colors vars and a class on the body tag as we have already been doing. As you can see in my repo I tried to keep doing what is already implemented and it works perfectly.
@Nirajn2311 Thanks for the link! I'll take a look. It's just that I have not written code with atomic CSS for a long time, and I never knew I would need to relearn to get back to this (as in I don't know what the right coding pattern should be now) 😅
@Nrestrepo05 First of all, welcome to freeCodeCamp and big thank for the demo repo! I am also in favor of following the current implementation. I personally find it easier to maintain that way (though that could be because I'm so used to this implementation approach); but it will help reduce a lot of configurations and changes we need to make.
The issue's status is "discussing" currently as we have not finalized path to proceed. I'm more than happy to pass it to you once we have things ironed out, so please be patient with us 😄
In the meantime, please check out other issues with "first timers Only" or "help wanted" label, and come say hi in our contributors chat room.
Get the benefits of the library by following its pattern (I'm not sure 100% what the benefits are except for the CSS purging)
Cons:
The introduction of the dark class as Tailwind uses it as the theme identifier
The HTML may be bloated with all sort of class names. For example: bg-colorA, focus:bg-colorB, hover:bg-colorC, dark:bg-colorD, dark:focus:bg-colorE,... )
I think approach (1) is more viable. This is not saying that we shouldn't use Tailwind classes at all, as I reckon it will be very useful and convenient when it comes to handling layout. But for dark theme styling specifically, I think we are better off with our current way of writing CSS.
A little bit of history: we use to set the "night" css class in the html and style elements by adding .night to the night mode selectors. We ended up with a lot of styles to maintain. Then, we moved on to contrast based theming and simplified our sheets a bit by using css variables.
I think we could use the current convention and keep things dry and straightforward. We could add class based styles later on if we wanted more control.
sorry @ahmadabdolsaheb I didn't understand so well. Do you want to keep doing things like they are already (css variables) or you want to use the tailwind convention?
Since our colors have evolved since we published the design style guide, there are a couple of notes to take into account when approaching the colors config, naming, etc. in developing the component library:
there are to main types of colors: the colors that switch during the theme change (background, foreground) and colors that do not (cta yellow).
colors that change have less saturation, and are more appropriate for background and foreground.
all background and foreground colors could be produced using scss mix or css color-mix functions
// colors that change with theme change
Here is a sample of how we could name our colors moving forward (just a suggestion):
gray-foreground-primary
gray-background-primary
red
red-foreground-primary
red-background-primary
blue
capri
gold
Note: The colors that don't change should maintain a good contrast regardless of the theme.
Note: We should be able to programmatically derive all colors using a couple of scsss functions, but I have not looked into it yet. ( might be an overkill )
Do you see gray-foreground-primary, gray-background-primary,... as names for color variables (those in colors.css), or for the semantic colors (those in the config file)?
My take on this is that, semantic colors won't have anything that refers to the actual color they use. An example can be the Alert component. Bootstrap and Material UI call the variants success, info, warning, ... instead of green, blue, yellow.
So I guess gray-foreground-primary would be a color in the variable file, and it is mapped to, say, default-foreground-primary in the config file. Then red-foreground-primary would be something like danger-foreground-primary, etc.
With the colors are already added to colors.css, our next step is to map them to semantic tokens in the config file. Since the naming of colors in both layers will need to be adjusted again once the design style guide gets new updates, are you okay with me coming up with some temporary tokens for now?
Though I think I should do it incrementally as I build the components, rather than assuming what each color means right now and add their tokens in bulk.
Reacted by Oliver Eyton-Williams and Ahmad Abdolsaheb
scope: tools/scriptsScripts for supporting dev work, generating config and build artifacts, etc.status: discussingUnder discussion threads. Closed as stale after 60 days of inactivity.
Activity
huyenltnguyen commentedon May 19, 2021
@ahmadabdolsaheb I'm using the color palette in the style guide as the starting point, but do you think we need other colors in /client's variables.css as well?
ahmaxed commentedon May 20, 2021
Yes we should add variables.css in addition to the design style guide colors. The whole dark mode, layout, and accent colors might need another review, but that will come later.
huyenltnguyen commentedon May 20, 2021
Thanks @ahmadabdolsaheb!
I have updated the issue description to lay out the requirements. I might need to discuss with you on the token naming (I'm considering using
foregroundandbackground), but that is just a minor thing that came into my mind. We can leave it for later since the color palette will be reviewed.huyenltnguyen commentedon May 20, 2021
I'm going to open this issue up for first-time contributor. If you are interested in helping us with this issue, please add a comment here to let us know.
Please also make sure you read our guidelines for contributing, we prioritize contributors following the instructions in our guides. Join us in our chat room or the forum if you need help contributing, our moderators will guide you through this.
Sometimes we may get more than one pull requests. We typically accept the most quality contribution followed by the one that is made first.
Happy contributing.
ChrisPrzR commentedon May 20, 2021
I'd like to work on this.
ahmaxed commentedon May 21, 2021
@huyenltnguyen I know there are different ways to setup the night mode.
How about adjusting global.css (or adding another .css file) in our tailwind setup to include all of our variables.
Then we could set tailwind config colors to CSS variables similar to this, but while having our root colors intact.
Do you see any pros or cons for this setup?
We could build on @ChrisPrzR's pr if necessary.
huyenltnguyen commentedon May 21, 2021
Yeah I was looking for a way to keep the colors in a variable CSS file instead of porting them to the config file as well. The article I read suggested the same approach as the one you shared.
With that approach, we would need to maintain a file with CSS variables and map the variables to a corresponding color property in the tailwind config. That extra mapping step makes me hesitant to keep a CSS file, and I wasn't sure how complex the palette would eventually be, so I opted for a simpler approach.
However, I guess we could consider having two layers for our colors (this is what I said I would discuss with you more):
And to translate to code:
The first layer is in a CSS file
The second layer is in the config file, whose tokens will then be used in the styling of our components
ahmaxed commentedon May 21, 2021
I think that is a simple approach. How would the component color change from primaryText to primaryTextDark?
Do we need to add that logic per component based on the theme props it receives?
Also, I think foreground and background would work since we use color fore more than just text, borders, br, ...
huyenltnguyen commentedon May 21, 2021
To be honest, I haven't put much thoughts into the dark theme support. I have added an item for this in the main issue, but the traditional
.dark {}way is what I have at the moment. However, I'm afraid that it might not work well with the CSS purging that Tailwind offers.Happy to hear you thoughts on this.
huyenltnguyen commentedon May 21, 2021
I skimmed the Tailwind doc yesterday and found that it provides a
darkModeoption in the config. I think I would try out and see if I can use the tokens I proposed with it.Here is the doc: https://tailwindcss.com/docs/dark-mode#toggling-dark-mode-manually
5 remaining items
nicorr-05 commentedon Jun 11, 2021
I already finished the repo, here is the link:
https://github.com/Nrestrepo05/darkmode
I think we can still use colors vars and a class on the body tag as we have already been doing. As you can see in my repo I tried to keep doing what is already implemented and it works perfectly.
Hope to know what you think!
huyenltnguyen commentedon Jun 12, 2021
@Nirajn2311 Thanks for the link! I'll take a look. It's just that I have not written code with atomic CSS for a long time, and I never knew I would need to relearn to get back to this (as in I don't know what the right coding pattern should be now) 😅
@Nrestrepo05 First of all, welcome to freeCodeCamp and big thank for the demo repo! I am also in favor of following the current implementation. I personally find it easier to maintain that way (though that could be because I'm so used to this implementation approach); but it will help reduce a lot of configurations and changes we need to make.
The issue's status is "discussing" currently as we have not finalized path to proceed. I'm more than happy to pass it to you once we have things ironed out, so please be patient with us 😄
In the meantime, please check out other issues with "first timers Only" or "help wanted" label, and come say hi in our contributors chat room.
huyenltnguyen commentedon Jun 12, 2021
@ahmadabdolsaheb hope you could weigh in on this. To sum up the entire discussion, there are two approaches we can take regarding dark theme support:
.nightselector for dark mode.darkclass as Tailwind uses it as the theme identifierbg-colorA,focus:bg-colorB,hover:bg-colorC,dark:bg-colorD,dark:focus:bg-colorE,... )I think approach (1) is more viable. This is not saying that we shouldn't use Tailwind classes at all, as I reckon it will be very useful and convenient when it comes to handling layout. But for dark theme styling specifically, I think we are better off with our current way of writing CSS.
ahmaxed commentedon Jun 13, 2021
@huyenltnguyen, thank you for the extensive research.
A little bit of history: we use to set the "night" css class in the html and style elements by adding .night to the night mode selectors. We ended up with a lot of styles to maintain. Then, we moved on to contrast based theming and simplified our sheets a bit by using css variables.
Although approach 1 is not tailwind's current official method to implement dark mode, it is well documented in the community ex. https://jeffjadulco.com/blog/dark-mode-react-tailwinds
I think we could use the current convention and keep things dry and straightforward. We could add class based styles later on if we wanted more control.
nicorr-05 commentedon Jun 14, 2021
sorry @ahmadabdolsaheb I didn't understand so well. Do you want to keep doing things like they are already (css variables) or you want to use the tailwind convention?
ahmaxed commentedon Jun 14, 2021
CSS variables.
nicorr-05 commentedon Jun 14, 2021
Thank you @ahmadabdolsaheb, do you think there something that I can do on this issue?
ahmaxed commentedon Jun 15, 2021
@Nrestrepo05, thanks for your interest, but I think @huyenltnguyen has got this one.
ahmaxed commentedon Jun 15, 2021
Since our colors have evolved since we published the design style guide, there are a couple of notes to take into account when approaching the colors config, naming, etc. in developing the component library:
// colors that change with theme change
Here is a sample of how we could name our colors moving forward (just a suggestion):
gray-foreground-primary
gray-background-primary
red
red-foreground-primary
red-background-primary
blue
capri
gold
Note: The colors that don't change should maintain a good contrast regardless of the theme.
Note: We should be able to programmatically derive all colors using a couple of scsss functions, but I have not looked into it yet. ( might be an overkill )
huyenltnguyen commentedon Jun 19, 2021
Do you see
gray-foreground-primary,gray-background-primary,... as names for color variables (those incolors.css), or for the semantic colors (those in the config file)?My take on this is that, semantic colors won't have anything that refers to the actual color they use. An example can be the Alert component. Bootstrap and Material UI call the variants
success,info,warning, ... instead ofgreen,blue,yellow.So I guess
gray-foreground-primarywould be a color in the variable file, and it is mapped to, say,default-foreground-primaryin the config file. Thenred-foreground-primarywould be something likedanger-foreground-primary, etc.With the colors are already added to
colors.css, our next step is to map them to semantic tokens in the config file. Since the naming of colors in both layers will need to be adjusted again once the design style guide gets new updates, are you okay with me coming up with some temporary tokens for now?Though I think I should do it incrementally as I build the components, rather than assuming what each color means right now and add their tokens in bulk.
ahmaxed commentedon Jun 23, 2021
Yes, your plan makes more sense to me. Please feel free to proceed with mapping the color names to the config file.