From 6de1156129ed89e84d36c3b5ccd9f8cb799df790 Mon Sep 17 00:00:00 2001 From: Volpeon Date: Thu, 14 Nov 2024 18:10:54 +0100 Subject: Add tabs --- src/_iro-design.scss | 1 + src/objects/_tabs.scss | 90 +++++++++++++++++++++++++++++++++++++++++++++ src/objects/_tabs.vars.scss | 22 +++++++++++ src_demo/index.scss | 1 + 4 files changed, 114 insertions(+) create mode 100644 src/objects/_tabs.scss create mode 100644 src/objects/_tabs.vars.scss diff --git a/src/_iro-design.scss b/src/_iro-design.scss index 3132199..ac07846 100644 --- a/src/_iro-design.scss +++ b/src/_iro-design.scss @@ -63,6 +63,7 @@ $breakpoints: ( @forward 'objects/status-indicator' as o-status-indicator--*; @forward 'objects/switch' as o-switch--*; @forward 'objects/table' as o-table--*; +@forward 'objects/tabs' as o-tabs--*; @forward 'objects/text-field' as o-text-field--*; @forward 'objects/thumbnail' as o-thumbnail--*; diff --git a/src/objects/_tabs.scss b/src/objects/_tabs.scss new file mode 100644 index 0000000..25894d5 --- /dev/null +++ b/src/objects/_tabs.scss @@ -0,0 +1,90 @@ +@use 'sass:map'; +@use 'sass:meta'; +@use 'sass:string'; +@use 'iro-sass/src/bem'; +@use 'iro-sass/src/props'; +@use '../props' as *; + +@forward 'tabs.vars'; +@use 'tabs.vars' as vars; + +@mixin styles { + @include materialize-at-root(meta.module-variables('vars')); + + @include bem.object('tabs') { + display: flex; + gap: props.get(vars.$spacing); + + @include bem.elem('tab') { + position: relative; + display: flex; + align-items: center; + padding-inline: props.get(vars.$tab--pad-i); + margin-inline: calc(-1 * props.get(vars.$tab--pad-i)); + color: props.get(vars.$tab--text-color); + + &::before, + &::after { + position: absolute; + z-index: -10; + content: ''; + } + + &::before { + inset-block-start: 50%; + inset-inline: 0; + block-size: 1.5em; + border-radius: props.get(vars.$rounding); + transform: translateY(-50%); + } + + &::after { + inset-block-end: 0; + inset-inline: props.get(vars.$tab--pad-i); + display: none; + block-size: props.get(vars.$indicator--width); + background-color: props.get(vars.$tab--selected--text-color); + } + + &:link, + &:visited { + &:hover, + &:active, + &:focus-visible { + color: props.get(vars.$tab--selected--text-color); + } + + &:focus-visible { + &::before { + color: props.get(vars.$key-focus--text-color); + text-decoration: none; + outline: props.get(vars.$key-focus--border-color) solid props.get(vars.$key-focus--border-width); + box-shadow: 0 0 0 + calc(props.get(vars.$key-focus--border-width) + props.get(vars.$key-focus--outline-width)) + props.get(vars.$key-focus--outline-color); + } + } + } + + @include bem.is('selected') { + color: props.get(vars.$tab--selected--text-color); + + &::after { + display: block; + } + } + } + + @include bem.modifier('accent') { + @include bem.elem('tab') { + &::after { + background-color: props.get(vars.$tab--accent--text-color); + } + + @include bem.is('selected') { + color: props.get(vars.$tab--accent--text-color); + } + } + } + } +} diff --git a/src/objects/_tabs.vars.scss b/src/objects/_tabs.vars.scss new file mode 100644 index 0000000..620228a --- /dev/null +++ b/src/objects/_tabs.vars.scss @@ -0,0 +1,22 @@ +@use 'sass:map'; +@use 'sass:string'; +@use 'iro-sass/src/props'; +@use '../core.vars' as core; + +$rounding: props.def(--o-tabs--rounding, props.get(core.$rounding)) !default; +$spacing: props.def(--o-tabs--spacing, props.get(core.$size--400)) !default; +$tab--pad-i: props.def(--o-tabs--tab--pad-i, props.get(core.$size--50)) !default; + +$indicator--width: props.def(--o-tabs--indicator--width, props.get(core.$border-width--medium)) !default; + +$key-focus--border-width: props.def(--o-tabs--key-focus--border-width, props.get(core.$key-focus--border-width)) !default; +$key-focus--border-offset: props.def(--o-tabs--key-focus--border-offset, props.get(core.$key-focus--border-offset)) !default; +$key-focus--outline-width: props.def(--o-tabs--key-focus--outline-width, props.get(core.$key-focus--outline-width)) !default; + +$tab--text-color: props.def(--o-tabs--tab--text-color, props.get(core.$theme, --text-mute), 'color') !default; +$tab--selected--text-color: props.def(--o-tabs--tab--selected--text-color, props.get(core.$theme, --heading), 'color') !default; +$tab--accent--text-color: props.def(--o-tabs--tab--accent--text-color, props.get(core.$theme, --accent, --1100), 'color') !default; + +$key-focus--text-color: props.def(--o-tabs--key-focus--text-color, props.get(core.$theme, --focus, --text), 'color') !default; +$key-focus--border-color: props.def(--o-tabs--key-focus--border-color, props.get(core.$theme, --focus, --border), 'color') !default; +$key-focus--outline-color: props.def(--o-tabs--key-focus--outline-color, props.get(core.$theme, --focus, --outline), 'color') !default; diff --git a/src_demo/index.scss b/src_demo/index.scss index 1fdf290..4b345dd 100644 --- a/src_demo/index.scss +++ b/src_demo/index.scss @@ -41,6 +41,7 @@ @include iro.o-status-indicator--styles; @include iro.o-switch--styles; @include iro.o-table--styles; +@include iro.o-tabs--styles; @include iro.o-text-field--styles; @include iro.o-thumbnail--styles; -- cgit v1.2.3-70-g09d2