From 3799950b0a869aee0e2725a8aafbb53c26723942 Mon Sep 17 00:00:00 2001 From: Volpeon Date: Sat, 19 Oct 2024 14:46:06 +0200 Subject: Update --- src/objects/_radio.scss | 118 ++++++++++++++++++------------------------------ 1 file changed, 43 insertions(+), 75 deletions(-) (limited to 'src/objects/_radio.scss') diff --git a/src/objects/_radio.scss b/src/objects/_radio.scss index ad3e8d4..c1182d0 100644 --- a/src/objects/_radio.scss +++ b/src/objects/_radio.scss @@ -1,88 +1,51 @@ +@use 'sass:meta'; @use 'iro-sass/src/iro-sass' as iro; -@use '../functions' as fn; +@use '../props'; +@use '../core.vars' as core; -@include iro.props-namespace('radio') { - @include iro.props-store(( - --dims: ( - --diameter: fn.global-dim(--size --200), - --label-gap: fn.global-dim(--size --125), - --border: fn.global-dim(--border --medium), - --pad-i: fn.global-dim(--size --65), - --pad-b: fn.global-dim(--size --65), - --rounding: fn.global-dim(--rounding), - --spacing-sibling: fn.global-dim(--size --300), +@forward 'radio.vars'; +@use 'radio.vars' as vars; - --key-focus: ( - --border: fn.global-dim(--key-focus --border), - --border-offset: fn.global-dim(--key-focus --border-offset), - --outline: fn.global-dim(--key-focus --outline), - ), - ), - --colors: ( - --circle-border: fn.global-color(--text-mute-more), - --circle-bg: fn.global-color(--base --75), - - --hover: ( - --label: fn.global-color(--heading), - --circle-border: fn.global-color(--text-mute), - ), - --accent: ( - --circle-border: fn.global-color(--accent --900), - - --hover: ( - --circle-border: fn.global-color(--accent --1000), - ), - ), - --disabled: ( - --label: fn.global-color(--text-disabled), - --circle-border: fn.global-color(--border-strong), - --circle-bg: fn.global-color(--base --75), - ), - --key-focus: ( - --label: fn.global-color(--focus --text), - --border: fn.global-color(--focus --border), - --outline: fn.global-color(--focus --outline), - ), - ), - )); +@mixin styles { + @include props.materialize(meta.module-variables('vars')); - @include iro.bem-object(iro.props-namespace()) { + @include iro.bem-object('radio') { position: relative; display: inline-block; - padding-block: fn.dim(--pad-b); - padding-inline: fn.dim(--pad-i); + padding-block: props.get(vars.$pad-b); + padding-inline: props.get(vars.$pad-i); margin-inline: - calc(-1 * fn.dim(--pad-i) - fn.dim(--key-focus --border-offset)) - calc(fn.dim(--spacing-sibling) - fn.dim(--pad-i) - fn.dim(--key-focus --border-offset)); + calc(-1 * props.get(vars.$pad-i) - props.get(vars.$key-focus--border-offset)) + calc(props.get(vars.$spacing-sibling) - props.get(vars.$pad-i) - props.get(vars.$key-focus--border-offset)); @include iro.bem-elem('circle') { display: inline-block; flex: 0 0 auto; - inline-size: fn.dim(--diameter); - block-size: fn.dim(--diameter); - margin-block-start: calc(.5em * fn.global-dim(--font --standard --line-height) - .5 * fn.dim(--diameter) - fn.dim(--key-focus --border-offset)); + inline-size: props.get(vars.$diameter); + block-size: props.get(vars.$diameter); + margin-block-start: calc(.5em * props.get(core.$font--standard--line-height) - .5 * props.get(vars.$diameter) - props.get(vars.$key-focus--border-offset)); vertical-align: top; - background-color: fn.color(--circle-border); + background-color: props.get(vars.$circle-border-color); background-clip: padding-box; - border: fn.dim(--key-focus --border-offset) solid transparent; + border: props.get(vars.$key-focus--border-offset) solid transparent; border-radius: 2em; &::after { position: relative; - inset-block-start: fn.dim(--border); - inset-inline-start: fn.dim(--border); + inset-block-start: props.get(vars.$border-width); + inset-inline-start: props.get(vars.$border-width); display: block; - inline-size: calc(fn.dim(--diameter) - 2 * fn.dim(--border)); - block-size: calc(fn.dim(--diameter) - 2 * fn.dim(--border)); + inline-size: calc(props.get(vars.$diameter) - 2 * props.get(vars.$border-width)); + block-size: calc(props.get(vars.$diameter) - 2 * props.get(vars.$border-width)); content: ''; - background-color: fn.color(--circle-bg); - border-radius: fn.dim(--diameter); + background-color: props.get(vars.$circle-bg-color); + border-radius: props.get(vars.$diameter); transition: transform .2s ease; } } @include iro.bem-elem('label') { - margin-inline-start: calc(fn.dim(--label-gap) - fn.dim(--key-focus --border-offset)); + margin-inline-start: calc(props.get(vars.$label-gap) - props.get(vars.$key-focus--border-offset)); } @include iro.bem-elem('native') { @@ -96,16 +59,16 @@ margin: 0; overflow: hidden; appearance: none; - border-radius: fn.dim(--rounding); + border-radius: props.get(vars.$rounding); &:hover, &:focus-visible { @include iro.bem-sibling-elem('label') { - color: fn.color(--hover --label); + color: props.get(vars.$hover--label-color); } @include iro.bem-sibling-elem('circle') { - background-color: fn.color(--hover --circle-border); + background-color: props.get(vars.$hover--circle-border-color); } } @@ -119,26 +82,31 @@ &:disabled { @include iro.bem-sibling-elem('label') { - color: fn.color(--disabled --label); + color: props.get(vars.$disabled--label-color); } @include iro.bem-sibling-elem('circle') { - background-color: fn.color(--disabled --circle-border); + background-color: props.get(vars.$disabled--circle-border-color); &::after { - background-color: fn.color(--disabled --circle-bg); + background-color: props.get(vars.$disabled--circle-bg-color); } } } &:focus-visible { @include iro.bem-sibling-elem('label') { - color: fn.color(--key-focus --label); + color: props.get(vars.$key-focus--label-color); } @include iro.bem-sibling-elem('circle') { - outline: fn.color(--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(--key-focus --outline); + outline: props.get(vars.$key-focus--border-color) solid props.get(vars.$key-focus--border-width); + box-shadow: + 0 + 0 + 0 + calc(props.get(vars.$key-focus--border-width) + props.get(vars.$key-focus--outline-width)) + props.get(vars.$key-focus--outline-color); } } } @@ -153,29 +121,29 @@ @include iro.bem-elem('native') { &:checked { @include iro.bem-sibling-elem('circle') { - background-color: fn.color(--accent --circle-border); + background-color: props.get(vars.$accent--circle-border-color); } &:hover, &:focus-visible { @include iro.bem-sibling-elem('circle') { - background-color: fn.color(--accent --hover --circle-border); + background-color: props.get(vars.$accent--hover--circle-border-color); } } } &:disabled { @include iro.bem-sibling-elem('circle') { - background-color: fn.color(--disabled --circle-border); + background-color: props.get(vars.$disabled--circle-border-color); &::after { - background-color: fn.color(--disabled --circle-bg); + background-color: props.get(vars.$disabled--circle-bg-color); } } &:checked { @include iro.bem-sibling-elem('circle') { - background-color: fn.color(--disabled --circle-border); + background-color: props.get(vars.$disabled--circle-border-color); } } } -- cgit v1.2.3-70-g09d2