sass-site/source/assets/sass/components/_pop-stripe.scss

42 lines
1.0 KiB
SCSS
Raw Normal View History

2023-01-12 20:54:24 +01:00
@use 'sass:math';
@use 'sass:list';
@use 'sass:meta';
2023-03-13 21:02:47 +01:00
@use 'sass:map';
2023-01-12 20:54:24 +01:00
@use '../functions';
@use '../config/color/brand';
2023-01-12 19:19:42 +01:00
2023-03-13 21:02:47 +01:00
$sl-colors: ();
// loop over the variable names in config/color/brand.scss
@each $color-name in map.keys(meta.module-variables('brand')) {
// turn each sass variable name into a css var() function
$var: var(--#{$color-name});
// add each var() function to the space-separated list
$sl-colors: list.append($sl-colors, $var, space);
}
2023-01-06 22:40:29 +01:00
@function stripes($position, $sl-colors) {
2023-01-09 20:10:02 +01:00
$sl-colors: if(
2023-01-12 19:19:42 +01:00
meta.type-of($sl-colors) != 'list',
2023-01-09 20:10:02 +01:00
compact($sl-colors),
$sl-colors
);
2023-01-12 19:19:42 +01:00
$gradient: ();
$width: math.div(100%, list.length($sl-colors));
2023-01-06 22:40:29 +01:00
2023-01-12 19:19:42 +01:00
@for $i from 1 through list.length($sl-colors) {
$pop: list.nth($sl-colors, $i);
2023-01-09 20:10:02 +01:00
$new: $pop ($width * ($i - 1)), $pop ($width * $i);
2023-01-12 19:19:42 +01:00
$gradient: list.join($gradient, $new, comma);
2023-01-06 22:40:29 +01:00
}
@return linear-gradient($position, $gradient);
}
.sl-c-pop-stripe {
2023-01-12 19:19:42 +01:00
height: functions.sl-px-to-rem(4px);
2023-01-06 22:40:29 +01:00
background-image: stripes((to right), ($sl-colors));
background-size: 100%;
}