Skip to content

Instantly share code, notes, and snippets.

@lukaszklis
Created January 17, 2017 17:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lukaszklis/e24a539a34163aed928d86c47b655ec0 to your computer and use it in GitHub Desktop.
Save lukaszklis/e24a539a34163aed928d86c47b655ec0 to your computer and use it in GitHub Desktop.
/* Default variant */
.name-badge {}
.name-badge__name {}
.name-badge__avatar {}
.name-badge__description {}
/* Small variant */
.name-badge--small {}
.name-badge--small .name-badge__name {}
.name-badge--small .name-badge__avatar {}
.name-badge--small .name-badge__description {}
<!-- Default variant -->
<div clas="name-badge">
<div class="name-badge__name"></div>
<img class="name-badge__avatar">
<div class="name-badge__description"></div>
</div>
<!-- Small variant -->
<div clas="name-badge name-badge--small">
<div class="name-badge__name"></div>
<img class="name-badge__avatar">
<div class="name-badge__description"></div>
</div>
@lukaszklis
Copy link
Author

When using a modifier for the parent element only, and using the selector as shown above, the only thing you have to change is the class name for the parent element, and not changing class names for all elements inside of the parent. Not necessarily everything would have to be overwritten by the modifier (for instance, the font-size of the description wouldn’t change, or description would be even hidden in the "small" version).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment