From 6b0fcac695aa7a5517f6f53cec50da493acc4582 Mon Sep 17 00:00:00 2001 From: Volpeon Date: Sat, 22 Jun 2024 19:30:00 +0200 Subject: Update --- src/objects/_badge.scss | 194 ++++++++++++++++++++++++++++++++++++++++++++++ src/objects/_button.scss | 173 +++++++++++++++++++++++++++++++++++++++++ src/objects/_divider.scss | 16 ++-- src/objects/_emoji.scss | 73 +++++++++++++++++ src/objects/_icon.scss | 26 +++++++ src/objects/_palette.scss | 22 +++++- 6 files changed, 494 insertions(+), 10 deletions(-) create mode 100644 src/objects/_badge.scss create mode 100644 src/objects/_button.scss create mode 100644 src/objects/_emoji.scss create mode 100644 src/objects/_icon.scss (limited to 'src/objects') diff --git a/src/objects/_badge.scss b/src/objects/_badge.scss new file mode 100644 index 0000000..0d95751 --- /dev/null +++ b/src/objects/_badge.scss @@ -0,0 +1,194 @@ +@use 'iro-sass/src/index' as iro; +@use '../functions' as fn; + +$themes: accent positive negative warning; + +@include iro.props-namespace('badge') { + @include iro.props-store(( + --dims: ( + --pad-b: fn.global-dim(--size --100), + --pad-i: fn.global-dim(--size --150), + --pad-i-pill: fn.global-dim(--size --200), + --rounding: fn.global-dim(--rounding), + --font-size: fn.global-dim(--font-size --100), + + --50: ( + --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: ( + --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: ( + --pad-b: fn.global-dim(--size --160), + --pad-i: fn.global-dim(--size --225), + --pad-i-pill: fn.global-dim(--size --300), + --font-size: fn.global-dim(--font-size --200), + ), + ), + --colors: ( + --bg: fn.global-color(--heading), + --label: fn.global-color(--bg-l2), + --hover: ( + --bg: fn.global-color(--text), + ), + --active: ( + --bg: fn.global-color(--text), + ), + --key-focus: ( + --bg: fn.global-color(--base --50), + --label: fn.global-color(--heading), + --border: fn.global-color(--yellow-static --400), + ), + + --quiet: ( + --bg: fn.global-color(--border-mute), + --label: fn.global-color(--heading), + --hover: ( + --bg: fn.global-color(--border), + ), + --active: ( + --bg: fn.global-color(--border-strong), + ), + ), + ), + )); + + @each $theme in $themes { + @include iro.props-store(( + --colors: ( + --#{$theme}: ( + --bg: fn.global-color(--#{$theme} --800), + --label: fn.global-color(--#{$theme} --800-text), + --hover: ( + --bg: fn.global-color(--#{$theme} --900), + ), + --active: ( + --bg: fn.global-color(--#{$theme} --900), + ), + ), + + --#{$theme}-quiet: ( + --bg: fn.global-color(--#{$theme} --200), + --label: fn.global-color(--#{$theme} --1100), + --hover: ( + --bg: fn.global-color(--#{$theme} --300), + ), + --active: ( + --bg: fn.global-color(--#{$theme} --300), + ), + ) + ), + )); + } + + @include iro.bem-object(iro.props-namespace()) { + display: inline-block; + padding-block: fn.dim(--pad-b); + padding-inline: fn.dim(--pad-i); + border-radius: fn.dim(--rounding); + background-color: fn.color(--bg); + color: fn.color(--label); + font-size: fn.dim(--font-size); + line-height: fn.global-dim(--font --standard --line-height); + text-align: center; + text-decoration: none; + + &:link, + &:visited, + &:enabled { + &:hover { + background-color: fn.color(--hover --bg); + } + + &:active { + background-color: fn.color(--active --bg); + } + } + + @include iro.bem-modifier('quiet') { + background-color: fn.color(--quiet --bg); + color: fn.color(--quiet --label); + + &:link, + &:visited, + &:enabled { + &:hover { + background-color: fn.color(--quiet --hover --bg); + } + + &:active { + background-color: fn.color(--quiet --active --bg); + } + } + } + + @each $theme in $themes { + @include iro.bem-modifier($theme) { + background-color: fn.color(--#{$theme} --bg); + color: fn.color(--#{$theme} --label); + + &:link, + &:visited, + &:enabled { + &:hover { + background-color: fn.color(--#{$theme} --hover --bg); + } + + &:active { + background-color: fn.color(--#{$theme} --active --bg); + } + } + + @include iro.bem-modifier('quiet') { + background-color: fn.color(--#{$theme}-quiet --bg); + color: fn.color(--#{$theme}-quiet --label); + + &:link, + &:visited, + &:enabled { + &:hover { + background-color: fn.color(--#{$theme}-quiet --hover --bg); + } + + &:active { + background-color: fn.color(--#{$theme}-quiet --active --bg); + } + } + } + } + } + + &:link, + &:visited, + &:enabled { + &:focus-visible { + background-color: fn.color(--key-focus --bg); + box-shadow: 0 0 0 fn.global-dim(--border --thick) fn.color(--key-focus --border); + color: fn.color(--key-focus --label); + } + } + + @include iro.bem-modifier('pill') { + padding-inline: fn.dim(--pad-i-pill); + border-radius: 10em; + } + + @each $size in '50' '200' '300' { + @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 iro.bem-modifier('pill') { + padding-inline: fn.dim(--#{$size} --pad-i-pill); + } + } + } + } +} diff --git a/src/objects/_button.scss b/src/objects/_button.scss new file mode 100644 index 0000000..d3588f6 --- /dev/null +++ b/src/objects/_button.scss @@ -0,0 +1,173 @@ +@use 'sass:list'; +@use 'iro-sass/src/index' as iro; +@use '../functions' as fn; + +$themes: primary accent positive negative warning; + +@mixin button-variant($theme: null) { + $key: if($theme == null, (), --#{$theme}); + + &:link, + &:visited, + &:enabled { + border-color: fn.color(list.join($key, --bg)); + background-color: fn.color(list.join($key, --bg)); + color: fn.color(list.join($key, --label)); + } + + @include iro.bem-modifier('outline') { + &:link, + &:visited, + &:enabled { + background-color: transparent; + color: fn.color(list.join($key, --outline-label)); + } + } + + &:link, + &:visited, + &:enabled { + &:hover { + border-color: fn.color(list.join($key, --hover --bg)); + background-color: fn.color(list.join($key, --hover --bg)); + color: fn.color(list.join($key, --hover --label)); + } + + &:active { + border-color: fn.color(list.join($key, --active --bg)); + background-color: fn.color(list.join($key, --active --bg)); + color: fn.color(list.join($key, --active --label)); + } + } +} + +@include iro.props-namespace('button') { + @include iro.props-store(( + --dims: ( + --line-height: 1.4, + --pad-i: fn.global-dim(--size --225), + --pad-b: fn.global-dim(--size --65), + --rounding: 10em, + + --lg: ( + --pad-i: fn.global-dim(--size --300), + --pad-b: fn.global-dim(--size --100), + ), + ), + --colors: ( + --bg: fn.global-color(--border-mute), + --label: fn.global-color(--text), + --outline-label: fn.global-color(--text), + + --hover: ( + --bg: fn.global-color(--border), + --label: fn.global-color(--heading), + ), + --active: ( + --bg: fn.global-color(--border-strong), + --label: fn.global-color(--heading), + ), + --disabled: ( + --bg: fn.global-color(--border-mute), + --label: fn.global-color(--text-disabled), + ), + --key-focus: ( + --bg: fn.global-color(--base --50), + --label: fn.global-color(--heading), + --border: fn.global-color(--yellow-static --400), + ), + + --primary: ( + --bg: fn.global-color(--base --800), + --label: fn.global-color(--base --800-text), + --outline-label: fn.global-color(--text), + + --hover: ( + --bg: fn.global-color(--base --900), + --label: fn.global-color(--base --900-text), + ), + --active: ( + --bg: fn.global-color(--base --900), + --label: fn.global-color(--base --900-text), + ), + ), + ), + )); + + @each $theme in $themes { + @if $theme != primary { + @include iro.props-store(( + --colors: ( + --#{$theme}: ( + --bg: fn.global-color(--#{$theme} --900), + --label: fn.global-color(--#{$theme} --900-text), + --outline-label: fn.global-color(--#{$theme} --1000), + + --hover: ( + --bg: fn.global-color(--#{$theme} --1000), + --label: fn.global-color(--#{$theme} --1000-text), + ), + --active: ( + --bg: fn.global-color(--#{$theme} --1100), + --label: fn.global-color(--#{$theme} --1100-text), + ), + ), + ), + )); + } + } + + @include iro.bem-object(iro.props-namespace()) { + display: inline-block; + padding-block: fn.dim(--pad-b); + padding-inline: fn.dim(--pad-i); + border: 2px 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-weight: 500; + line-height: fn.dim(--line-height); + text-align: center; + text-decoration: none; + vertical-align: top; + + @include iro.bem-modifier('block') { + display: block; + } + + @include iro.bem-modifier('outline') { + background-color: transparent; + box-shadow: none; + } + + @include iro.bem-modifier('lg') { + padding-block: fn.dim(--lg --pad-b); + padding-inline: fn.dim(--lg --pad-i); + } + + @include button-variant(); + + @each $theme in $themes { + @include iro.bem-modifier($theme) { + @include button-variant($theme); + } + } + + &:link, + &:visited, + &:enabled { + &:focus-visible { + border-color: fn.color(--key-focus --border); + background-color: fn.color(--key-focus --bg); + color: fn.color(--key-focus --label); + } + } + + @include iro.bem-modifier('round') { + inline-size: calc(1em * fn.dim(--line-height) + 2 * fn.dim(--pad-b)); + padding-inline: 0; + border-radius: 100em; + } + } +} diff --git a/src/objects/_divider.scss b/src/objects/_divider.scss index 3332331..5e80de4 100644 --- a/src/objects/_divider.scss +++ b/src/objects/_divider.scss @@ -42,7 +42,7 @@ @include iro.props-store(( --colors: ( $color: ( - --bg: fn.global-color($color --700), + --bg: fn.global-color($color --800), --label: fn.global-color($color --1000), ) ), @@ -54,7 +54,7 @@ display: flex; flex-direction: row; align-items: center; - height: 1em; + block-size: 1em; margin-block: fn.dim(--margin-b); color: fn.color(--strong --label); font-size: fn.dim(--strong --label-font-size); @@ -67,8 +67,8 @@ &::after { content: ''; flex: 1 1 auto; - width: 100%; - height: fn.dim(--strong --border); + inline-size: 100%; + block-size: fn.dim(--strong --border); background-color: fn.color(--strong --bg); } @@ -82,8 +82,8 @@ @include iro.bem-modifier('vertical') { align-self: stretch; - width: 1px; - height: auto; + inline-size: 1px; + block-size: auto; margin-block: 0; background-color: fn.color(--faint --bg); @@ -100,7 +100,7 @@ &::before, &::after { - height: fn.dim(--medium --border); + block-size: fn.dim(--medium --border); background-color: fn.color(--medium --bg); } } @@ -112,7 +112,7 @@ &::before, &::after { - height: fn.dim(--faint --border); + block-size: fn.dim(--faint --border); background-color: fn.color(--faint --bg); } } diff --git a/src/objects/_emoji.scss b/src/objects/_emoji.scss new file mode 100644 index 0000000..d8d1289 --- /dev/null +++ b/src/objects/_emoji.scss @@ -0,0 +1,73 @@ +@use 'iro-sass/src/index' as iro; +@use '../functions' as fn; +@use 'sass:math'; + +@use 'icon'; + +@include iro.props-namespace('emoji') { + @include iro.props-store(( + --dims: ( + --size: calc(1 / 14 * 18em), + --pad: .3em, + --rounding: fn.global-dim(--rounding), + --zoom: 3, + --valign: -.25em, + + --125: ( + --size: calc(1 / 14 * 23em), + --valign: -.45em, + ), + + --150: ( + --size: calc(1 / 14 * 28em), + --valign: -.65em, + ), + + --200: ( + --size: calc(1 / 14 * 38em), + --valign: -1em, + ) + ), + --colors: ( + --bg: fn.global-color(--border-mute), + ) + )); + + @include iro.bem-object(iro.props-namespace()) { + display: inline-block; + position: relative; + inline-size: calc(fn.dim(--size)); + block-size: calc(fn.dim(--size)); + margin: calc(-1 * fn.dim(--pad)); + padding: calc(fn.dim(--pad)); + vertical-align: fn.dim(--valign); + object-fit: contain; + + @include iro.bem-modifier('icon') { + margin: calc(-1 * fn.dim(--pad) - .5 * (fn.dim(--size) - fn.foreign-dim(--icon, --size))); + vertical-align: fn.foreign-dim(--icon, --valign); + } + + @each $size in '125' '150' '200' { + @include iro.bem-modifier($size) { + inline-size: fn.dim(--#{$size} --size); + block-size: fn.dim(--#{$size} --size); + vertical-align: fn.dim(--#{$size} --valign); + + @include iro.bem-modifier('icon') { + margin: calc(-1 * fn.dim(--pad) - .5 * (fn.dim(--#{$size} --size) - fn.foreign-dim(--icon, --size))); + } + } + } + + @include iro.bem-modifier('zoomable') { + transition: transform .2s ease, background-color .2s ease; + border-radius: calc(fn.dim(--rounding) / fn.dim(--zoom)); + + &:hover { + transform: scale(fn.dim(--zoom)); + background-color: fn.color(--bg); + } + } + } +} diff --git a/src/objects/_icon.scss b/src/objects/_icon.scss new file mode 100644 index 0000000..1491dd9 --- /dev/null +++ b/src/objects/_icon.scss @@ -0,0 +1,26 @@ +@use 'iro-sass/src/index' as iro; +@use '../functions' as fn; + +@include iro.props-namespace('icon') { + @include iro.props-store(( + --dims: ( + --stroke: 1.5px, + --size: calc(1 / 14 * 16em), + --valign: -.2em, + ) + )); + + @include iro.bem-object(iro.props-namespace()) { + display: inline; + inline-size: fn.dim(--size); + block-size: fn.dim(--size); + stroke-width: fn.dim(--stroke); + stroke-linecap: round; + stroke-linejoin: round; + vertical-align: fn.dim(--valign); + + @include iro.bem-modifier('block') { + display: block; + } + } +} diff --git a/src/objects/_palette.scss b/src/objects/_palette.scss index 9ecdfac..19f282f 100644 --- a/src/objects/_palette.scss +++ b/src/objects/_palette.scss @@ -7,8 +7,8 @@ @include iro.props-namespace('palette') { @include iro.bem-object(iro.props-namespace()) { - display: flex; - height: 3em; + display: flex; + block-size: 3em; @include iro.bem-elem('item') { flex: 1 1 auto; @@ -40,5 +40,23 @@ } } } + + @include iro.bem-modifier('static') { + @each $palette-name, $palette in map.get(config.$static-colors, --palettes) { + $contrasts: map.get(config.$static-colors, --contrasts); + + @include iro.bem-modifier(string.slice($palette-name, 3)) { + @include iro.bem-elem('item') { + @for $i from 1 through list.length($contrasts) { + $key: list.nth(map.keys($contrasts), $i); + + &:nth-child(#{$i}) { + background-color: fn.global-color(#{$palette-name}-static $key); + } + } + } + } + } + } } } -- cgit v1.2.3-70-g09d2