Skip to content

Instantly share code, notes, and snippets.

@laphilosophia
Last active January 5, 2018 13:13
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 laphilosophia/dfe8cfc0076355cad36f to your computer and use it in GitHub Desktop.
Save laphilosophia/dfe8cfc0076355cad36f to your computer and use it in GitHub Desktop.
Color Palettes
.colors {
background-color: #153e78;
}
// ----
// libsass (v3.2.5)
// ----
@function remove-nth($list, $index) {
$result: null;
@if type-of($index) != number {
@warn "$index: #{quote($index)} is not a number for `remove-nth`.";
}
@else if $index == 0 {
@warn "List index 0 must be a non-zero integer for `remove-nth`.";
}
@else if abs($index) > length($list) {
@warn "List index is #{$index} but list is only #{length($list)} item long for `remove-nth`.";
}
@else {
$result: ();
$index: if($index < 0, length($list) + $index + 1, $index);
@for $i from 1 through length($list) {
@if $i != $index {
$result: append($result, nth($list, $i));
}
}
}
@return $result;
}
@function val($map, $keys...) {
@if nth($keys, 1) == null {
$keys: remove-nth($keys, 1);
}
@each $key in $keys {
$map: map-get($map, $key);
}
@return $map;
}
@function _palette($keys...) {
@return val($palette, $keys...);
}
$palette: (
primary-color: #153e78,
secondary-color: #37bb78,
third-color: #9013fe,
fourth-color: #72d3d5,
fifth-color: #ffc21f,
sixth-color: #f36e35,
default-black: #000000,
default-white: #ffffff
);
.colors {
background-color: _palette(primary-color);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment