@use 'sass:list'; @use 'sass:map'; @use 'sass:meta'; @use 'sass:string'; @use 'iro-sass/src/iro-sass' as iro; @use '../props'; @use '../core.vars' as core; @forward 'button.vars'; @use 'button.vars' as vars; @mixin -apply-theme($theme, $key: ()) { &:link, &:visited, &:enabled { color: props.get($theme, list.join($key, --label)...); background-color: props.get($theme, list.join($key, --bg)...); border-color: transparent; } @include iro.bem-modifier('outline') { &:link, &:visited, &:enabled { color: props.get($theme, list.join($key, --outline-label)); background-color: transparent; border-color: props.get($theme, list.join($key, --outline-border)); } } &:link, &:visited, &:enabled { &:hover, &:focus-visible { color: props.get($theme, list.join($key, --hover --label)); background-color: props.get($theme, list.join($key, --hover --bg)); border-color: transparent; } &:active { color: props.get($theme, list.join($key, --active --label)); background-color: props.get($theme, list.join($key, --active --bg)); border-color: transparent; } } } @mixin -apply-static-theme($theme, $key: ()) { color: props.get($theme, list.join($key, --disabled --label)); background-color: props.get($theme, list.join($key, --disabled --bg)); border-color: transparent; &::after { outline: props.get($theme, list.join($key, --key-focus --border)) 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($theme, list.join($key, --key-focus --outline)); } @include iro.bem-modifier('outline') { background-color: transparent; border-color: props.get($theme, list.join($key, --disabled --outline-border)); } @include -apply-theme($theme, $key); @include iro.bem-modifier('primary') { @include -apply-theme($theme, list.join($key, --primary)); } } @mixin styles { @include props.materialize(meta.module-variables('vars')); @include iro.bem-object('button') { position: relative; display: inline-block; padding-block: props.get(vars.$pad-b); padding-inline: props.get(vars.$pad-i); font-size: props.get(vars.$font-size); font-weight: 500; line-height: props.get(vars.$line-height); text-align: center; text-decoration: none; border: props.get(vars.$border-width) solid transparent; border-radius: props.get(vars.$rounding); &::after { position: absolute; inset: calc(-1 * props.get(vars.$border-width) - props.get(vars.$key-focus--border-offset)); z-index: 1; display: none; pointer-events: none; content: ''; border-radius: calc(props.get(vars.$rounding) + props.get(vars.$key-focus--border-offset)); outline: transparent solid props.get(vars.$key-focus--border-width); } &:link, &:visited, &:enabled { &:focus-visible { &::after { display: block; } } } @include iro.bem-elem('label') { margin-inline: props.get(vars.$pad-i-label); } @include iro.bem-modifier('block') { display: block; } @include iro.bem-modifier('outline') { background-color: transparent; } @each $mod, $pad-i, $pad-i-label, $pad-b, $font-size in vars.$sizes { @include iro.bem-modifier($mod) { padding-block: props.get($pad-b); padding-inline: props.get($pad-i); font-size: props.get($font-size); @include iro.bem-elem('label') { margin-inline: props.get($pad-i-label); } } } @include -apply-static-theme(vars.$default-theme); @each $theme in map.keys(props.get(vars.$themes)) { @include iro.bem-modifier(string.slice($theme, 3)) { @include -apply-theme(vars.$themes, $theme); } } @each $theme in map.keys(props.get(vars.$static-themes)) { @include iro.bem-modifier(string.slice($theme, 3)) { @include -apply-static-theme(vars.$static-themes, $theme); } } @include iro.bem-modifier('round') { inline-size: calc(1em * props.get(vars.$line-height) + 2 * props.get(vars.$pad-b)); padding-inline: 0; border-radius: 100em; } } }