Skip to content

Latest commit

 

History

History
67 lines (50 loc) · 2.12 KB

readme.md

File metadata and controls

67 lines (50 loc) · 2.12 KB

Strateg (S)CSS Styleguide

Table of Contents

Terminology

CSS-Tricks does a great job of explaining the basic CSS terminology here.

Linting

We use stylelint with our custom config to ensure that we write clean and maintanable code.

Naming convention

We use BEM or "Block-Element-Modifier" to help us build reusable, scalable components and to keep the selector specificity low. But we are using a more atomic approach to BEM that looks like this .block__element -modifier to avoid long class names when combinding multiple modifiers.

Useful reading

Formatting

Do not use ID selectors

This will only create unnecessary selector specificity.

camelCase selectors

camelCasing will provide a better grouping of class names and make them easier to read and mentally process.

🚫 Don't

.header-nav__list-item.-is-active {}

✅ Do

.headerNav__listItem.-isActive {}

Note: the only exception of this rule are the JavaScript hooks.

Never chain BEM element selectors

If you need to chain element selectors it probably means that you need to convert an element to a block.

🚫 Don't

.nav__list__item {}

✅ Do

.nav__item {}
/* or */
.navItem {}

JavaScript hooks

Avoid binding to the same class in your CSS and JavaScript. Using the same class will make it harder to refactor and reuse functionality. We use a specific JavaScript class prefixed with .js- instead.

<button class="button js-open-menu">Open menu</button>