of documentation. • Lack of structure, quality assurance. • Lack of knowledge (about CSS or the project itself) • Different styles, preferences, ways of working. • Not looking to see/being aware of what exists already. • Adding new styles to the end of stylesheets. • The cascade and inheritance. • Very loose. • Highly dependent on source order. • Specificity • Lots of gotchas
a component. */ .modal {} /** * An ‘Element’ that is a part of the larger Block. */ .modal__title {} /** * A ‘Modifier’ of the Block. */ .modal--large {}
c-; Signify that something is a Component u-; Signify that this class is a Utility class t-; Signify that a class is responsible for adding a Theme to a view s-; Signify that a class creates a new styling context or Scope is-,has-; Signify that the piece of UI in question is currently styled a certain way because of a state or condition. _; Signify that this class is a hack js-; Signify that this piece of the DOM has some behaviour acting upon it, and that JavaScript binds onto it to provide that behaviour qa-; Signify that a QA or Test Engineering team is running an automated UI test which needs to find or bind onto these parts of the DOM
.o-layout__item {} .o-layout--fixed {} Rules: • Objects are abstract. • They can be used in many places • Avoid modifying their styles • Be careful around anything with a leading
.c-modal__title {} .c-modal--gallery {} Rules: • Components are implementation of UI • They are quite safe to modify • Anything with a leading c- is a specific thing
.tabs { background-color: gray; .t-red & { background-color: red; } .t-blue & { background-color: blue; } } SCSS format: Rules: • Theme namespaces are very high-level • They provide a context or scope for many other rules • It’s useful to signal the current condition of the UI
.has-dropdown {} Rules: • States are very temporary • Ensure that States are easily noticed and understood in our HTML • Never write a bare State class.
Rules: • Hacks are ugly—give them ugly classes • Hacks should be temporary, do not reuse or bind onto their classes • Keep an eye on the number of Hacks classes in your codebase
Rules: • JavaScript and CSS are separate concerns—use separate hooks for them • Giving different teams/roles different hooks makes for safer collaboration.
Rules: • Binding automated UI tests onto style hooks is too inexplicit—don’t do it • Bind tests onto dedicated test classes • Ensure that any UI refactoring doesn’t affect the QA team’s hooks