From 3524f1bac11c8a9d1640bfeac5ceb063ff96d623 Mon Sep 17 00:00:00 2001 From: Volpeon Date: Sun, 6 Feb 2022 17:17:33 +0100 Subject: Improved variable structure --- src/objects/_button.scss | 112 ++++++++++++++++++++++++----------------------- 1 file changed, 58 insertions(+), 54 deletions(-) (limited to 'src/objects/_button.scss') diff --git a/src/objects/_button.scss b/src/objects/_button.scss index 3932575..135ada0 100644 --- a/src/objects/_button.scss +++ b/src/objects/_button.scss @@ -1,33 +1,34 @@ @use 'iro-sass/src/index' as iro; +@use '../functions' as fn; @use '../vars'; @use '../mixins/typography'; @mixin button-variant($variant) { - border-color: iro.props-get((--colors, --#{$variant}, --bg)); - background-color: iro.props-get((--colors, --#{$variant}, --bg)); - box-shadow: iro.props-get((--colors, --#{$variant}, --shadow)); - color: iro.props-get((--colors, --#{$variant}, --label)); + border-color: fn.color((--#{$variant}, --bg)); + background-color: fn.color((--#{$variant}, --bg)); + box-shadow: fn.color((--#{$variant}, --shadow)); + color: fn.color((--#{$variant}, --label)); @include iro.bem-multi('&:link, &:visited', 'modifier' 'native') { &:hover { - border-color: iro.props-get((--colors, --#{$variant}, --hover, --bg)); - background-color: iro.props-get((--colors, --#{$variant}, --hover, --bg)); - box-shadow: iro.props-get((--colors, --#{$variant}, --hover, --shadow)); - color: iro.props-get((--colors, --#{$variant}, --hover, --label)); + border-color: fn.color((--#{$variant}, --hover, --bg)); + background-color: fn.color((--#{$variant}, --hover, --bg)); + box-shadow: fn.color((--#{$variant}, --hover, --shadow)); + color: fn.color((--#{$variant}, --hover, --label)); } &:active { - border-color: iro.props-get((--colors, --#{$variant}, --active, --bg)); - background-color: iro.props-get((--colors, --#{$variant}, --active, --bg)); - box-shadow: iro.props-get((--colors, --#{$variant}, --active, --shadow)); - color: iro.props-get((--colors, --#{$variant}, --active, --label)); + border-color: fn.color((--#{$variant}, --active, --bg)); + background-color: fn.color((--#{$variant}, --active, --bg)); + box-shadow: fn.color((--#{$variant}, --active, --shadow)); + color: fn.color((--#{$variant}, --active, --label)); } } @include iro.bem-modifier('outline') { background-color: transparent; box-shadow: none; - color: iro.props-get((--colors, --#{$variant}, --outline-label)); + color: fn.color((--#{$variant}, --outline-label)); } } @@ -38,81 +39,84 @@ --padding-y: .5rem, --rounding: 10em, ), + ), 'dims'); + + @include iro.props-store(( --colors: ( --any: ( --disabled: ( - --bg: iro.props-get(--colors --obj-hi, $global: true), - --label: iro.props-get(--colors --fg-hi3, $global: true), + --bg: fn.color(--obj-hi, $global: true), + --label: fn.color(--fg-hi3, $global: true), --shadow: 0 0 0 0 transparent, ), --key-focus: ( --bg: transparent, - --label: iro.props-get(--colors --accent --primary-lo2, $global: true), - --border: iro.props-get(--colors --focus --fill, $global: true), - --shadow: iro.props-get(--colors --focus --shadow, $global: true), + --label: fn.color(--accent --primary-lo2, $global: true), + --border: fn.color(--focus --fill, $global: true), + --shadow: fn.color(--focus --shadow, $global: true), ), ), --accent: ( - --bg: iro.props-get(--colors --accent --primary, $global: true), - --label: iro.props-get(--colors --accent --primary-fg, $global: true), - --outline-label: iro.props-get(--colors --accent --primary-lo, $global: true), + --bg: fn.color(--accent --primary, $global: true), + --label: fn.color(--accent --primary-fg, $global: true), + --outline-label: fn.color(--accent --primary-lo, $global: true), --shadow: 0 0 0 0 transparent, --hover: ( - --bg: iro.props-get(--colors --accent --primary-lo, $global: true), - --label: iro.props-get(--colors --accent --primary-fg, $global: true), + --bg: fn.color(--accent --primary-lo, $global: true), + --label: fn.color(--accent --primary-fg, $global: true), --shadow: 0 0 0 0 transparent, ), --active: ( - --bg: iro.props-get(--colors --accent --primary-lo2, $global: true), - --label: iro.props-get(--colors --accent --primary-fg, $global: true), + --bg: fn.color(--accent --primary-lo2, $global: true), + --label: fn.color(--accent --primary-fg, $global: true), --shadow: 0 0 0 0 transparent, ), ), --primary: ( - --bg: iro.props-get(--colors --fg, $global: true), - --label: iro.props-get(--colors --bg-hi2, $global: true), - --outline-label: iro.props-get(--colors --fg, $global: true), + --bg: fn.color(--fg, $global: true), + --label: fn.color(--bg-hi2, $global: true), + --outline-label: fn.color(--fg, $global: true), --shadow: 0 0 0 0 transparent, --hover: ( - --bg: iro.props-get(--colors --fg-lo, $global: true), - --label: iro.props-get(--colors --bg-hi2, $global: true), + --bg: fn.color(--fg-lo, $global: true), + --label: fn.color(--bg-hi2, $global: true), --shadow: 0 0 0 0 transparent, ), --active: ( - --bg: iro.props-get(--colors --fg-lo, $global: true), - --label: iro.props-get(--colors --bg-hi2, $global: true), + --bg: fn.color(--fg-lo, $global: true), + --label: fn.color(--bg-hi2, $global: true), --shadow: 0 0 0 0 transparent, ), ), --secondary: ( - --bg: iro.props-get(--colors --obj-hi, $global: true), - --label: iro.props-get(--colors --fg, $global: true), - --outline-label: iro.props-get(--colors --fg, $global: true), + --bg: fn.color(--obj-hi, $global: true), + --label: fn.color(--fg, $global: true), + --outline-label: fn.color(--fg, $global: true), --shadow: 0 0 0 0 transparent, --hover: ( - --bg: iro.props-get(--colors --obj, $global: true), - --label: iro.props-get(--colors --fg-lo, $global: true), + --bg: fn.color(--obj, $global: true), + --label: fn.color(--fg-lo, $global: true), --shadow: 0 0 0 0 transparent, ), --active: ( - --bg: iro.props-get(--colors --obj-lo, $global: true), - --label: iro.props-get(--colors --fg-lo, $global: true), + --bg: fn.color(--obj-lo, $global: true), + --label: fn.color(--fg-lo, $global: true), --shadow: 0 0 0 0 transparent, ), ), ), - )); + ), 'colors'); @include iro.bem-object(iro.props-namespace()) { @include typography.set-font(vars.$font--main, (weight: 500)); display: inline-block; - padding: iro.props-get(--dims --padding-y) iro.props-get(--dims --padding-x); + padding: fn.dim(--padding-y) fn.dim(--padding-x); border: 2px solid transparent; - border-radius: iro.props-get(--dims --rounding); + border-radius: fn.dim(--rounding); line-height: 1; text-align: center; text-decoration: none; @@ -138,26 +142,26 @@ @include iro.bem-at-theme('keyboard') { &:focus { - border-color: iro.props-get(--colors --any --key-focus --border); - background-color: iro.props-get(--colors --any --key-focus --bg); - box-shadow: iro.props-get(--colors --any --key-focus --shadow); - color: iro.props-get(--colors --any --key-focus --label); + border-color: fn.color(--any --key-focus --border); + background-color: fn.color(--any --key-focus --bg); + box-shadow: fn.color(--any --key-focus --shadow); + color: fn.color(--any --key-focus --label); } } @include iro.bem-is('disabled') { - border-color: iro.props-get(--colors --any --disabled --bg); - background-color: iro.props-get(--colors --any --disabled --bg); - box-shadow: iro.props-get(--colors --any --disabled --shadow); - color: iro.props-get(--colors --any --disabled --label); + border-color: fn.color(--any --disabled --bg); + background-color: fn.color(--any --disabled --bg); + box-shadow: fn.color(--any --disabled --shadow); + color: fn.color(--any --disabled --label); @include iro.bem-multi('&:link, &:visited', 'modifier' 'native') { &:hover, &:active { - border-color: iro.props-get(--colors --any --disabled --bg); - background-color: iro.props-get(--colors --any --disabled --bg); - box-shadow: iro.props-get(--colors --any --disabled --shadow); - color: iro.props-get(--colors --any --disabled --label); + border-color: fn.color(--any --disabled --bg); + background-color: fn.color(--any --disabled --bg); + box-shadow: fn.color(--any --disabled --shadow); + color: fn.color(--any --disabled --label); } } -- cgit v1.2.3-54-g00ecf