Using Conditional Classes in SCSS

Nil Seri
1 min readMay 7, 2021

--

Photo by Mathilde Langevin on Unsplash

There was a requirement where I had to show an account’s selected calendars on the right side and there was a list of select boxes on the left sidebar. Each selectbox-calendar pair had to be the same color to indicate a select/unselect would affect the related calendar in a visual way.

Firstly, we define colors to use them as a variable in multiple css files.

I defined these variables in another file as a constant array so that I would use them to assign to all calendars beforehand. There is also a case where the number of calendars are more than the number of these defines colors so I chose to apply mod operator.

Each appointment in a calendar should have a background related to its main theme color. To do this, I created a css file content just like below (here we use fullcalendar so the class names may be familiar):

Happy Coding!

--

--

Nil Seri
Nil Seri

Written by Nil Seri

I would love to change the world, but they won’t give me the source code | coding 👩🏻‍💻 | coffee ☕️ | jazz 🎷 | anime 🐲 | books 📚 | drawing 🎨

No responses yet