From 69d753931c098bc18cd23e96af18f736a772f416 Mon Sep 17 00:00:00 2001 From: Volpeon Date: Sat, 22 Jun 2024 23:00:16 +0200 Subject: Update --- src/.old/objects/_field-label.scss | 89 -------------- src/.old/objects/_text-field.scss | 232 ------------------------------------- src/_objects.scss | 4 +- src/objects/_badge.scss | 8 +- src/objects/_button.scss | 30 ++++- src/objects/_field-label.scss | 86 ++++++++++++++ src/objects/_text-field.scss | 209 +++++++++++++++++++++++++++++++++ 7 files changed, 325 insertions(+), 333 deletions(-) delete mode 100644 src/.old/objects/_field-label.scss delete mode 100644 src/.old/objects/_text-field.scss create mode 100644 src/objects/_field-label.scss create mode 100644 src/objects/_text-field.scss (limited to 'src') diff --git a/src/.old/objects/_field-label.scss b/src/.old/objects/_field-label.scss deleted file mode 100644 index 2127a09..0000000 --- a/src/.old/objects/_field-label.scss +++ /dev/null @@ -1,89 +0,0 @@ -@use 'iro-sass/src/index' as iro; -@use '../functions' as fn; - -@include iro.props-namespace('field-label') { - @include iro.props-store(( - --dims: ( - --spacing-x: fn.global-dim(--size --150), - --spacing-y: fn.global-dim(--size --85), - --label-font-size: fn.global-dim(--font-size --75), - --hint-font-size: fn.global-dim(--font-size --75), - ), - ), 'dims'); - - @include iro.props-store(( - --colors: ( - --label: fn.global-color(--fg-hi), - --hint: fn.global-color(--fg-hi), - --error-hint: fn.global-color(--accent --error --quiet --fg), - --disabled: fn.global-color(--fg-hi3), - ), - ), 'colors'); - - @include iro.bem-object(iro.props-namespace()) { - display: block; - - @include iro.bem-elem('label') { - display: block; - flex: 0 0 auto; - padding-right: fn.dim(--spacing-x); - 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-top: fn.dim(--spacing-y); - } - } - - @include iro.bem-elem('content') { - display: block; - width: 100%; - } - - @include iro.bem-elem('hint') { - display: block; - margin-top: fn.dim(--spacing-y); - 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('left', 'right') { - display: flex; - align-items: baseline; - - @include iro.bem-elem('label') { - display: inline-block; - - @include iro.bem-next-elem('content') { - margin-top: 0; - } - } - } - - @include iro.bem-modifier('left') { - @include iro.bem-elem('label') { - text-align: left; - } - } - - @include iro.bem-modifier('right') { - @include iro.bem-elem('label') { - text-align: right; - } - } - } -} diff --git a/src/.old/objects/_text-field.scss b/src/.old/objects/_text-field.scss deleted file mode 100644 index 88c4535..0000000 --- a/src/.old/objects/_text-field.scss +++ /dev/null @@ -1,232 +0,0 @@ -@use 'iro-sass/src/index' as iro; -@use '../functions' as fn; - -@mixin invalid { - @include iro.bem-sibling-elem('bg') { - border-color: fn.color(--error --border); - box-shadow: fn.color(--error --shadow); - } - - &:hover { - @include iro.bem-sibling-elem('bg') { - border-color: fn.color(--error --hover --border); - box-shadow: fn.color(--error --hover --shadow); - } - } - - &:focus { - @include iro.bem-sibling-elem('bg') { - border-color: fn.color(--error --focus --border); - box-shadow: fn.color(--error --focus --shadow); - } - } -} - -@mixin keyboard-focus { - @include iro.bem-sibling-elem('bg') { - border-color: fn.color(--key-focus --border); - box-shadow: fn.color(--key-focus --shadow); - } -} - -@include iro.props-namespace('text-field') { - @include iro.props-store(( - --dims: ( - --pad-x: fn.global-dim(--size --125), - --pad-y: fn.global-dim(--size --125), - --border: fn.global-dim(--border --thin), - --rounding: 2px, - - --extended: ( - --pad: fn.global-dim(--size --50), - --rounding: 6px, - ), - - --focus: ( - --border: fn.global-dim(--border --medium), - ) - ), - ), 'dims'); - - @include iro.props-store(( - --colors: ( - --bg: fn.global-color(--bg-hi2), - --placeholder: fn.global-color(--fg-hi2), - --text: fn.global-color(--fg), - --border: fn.global-color(--obj-lo), - --shadow: 0 0 0 0 transparent, - - --hover: ( - --border: fn.global-color(--fg-hi2), - --shadow: 0 0 0 0 transparent, - ), - --focus: ( - --border: fn.global-color(--accent --primary --solid --bg), - --shadow: 0 0 0 0 transparent, - ), - --key-focus: ( - --border: fn.global-color(--focus --fill), - --shadow: fn.global-color(--focus --shadow), - ), - --error: ( - --border: fn.global-color(--accent --error --solid --bg-hi), - --shadow: 0 0 0 0 transparent, - - --hover: ( - --border: fn.global-color(--accent --error --solid --bg), - --shadow: 0 0 0 0 transparent, - ), - --focus: ( - --border: fn.global-color(--accent --error --solid --bg), - --shadow: 0 0 0 0 transparent, - ), - ), - --disabled: ( - --bg: fn.global-color(--obj-hi), - --placeholder: fn.global-color(--fg-hi3), - --text: fn.global-color(--fg-hi3), - --border: fn.global-color(--obj-hi), - --shadow: 0 0 0 0 transparent, - ), - ), - ), 'colors'); - - @include iro.bem-object(iro.props-namespace()) { - $line-height: 1.4; - $focus-border-offset: calc(fn.dim(--border) - fn.dim(--focus --border)); - - position: relative; - min-width: 0; - border-radius: fn.dim(--rounding); - background-color: fn.color(--bg); - - @include iro.bem-elem('bg') { - display: block; - position: absolute; - top: 0; - right: 0; - bottom: 0; - left: 0; - border: fn.dim(--border) solid fn.color(--border); - border-radius: fn.dim(--rounding); - box-shadow: fn.color(--shadow); - pointer-events: none; - } - - @include iro.bem-elem('native') { - box-sizing: border-box; - width: 100%; - padding: calc(fn.dim(--pad-y) - .5em * ($line-height - 1)) fn.dim(--pad-x); - border: 1px solid transparent; - background-color: transparent; - color: fn.color(--text); - font: inherit; - line-height: $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); - box-shadow: fn.color(--hover --shadow); - } - } - - &:focus { - outline: 0; - - @include iro.bem-sibling-elem('bg') { - top: $focus-border-offset; - right: $focus-border-offset; - bottom: $focus-border-offset; - left: $focus-border-offset; - border: fn.dim(--focus --border) solid fn.color(--focus --border); - border-radius: calc(fn.dim(--rounding) - $focus-border-offset); - box-shadow: fn.color(--focus --shadow); - } - } - - &:invalid { - @include invalid; - } - } - - @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(--extended --rounding) - $focus-border-offset); - } - } - } - } - - @include iro.bem-is('invalid') { - @include iro.bem-elem('native') { - @include invalid; - } - } - - @include iro.bem-at-theme('keyboard') { - @include iro.bem-elem('native') { - &:focus, - &:invalid:focus { - @include keyboard-focus; - } - } - - @include iro.bem-is('invalid') { - @include iro.bem-elem('native') { - &:focus { - @include keyboard-focus; - } - } - } - } - - @include iro.bem-is('disabled') { - background-color: fn.color(--disabled --bg); - box-shadow: fn.color(--disabled --shadow); - - @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); - } - } - } - } - } -} diff --git a/src/_objects.scss b/src/_objects.scss index 68bf3a7..3dd5176 100644 --- a/src/_objects.scss +++ b/src/_objects.scss @@ -4,8 +4,8 @@ @use 'objects/divider'; @use 'objects/badge'; @use 'objects/button'; -// @use 'objects/text-field'; -// @use 'objects/field-label'; +@use 'objects/text-field'; +@use 'objects/field-label'; // @use 'objects/radio'; // @use 'objects/checkbox'; // @use 'objects/switch'; 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