From 71af9d144c4dfc27c8824aec4d945897289ed440 Mon Sep 17 00:00:00 2001 From: Volpeon Date: Wed, 26 Jun 2024 14:46:36 +0200 Subject: Add static themes to action button --- src/objects/_button.scss | 83 ++++++++++++++++++++++-------------------------- 1 file changed, 38 insertions(+), 45 deletions(-) (limited to 'src/objects/_button.scss') diff --git a/src/objects/_button.scss b/src/objects/_button.scss index 27d3726..98ac8ef 100644 --- a/src/objects/_button.scss +++ b/src/objects/_button.scss @@ -6,24 +6,22 @@ $sizes: 'sm' 'lg' 'xl' !default; $themes: 'accent' 'negative' !default; $static-themes: 'black' 'white' !default; -@mixin theme($theme: null) { - $key: if($theme == null, (), --#{$theme}); - +@mixin theme($theme: ()) { &:link, &:visited, &:enabled { border-color: transparent; - background-color: fn.color(list.join($key, --bg)); - color: fn.color(list.join($key, --label)); + background-color: fn.color(list.join($theme, --bg)); + color: fn.color(list.join($theme, --label)); } @include iro.bem-modifier('outline') { &:link, &:visited, &:enabled { - border-color: fn.color(list.join($key, --outline-border)); + border-color: fn.color(list.join($theme, --outline-border)); background-color: transparent; - color: fn.color(list.join($key, --outline-label)); + color: fn.color(list.join($theme, --outline-label)); } } @@ -33,35 +31,37 @@ $static-themes: 'black' 'white' !default; &:hover, &:focus-visible { border-color: transparent; - background-color: fn.color(list.join($key, --hover --bg)); - color: fn.color(list.join($key, --hover --label)); + background-color: fn.color(list.join($theme, --hover --bg)); + color: fn.color(list.join($theme, --hover --label)); } &:active { border-color: transparent; - background-color: fn.color(list.join($key, --active --bg)); - color: fn.color(list.join($key, --active --label)); + background-color: fn.color(list.join($theme, --active --bg)); + color: fn.color(list.join($theme, --active --label)); } } } -@mixin static-theme($theme, $disabled-theme: $theme) { - $key: --static-#{$disabled-theme}; - +@mixin static-theme($theme: ()) { border-color: transparent; - background-color: fn.color(list.join($key, --disabled --bg)); - color: fn.color(list.join($key, --disabled --label)); + background-color: fn.color(list.join($theme, --disabled --bg)); + color: fn.color(list.join($theme, --disabled --label)); + + &::after { + outline: fn.color(list.join($theme, --key-focus --border)) solid fn.dim(--key-focus --border); + box-shadow: 0 0 0 calc(fn.dim(--key-focus --border) + fn.dim(--key-focus --outline)) fn.color(list.join($theme, --key-focus --outline)); + } @include iro.bem-modifier('outline') { - border-color: fn.color(list.join($key, --disabled --outline-border)); + border-color: fn.color(list.join($theme, --disabled --outline-border)); background-color: transparent; } - @include theme(static-#{$theme}); + @include theme($theme); - &::after { - outline: fn.color(list.join($key, --key-focus --border)) solid fn.dim(--key-focus --border); - box-shadow: 0 0 0 calc(fn.dim(--key-focus --border) + fn.dim(--key-focus --outline)) fn.color(list.join($key, --key-focus --outline)); + @include iro.bem-modifier('primary') { + @include theme(list.join($theme, --primary)); } } @@ -190,20 +190,21 @@ $static-themes: 'black' 'white' !default; --border: fn.global-color(--#{$theme}-transparent --900), --outline: fn.global-color(--#{$theme}-transparent --300), ), - ), - --static-#{$theme}-primary: ( - --bg: fn.global-color(--#{$theme}-transparent --800), - --label: fn.global-color(--#{$theme}-transparent --text), - --outline-border: fn.global-color(--#{$theme}-transparent --800), - --outline-label: fn.global-color(--#{$theme}-transparent --900), - --hover: ( - --bg: fn.global-color(--#{$theme}-transparent --900), - --label: fn.global-color(--#{$theme}-transparent --text), - ), - --active: ( - --bg: fn.global-color(--#{$theme}-transparent --900), - --label: fn.global-color(--#{$theme}-transparent --text), + --primary: ( + --bg: fn.global-color(--#{$theme}-transparent --800), + --label: fn.global-color(--#{$theme}-transparent --text), + --outline-border: fn.global-color(--#{$theme}-transparent --800), + --outline-label: fn.global-color(--#{$theme}-transparent --900), + + --hover: ( + --bg: fn.global-color(--#{$theme}-transparent --900), + --label: fn.global-color(--#{$theme}-transparent --text), + ), + --active: ( + --bg: fn.global-color(--#{$theme}-transparent --900), + --label: fn.global-color(--#{$theme}-transparent --text), + ), ), ), ), @@ -265,25 +266,17 @@ $static-themes: 'black' 'white' !default; } } - @include theme(); - - @include iro.bem-modifier('primary') { - @include theme('primary'); - } + @include static-theme; @each $theme in $themes { @include iro.bem-modifier($theme) { - @include theme($theme); + @include theme(--#{$theme}); } } @each $theme in $static-themes { @include iro.bem-modifier(static-#{$theme}) { - @include static-theme($theme); - } - - @include iro.bem-modifier(static-#{$theme}-primary) { - @include static-theme(#{$theme}-primary, $theme); + @include static-theme(--static-#{$theme}); } } -- cgit v1.2.3-54-g00ecf