Skip to content

Commit f0edb0c

Browse files
committed
feat(developer): Add BEM to CSS documentation
Signed-off-by: Ferdinand Thiessen <[email protected]>
1 parent 633d170 commit f0edb0c

File tree

1 file changed

+41
-5
lines changed

1 file changed

+41
-5
lines changed

developer_manual/getting_started/codingguidelines.rst

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -444,9 +444,10 @@ Control structures
444444
CSS
445445
---
446446

447-
Take a look at the `Writing Tactical CSS & HTML <https://www.youtube.com/watch?v=hou2wJCh3XE&feature=plcp>`_ video on YouTube.
448-
449-
Don't bind your CSS too much to your HTML structure and try to avoid IDs. Also try to make your CSS reusable by grouping common attributes into classes.
447+
- Do not bind your CSS to much to your HTML structure.
448+
- Try to avoid IDs.
449+
- Try to make your CSS reusable by grouping common attributes into classes.
450+
- Take a look at the `Writing Tactical CSS & HTML <https://www.youtube.com/watch?v=hou2wJCh3XE&feature=plcp>`_ video on YouTube.
450451

451452
**DO**:
452453

@@ -456,7 +457,7 @@ Don't bind your CSS too much to your HTML structure and try to avoid IDs. Also t
456457
list-style-type: none;
457458
}
458459
459-
.list > .list_item {
460+
.list > .list__item {
460461
display: inline-block;
461462
}
462463
@@ -477,4 +478,39 @@ Don't bind your CSS too much to your HTML structure and try to avoid IDs. Also t
477478
display: inline-block;
478479
}
479480
480-
**TBD**
481+
Naming convention
482+
^^^^^^^^^^^^^^^^^
483+
484+
We recommend to use the BEM (Block-Element-Modifier) naming convention for CSS classes.
485+
BEM helps with making CSS reusable and better maintainable, especially when using pre-processors like SASS.
486+
487+
**DO**:
488+
489+
.. code-block:: css
490+
491+
.button {
492+
background-color: var(--color-main-background);
493+
}
494+
495+
.button--primary {
496+
background-color: var(--color-primary);
497+
}
498+
499+
.button__icon {
500+
width: 20px;
501+
}
502+
503+
**DON'T**:
504+
505+
.. code-block:: css
506+
507+
button.btn {
508+
background-color: var(--color-main-background);
509+
}
510+
511+
button.btn.primary {
512+
background-color: var(--color-primary);
513+
}
514+
button.btn span.myIcon {
515+
width: 20px;
516+
}

0 commit comments

Comments
 (0)