UNPKG

963 BSCSSView Raw
1// Custom functions (not available in Bootstrap)
2@function hsb($h-hsb, $s-hsb, $b-hsb) {
3 // Checking hsb values for 0 and turning them into 1 to avoid issues with SASS compiler
4 @if $h-hsb < 1 {
5 $h-hsb: 1;
6 }
7 @if $s-hsb < 1 {
8 $s-hsb: 1;
9 }
10 @if $b-hsb < 1 {
11 $b-hsb: 1;
12 }
13
14 @if $b-hsb < 1 {
15 @return hsl(0, 0%, 0%);
16 } @else {
17 $l-hsl: calc($b-hsb / 2) * (2 - calc($s-hsb / 100));
18 $s-hsl: calc(($b-hsb * $s-hsb) / if($l-hsl < 50, $l-hsl * 2, 200 - $l-hsl * 2));
19 @return hsl($h-hsb, $s-hsl * 1%, $l-hsl * 1%);
20 }
21}
22
23@function hsb-with-brightness-modifier($h-hsb, $s-hsb, $b-hsb, $b-variant) {
24 $b-hsb: $b-hsb + $b-variant;
25 @return hsb($h-hsb, $s-hsb, $b-hsb);
26}
27
28@function color-hover($color) {
29 @return desaturate(shade-color($color, 10%), 10%);
30}
31
32@function url-friendly-color($color) {
33 @if str-slice('#{$color}', 1, 1) == '#' {
34 @return '%23' + str-slice('#{$color}', 2, -1);
35 } @else {
36 @return $color;
37 }
38}