sass/README.md
Shared stylelint configuration
When using sass-rails, use the provided asset-helpers (e.g. image-url
and font-url), so that Rails' Asset Pipeline will re-write the correct paths
to assets.
Prefer mixins to @extend.
Use maps and variables to codify and centralize breakpoint values
small, medium, large, etc. instead of
specific devicesspan-columns
not span_columns or spanColumns.background-color: #ff0000;, not background: #ff0000;// for comment blocks not /* */.padding: $variable * 1.5 variable * 2)padding: ($variable * 1.5) ($variable * 2);% unit for the amount/weight when using Sass's color functions:
darken($color, 20%), not darken($color, 20)$visual-grid-color not $color or $vslgrd-clr.base directory for styling element selectors, global variables, global
extends and global mixins.@includeAlphabetize declarations:
.class {
display: block;
text-align: center;
width: 100%;
}
Alphabetize prefixed properties as if the prefix doesn't exist:
.class {
font-family: system-ui;
-webkit-font-smoothing: antialiased;
font-weight: $weight-variable;
}
Comprehensive example of ordering items within a declaration block:
.class {
@include size(10px);
display: block;
margin: $spacing-variable;
@media (min-width: $screen-variable) {
padding: $spacing-variable;
}
&:focus {
border-color: $color-variable;
}
&::before {
content: "";
}
.nested-element {
margin: $spacing-variable;
}
}
Alphabetizing can be automated and is commonly a feature built into code editors (see Resources below).
Alphabetical declaration ordering can be linted using stylelint with the
stylelint-order plugin and its order/properties-alphabetical-order rule.
Edit > Sort Lines menu item, or press
<kbd>F5</kbd> to sort lines alphabetically.