From 50f6acc739f24bfa2ca080d08e90d82f8fa83543 Mon Sep 17 00:00:00 2001 From: Volpeon Date: Thu, 17 Oct 2024 16:45:00 +0200 Subject: Revamped variable management --- src/_vars.scss | 400 ++++++++++++++++++++++----------------------------------- 1 file changed, 155 insertions(+), 245 deletions(-) (limited to 'src/_vars.scss') diff --git a/src/_vars.scss b/src/_vars.scss index afe1e15..aaa38a0 100644 --- a/src/_vars.scss +++ b/src/_vars.scss @@ -4,243 +4,161 @@ @use 'iro-sass/src/index' as iro; @use 'include-media/dist/include-media' as media; @use 'functions' as fn; -@use 'config'; +@use 'palettes'; +@use 'props'; + +$size--0: props.def(--size--0, 0) !default; +$size--10: props.def(--size--10, iro.fn-px-to-rem(1px)) !default; +$size--25: props.def(--size--25, iro.fn-px-to-rem(2px)) !default; +$size--40: props.def(--size--40, iro.fn-px-to-rem(3px)) !default; +$size--50: props.def(--size--50, iro.fn-px-to-rem(4px)) !default; +$size--65: props.def(--size--65, iro.fn-px-to-rem(5px)) !default; +$size--75: props.def(--size--75, iro.fn-px-to-rem(6px)) !default; +$size--85: props.def(--size--85, iro.fn-px-to-rem(7px)) !default; +$size--100: props.def(--size--100, iro.fn-px-to-rem(8px)) !default; +$size--115: props.def(--size--115, iro.fn-px-to-rem(9px)) !default; +$size--125: props.def(--size--125, iro.fn-px-to-rem(10px)) !default; +$size--130: props.def(--size--130, iro.fn-px-to-rem(11px)) !default; +$size--150: props.def(--size--150, iro.fn-px-to-rem(12px)) !default; +$size--160: props.def(--size--160, iro.fn-px-to-rem(13px)) !default; +$size--175: props.def(--size--175, iro.fn-px-to-rem(14px)) !default; +$size--200: props.def(--size--200, iro.fn-px-to-rem(16px)) !default; +$size--225: props.def(--size--225, iro.fn-px-to-rem(18px)) !default; +$size--250: props.def(--size--250, iro.fn-px-to-rem(20px)) !default; +$size--275: props.def(--size--275, iro.fn-px-to-rem(22px)) !default; +$size--300: props.def(--size--300, iro.fn-px-to-rem(24px)) !default; +$size--325: props.def(--size--325, iro.fn-px-to-rem(26px)) !default; +$size--350: props.def(--size--350, iro.fn-px-to-rem(28px)) !default; +$size--375: props.def(--size--375, iro.fn-px-to-rem(30px)) !default; +$size--400: props.def(--size--400, iro.fn-px-to-rem(32px)) !default; +$size--450: props.def(--size--450, iro.fn-px-to-rem(36px)) !default; +$size--500: props.def(--size--500, iro.fn-px-to-rem(40px)) !default; +$size--550: props.def(--size--550, iro.fn-px-to-rem(44px)) !default; +$size--600: props.def(--size--600, iro.fn-px-to-rem(48px)) !default; +$size--650: props.def(--size--650, iro.fn-px-to-rem(52px)) !default; +$size--700: props.def(--size--700, iro.fn-px-to-rem(56px)) !default; +$size--800: props.def(--size--800, iro.fn-px-to-rem(64px)) !default; +$size--900: props.def(--size--900, iro.fn-px-to-rem(72px)) !default; +$size--1000: props.def(--size--1000, iro.fn-px-to-rem(80px)) !default; +$size--1200: props.def(--size--1200, iro.fn-px-to-rem(96px)) !default; +$size--1600: props.def(--size--1600, iro.fn-px-to-rem(128px)) !default; +$size--2000: props.def(--size--2000, iro.fn-px-to-rem(160px)) !default; +$size--2400: props.def(--size--2400, iro.fn-px-to-rem(192px)) !default; +$size--2500: props.def(--size--2500, iro.fn-px-to-rem(200px)) !default; +$size--2600: props.def(--size--2600, iro.fn-px-to-rem(208px)) !default; +$size--2800: props.def(--size--2800, iro.fn-px-to-rem(224px)) !default; +$size--3200: props.def(--size--3200, iro.fn-px-to-rem(256px)) !default; +$size--3400: props.def(--size--3400, iro.fn-px-to-rem(272px)) !default; +$size--3500: props.def(--size--3500, iro.fn-px-to-rem(280px)) !default; +$size--3600: props.def(--size--3600, iro.fn-px-to-rem(288px)) !default; +$size--3800: props.def(--size--3800, iro.fn-px-to-rem(304px)) !default; +$size--4600: props.def(--size--4600, iro.fn-px-to-rem(368px)) !default; +$size--5000: props.def(--size--5000, iro.fn-px-to-rem(400px)) !default; +$size--6000: props.def(--size--6000, iro.fn-px-to-rem(480px)) !default; + +$font--standard--family: props.def(--font--standard--family, ('Inter', 'Open Sans', 'Segoe UI', 'Droid Sans', Roboto, Oxygen, 'Helvetica Neue', Helvetica, Tahoma, Arial, sans-serif)) !default; +$font--standard--line-height: props.def(--font--standard--line-height, 1.5) !default; +$font--standard--feature-settings: props.def(--font--standard--feature-settings, ('\'ss01\'')) !default; + +$font--headline--family: props.def(--font--headline--family, ('Inter', props.get($font--standard--family))) !default; +$font--headline--line-height: props.def(--font--headline--line-height, 1.3) !default; +$font--headline--weight: props.def(--font--headline--weight, 800) !default; +$font--headline--feature-settings: props.def(--font--headline--feature-settings, ('\'opsz\'' 32, '\'ss01\'', '\'cv06\'')) !default; + +$font--mono--family: props.def(--font--mono--family, ('Iosevka Term SS09', 'IBM Plex Mono', 'Menlo', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Courier, monospace)) !default; +$font--mono--line-height: props.def(--font--mono--line-height, 1.4) !default; + +$font-size--50: props.def(--font-size--50, iro.fn-px-to-rem(12px)) !default; +$font-size--75: props.def(--font-size--75 , iro.fn-px-to-rem(13px)) !default; +$font-size--100: props.def(--font-size--100, iro.fn-px-to-rem(14px)) !default; +$font-size--150: props.def(--font-size--150, iro.fn-px-to-rem(16px)) !default; +$font-size--200: props.def(--font-size--200, iro.fn-px-to-rem(18px)) !default; +$font-size--300: props.def(--font-size--300, iro.fn-px-to-rem(20px)) !default; +$font-size--400: props.def(--font-size--400, iro.fn-px-to-rem(24px)) !default; +$font-size--500: props.def(--font-size--500, iro.fn-px-to-rem(28px)) !default; +$font-size--600: props.def(--font-size--600, iro.fn-px-to-rem(32px)) !default; +$font-size--700: props.def(--font-size--700, iro.fn-px-to-rem(36px)) !default; +$font-size--800: props.def(--font-size--800, iro.fn-px-to-rem(40px)) !default; +$font-size--900: props.def(--font-size--900, iro.fn-px-to-rem(45px)) !default; +$font-size--1000: props.def(--font-size--1000, iro.fn-px-to-rem(50px)) !default; +$font-size--1100: props.def(--font-size--1100, iro.fn-px-to-rem(60px)) !default; + +$border-width--thick: props.def(--border-width--thick, 4px) !default; +$border-width--medium: props.def(--border-width--medium, 2px) !default; +$border-width--thin: props.def(--border-width--thin, 1px) !default; + +$shadow--x: props.def(--shadow--x, 0) !default; +$shadow--y: props.def(--shadow--y, 1px) !default; +$shadow--blur: props.def(--shadow--blur, 4px) !default; + +$rounding: props.def(--rounding, 4px) !default; + +$key-focus--outline-width: props.def(--key-focus--outline-width, props.get($border-width--thick)) !default; +$key-focus--border: props.def(--key-focus--border, props.get($border-width--medium)) !default; +$key-focus--border-offset: props.def(--key-focus--border-offset, props.get($border-width--medium)) !default; + +$paragraph--margin-bs: props.def(--paragraph--margin-bs, props.get($size--300)) !default; + +$heading--margin-bs: props.def(--heading--margin-bs, props.get($size--700)) !default; +$heading--margin-bs-sibling: props.def(--heading--margin-bs-sibling, props.get($size--325)) !default; +$heading--xxl: props.def(--heading--xxl, props.get($font-size--300)) !default; +$heading--xl: props.def(--heading--xl, props.get($font-size--200)) !default; +$heading--lg: props.def(--heading--lg, props.get($font-size--150)) !default; +$heading--md: props.def(--heading--md, props.get($font-size--100)) !default; +$heading--sm: props.def(--heading--sm, props.get($font-size--75)) !default; +$heading--xs: props.def(--heading--xs, props.get($font-size--50)) !default; +$heading--display--xxl: props.def(--heading--display--xxl, props.get($font-size--1100)) !default; +$heading--display--xl: props.def(--heading--display--xl, props.get($font-size--700)) !default; +$heading--display--lg: props.def(--heading--display--lg, props.get($font-size--300)) !default; +$heading--display--md: props.def(--heading--display--md, props.get($font-size--150)) !default; +$heading--display--sm: props.def(--heading--display--sm, props.get($font-size--75)) !default; +$heading--display--xs: props.def(--heading--display--xs, props.get($font-size--50)) !default; +$heading--display-sm--xxl: props.def(--heading--display-sm--xxl, props.get($font-size--900)) !default; +$heading--display-sm--xl: props.def(--heading--display-sm--xl, props.get($font-size--600)) !default; +$heading--display-sm--lg: props.def(--heading--display-sm--lg, props.get($font-size--200)) !default; +$heading--display-sm--md: props.def(--heading--display-sm--md, props.get($font-size--100)) !default; +$heading--display-sm--sm: props.def(--heading--display-sm--sm, props.get($font-size--75)) !default; +$heading--display-sm--xs: props.def(--heading--display-sm--xs, props.get($font-size--50)) !default; + +$list--indent: props.def(--list--indent, props.get($size--400)) !default; +$list--compact-indent: props.def(--list--indent, props.get($size--250)) !default; -@include iro.props-store(( - --dims: ( - --size: ( - --0: 0, - --10: iro.fn-px-to-rem(1px), - --25: iro.fn-px-to-rem(2px), - --40: iro.fn-px-to-rem(3px), - --50: iro.fn-px-to-rem(4px), - --65: iro.fn-px-to-rem(5px), - --75: iro.fn-px-to-rem(6px), - --85: iro.fn-px-to-rem(7px), - --100: iro.fn-px-to-rem(8px), - --115: iro.fn-px-to-rem(9px), - --125: iro.fn-px-to-rem(10px), - --130: iro.fn-px-to-rem(11px), - --150: iro.fn-px-to-rem(12px), - --160: iro.fn-px-to-rem(13px), - --175: iro.fn-px-to-rem(14px), - --200: iro.fn-px-to-rem(16px), - --225: iro.fn-px-to-rem(18px), - --250: iro.fn-px-to-rem(20px), - --275: iro.fn-px-to-rem(22px), - --300: iro.fn-px-to-rem(24px), - --325: iro.fn-px-to-rem(26px), - --350: iro.fn-px-to-rem(28px), - --375: iro.fn-px-to-rem(30px), - --400: iro.fn-px-to-rem(32px), - --450: iro.fn-px-to-rem(36px), - --500: iro.fn-px-to-rem(40px), - --550: iro.fn-px-to-rem(44px), - --600: iro.fn-px-to-rem(48px), - --650: iro.fn-px-to-rem(52px), - --700: iro.fn-px-to-rem(56px), - --800: iro.fn-px-to-rem(64px), - --900: iro.fn-px-to-rem(72px), - --1000: iro.fn-px-to-rem(80px), - --1200: iro.fn-px-to-rem(96px), - --1600: iro.fn-px-to-rem(128px), - --2000: iro.fn-px-to-rem(160px), - --2400: iro.fn-px-to-rem(192px), - --2500: iro.fn-px-to-rem(200px), - --2600: iro.fn-px-to-rem(208px), - --2800: iro.fn-px-to-rem(224px), - --3200: iro.fn-px-to-rem(256px), - --3400: iro.fn-px-to-rem(272px), - --3500: iro.fn-px-to-rem(280px), - --3600: iro.fn-px-to-rem(288px), - --3800: iro.fn-px-to-rem(304px), - --4600: iro.fn-px-to-rem(368px), - --5000: iro.fn-px-to-rem(400px), - --6000: iro.fn-px-to-rem(480px), - ), - - --font: ( - --standard: ( - --family: ('Inter', 'Open Sans', 'Segoe UI', 'Droid Sans', Roboto, Oxygen, 'Helvetica Neue', Helvetica, Tahoma, Arial, sans-serif), - --line-height: 1.5, - --feature-settings: ('\'ss01\''), - ), - --headline: ( - --family: ('Inter', fn.dim(--font --standard --family, null)), - --line-height: 1.3, - --weight: 800, - --feature-settings: ('\'opsz\'' 32, '\'ss01\'', '\'cv06\''), - ), - --mono: ( - --family: ('Iosevka Term SS09', 'IBM Plex Mono', 'Menlo', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Courier, monospace), - --line-height: 1.4, - ) - ), - - --font-size: ( - --50: iro.fn-px-to-rem(12px), - --75: iro.fn-px-to-rem(13px), - --100: iro.fn-px-to-rem(14px), - --150: iro.fn-px-to-rem(16px), - --200: iro.fn-px-to-rem(18px), - --300: iro.fn-px-to-rem(20px), - --400: iro.fn-px-to-rem(24px), - --500: iro.fn-px-to-rem(28px), - --600: iro.fn-px-to-rem(32px), - --700: iro.fn-px-to-rem(36px), - --800: iro.fn-px-to-rem(40px), - --900: iro.fn-px-to-rem(45px), - --1000: iro.fn-px-to-rem(50px), - --1100: iro.fn-px-to-rem(60px), - ), - - --border: ( - --thick: 4px, - --medium: 2px, - --thin: 1px, - ), - - --shadow: ( - --x: 0, - --y: 1px, - --blur: 4px, - ), - - --rounding: 4px, - - --key-focus: ( - --outline: fn.dim(--border --thick, null), - --border: fn.dim(--border --medium, null), - --border-offset: fn.dim(--border --medium, null), - ), - - --paragraph: ( - --margin-bs: fn.dim(--size --300, null), - ), - - --heading: ( - --margin-bs: fn.dim(--size --700, null), - --margin-bs-sibling: fn.dim(--size --325, null), - - --xxl: fn.dim(--font-size --300, null), - --xl: fn.dim(--font-size --200, null), - --lg: fn.dim(--font-size --150, null), - --md: fn.dim(--font-size --100, null), - --sm: fn.dim(--font-size --75, null), - --xs: fn.dim(--font-size --50, null), - - --display: ( - --xxl: fn.dim(--font-size --1100, null), - --xl: fn.dim(--font-size --700, null), - --lg: fn.dim(--font-size --300, null), - --md: fn.dim(--font-size --150, null), - --sm: fn.dim(--font-size --75, null), - --xs: fn.dim(--font-size --50, null), - ), - - --display-sm: ( - --xxl: fn.dim(--font-size --900, null), - --xl: fn.dim(--font-size --600, null), - --lg: fn.dim(--font-size --200, null), - --md: fn.dim(--font-size --100, null), - --sm: fn.dim(--font-size --75, null), - --xs: fn.dim(--font-size --50, null), - ) - ), - - --list: ( - --indent: fn.dim(--size --400, null), - --compact-indent: fn.dim(--size --250, null), - ), - ), -)); +// -@each $breakpoint in map.keys(media.$breakpoints) { - @include media.media('<=#{$breakpoint}') { - @include iro.props-store((), $breakpoint); - } +$static-colors: props.def(--static-colors); +@each $palette-name, $palette in map.get(palettes.$static-colors, --palettes) { + $palette: fn.palette($palette, map.get(palettes.$static-colors, --contrasts), 1, map.get(palettes.$static-colors, --base)); + $static-colors: props.merge($static-colors, ( $palette-name: $palette )); } -@include iro.props-store(( - --dims: ( - --heading: ( - --margin-bs: fn.dim(--size --600, null), - ), - - --list: ( - --indent: fn.dim(--size --300), - ), - ) -), 'sm'); - -@include iro.props-store(( - --dims: ( - --heading: ( - --margin-bs: fn.dim(--size --500, null), - ), - - --list: ( - --indent: fn.dim(--size --250), - ), - ) -), 'xs'); - // -@each $palette-name, $palette in map.get(config.$static-colors, --palettes) { - @include iro.props-store(( - --colors: ( - #{$palette-name}-static: fn.palette( - $palette, - map.get(config.$static-colors, --contrasts), - 1, - map.get(config.$static-colors, --base), - ), - ), - )); -} - +$transparent-colors: props.def(--transparent-colors); @each $palette-name, $palette in (--black: #000 #fff, --white: #fff #000) { $color: list.nth($palette, 1); $text: list.nth($palette, 2); - @include iro.props-store(( - --colors: ( - #{$palette-name}-transparent: fn.transparent-palette( - $color, - $text, - map.get(config.$static-colors, --transparents), - ), - ), - )); + $palette: fn.transparent-palette($color, $text, map.get(palettes.$static-colors, --transparents)); + $transparent-colors: props.merge($transparent-colors, ( $palette-name: $palette )); } -@each $theme-name, $theme in config.$themes { - $tree: if($theme-name == config.$theme-default, iro.$props-default-tree, $theme-name); +// + +$themes: props.def(--themes); +@each $theme-name, $theme in palettes.$themes { + $themes: props.merge($themes, ( --#{$theme-name}: () )); @each $palette-name, $palette in map.get($theme, --palettes) { $base-color: list.nth($palette, 1); $contrasts: list.nth($palette, 2); $ranges: list.nth($palette, 3); - @include iro.props-store(( - --colors: ( - $palette-name: fn.palette( - $base-color, - map.get($theme, --contrasts, $contrasts), - map.get($theme, --ranges, $ranges), - list.nth(map.get($theme, --palettes, --base), 1), - ), - ), - ), $tree); + $palette: fn.palette($base-color, map.get($theme, --contrasts, $contrasts), map.get($theme, --ranges, $ranges), list.nth(map.get($theme, --palettes, --base), 1)); + $themes: props.merge($themes, ( --#{$theme-name}: ( $palette-name: $palette ) )); } @each $color, $value in map.get($theme, --constants) { - @include iro.props-store(( - --colors: ( - $color: $value, - ), - ), $tree); + $themes: props.merge($themes, ( --#{$theme-name}: ( $color: $value ) )); } @each $color, $ref in map.get($theme, --semantic) { @@ -248,42 +166,34 @@ @if meta.type-of($ref) == 'map' { @each $key, $r in $ref { - $res: map.set($res, $key, fn.color($r)); - } - } @else { - $res: fn.color($ref); - } + $repo-name: list.nth($r, 1); + $re1: list.nth($r, 2); + $re2: iro.fn-list-slice($r, 3); - @include iro.props-store(( - --colors: ( - $color: $res, - ), - ), $tree); - } -} + $res2: null; -@each $theme-name, $theme in config.$themes { - $tree: if($theme-name == config.$theme-default, iro.$props-default-tree, $theme-name); + @if $repo-name == --static { + $res2: props.get($static-colors, $re1, $re2...); + } @else { + $res2: props.get($themes, --#{$theme-name}, $re1, $re2...); + } - @include iro.props-store(( - --colors: ( - - ), - ), $tree); -} + $res: map.merge($res, ($key: $res2)); + } + } @else { + $repo-name: list.nth($ref, 1); + $ref1: list.nth($ref, 2); + $ref2: iro.fn-list-slice($ref, 3); -@mixin apply-vars { - :root { - @include iro.props-assign; + $res: null; - @each $breakpoint in map.keys(media.$breakpoints) { - @include media.media('<=#{$breakpoint}') { - @include iro.props-assign($breakpoint); + @if $repo-name == --static { + $res: props.get($static-colors, $ref1, $ref2...); + } @else { + $res: props.get($themes, --#{$theme-name}, $ref1, $ref2...); } } - @media (prefers-color-scheme: dark) { - @include iro.props-assign('dark'); - } + $themes: props.merge($themes, ( --#{$theme-name}: ( $color: $res ) )); } } -- cgit v1.2.3-70-g09d2