From 1e902449652213eb1feae5e61740cb9ce3b9d6e3 Mon Sep 17 00:00:00 2001 From: Volpeon Date: Sat, 22 Jun 2024 10:39:48 +0200 Subject: WIP: Refactoring --- src/objects/_palette.scss | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'src/objects/_palette.scss') diff --git a/src/objects/_palette.scss b/src/objects/_palette.scss index a86c026..9ecdfac 100644 --- a/src/objects/_palette.scss +++ b/src/objects/_palette.scss @@ -1,5 +1,6 @@ @use 'sass:map'; @use 'sass:list'; +@use 'sass:string'; @use 'iro-sass/src/index' as iro; @use '../functions' as fn; @use '../config'; @@ -12,8 +13,11 @@ @include iro.bem-elem('item') { flex: 1 1 auto; - @for $i from 1 through list.length(map.get(config.$theme-light, --grays)) { - $key: list.nth(map.keys(map.get(config.$theme-light, --grays)), $i); + $palette: map.get(config.$themes, config.$theme-default, --palettes, --base); + $contrasts: map.get(config.$themes, config.$theme-default, --contrasts, list.nth($palette, 2)); + + @for $i from 1 through list.length($contrasts) { + $key: list.nth(map.keys($contrasts), $i); &:nth-child(#{$i}) { background-color: fn.global-color(--base $key); @@ -21,14 +25,16 @@ } } - @each $palette in 'blue' 'purple' 'red' 'green' 'yellow' { - @include iro.bem-modifier($palette) { + @each $palette-name, $palette in map.get(config.$themes, config.$theme-default, --palettes) { + $contrasts: map.get(config.$themes, config.$theme-default, --contrasts, list.nth($palette, 2)); + + @include iro.bem-modifier(string.slice($palette-name, 3)) { @include iro.bem-elem('item') { - @for $i from 1 through list.length(map.get(config.$theme-light, --colors)) { - $key: list.nth(map.keys(map.get(config.$theme-light, --colors)), $i); + @for $i from 1 through list.length($contrasts) { + $key: list.nth(map.keys($contrasts), $i); &:nth-child(#{$i}) { - background-color: fn.global-color(--#{$palette} $key); + background-color: fn.global-color($palette-name $key); } } } -- cgit v1.2.3-70-g09d2