From 365c56edcc36b5b92902bac01ce44b43d01e8685 Mon Sep 17 00:00:00 2001 From: Volpeon Date: Fri, 18 Oct 2024 18:08:24 +0200 Subject: Refactoring --- src/layouts/_button-group.scss | 16 ++++++++ src/layouts/_button-group.vars.scss | 4 ++ src/layouts/_card-list.scss | 76 +++++++++++++++++++++++++++++++++++++ src/layouts/_card-list.vars.scss | 19 ++++++++++ src/layouts/_container.scss | 27 +++++++++++++ src/layouts/_container.vars.scss | 22 +++++++++++ src/layouts/_flex.scss | 27 +++++++++++++ src/layouts/_form.scss | 58 ++++++++++++++++++++++++++++ src/layouts/_form.vars.scss | 5 +++ src/layouts/_media.scss | 40 +++++++++++++++++++ src/layouts/_media.vars.scss | 16 ++++++++ src/layouts/_overflow.scss | 11 ++++++ 12 files changed, 321 insertions(+) create mode 100644 src/layouts/_button-group.scss create mode 100644 src/layouts/_button-group.vars.scss create mode 100644 src/layouts/_card-list.scss create mode 100644 src/layouts/_card-list.vars.scss create mode 100644 src/layouts/_container.scss create mode 100644 src/layouts/_container.vars.scss create mode 100644 src/layouts/_flex.scss create mode 100644 src/layouts/_form.scss create mode 100644 src/layouts/_form.vars.scss create mode 100644 src/layouts/_media.scss create mode 100644 src/layouts/_media.vars.scss create mode 100644 src/layouts/_overflow.scss (limited to 'src/layouts') diff --git a/src/layouts/_button-group.scss b/src/layouts/_button-group.scss new file mode 100644 index 0000000..95b63c9 --- /dev/null +++ b/src/layouts/_button-group.scss @@ -0,0 +1,16 @@ +@use 'sass:meta'; +@use 'iro-sass/src/iro-sass' as iro; +@use '../props'; + +@forward 'button-group.vars'; +@use 'button-group.vars' as vars; + +@mixin styles { + @include props.materialize(meta.module-variables('vars')); + + @include iro.bem-layout('button-group') { + display: flex; + flex-wrap: wrap; + gap: props.get(vars.$spacing); + } +} diff --git a/src/layouts/_button-group.vars.scss b/src/layouts/_button-group.vars.scss new file mode 100644 index 0000000..ac57b44 --- /dev/null +++ b/src/layouts/_button-group.vars.scss @@ -0,0 +1,4 @@ +@use '../props'; +@use '../vars'; + +$spacing: props.def(--l-button-group--spacing, props.get(vars.$size--150)) !default; diff --git a/src/layouts/_card-list.scss b/src/layouts/_card-list.scss new file mode 100644 index 0000000..1aea7bc --- /dev/null +++ b/src/layouts/_card-list.scss @@ -0,0 +1,76 @@ +@use 'sass:meta'; +@use 'include-media/dist/include-media' as media; +@use 'iro-sass/src/iro-sass' as iro; +@use '../props'; + +@forward 'card-list.vars'; +@use 'card-list.vars' as vars; + +@mixin styles { + @include props.materialize(meta.module-variables('vars')); + + @include iro.bem-layout('card-list') { + display: flex; + flex-direction: column; + gap: props.get(vars.$row-gap) props.get(vars.$col-gap); + + @include iro.bem-modifier('grid') { + display: grid; + grid-template-columns: repeat(auto-fill, minmax(props.get(vars.$grid--col-width), 1fr)); + gap: props.get(vars.$grid--col-gap); + + @include iro.bem-modifier('quiet') { + row-gap: props.get(vars.$grid--row-gap); + } + } + + @include iro.bem-modifier('masonry') { + display: block; + columns: auto props.get(vars.$masonry--col-width); + column-gap: props.get(vars.$masonry--col-gap); + + @include iro.bem-elem('card') { + margin-block-end: props.get(vars.$masonry--col-gap); + break-inside: avoid; + } + + @include iro.bem-modifier('quiet') { + @include iro.bem-elem('card') { + margin-block-end: props.get(vars.$masonry--row-gap); + } + } + } + + @include iro.bem-modifier('masonry-h') { + flex-flow: row wrap; + gap: props.get(vars.$masonry-h--col-gap); + + &::after { + display: block; + flex: 1 0 auto; + inline-size: props.get(vars.$masonry-h--row-height); + block-size: 0; + content: ''; + } + + @include iro.bem-elem('card') { + flex: 1 0 auto; + max-inline-size: 100%; + } + + @include iro.bem-elem('card-image') { + block-size: props.get(vars.$masonry-h--row-height); + } + + @include iro.bem-modifier('quiet') { + row-gap: props.get(vars.$masonry-h--row-gap); + } + } + + @include iro.bem-modifier('aspect-5\\/4') { + @include iro.bem-elem('card-image') { + aspect-ratio: 5 / 4; + } + } + } +} diff --git a/src/layouts/_card-list.vars.scss b/src/layouts/_card-list.vars.scss new file mode 100644 index 0000000..b3aaac4 --- /dev/null +++ b/src/layouts/_card-list.vars.scss @@ -0,0 +1,19 @@ +@use '../props'; +@use '../vars'; + +$row-gap: props.def(--l-card-list--row-gap, props.get(vars.$size--800)) !default; +$col-gap: props.def(--l-card-list--col-gap, props.get(vars.$size--400)) !default; + +$grid--row-gap: props.def(--l-card-list--grid--row-gap, props.get(vars.$size--800)) !default; +$grid--col-gap: props.def(--l-card-list--grid--col-gap, props.get(vars.$size--400)) !default; +$grid--col-width: props.def(--l-card-list--grid--col-width, props.get(vars.$size--3200)) !default; + +$masonry--row-gap: props.def(--l-card-list--masonry--row-gap, props.get(vars.$size--800)) !default; +$masonry--col-gap: props.def(--l-card-list--masonry--col-gap, props.get(vars.$size--400)) !default; +$masonry--col-width: props.def(--l-card-list--masonry--col-width, props.get(vars.$size--3200)) !default; + +$masonry-h--row-gap: props.def(--l-card-list--masonry-h--row-gap, props.get(vars.$size--800)) !default; +$masonry-h--col-gap: props.def(--l-card-list--masonry-h--col-gap, props.get(vars.$size--400)) !default; +$masonry-h--row-height: props.def(--l-card-list--masonry-h--row-height, props.get(vars.$size--3200)) !default; + +$border-color: props.def(--l-card-list--border-color, props.get(vars.$theme, --border)) !default; diff --git a/src/layouts/_container.scss b/src/layouts/_container.scss new file mode 100644 index 0000000..34c4bf0 --- /dev/null +++ b/src/layouts/_container.scss @@ -0,0 +1,27 @@ +@use 'sass:meta'; +@use 'iro-sass/src/iro-sass' as iro; +@use '../props'; + +@forward 'container.vars'; +@use 'container.vars' as vars; + +@mixin styles { + @include props.materialize(meta.module-variables('vars')); + + @include iro.bem-layout('container') { + @each $mod, $size in vars.$fixed-sizes { + @include iro.bem-modifier($mod) { + max-inline-size: props.get($size); + margin-inline: auto; + } + } + + @include iro.bem-modifier('pad-i') { + padding-inline: props.get(vars.$pad-i); + } + + @include iro.bem-modifier('pad-b') { + padding-block: props.get(vars.$pad-b); + } + } +} diff --git a/src/layouts/_container.vars.scss b/src/layouts/_container.vars.scss new file mode 100644 index 0000000..8b2258a --- /dev/null +++ b/src/layouts/_container.vars.scss @@ -0,0 +1,22 @@ +@use 'iro-sass/src/iro-sass' as iro; +@use '../props'; +@use '../vars'; + +$fixed-125: props.def(--l-container--fixed-125, iro.fn-px-to-rem(720px)) !default; +$fixed: props.def(--l-container--fixed, iro.fn-px-to-rem(610px)) !default; +$fixed-75: props.def(--l-container--fixed-75, iro.fn-px-to-rem(500px)) !default; + +$fixed-sizes: ( + 'fixed-125': $fixed-125, + 'fixed': $fixed, + 'fixed-75': $fixed-75 +) !default; + +$pad-i: props.def(--l-container--pad-i, props.get(vars.$size--400)) !default; +$pad-b: props.def(--l-container--pad-b, props.get(vars.$size--800)) !default; + +$pad-i--sm: props.def(--l-container--pad-i, props.get(vars.$size--200), 'sm') !default; +$pad-b--sm: props.def(--l-container--pad-b, props.get(vars.$size--600), 'sm') !default; + +$pad-i--xs: props.def(--l-container--pad-i, props.get(vars.$size--150), 'xs') !default; +$pad-b--xs: props.def(--l-container--pad-b, props.get(vars.$size--450), 'xs') !default; diff --git a/src/layouts/_flex.scss b/src/layouts/_flex.scss new file mode 100644 index 0000000..6cc9dc6 --- /dev/null +++ b/src/layouts/_flex.scss @@ -0,0 +1,27 @@ +@use 'iro-sass/src/iro-sass' as iro; + +@mixin styles { + @include iro.bem-layout('flex') { + display: flex; + + @include iro.bem-modifier('align-stretch') { + align-items: stretch; + } + + @include iro.bem-modifier('align-center') { + align-items: center; + } + + @include iro.bem-modifier('align-start') { + align-items: flex-start; + } + + @include iro.bem-modifier('align-end') { + align-items: flex-end; + } + + @include iro.bem-modifier('column') { + flex-direction: column; + } + } +} diff --git a/src/layouts/_form.scss b/src/layouts/_form.scss new file mode 100644 index 0000000..824d7ca --- /dev/null +++ b/src/layouts/_form.scss @@ -0,0 +1,58 @@ +@use 'sass:meta'; +@use 'iro-sass/src/iro-sass' as iro; +@use '../props'; + +@forward 'form.vars'; +@use 'form.vars' as vars; + +@mixin styles { + @include props.materialize(meta.module-variables('vars')); + + @include iro.bem-layout('form') { + display: flex; + flex-direction: column; + gap: props.get(vars.$item-spacing-b) props.get(vars.$label-spacing-i); + + @include iro.bem-elem('item') { + display: block; + } + + @include iro.bem-elem('item-content') { + @include iro.bem-modifier('align-start') { + align-self: start; + } + } + + @include iro.bem-modifier('row') { + flex-direction: row; + align-items: flex-end; + } + + @include iro.bem-modifier('labels-start', 'labels-end') { + display: grid; + grid-template-rows: auto; + grid-template-columns: auto 1fr; + align-items: baseline; + + @include iro.bem-elem('item') { + display: contents; + } + + @include iro.bem-elem('item-label') { + grid-column: 1; + padding-inline-end: 0; + } + + @include iro.bem-elem('item-content') { + grid-column: 2; + margin-block-start: 0; + } + } + + @include iro.bem-modifier('labels-end') { + @include iro.bem-elem('item-label') { + text-align: end; + } + } + } +} diff --git a/src/layouts/_form.vars.scss b/src/layouts/_form.vars.scss new file mode 100644 index 0000000..45faf29 --- /dev/null +++ b/src/layouts/_form.vars.scss @@ -0,0 +1,5 @@ +@use '../props'; +@use '../vars'; + +$item-spacing-b: props.def(--l-form--item-spacing-b, props.get(vars.$size--325)) !default; +$label-spacing-i: props.def(--l-form--label-spacing-i, props.get(vars.$size--325)) !default; diff --git a/src/layouts/_media.scss b/src/layouts/_media.scss new file mode 100644 index 0000000..7483f12 --- /dev/null +++ b/src/layouts/_media.scss @@ -0,0 +1,40 @@ +@use 'sass:meta'; +@use 'iro-sass/src/iro-sass' as iro; +@use '../props'; + +@forward 'media.vars'; +@use 'media.vars' as vars; + +@mixin styles { + @include props.materialize(meta.module-variables('vars')); + + @include iro.bem-layout('media') { + display: flex; + gap: props.get(vars.$gap); + align-items: center; + line-height: 1.4; + + @each $mod, $size in vars.$sizes { + @include iro.bem-modifier($mod) { + gap: props.get($size); + } + } + + @include iro.bem-modifier('wrap') { + flex-wrap: wrap; + } + + @include iro.bem-elem('block') { + flex: 0 0 auto; + + @include iro.bem-modifier('shrink', 'main') { + flex-shrink: 1; + min-inline-size: 0; + } + + @include iro.bem-modifier('main') { + inline-size: 100%; + } + } + } +} diff --git a/src/layouts/_media.vars.scss b/src/layouts/_media.vars.scss new file mode 100644 index 0000000..3444611 --- /dev/null +++ b/src/layouts/_media.vars.scss @@ -0,0 +1,16 @@ +@use '../props'; +@use '../vars'; + +$gap: props.def(--l-media--gap, props.get(vars.$size--150)) !default; + +$gapless: props.def(--l-media--gapless, 0) !default; +$sm: props.def(--l-media--sm, props.get(vars.$size--100)) !default; +$lg: props.def(--l-media--lg, props.get(vars.$size--300)) !default; +$xl: props.def(--l-media--xl, props.get(vars.$size--450)) !default; + +$sizes: ( + 'gapless': $gapless, + 'sm': $sm, + 'lg': $lg, + 'xl': $xl, +) !default; diff --git a/src/layouts/_overflow.scss b/src/layouts/_overflow.scss new file mode 100644 index 0000000..2589d2c --- /dev/null +++ b/src/layouts/_overflow.scss @@ -0,0 +1,11 @@ +@use 'iro-sass/src/iro-sass' as iro; +@use '../props'; +@use '../vars'; + +@mixin styles { + @include iro.bem-layout('overflow') { + overflow: auto; + scrollbar-color: props.get(vars.$theme, --text-disabled) transparent; + } +} + -- cgit v1.2.3-70-g09d2