One criticism of Sass is that, particularly because of nesting, things can get complicated quickly and other developers may not know what’s going on when you pass off your code. I like to follow these three rules:
People may not be familiar with SMACSS or whatever personal version of it you’re using. Docblock comments makes your files easy to navigate.
In each file, I state the purpose of the file, and include anything that may not be extremely evident. This is the docblock of a layout partial for a tricky map page:
/**
* @file
*
* Front page layout.
*
* On small screens, map takes up 85% of viewport height (vh) and sidebar
* is below. On larger screens, everything is on top of map with 100% width
* and height.
*/
// Title box: 10 columns on mobile and narrow, 6 on wide and up.
.node-title-box {
@include span-columns(10 of 10);
@include media ($wide) {
@include span-columns(6 of 8);
@include shift(1 of 8);
}
}
This is as much for yourself in 6 months as it is for other developers who may someday look at your code. (I’m not the only one who forgets why I did something in the first place unless I comment it, right?)
// On mobile, move zoom controls up so sidebar content doesn't cover it.
@include media ($wide) {
.leaflet-bottom {
bottom: 15vh;
}
}