From 3b7e35551b499a7b8887adb068d3a80e4088b0c2 Mon Sep 17 00:00:00 2001 From: Volpeon Date: Sat, 5 Feb 2022 19:23:14 +0100 Subject: Added field-label --- src/objects/_field-label.scss | 85 +++++++++++++++++++++++++++++++++++++++++++ src/objects/_text-field.scss | 5 +-- 2 files changed, 87 insertions(+), 3 deletions(-) create mode 100644 src/objects/_field-label.scss (limited to 'src/objects') diff --git a/src/objects/_field-label.scss b/src/objects/_field-label.scss new file mode 100644 index 0000000..341bf49 --- /dev/null +++ b/src/objects/_field-label.scss @@ -0,0 +1,85 @@ +@use 'iro-sass/src/index' as iro; +@use '../vars'; +@use '../mixins/typography'; + +@include iro.props-namespace('field-label') { + @include iro.props-store(( + --dims: ( + --spacing-x: iro.props-get(--dims --spacing --x --sm, $global: true), + --spacing-y: iro.props-get(--dims --spacing --y --xs, $global: true), + --label-font-size: iro.props-get(--dims --font-size --sm, $global: true), + --hint-font-size: iro.props-get(--dims --font-size --sm, $global: true), + ), + --colors: ( + --label: iro.props-get(--colors --fg-hi, $global: true), + --hint: iro.props-get(--colors --fg, $global: true), + --error-hint: iro.props-get(--colors --accent --error, $global: true), + --disabled: iro.props-get(--colors --fg-hi3, $global: true), + ), + )); + + @include iro.bem-object(iro.props-namespace()) { + display: inline-block; + + @include iro.bem-elem('label') { + display: block; + padding-right: iro.props-get(--dims --spacing-x); + color: iro.props-get(--colors --label); + font-size: iro.props-get(--dims --label-font-size); + font-weight: 400; + line-height: 1.3; + + @include iro.bem-next-elem('content') { + margin-top: iro.props-get(--dims --spacing-y); + } + } + + @include iro.bem-elem('content') { + display: inline-block; + } + + @include iro.bem-elem('hint') { + display: block; + margin-top: iro.props-get(--dims --spacing-y); + color: iro.props-get(--colors --hint); + font-size: iro.props-get(--dims --hint-font-size); + } + + @include iro.bem-is('invalid') { + @include iro.bem-elem('hint') { + color: iro.props-get(--colors --error-hint); + } + } + + @include iro.bem-is('disabled') { + @include iro.bem-elem('label', 'hint') { + color: iro.props-get(--colors --disabled); + } + } + + @include iro.bem-modifier('left', 'right') { + display: inline-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/objects/_text-field.scss b/src/objects/_text-field.scss index f2c3678..ac48216 100644 --- a/src/objects/_text-field.scss +++ b/src/objects/_text-field.scss @@ -78,9 +78,8 @@ @include iro.bem-elem('input') { @include typography.set-font(vars.$font--main, (size: 1em, line-height: vars.$line-height)); - display: block; - color: iro.props-get(--colors --text); - resize: none; + color: iro.props-get(--colors --text); + resize: none; &::placeholder { opacity: 1; -- cgit v1.2.3-70-g09d2