Skip to content

nerdpruitt/style-guide

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 

Repository files navigation

Base, Layout, Module, State

Division of style responsibilities.

JavaScript Selectors

A selector that is used only for JavaScript logic

.js-*

Examples:

  • .js-open
  • .js-needs-attention
<button class="btn js-submit">Submit</button>

State Selector

Shared by Sass and JavaScript and/or Handlebars. Should never be styled directly; only styled as an adjoining.

.is-* .has-*

Examples:

  • .is-selected
  • .has-error
.btn {
  background-color: red;

  &.is-pressed {
    box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.25);
  }
}

BEM Style Selector

Block, Element, Modifier. Used only in Sass. All modular and such. Favor multiple classes over @extends or it gets all wacky.

Examples:

  • .list
  • .list__heading
  • .list__heading--small
  • .list__heading--large
  • .list__heading--all-caps
<ul class="list">
  <li class="list__item">
    <h2 class="list__heading">Heading</h2>
    <h3 class="list__heading list__heading--small">Smaller Heading</h3>
    <p class="list__text">And a complete sentence.</p>
  </li>
  <li class="list__item"></li>
  <li class="list__item"></li>
</ul>

Sass

Rule sets should be ordered as follows:

  • @extend
  • @include without @content
  • properties
  • @include with @content
  • nested rule sets
.element {
  $scoped-variable: whatever;
  @extend .other-element;
  @include mixin($argument);
  property: value;

  @include breakpoint($size) {
    /* styles here */
  }

  &:pseudo {
    /* styles here */
  }

  .nested {
    /* styles here */
  }
}

Comment Levels

// *************************************
//
//   First Level
//   -> Description
//
// *************************************

// -------------------------------------
//   Second Level
// -------------------------------------

// ----- Third Level ----- //

// Fourth Level

Using @extend and @mixin

@extend should only be used in a single file. @mixin should be used when working across different partials.

About

A front end style guide for my projects.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published