Make everything opt-in
Start with a plain base and make any styling changes optional extras that can be added.
- Ensure people can choose what they want.
- Never force changes unless you really mean to. Provide additional functionality via options.
- Expose API-like CSS.
- It’s easier to opt into something than it is to undo it.
Single Responsibility Principle
- One thing, one thing only, one thing well. Keeps things focused!
- Keeps thing small.
- Keeps things composable.
- Think Subway. 🥪
Separation of Concerns
- Let each piece of code solve its own problems.
- Keep things decoupled.
Make everything generic
A style guide should be thought of a design system of components and not set of pages. Having a naming convention that binds a component to its context of a page means its harder to share and scale.
Problems:
- When a sub heading can only be used for a sub heading (not scaleable)
- The naming convention mixes sizes ('Title large') with context ('Button')
- You can't increase / decrease the size names (Title xl-large, etc...)
... proposed solution 🥁
Split up typography types into headings and body styles.
Style names go up in size
Header styles | Body styles |
---|---|
Header One | Body One |
Header Two | Body Two |
Header Three | Body Three |
Header Four | Body Four |
Header Five | Body Five |
Header Six | Body Six |
CSS
@include font-style('header', 'two'); // auto breakpoint
@include font-style('header', 'two', 'mobile'); // no breakpoint
Mixins
.hero-banner {
@include font-style('header', 'three', 'mobile');
@media screen and (min-width: 900px) {
@include font-style('header', 'one', 'desktop');
}
}
Inline styles
Base class includes styling and also includes a breakpoint for mobile and desktop.
.u-header-one { @include font-style('header', 'one') }
Modifiers
.u-header-one--desktop {}
.u-header-one--mobile {}
.u-header-one--print {}
- Binding the names to context.
- No scope for other variations of colours e.g (brand--darker)
- Not scaleable
- Will neet aliasing to use the colours in correct context
- Hard to use across other sites (Boots, Next)
The ideal solution needs to be:
- Generic naming convention, so they're not tied to context
- White label Work across other sites
- Scalable (extra colours and shades)
http://chir.ag/projects/name-that-color/
CSS
Colour declarations (one for each theme)
$lima: #6EB01B; // green
$crimson: #C9112F; // red
$lipstick: #CA0051; // pink
$sorbus: #FD820A; // orange
$supernova: #FEC30A; // yellow
$dodger-blue: #358DF6; // light blue
$denim: #0A5DC1; // blue
Semantic variable names (default - ao)
/* Theme Colours Variables
========================================================================== */
$primary: $dodger-blue !default; // blue
$accent: $lima !default; // green
/* Buttons
========================================================================== */
$btn-bg--default: $alto !default; // grey
$btn-bg--primary: $primary !default; // blue
$btn-bg--success: $lima !default; // green
$btn-bg--error: $crimson !default; // red
$btn-color--default: $white !default; // white
$btn-color--disabled: $gray !default; // grey
/* Stars
========================================================================== */
$star-bg: $gray !default; // grey
$star-bg--filled-in: $supernova !default; // yellow
CSS component
/* ==========================================================================
#BUTTONS
========================================================================== */
.c-btn {
color: $btn-color--default;
}
/* Style variants
========================================================================== */
.c-btn--primary {
background: $btn-bg--primary;
}
/* Colour Utitlies
========================================================================== */
.u-color--primary { color: $primary !important; }
.u-color--accent { color: $accent !important; }
.u-background--primary { background: $primary !important; }
.u-background--accent { background: $accent !important; }
Atomic OOBEMITSCSS (joke-ish)