Skip to content

Instantly share code, notes, and snippets.

@lostpebble
Last active July 11, 2017 09:23
Show Gist options
  • Save lostpebble/cf94244bf772843f2e7e7a88e685b74d to your computer and use it in GitHub Desktop.
Save lostpebble/cf94244bf772843f2e7e7a88e685b74d to your computer and use it in GitHub Desktop.
An example of an atomic-style SASS file, here for some colour and graphical uses
// INDIVIDUAL COLORS
$color-blue-shadow: rgb(46, 54, 64);
$color-mid-blue-shadow: rgb(88, 100, 115);
$color-light-blue-shadow: rgb(124, 139, 153);
$color-warn: rgb(255,117,25);
$color-dark-blue: #267eae;
$color-mid-blue: rgb(108, 181, 227);
$color-light-blue: rgb(89, 195, 251);
$color-lightest-blue: rgb(191, 248, 255);
$color-white-blue: rgb(238, 248, 255);
$color-red: #ec5d59;
$color-peach-red: #e47776;
$color-rating-gold: #fff776;
$color-light-gold: #fff690;
$color-lightest-gold: #fffdb9;
$color-light-grey: #e2e6eb;
.bx-shadow-soft {
box-shadow: 0 2px 15px 1px rgba($color-blue-shadow, 0.1);
}
.bx-shadow-inset-soft {
box-shadow: inset 0 6px 6px -2px rgba($color-blue-shadow, 0.2), inset 0 2px 3px -1px rgba($color-blue-shadow, 0.25);
}
.bx-shadow-inset-softest {
box-shadow: inset 0 6px 6px -2px rgba($color-blue-shadow, 0.15), inset 0 2px 3px -1px rgba($color-blue-shadow, 0.07);
}
$color-list: (
("white", rgb(255,255,255))
("warn", $color-warn)
("blue-shadow", $color-blue-shadow)
("mid-blue-shadow", $color-mid-blue-shadow)
("light-blue-shadow", $color-light-blue-shadow)
("light-blue", $color-light-blue)
("mid-blue", $color-mid-blue)
("dark-blue", $color-dark-blue)
("red", $color-red)
("peach-red", $color-peach-red)
("rating-gold", $color-rating-gold)
("lightest-blue", $color-lightest-blue)
("white-blue", $color-white-blue)
("light-grey", $color-light-grey)
("lightest-gold", $color-lightest-gold)
("light-gold", $color-light-gold)
);
@for $c from 1 through 9 {
.op-#{$c}0 {
opacity: get-opacity-tenths($c);
}
.op-#{$c}5 {
opacity: get-opacity-tenths($c) + 0.05;
}
}
@for $c from 1 through length($color-list) {
$current: nth($color-list, $c);
$name: nth($current, 1);
$color: nth($current, 2);
.col-#{$name} {
color: $color;
}
.bg-#{$name} {
background-color: $color;
}
.svg-col-#{$name} {
svg {
fill: $color;
}
}
.pop-col-#{$name} {
box-shadow: 0 0.15em darken(desaturate($color, 2), 7), 0 calc(0.15em + 1px) 1px -0.5px rgba(darken($color, 20), 0.65);
}
.pop-col-#{$name}-half {
box-shadow: 0 0.15em rgba(darken(desaturate($color, 2), 4), 0.7), 0 calc(0.15em + 1px) 1px -0.5px rgba(darken($color, 20), 0.35);
}
.drop-col-#{$name} {
box-shadow: inset 0 0.15em darken($color, 7), inset 0 0.3em 0.25em rgba(darken($color, 10), 0.25), inset 0 0.2em 0.2em rgba(darken($color, 10), 0.65);
}
.drop-col-#{$name}-op-5 {
box-shadow: inset 0 0.15em rgba(darken($color, 7), 0.1), inset 0 0.3em 0.25em rgba(darken($color, 10), 0.1), inset 0 0.2em 0.2em rgba(darken($color, 10), 0.1);
}
.btn-shadow-col-#{$name} {
box-shadow: 0 0.35em darken(desaturate($color, 2), 11), 0 calc(0.35em + 1px) 4px -0.5px rgba(darken($color, 40), 0.65);
}
.btn-pressed-shadow-col-#{$name} {
box-shadow: inset 0 0.35em darken($color, 10), inset 0 0.95em 0.5em rgba(darken($color, 45), 0.25), inset 0 0.45em 0.2em rgba(darken($color, 40), 0.65);
}
@for $i from 1 through 9 {
$opacity: get-opacity-tenths($i);
.bg-#{$name}-op-#{$i} {
background-color: rgba($color, $opacity);
}
@if $name == "white" or $name == "blue-shadow" or $i >= 5 {
.col-#{$name}-op-#{$i} {
color: rgba($color, $opacity);
}
.svg-col-#{$name}-op-#{$i} {
svg {
fill: rgba($color, $opacity);
}
}
}
}
.col-#{$name}-op-95 {
color: rgba($color, 0.95);
}
.bg-#{$name}-op-95 {
background-color: rgba($color, 0.95);
}
.svg-col-#{$name}-op-95 {
svg {
fill: rgba($color, 0.95);
}
}
.bg-hov-#{$name} {
transition: background-color 0.2s ease-in-out;
&:hover {
background-color: rgba($color, 1);
}
}
.bg-hov-#{$name}-op-8 {
transition: background-color 0.2s ease-in-out;
&:hover {
background-color: rgba($color, 0.8);
}
}
.hov-block:hover {
.col-hov-#{$name} {
color: rgba($color, 1);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment