How does one handle making "variation classes" in Sass? Example:
.bookshelf {
color: brown;
height: 100px;
.panel {
trimmed: no;
height: 10px;
}
.door {
height: 100px;
.knob {
shape: circle;
height: 10px;
}
}
}
You want to make a .bookshelf.small
variation. Is there a way to write the variation code inside the main element using mixins or something that would "bubble up" the data?
.bookshelf {
color: brown;
height: 100px;
@include small-version {
height: 50px;
}
.panel {
trimmed: no;
height: 10px;
@include small-version {
height: 5px;
}
}
.door {
height: 100px;
@include small-version {
height: 50px;
}
.knob {
shape: circle;
height: 10px;
@include small-version {
height: 5px;
}
}
}
}
And the output of the mixin would be
.bookshelf.small {
height: 50px;
.panel {
height: 5px;
}
.door {
height: 50px;
.knob {
height: 5px;
}
}
Several things looked promising, such as the @at-root function and @content function, but neither would work for this scenario. I know if I write @media settings, they will bubble up. But I do not want this tied to a media query, I want this tied to a specific class (if .bookshelf also has the class small, apply these rules).
.small & { /**/ }
where the theme specific rules need to be. But that would produce .small .bookshelf instead of .small.bookshelf if a way to concat them isn't available. – Ayub