From 4de75e0f305b2cb4a026073440f2bac7c34df817 Mon Sep 17 00:00:00 2001 From: Volpeon Date: Tue, 25 Jun 2024 17:39:03 +0200 Subject: Focus indicator style --- src/objects/_radio.scss | 62 ++++++++++++++++++++++++------------------------- 1 file changed, 30 insertions(+), 32 deletions(-) (limited to 'src/objects/_radio.scss') diff --git a/src/objects/_radio.scss b/src/objects/_radio.scss index 12dc6ca..7ade7e1 100644 --- a/src/objects/_radio.scss +++ b/src/objects/_radio.scss @@ -11,14 +11,20 @@ --pad-b: fn.global-dim(--size --65), --rounding: fn.global-dim(--rounding), --spacing-sibling: fn.global-dim(--size --300), + + --key-focus: ( + --border: fn.global-dim(--key-focus --border), + --border-offset: fn.global-dim(--key-focus --border-offset), + --outline: fn.global-dim(--key-focus --border), + ), ), --colors: ( - --circle-border: fn.global-color(--text-mute), + --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), + --circle-border: fn.global-color(--text-mute), ), --accent: ( --circle-border: fn.global-color(--accent --900), @@ -27,37 +33,39 @@ --circle-border: fn.global-color(--accent --1000), ), ), - --key-focus: ( - --bg: fn.global-color(--focus-static --400), - --label: fn.global-color(--focus-static --400-text), - --circle-border: fn.global-color(--focus-static --1000), - --circle-bg: fn.global-color(--focus-static --1000-text), - ), --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), + ), ), )); @include iro.bem-object(iro.props-namespace()) { - display: inline-flex; + display: inline-block; position: relative; - align-items: flex-start; - margin-inline: calc(-1 * fn.dim(--pad-i)) calc(fn.dim(--spacing-sibling) - fn.dim(--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)); padding-block: fn.dim(--pad-b); padding-inline: fn.dim(--pad-i); @include iro.bem-elem('circle') { - display: block; - box-sizing: border-box; + display: inline-block; flex: 0 0 auto; inline-size: fn.dim(--diameter); block-size: fn.dim(--diameter); - margin-block-start: calc(.5 * (fn.global-dim(--font --standard --line-height) * 1em - 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)); + border: fn.dim(--key-focus --border-offset) solid transparent; border-radius: 2em; background-color: fn.color(--circle-border); + background-clip: padding-box; + vertical-align: top; &::after { content: ''; @@ -74,8 +82,7 @@ } @include iro.bem-elem('label') { - align-self: baseline; - margin-inline-start: fn.dim(--label-gap); + margin-inline-start: calc(fn.dim(--label-gap) - fn.dim(--key-focus --border-offset)); } @include iro.bem-elem('native') { @@ -91,7 +98,8 @@ overflow: hidden; border-radius: fn.dim(--rounding); - &:hover { + &:hover, + &:focus-visible { @include iro.bem-sibling-elem('label') { color: fn.color(--hover --label); } @@ -124,18 +132,13 @@ } &:focus-visible { - background-color: fn.color(--key-focus --bg); - @include iro.bem-sibling-elem('label') { color: fn.color(--key-focus --label); } @include iro.bem-sibling-elem('circle') { - background-color: fn.color(--key-focus --circle-border); - - &::after { - background-color: fn.color(--key-focus --circle-bg); - } + 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); } } } @@ -153,7 +156,8 @@ background-color: fn.color(--accent --circle-border); } - &:hover { + &:hover, + &:focus-visible { @include iro.bem-sibling-elem('circle') { background-color: fn.color(--accent --hover --circle-border); } @@ -175,12 +179,6 @@ } } } - - &:focus-visible { - @include iro.bem-sibling-elem('circle') { - background-color: fn.color(--key-focus --circle-border); - } - } } } } -- cgit v1.2.3-70-g09d2