genkio / blog

Stay hungry stay foolish
https://slashbit.github.io/blog/
0 stars 1 forks source link

SMACSS. scalable modular architecture for CSS #129

Open genkio opened 7 years ago

genkio commented 7 years ago

study notes taken from the frontendmasters Scalable Modular Architecture for CSS course.

knowledge I obtained in this course + blended with my own take = Less SMACSS starter

What is SMACSS?

SMACSS is Categorization

Base

html {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
}

body {
  margin: 0;
  padding: 0;
}

h1, h2, h3 {
  margin: 1em 0;
}

Layout

.l-highlight { background-color: #CCC; }
.l-featured { background-color: #CCC; }
.l-constrained { width: 760px; }
.l-content {
  float: right;
  width: 20%;
}
.l-sidebar {
  float: right;
  width: 80%;
}
<div>
  <div class="layout-constrained"></div>
</div>
<div class="layout-highlight">
  <div class="layout-constrained"></div>
</div>

Module

Sub-module

Sub-component

SMACSS is Naming Convention

Module

.module-name {} /*allows for hyphens, always a root node*/
.module-name--submodule {} /*hyphens*/
.module-name__subcomponent {} /*underscores*/

/*or*/

.moduleName {}
.moduleName-subModule {}
.moduleName--subComponent {}

State

.btn {}
.btn-is-active {}
.btn-is-disabled {}

Theme

.theme-header {}
.theme-border {}
.theme-background {}

Helpers

.text-xl { font-size: 140%; }
.text-l { font-size: 120%; }
.text {}
.text-s { font-size: 90%; }
.text-xs { font-size: 80%; }

Prefixing for versioning

.next-btn {}
.next-btn-is-active {}
.next-btn-is-disabled {}

Wrap up

SMACSS is Decoupling CSS from HTML

Some other conventions