- Don't repeat, or unset styles
- Code 'mess' has to live somewhere
stemCSS achieves this by:
- If a
color: black
is only applied on:hover
at breakpointlarge
, your class is.u-color-black@hover@large
- Which in your compiled css would be:
@media (min-width: 1240px) {
.u-color-black\@hover\@large {
color: black;
}
}
.c-form {
&__label {
@include breakpoint(large) {
&:hover {
color: $colour-black;
}
}
}
}
- The codebase creates
.u-color-black
as a Utility - Five components want to use
color: black;
.c-button { @extend .u-color-black; }
- Compiled CSS:
.u-color-black, .c-button { color: black; }
You can build up and style your components in your HTML, or in your SCSS. This is where your mess will live.
<a class="u-flex u-ai-center u-jc-center u-bgcolor-green u-shadow u-h4 u-weight-bold u-family-roboto">Submit</a>
.c-submit {
@extend .u-flex;
@extend .u-ai-center;
@extend .u-jc-center;
@extend .u-bgcolor-green;
@extend .u-shadow;
@extend .u-h4;
@extend .u-weight-bold;
@extend .u-family-roboto;
}
<a class="c-submit u-bgcolor-green u-shadow">Submit</a>
.c-submit {
@extend .u-flex;
@extend .u-ai-center;
@extend .u-jc-center;
@extend .u-h4;
@extend .u-weight-bold;
@extend .u-family-roboto;
}