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/_radio.scss | 86 ++++++++++++++++++++++++++----------------------- 1 file changed, 45 insertions(+), 41 deletions(-) (limited to 'src/objects/_radio.scss') diff --git a/src/objects/_radio.scss b/src/objects/_radio.scss index 213b7c4..fd821d3 100644 --- a/src/objects/_radio.scss +++ b/src/objects/_radio.scss @@ -1,61 +1,65 @@ @use 'iro-sass/src/index' as iro; +@use '../functions' as fn; @include iro.props-namespace('radio') { @include iro.props-store(( --dims: ( --diameter: iro.fn-px-to-rem(15px), --label-gap: .6rem, - --border-width: iro.props-get(--dims --border-width --medium, $global: true), + --border-width: fn.dim(--border-width --medium, $global: true), --padding-x: .3rem, --padding-y: .3rem, - --margin-right: iro.props-get(--dims --spacing --x --md, $global: true), + --margin-right: fn.dim(--spacing --x --md, $global: true), ), + ), 'dims'); + + @include iro.props-store(( --colors: ( - --circle-border: iro.props-get(--colors --fg-hi, $global: true), - --circle-bg: iro.props-get(--colors --bg-hi, $global: true), + --circle-border: fn.color(--fg-hi, $global: true), + --circle-bg: fn.color(--bg-hi, $global: true), --hover: ( - --label: iro.props-get(--colors --fg-lo, $global: true), - --circle-border: iro.props-get(--colors --fg, $global: true), + --label: fn.color(--fg-lo, $global: true), + --circle-border: fn.color(--fg, $global: true), ), --accent: ( - --circle-border: iro.props-get(--colors --accent --primary, $global: true), + --circle-border: fn.color(--accent --primary, $global: true), --hover: ( - --circle-border: iro.props-get(--colors --accent --primary-lo, $global: true), + --circle-border: fn.color(--accent --primary-lo, $global: true), ), ), --key-focus: ( - --label: iro.props-get(--colors --focus --text, $global: true), - --circle-border: iro.props-get(--colors --focus --fill, $global: true), - --shadow: iro.props-get(--colors --focus --shadow, $global: true), + --label: fn.color(--focus --text, $global: true), + --circle-border: fn.color(--focus --fill, $global: true), + --shadow: fn.color(--focus --shadow, $global: true), ), --disabled: ( - --label: iro.props-get(--colors --fg-hi3, $global: true), - --circle-border: iro.props-get(--colors --obj-lo, $global: true), - --circle-bg: iro.props-get(--colors --bg-hi, $global: true), + --label: fn.color(--fg-hi3, $global: true), + --circle-border: fn.color(--obj-lo, $global: true), + --circle-bg: fn.color(--bg-hi, $global: true), ) ), - )); + ), 'colors'); @include iro.bem-object(iro.props-namespace()) { display: inline-flex; position: relative; align-items: flex-start; - margin-right: calc(-1 * iro.props-get(--dims --padding-x) + iro.props-get(--dims --margin-right)); - margin-left: calc(-1 * iro.props-get(--dims --padding-x)); - padding: iro.props-get(--dims --padding-y) iro.props-get(--dims --padding-x); + margin-right: calc(-1 * fn.dim(--padding-x) + fn.dim(--margin-right)); + margin-left: calc(-1 * fn.dim(--padding-x)); + padding: fn.dim(--padding-y) fn.dim(--padding-x); @include iro.bem-elem('circle') { display: block; position: relative; box-sizing: border-box; flex: 0 0 auto; - width: iro.props-get(--dims --diameter); - height: iro.props-get(--dims --diameter); - margin-top: calc(.5 * (#{$line-height * 1em} - #{iro.props-get(--dims --diameter)})); + width: fn.dim(--diameter); + height: fn.dim(--diameter); + margin-top: calc(.5 * (#{$line-height * 1em} - #{fn.dim(--diameter)})); border-radius: 2em; - background-color: iro.props-get(--colors --circle-border); + background-color: fn.color(--circle-border); &::after { content: ''; @@ -63,19 +67,19 @@ position: absolute; z-index: 10; top: 50%; - left: iro.props-get(--dims --border-width); - width: calc(iro.props-get(--dims --diameter) - 2 * iro.props-get(--dims --border-width)); - height: calc(iro.props-get(--dims --diameter) - 2 * iro.props-get(--dims --border-width)); + left: fn.dim(--border-width); + width: calc(fn.dim(--diameter) - 2 * fn.dim(--border-width)); + height: calc(fn.dim(--diameter) - 2 * fn.dim(--border-width)); transform: translateY(-50%); transition: transform .2s ease; - border-radius: iro.props-get(--dims --diameter); - background-color: iro.props-get(--colors --circle-bg); + border-radius: fn.dim(--diameter); + background-color: fn.color(--circle-bg); } } @include iro.bem-elem('label') { align-self: baseline; - margin-left: iro.props-get(--dims --label-gap); + margin-left: fn.dim(--label-gap); } @include iro.bem-elem('native') { @@ -91,11 +95,11 @@ &:hover { @include iro.bem-sibling-elem('label') { - color: iro.props-get(--colors --hover --label); + color: fn.color(--hover --label); } @include iro.bem-sibling-elem('circle') { - background-color: iro.props-get(--colors --hover --circle-border); + background-color: fn.color(--hover --circle-border); } } @@ -109,14 +113,14 @@ &:disabled { @include iro.bem-sibling-elem('label') { - color: iro.props-get(--colors --disabled --label); + color: fn.color(--disabled --label); } @include iro.bem-sibling-elem('circle') { - background-color: iro.props-get(--colors --disabled --circle-border); + background-color: fn.color(--disabled --circle-border); &::after { - background-color: iro.props-get(--colors --disabled --circle-bg); + background-color: fn.color(--disabled --circle-bg); } } } @@ -124,12 +128,12 @@ @include iro.bem-at-theme('keyboard') { &:focus { @include iro.bem-sibling-elem('label') { - color: iro.props-get(--colors --key-focus --label); + color: fn.color(--key-focus --label); } @include iro.bem-sibling-elem('circle') { - background-color: iro.props-get(--colors --key-focus --circle-border); - box-shadow: iro.props-get(--colors --key-focus --shadow); + background-color: fn.color(--key-focus --circle-border); + box-shadow: fn.color(--key-focus --shadow); } } } @@ -139,28 +143,28 @@ @include iro.bem-elem('native') { &:checked { @include iro.bem-sibling-elem('circle') { - background-color: iro.props-get(--colors --accent --circle-border); + background-color: fn.color(--accent --circle-border); } &:hover { @include iro.bem-sibling-elem('circle') { - background-color: iro.props-get(--colors --accent --hover --circle-border); + background-color: fn.color(--accent --hover --circle-border); } } } &:disabled { @include iro.bem-sibling-elem('circle') { - background-color: iro.props-get(--colors --disabled --circle-border); + background-color: fn.color(--disabled --circle-border); &::after { - background-color: iro.props-get(--colors --disabled --circle-bg); + background-color: fn.color(--disabled --circle-bg); } } &:checked { @include iro.bem-sibling-elem('circle') { - background-color: iro.props-get(--colors --disabled --circle-border); + background-color: fn.color(--disabled --circle-border); } } } -- cgit v1.2.3-54-g00ecf