@use 'iro-sass/src/index' as iro; @use '../functions' as fn; @include iro.props-namespace('checkbox') { @include iro.props-store(( --dims: ( --size: iro.fn-px-to-rem(14px), --label-gap: iro.fn-px-to-rem(10px), --border-width: fn.global-dim(--border-width --medium), --pad-x: iro.fn-px-to-rem(5px), --pad-y: iro.fn-px-to-rem(5px), --margin-right: fn.global-dim(--spacing --x --md), ), ), 'dims'); @include iro.props-store(( --colors: ( --box-border: fn.global-color(--fg-hi), --box-bg: fn.global-color(--bg-hi), --hover: ( --label: fn.global-color(--fg-lo), --box-border: fn.global-color(--fg), ), --accent: ( --box-border: fn.global-color(--accent --primary --main), --hover: ( --box-border: fn.global-color(--accent --primary --lo), ), ), --key-focus: ( --label: fn.global-color(--focus --text), --box-border: fn.global-color(--focus --fill), --shadow: fn.global-color(--focus --shadow), ), --disabled: ( --label: fn.global-color(--fg-hi3), --box-border: fn.global-color(--obj-lo), --box-bg: fn.global-color(--bg-hi), ) ), ), 'colors'); @include iro.bem-object(iro.props-namespace()) { display: inline-flex; position: relative; align-items: flex-start; margin-right: calc(-1 * fn.dim(--pad-x) + fn.dim(--margin-right)); margin-left: calc(-1 * fn.dim(--pad-x)); padding: fn.dim(--pad-y) fn.dim(--pad-x); @include iro.bem-elem('box') { display: block; position: relative; flex: 0 0 auto; width: fn.dim(--size); height: fn.dim(--size); margin-top: calc(.5 * (fn.global-dim(--font --standard --line-height) * 1em - fn.dim(--size))); border-radius: fn.dim(--border-width); background-color: fn.color(--box-border); &::before, &::after { content: ''; display: block; position: absolute; } &::before { z-index: 2; top: fn.dim(--border-width); left: fn.dim(--border-width); width: calc(fn.dim(--size) - 2 * fn.dim(--border-width)); height: calc(fn.dim(--size) - 2 * fn.dim(--border-width)); transition: transform .2s ease; background-color: fn.color(--box-bg); } &::after { z-index: 3; top: calc(.5 * fn.dim(--size) - 1px); left: calc(1.5 * fn.dim(--border-width)); box-sizing: border-box; width: calc(fn.dim(--size) - 3 * fn.dim(--border-width)); height: 0; transform: scale(0); transition: transform .2s ease; border-width: 0 2px 2px 0; border-style: solid; border-radius: 2px; border-color: fn.color(--box-bg); } } @include iro.bem-elem('check-icon') { display: block; position: absolute; z-index: 2; top: calc(1 * fn.dim(--border-width)); left: calc(1 * fn.dim(--border-width)); width: calc(100% - 2 * fn.dim(--border-width)); height: calc(100% - 2 * fn.dim(--border-width)); transform: scale(0); transform-origin: 40% 90%; transition: transform .2s ease; stroke-width: iro.fn-px-to-rem(3px); color: fn.color(--box-bg); } @include iro.bem-elem('label') { align-self: baseline; margin-left: fn.dim(--label-gap); } @include iro.bem-elem('native') { position: absolute; top: 0; left: 0; width: 100%; height: 100%; margin: 0; padding: 0; overflow: hidden; opacity: .0001; &:hover { @include iro.bem-sibling-elem('label') { color: fn.color(--hover --label); } @include iro.bem-sibling-elem('box') { background-color: fn.color(--hover --box-border); } } &:checked { @include iro.bem-sibling-elem('box') { &::before { transform: scale(0); } @include iro.bem-elem('check-icon') { transform: scale(1); } } } &:indeterminate { @include iro.bem-sibling-elem('box') { &::before { transform: scale(0); } &::after { transform: scale(1); } @include iro.bem-elem('check-icon') { transform: scale(0); } } } &:disabled { @include iro.bem-sibling-elem('label') { color: fn.color(--disabled --label); } @include iro.bem-sibling-elem('box') { background-color: fn.color(--disabled --box-border); &::before { background-color: fn.color(--disabled --box-bg); } } } @include iro.bem-at-theme('keyboard') { &:focus { @include iro.bem-sibling-elem('label') { color: fn.color(--key-focus --label); } @include iro.bem-sibling-elem('box') { background-color: fn.color(--key-focus --box-border); box-shadow: fn.color(--key-focus --shadow); } } } } @include iro.bem-modifier('accent') { @include iro.bem-elem('native') { &:checked { @include iro.bem-sibling-elem('box') { background-color: fn.color(--accent --box-border); } &:hover { @include iro.bem-sibling-elem('box') { background-color: fn.color(--accent --hover --box-border); } } } &:indeterminate { @include iro.bem-sibling-elem('box') { background-color: fn.color(--accent --box-border); } &:hover { @include iro.bem-sibling-elem('box') { background-color: fn.color(--accent --hover --box-border); } } } &:disabled { @include iro.bem-sibling-elem('box') { background-color: fn.color(--disabled --box-border); &::before { background-color: fn.color(--disabled --box-bg); } } &:checked { @include iro.bem-sibling-elem('box') { background-color: fn.color(--disabled --box-border); } } &:indeterminate { @include iro.bem-sibling-elem('box') { background-color: fn.color(--disabled --box-border); } } } } } } }