Makes adding colors easier

Just map your colors, the bulma way ($name: ($color[,$invert]) into $custom-colors, and import bulma.
Note that, you can provide only the color as the inverted would be computed from it.
This commit is contained in:
Come2Daddy
2018-03-22 15:24:27 +01:00
committed by Jeremy Thomas
parent fecfa3c263
commit 4bf1010ec6
2 changed files with 25 additions and 2 deletions

View File

@@ -1,3 +1,25 @@
@function colorMap($bulma-colors, $custom-colors)
// we return at least bulma hardcoded colors
$merged-colors: $bulma-colors
// we want a map as input
@if type-of($custom-colors) == 'map'
@each $name, $components in $custom-colors
// color name should be a string and colors pair a list with at least one element
@if type-of($name) == 'string' and (type-of($components) == 'list' or type-of($components) == 'color') and length($components) >= 1
$color-base: nth($components, 1)
$color-invert: null
// is an inverted color provided ?
@if length($components) > 1
$color-invert: nth($components, 2)
// we only want a color as base color
@if type-of($color-base) == 'color'
// if inverted color is not provided or is not a color we compute it
@if type-of($color-invert) != 'color'
$color-invert: findColorInvert($color-base)
// we merge this colors elements as map with bulma colors (we can override them this way, no multiple definition for the same name)
$merged-colors: map_merge($merged-colors, ($name: ($color-base, $color-invert)))
@return $merged-colors
@function powerNumber($number, $exp)
$value: 1
@if $exp > 0