From 69d753931c098bc18cd23e96af18f736a772f416 Mon Sep 17 00:00:00 2001 From: Volpeon Date: Sat, 22 Jun 2024 23:00:16 +0200 Subject: Update --- src/objects/_badge.scss | 8 +- src/objects/_button.scss | 30 ++++-- src/objects/_field-label.scss | 86 +++++++++++++++++ src/objects/_text-field.scss | 209 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 323 insertions(+), 10 deletions(-) create mode 100644 src/objects/_field-label.scss create mode 100644 src/objects/_text-field.scss (limited to 'src/objects') diff --git a/src/objects/_badge.scss b/src/objects/_badge.scss index 0d95751..23ae305 100644 --- a/src/objects/_badge.scss +++ b/src/objects/_badge.scss @@ -12,19 +12,19 @@ $themes: accent positive negative warning; --rounding: fn.global-dim(--rounding), --font-size: fn.global-dim(--font-size --100), - --50: ( + --sm: ( --pad-b: fn.global-dim(--size --50), --pad-i: fn.global-dim(--size --115), --pad-i-pill: fn.global-dim(--size --150), --font-size: fn.global-dim(--font-size --75), ), - --200: ( + --lg: ( --pad-b: fn.global-dim(--size --125), --pad-i: fn.global-dim(--size --175), --pad-i-pill: fn.global-dim(--size --225), --font-size: fn.global-dim(--font-size --150), ), - --300: ( + --xl: ( --pad-b: fn.global-dim(--size --160), --pad-i: fn.global-dim(--size --225), --pad-i-pill: fn.global-dim(--size --300), @@ -179,7 +179,7 @@ $themes: accent positive negative warning; border-radius: 10em; } - @each $size in '50' '200' '300' { + @each $size in sm lg xl { @include iro.bem-modifier($size) { padding-block: fn.dim(--#{$size} --pad-b); padding-inline: fn.dim(--#{$size} --pad-i); diff --git a/src/objects/_button.scss b/src/objects/_button.scss index d3588f6..a823f17 100644 --- a/src/objects/_button.scss +++ b/src/objects/_button.scss @@ -47,11 +47,24 @@ $themes: primary accent positive negative warning; --line-height: 1.4, --pad-i: fn.global-dim(--size --225), --pad-b: fn.global-dim(--size --65), + --border: fn.global-dim(--border --medium), --rounding: 10em, + --font-size: fn.global-dim(--font-size --100), + --sm: ( + --pad-i: fn.global-dim(--size --150), + --pad-b: fn.global-dim(--size --25), + --font-size: fn.global-dim(--font-size --75), + ), --lg: ( - --pad-i: fn.global-dim(--size --300), - --pad-b: fn.global-dim(--size --100), + --pad-i: fn.global-dim(--size --300), + --pad-b: fn.global-dim(--size --100), + --font-size: fn.global-dim(--font-size --150), + ), + --xl: ( + --pad-i: fn.global-dim(--size --400), + --pad-b: fn.global-dim(--size --150), + --font-size: fn.global-dim(--font-size --200), ), ), --colors: ( @@ -121,11 +134,12 @@ $themes: primary accent positive negative warning; display: inline-block; padding-block: fn.dim(--pad-b); padding-inline: fn.dim(--pad-i); - border: 2px solid transparent; + border: fn.dim(--border) solid transparent; border-radius: fn.dim(--rounding); border-color: fn.color(--disabled --bg); background-color: fn.color(--disabled --bg); color: fn.color(--disabled --label); + font-size: fn.dim(--font-size); font-weight: 500; line-height: fn.dim(--line-height); text-align: center; @@ -141,9 +155,12 @@ $themes: primary accent positive negative warning; box-shadow: none; } - @include iro.bem-modifier('lg') { - padding-block: fn.dim(--lg --pad-b); - padding-inline: fn.dim(--lg --pad-i); + @each $size in sm lg xl { + @include iro.bem-modifier($size) { + padding-block: fn.dim(--#{$size} --pad-b); + padding-inline: fn.dim(--#{$size} --pad-i); + font-size: fn.dim(--#{$size} --font-size); + } } @include button-variant(); @@ -160,6 +177,7 @@ $themes: primary accent positive negative warning; &:focus-visible { border-color: fn.color(--key-focus --border); background-color: fn.color(--key-focus --bg); + box-shadow: 0 0 0 calc(fn.global-dim(--border --thick) - fn.dim(--border)) fn.color(--key-focus --border); color: fn.color(--key-focus --label); } } diff --git a/src/objects/_field-label.scss b/src/objects/_field-label.scss new file mode 100644 index 0000000..9f267cb --- /dev/null +++ b/src/objects/_field-label.scss @@ -0,0 +1,86 @@ +@use 'iro-sass/src/index' as iro; +@use '../functions' as fn; + +@include iro.props-namespace('field-label') { + @include iro.props-store(( + --dims: ( + --spacing-i: fn.global-dim(--size --150), + --spacing-b: fn.global-dim(--size --85), + --label-font-size: fn.global-dim(--font-size --75), + --hint-font-size: fn.global-dim(--font-size --75), + ), + --colors: ( + --label: fn.global-color(--text-mute), + --hint: fn.global-color(--text-mute), + --error-hint: fn.global-color(--negative --900), + --disabled: fn.global-color(--text-disabled), + ), + )); + + @include iro.bem-object(iro.props-namespace()) { + display: block; + + @include iro.bem-elem('label') { + display: block; + flex: 0 0 auto; + padding-inline-end: fn.dim(--spacing-i); + color: fn.color(--label); + font-size: fn.dim(--label-font-size); + font-weight: 400; + line-height: 1.3; + + @include iro.bem-next-elem('content') { + margin-block-start: fn.dim(--spacing-b); + } + } + + @include iro.bem-elem('content') { + display: block; + inline-size: 100%; + } + + @include iro.bem-elem('hint') { + display: block; + margin-block-start: fn.dim(--spacing-b); + color: fn.color(--hint); + font-size: fn.dim(--hint-font-size); + } + + @include iro.bem-is('invalid') { + @include iro.bem-elem('hint') { + color: fn.color(--error-hint); + } + } + + @include iro.bem-is('disabled') { + @include iro.bem-elem('label', 'hint') { + color: fn.color(--disabled); + } + } + + @include iro.bem-modifier('align-start', 'align-end') { + display: flex; + align-items: baseline; + + @include iro.bem-elem('label') { + display: inline-block; + + @include iro.bem-next-elem('content') { + margin-block-start: 0; + } + } + } + + @include iro.bem-modifier('align-start') { + @include iro.bem-elem('label') { + text-align: start; + } + } + + @include iro.bem-modifier('align-end') { + @include iro.bem-elem('label') { + text-align: end; + } + } + } +} diff --git a/src/objects/_text-field.scss b/src/objects/_text-field.scss new file mode 100644 index 0000000..de5bcd1 --- /dev/null +++ b/src/objects/_text-field.scss @@ -0,0 +1,209 @@ +@use 'iro-sass/src/index' as iro; +@use '../functions' as fn; + +@mixin invalid { + $focus-border-offset: calc(fn.dim(--border) - fn.dim(--focus --border)); + + @include iro.bem-sibling-elem('bg') { + inset-block: $focus-border-offset; + inset-inline: $focus-border-offset; + border: fn.dim(--focus --border) solid fn.color(--error --border); + border-radius: calc(fn.dim(--rounding) - $focus-border-offset); + } + + &:hover { + @include iro.bem-sibling-elem('bg') { + border-color: fn.color(--error --hover --border); + } + } + + &:focus { + @include iro.bem-sibling-elem('bg') { + border-color: fn.color(--error --focus --border); + } + } +} + +@mixin keyboard-focus { + @include iro.bem-sibling-elem('bg') { + border: fn.dim(--key-focus --border) solid fn.color(--key-focus --border); + } +} + +@include iro.props-namespace('text-field') { + @include iro.props-store(( + --dims: ( + --line-height: 1.4, + --pad-i: fn.global-dim(--size --125), + --pad-b: fn.global-dim(--size --125), + --border: fn.global-dim(--border --thin), + --rounding: fn.global-dim(--rounding), + + --extended: ( + --pad: fn.global-dim(--size --50), + ), + + --focus: ( + --border: fn.global-dim(--border --medium), + ), + --key-focus: ( + --border: fn.global-dim(--border --thick), + ) + ), + --colors: ( + --bg: fn.global-color(--base --50), + --placeholder: fn.global-color(--text-mute-more), + --text: fn.global-color(--text), + --border: fn.global-color(--border-strong), + + --hover: ( + --border: fn.global-color(--text-mute-more), + ), + --focus: ( + --border: fn.global-color(--accent --900), + ), + --key-focus: ( + --border: fn.global-color(--yellow-static --400), + ), + --error: ( + --border: fn.global-color(--negative --900), + + --hover: ( + --border: fn.global-color(--negative --800), + ), + --focus: ( + --border: fn.global-color(--negative --800), + ), + ), + --disabled: ( + --bg: fn.global-color(--border-mute), + --placeholder: fn.global-color(--text-disabled), + --text: fn.global-color(--text-disabled), + --border: fn.global-color(--border-mute), + ), + ), + )); + + @include iro.bem-object(iro.props-namespace()) { + $focus-border-offset: calc(fn.dim(--border) - fn.dim(--focus --border)); + + position: relative; + min-inline-size: 0; + border-radius: fn.dim(--rounding); + background-color: fn.color(--bg); + + @include iro.bem-elem('bg') { + display: block; + position: absolute; + inset-block: 0; + inset-inline: 0; + border: fn.dim(--border) solid fn.color(--border); + border-radius: fn.dim(--rounding); + pointer-events: none; + } + + @include iro.bem-elem('native') { + box-sizing: border-box; + inline-size: 100%; + padding-block: calc(fn.dim(--pad-b) - .5em * (fn.dim(--line-height) - 1)); + padding-inline: fn.dim(--pad-i); + border: 1px solid transparent; + background-color: transparent; + color: fn.color(--text); + font: inherit; + line-height: fn.dim(--line-height); + resize: none; + appearance: none; + + &::placeholder { + opacity: 1; + color: fn.color(--placeholder); + font-style: italic; + } + + &:hover { + @include iro.bem-sibling-elem('bg') { + border-color: fn.color(--hover --border); + } + } + + &:focus { + outline: 0; + + @include iro.bem-sibling-elem('bg') { + inset-block: $focus-border-offset; + inset-inline: $focus-border-offset; + border: fn.dim(--focus --border) solid fn.color(--focus --border); + border-radius: calc(fn.dim(--rounding) - $focus-border-offset); + } + } + + &:invalid { + @include invalid; + } + + &:focus-visible, + &:invalid:focus-visible { + @include keyboard-focus; + } + } + + @include iro.bem-modifier('extended') { + padding: fn.dim(--extended --pad); + + @include iro.bem-multi('&', 'elem' 'bg') { + border-radius: calc(fn.dim(--rounding) + fn.dim(--extended --pad)); + } + + @include iro.bem-elem('native') { + &:focus { + @include iro.bem-sibling-elem('bg') { + border-radius: calc(fn.dim(--rounding) + fn.dim(--extended --pad) - $focus-border-offset); + } + } + } + } + + @include iro.bem-is('invalid') { + @include iro.bem-elem('native') { + @include invalid; + + &:focus-visible { + @include keyboard-focus; + } + } + } + + @include iro.bem-is('disabled') { + background-color: fn.color(--disabled --bg); + + @include iro.bem-elem('native') { + color: fn.color(--disabled --text); + + &::placeholder { + color: fn.color(--disabled --placeholder); + } + } + + @include iro.bem-elem('bg') { + border-color: fn.color(--disabled --border); + } + + @include iro.bem-is('invalid') { + @include iro.bem-elem('native') { + @include iro.bem-sibling-elem('bg') { + border-color: fn.color(--disabled --border); + } + } + } + + @include iro.bem-elem('native') { + &:invalid { + @include iro.bem-sibling-elem('bg') { + border-color: fn.color(--disabled --border); + } + } + } + } + } +} -- cgit v1.2.3-70-g09d2