I have a series of a tags that form a grid (each a is a block with the class .portfolio-grid-item).
Each .portfolio-grid-item contains several div and heading elements and uses a default color via a variable ($grid-color: $blue;).
I am trying to create a SCSS rule that will do the following:
- Check if an additional class is assigned to the
atag. - If there is an additional class, replace the default color variable with a new one.
- If not, fallback to the default.
e.g.
An element classed as .portfolio-grid-item .orange should, replace $grid-color: $blue with $grid-color: $orange;
I have tried using an mixin with an if statement, but I have never done this before and I am not sure if the method is correct, or supported.
My Pen is here: http://codepen.io/anon/pen/EjwarE
Any advice would be really appreciated!
UPDATE:
To put this in some simple terms (I know this isn't true code, it's just the logic I am aiming for, hopefully this helps!):
// Default
$grid-color: $blue
// Statement
if HTML element has class = `.orange`
// Change the following variable
$grid-color: $orange
The idea being that this will override all instances of $grid-color in one shot