Syntax and Formatting
The Ushahidi Platform uses the SCSS syntax because it is more consistent and familiar with vanilla CSS.
Indentation should be 4 space tabs. CSS rules should be written on multi-lines.
White space after each declaration and after each ending curly brace.
Nesting
Nesting is one of the best features in Sass, but it can be overused and create unwanted CSS. A best practice is to nest no more than 3 levels deep and to only nest classes when that relationship is absolutely necessary to declare in order to achieve the desired style. Nesting for the sake of organizing the stylesheet is discouraged.
Sass
Compiled CSS Output
Color Formats
Hex is the default color format with RGBA being used when opacity is needed.
Hex
Hex values should be written in all caps.
RGB
When using RGB, single space after commas and no spaces after parentheses.
Numbers
Numbers should display leading zeros before a decimal value less than one and never display trailing zeros.
Zeros:
Units:
Calculations
Strings
Single quotes should be used with strings.
Font Stack Example:
Image URL Example:
Commenting
Commenting is CSS is an essential practice that can help explain why and how code is written. Ushahidi's CSS commenting is simple.
Css Rulesets
related selectors on the same line; unrelated selectors on new lines;
the opening brace ({) spaced from the last selector by a single space;
each declaration on its own new line;
a space after the colon (:);
a trailing semi-colon (;) at the end of all declarations;
the closing brace (}) on its own new line;
a new line after the closing brace (}).
Letter Case Usage & Naming Conventions
When naming classes use lower case letters and a hypen between words.