While developing websites with Drupal, it's common to get really complex selectors (especially with menu styling.)

There are 2 reasons for this:

  1. We are overriding CSS rules in core that are already complex.
  2. We have no easy classes to match exactly what we want.

While reading about the SMACSS technique, the class naming technique made a lot of sense. It uses modular class names. Related components get class names that include both the component name and the variant name.

.COMPONENT
.COMPONENT--VARIANT
.COMPONENT__SUB-ELEMENT
.COMPONENT--VARIANT__SUB-ELEMENT

For example, instead of ul li.expanded we should just use .menu__item-expanded.

Sub-issues:

#1713168: Add SMACSS-style classes to header
#1713170: Add SMACSS-style classes to menus
#1713172: Add SMACSS-style classes to tabs
#1713320: Add SMACSS-style classes to messages
#1714986: Add SMACSS-style rulesets to pager
#1719726: Simplify various selectors to use SMACSS-style classes

Comments

johnalbin’s picture

Issue summary: View changes

Add example

johnalbin’s picture

Issue summary: View changes

Add sub-issues

johnalbin’s picture

Issue summary: View changes

Add sub-task

johnalbin’s picture

Title: [META] Add SMACSS-style classes to markup » [META] Use component-based styling in CSS
Version: 7.x-5.x-dev » 7.x-6.x-dev
.MODULE
.MODULE--component
.MODULE-SUBMODULE
.MODULE-SUBMODULE--component

The class names are all off. They should follow the standards we developed for Drupal 8, so I've updated the issue summary.

I need to roll-back some of those sub-issues in the 7.x-5.x branch.

johnalbin’s picture

Issue summary: View changes

Add new sub-task

johnalbin’s picture

Version: 7.x-6.x-dev » 7.x-5.x-dev
Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

Update component class naming examples.