diff options
author | Volpeon <git@volpeon.ink> | 2024-10-18 18:08:24 +0200 |
---|---|---|
committer | Volpeon <git@volpeon.ink> | 2024-10-18 18:08:24 +0200 |
commit | 365c56edcc36b5b92902bac01ce44b43d01e8685 (patch) | |
tree | 644611792591a76e605068d0c9e230fad6a633e7 /src/_vars.scss | |
parent | Revamped variable management (diff) | |
download | iro-design-365c56edcc36b5b92902bac01ce44b43d01e8685.tar.gz iro-design-365c56edcc36b5b92902bac01ce44b43d01e8685.tar.bz2 iro-design-365c56edcc36b5b92902bac01ce44b43d01e8685.zip |
Refactoring
Diffstat (limited to 'src/_vars.scss')
-rw-r--r-- | src/_vars.scss | 214 |
1 files changed, 24 insertions, 190 deletions
diff --git a/src/_vars.scss b/src/_vars.scss index aaa38a0..78ead7c 100644 --- a/src/_vars.scss +++ b/src/_vars.scss | |||
@@ -1,199 +1,33 @@ | |||
1 | @use 'sass:map'; | 1 | @use 'sass:map'; |
2 | @use 'sass:meta'; | 2 | @use 'sass:meta'; |
3 | @use 'sass:list'; | 3 | @use 'iro-sass/src/props'; |
4 | @use 'iro-sass/src/index' as iro; | 4 | @use 'themes'; |
5 | @use 'include-media/dist/include-media' as media; | 5 | |
6 | @use 'functions' as fn; | 6 | @use 'vars.vars' as vars; |
7 | @use 'palettes'; | 7 | @forward 'vars.vars'; |
8 | @use 'props'; | 8 | |
9 | 9 | @mixin vars { | |
10 | $size--0: props.def(--size--0, 0) !default; | 10 | @each $theme-name, $theme in vars.$themes { |
11 | $size--10: props.def(--size--10, iro.fn-px-to-rem(1px)) !default; | 11 | @if $theme-name == themes.$theme-default { |
12 | $size--25: props.def(--size--25, iro.fn-px-to-rem(2px)) !default; | 12 | :root { |
13 | $size--40: props.def(--size--40, iro.fn-px-to-rem(3px)) !default; | 13 | @include props.materialize(map.get($theme, 'light')); |
14 | $size--50: props.def(--size--50, iro.fn-px-to-rem(4px)) !default; | 14 | |
15 | $size--65: props.def(--size--65, iro.fn-px-to-rem(5px)) !default; | 15 | @if map.has-key($theme, 'dark') { |
16 | $size--75: props.def(--size--75, iro.fn-px-to-rem(6px)) !default; | 16 | @media (prefers-color-scheme: dark) { |
17 | $size--85: props.def(--size--85, iro.fn-px-to-rem(7px)) !default; | 17 | @include props.materialize(map.get($theme, 'dark')); |
18 | $size--100: props.def(--size--100, iro.fn-px-to-rem(8px)) !default; | 18 | } |
19 | $size--115: props.def(--size--115, iro.fn-px-to-rem(9px)) !default; | ||
20 | $size--125: props.def(--size--125, iro.fn-px-to-rem(10px)) !default; | ||
21 | $size--130: props.def(--size--130, iro.fn-px-to-rem(11px)) !default; | ||
22 | $size--150: props.def(--size--150, iro.fn-px-to-rem(12px)) !default; | ||
23 | $size--160: props.def(--size--160, iro.fn-px-to-rem(13px)) !default; | ||
24 | $size--175: props.def(--size--175, iro.fn-px-to-rem(14px)) !default; | ||
25 | $size--200: props.def(--size--200, iro.fn-px-to-rem(16px)) !default; | ||
26 | $size--225: props.def(--size--225, iro.fn-px-to-rem(18px)) !default; | ||
27 | $size--250: props.def(--size--250, iro.fn-px-to-rem(20px)) !default; | ||
28 | $size--275: props.def(--size--275, iro.fn-px-to-rem(22px)) !default; | ||
29 | $size--300: props.def(--size--300, iro.fn-px-to-rem(24px)) !default; | ||
30 | $size--325: props.def(--size--325, iro.fn-px-to-rem(26px)) !default; | ||
31 | $size--350: props.def(--size--350, iro.fn-px-to-rem(28px)) !default; | ||
32 | $size--375: props.def(--size--375, iro.fn-px-to-rem(30px)) !default; | ||
33 | $size--400: props.def(--size--400, iro.fn-px-to-rem(32px)) !default; | ||
34 | $size--450: props.def(--size--450, iro.fn-px-to-rem(36px)) !default; | ||
35 | $size--500: props.def(--size--500, iro.fn-px-to-rem(40px)) !default; | ||
36 | $size--550: props.def(--size--550, iro.fn-px-to-rem(44px)) !default; | ||
37 | $size--600: props.def(--size--600, iro.fn-px-to-rem(48px)) !default; | ||
38 | $size--650: props.def(--size--650, iro.fn-px-to-rem(52px)) !default; | ||
39 | $size--700: props.def(--size--700, iro.fn-px-to-rem(56px)) !default; | ||
40 | $size--800: props.def(--size--800, iro.fn-px-to-rem(64px)) !default; | ||
41 | $size--900: props.def(--size--900, iro.fn-px-to-rem(72px)) !default; | ||
42 | $size--1000: props.def(--size--1000, iro.fn-px-to-rem(80px)) !default; | ||
43 | $size--1200: props.def(--size--1200, iro.fn-px-to-rem(96px)) !default; | ||
44 | $size--1600: props.def(--size--1600, iro.fn-px-to-rem(128px)) !default; | ||
45 | $size--2000: props.def(--size--2000, iro.fn-px-to-rem(160px)) !default; | ||
46 | $size--2400: props.def(--size--2400, iro.fn-px-to-rem(192px)) !default; | ||
47 | $size--2500: props.def(--size--2500, iro.fn-px-to-rem(200px)) !default; | ||
48 | $size--2600: props.def(--size--2600, iro.fn-px-to-rem(208px)) !default; | ||
49 | $size--2800: props.def(--size--2800, iro.fn-px-to-rem(224px)) !default; | ||
50 | $size--3200: props.def(--size--3200, iro.fn-px-to-rem(256px)) !default; | ||
51 | $size--3400: props.def(--size--3400, iro.fn-px-to-rem(272px)) !default; | ||
52 | $size--3500: props.def(--size--3500, iro.fn-px-to-rem(280px)) !default; | ||
53 | $size--3600: props.def(--size--3600, iro.fn-px-to-rem(288px)) !default; | ||
54 | $size--3800: props.def(--size--3800, iro.fn-px-to-rem(304px)) !default; | ||
55 | $size--4600: props.def(--size--4600, iro.fn-px-to-rem(368px)) !default; | ||
56 | $size--5000: props.def(--size--5000, iro.fn-px-to-rem(400px)) !default; | ||
57 | $size--6000: props.def(--size--6000, iro.fn-px-to-rem(480px)) !default; | ||
58 | |||
59 | $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; | ||
60 | $font--standard--line-height: props.def(--font--standard--line-height, 1.5) !default; | ||
61 | $font--standard--feature-settings: props.def(--font--standard--feature-settings, ('\'ss01\'')) !default; | ||
62 | |||
63 | $font--headline--family: props.def(--font--headline--family, ('Inter', props.get($font--standard--family))) !default; | ||
64 | $font--headline--line-height: props.def(--font--headline--line-height, 1.3) !default; | ||
65 | $font--headline--weight: props.def(--font--headline--weight, 800) !default; | ||
66 | $font--headline--feature-settings: props.def(--font--headline--feature-settings, ('\'opsz\'' 32, '\'ss01\'', '\'cv06\'')) !default; | ||
67 | |||
68 | $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; | ||
69 | $font--mono--line-height: props.def(--font--mono--line-height, 1.4) !default; | ||
70 | |||
71 | $font-size--50: props.def(--font-size--50, iro.fn-px-to-rem(12px)) !default; | ||
72 | $font-size--75: props.def(--font-size--75 , iro.fn-px-to-rem(13px)) !default; | ||
73 | $font-size--100: props.def(--font-size--100, iro.fn-px-to-rem(14px)) !default; | ||
74 | $font-size--150: props.def(--font-size--150, iro.fn-px-to-rem(16px)) !default; | ||
75 | $font-size--200: props.def(--font-size--200, iro.fn-px-to-rem(18px)) !default; | ||
76 | $font-size--300: props.def(--font-size--300, iro.fn-px-to-rem(20px)) !default; | ||
77 | $font-size--400: props.def(--font-size--400, iro.fn-px-to-rem(24px)) !default; | ||
78 | $font-size--500: props.def(--font-size--500, iro.fn-px-to-rem(28px)) !default; | ||
79 | $font-size--600: props.def(--font-size--600, iro.fn-px-to-rem(32px)) !default; | ||
80 | $font-size--700: props.def(--font-size--700, iro.fn-px-to-rem(36px)) !default; | ||
81 | $font-size--800: props.def(--font-size--800, iro.fn-px-to-rem(40px)) !default; | ||
82 | $font-size--900: props.def(--font-size--900, iro.fn-px-to-rem(45px)) !default; | ||
83 | $font-size--1000: props.def(--font-size--1000, iro.fn-px-to-rem(50px)) !default; | ||
84 | $font-size--1100: props.def(--font-size--1100, iro.fn-px-to-rem(60px)) !default; | ||
85 | |||
86 | $border-width--thick: props.def(--border-width--thick, 4px) !default; | ||
87 | $border-width--medium: props.def(--border-width--medium, 2px) !default; | ||
88 | $border-width--thin: props.def(--border-width--thin, 1px) !default; | ||
89 | |||
90 | $shadow--x: props.def(--shadow--x, 0) !default; | ||
91 | $shadow--y: props.def(--shadow--y, 1px) !default; | ||
92 | $shadow--blur: props.def(--shadow--blur, 4px) !default; | ||
93 | |||
94 | $rounding: props.def(--rounding, 4px) !default; | ||
95 | |||
96 | $key-focus--outline-width: props.def(--key-focus--outline-width, props.get($border-width--thick)) !default; | ||
97 | $key-focus--border: props.def(--key-focus--border, props.get($border-width--medium)) !default; | ||
98 | $key-focus--border-offset: props.def(--key-focus--border-offset, props.get($border-width--medium)) !default; | ||
99 | |||
100 | $paragraph--margin-bs: props.def(--paragraph--margin-bs, props.get($size--300)) !default; | ||
101 | |||
102 | $heading--margin-bs: props.def(--heading--margin-bs, props.get($size--700)) !default; | ||
103 | $heading--margin-bs-sibling: props.def(--heading--margin-bs-sibling, props.get($size--325)) !default; | ||
104 | $heading--xxl: props.def(--heading--xxl, props.get($font-size--300)) !default; | ||
105 | $heading--xl: props.def(--heading--xl, props.get($font-size--200)) !default; | ||
106 | $heading--lg: props.def(--heading--lg, props.get($font-size--150)) !default; | ||
107 | $heading--md: props.def(--heading--md, props.get($font-size--100)) !default; | ||
108 | $heading--sm: props.def(--heading--sm, props.get($font-size--75)) !default; | ||
109 | $heading--xs: props.def(--heading--xs, props.get($font-size--50)) !default; | ||
110 | $heading--display--xxl: props.def(--heading--display--xxl, props.get($font-size--1100)) !default; | ||
111 | $heading--display--xl: props.def(--heading--display--xl, props.get($font-size--700)) !default; | ||
112 | $heading--display--lg: props.def(--heading--display--lg, props.get($font-size--300)) !default; | ||
113 | $heading--display--md: props.def(--heading--display--md, props.get($font-size--150)) !default; | ||
114 | $heading--display--sm: props.def(--heading--display--sm, props.get($font-size--75)) !default; | ||
115 | $heading--display--xs: props.def(--heading--display--xs, props.get($font-size--50)) !default; | ||
116 | $heading--display-sm--xxl: props.def(--heading--display-sm--xxl, props.get($font-size--900)) !default; | ||
117 | $heading--display-sm--xl: props.def(--heading--display-sm--xl, props.get($font-size--600)) !default; | ||
118 | $heading--display-sm--lg: props.def(--heading--display-sm--lg, props.get($font-size--200)) !default; | ||
119 | $heading--display-sm--md: props.def(--heading--display-sm--md, props.get($font-size--100)) !default; | ||
120 | $heading--display-sm--sm: props.def(--heading--display-sm--sm, props.get($font-size--75)) !default; | ||
121 | $heading--display-sm--xs: props.def(--heading--display-sm--xs, props.get($font-size--50)) !default; | ||
122 | |||
123 | $list--indent: props.def(--list--indent, props.get($size--400)) !default; | ||
124 | $list--compact-indent: props.def(--list--indent, props.get($size--250)) !default; | ||
125 | |||
126 | // | ||
127 | |||
128 | $static-colors: props.def(--static-colors); | ||
129 | @each $palette-name, $palette in map.get(palettes.$static-colors, --palettes) { | ||
130 | $palette: fn.palette($palette, map.get(palettes.$static-colors, --contrasts), 1, map.get(palettes.$static-colors, --base)); | ||
131 | $static-colors: props.merge($static-colors, ( $palette-name: $palette )); | ||
132 | } | ||
133 | |||
134 | // | ||
135 | |||
136 | $transparent-colors: props.def(--transparent-colors); | ||
137 | @each $palette-name, $palette in (--black: #000 #fff, --white: #fff #000) { | ||
138 | $color: list.nth($palette, 1); | ||
139 | $text: list.nth($palette, 2); | ||
140 | |||
141 | $palette: fn.transparent-palette($color, $text, map.get(palettes.$static-colors, --transparents)); | ||
142 | $transparent-colors: props.merge($transparent-colors, ( $palette-name: $palette )); | ||
143 | } | ||
144 | |||
145 | // | ||
146 | |||
147 | $themes: props.def(--themes); | ||
148 | @each $theme-name, $theme in palettes.$themes { | ||
149 | $themes: props.merge($themes, ( --#{$theme-name}: () )); | ||
150 | |||
151 | @each $palette-name, $palette in map.get($theme, --palettes) { | ||
152 | $base-color: list.nth($palette, 1); | ||
153 | $contrasts: list.nth($palette, 2); | ||
154 | $ranges: list.nth($palette, 3); | ||
155 | |||
156 | $palette: fn.palette($base-color, map.get($theme, --contrasts, $contrasts), map.get($theme, --ranges, $ranges), list.nth(map.get($theme, --palettes, --base), 1)); | ||
157 | $themes: props.merge($themes, ( --#{$theme-name}: ( $palette-name: $palette ) )); | ||
158 | } | ||
159 | |||
160 | @each $color, $value in map.get($theme, --constants) { | ||
161 | $themes: props.merge($themes, ( --#{$theme-name}: ( $color: $value ) )); | ||
162 | } | ||
163 | |||
164 | @each $color, $ref in map.get($theme, --semantic) { | ||
165 | $res: (); | ||
166 | |||
167 | @if meta.type-of($ref) == 'map' { | ||
168 | @each $key, $r in $ref { | ||
169 | $repo-name: list.nth($r, 1); | ||
170 | $re1: list.nth($r, 2); | ||
171 | $re2: iro.fn-list-slice($r, 3); | ||
172 | |||
173 | $res2: null; | ||
174 | |||
175 | @if $repo-name == --static { | ||
176 | $res2: props.get($static-colors, $re1, $re2...); | ||
177 | } @else { | ||
178 | $res2: props.get($themes, --#{$theme-name}, $re1, $re2...); | ||
179 | } | 19 | } |
180 | |||
181 | $res: map.merge($res, ($key: $res2)); | ||
182 | } | 20 | } |
183 | } @else { | 21 | } @else { |
184 | $repo-name: list.nth($ref, 1); | 22 | @include iro.bem-theme($theme-name) { |
185 | $ref1: list.nth($ref, 2); | 23 | @include props.materialize(map.get($theme, 'light')); |
186 | $ref2: iro.fn-list-slice($ref, 3); | 24 | |
187 | 25 | @if map.has-key($theme, 'dark') { | |
188 | $res: null; | 26 | @media (prefers-color-scheme: dark) { |
189 | 27 | @include props.materialize(map.get($theme, 'dark')); | |
190 | @if $repo-name == --static { | 28 | } |
191 | $res: props.get($static-colors, $ref1, $ref2...); | 29 | } |
192 | } @else { | ||
193 | $res: props.get($themes, --#{$theme-name}, $ref1, $ref2...); | ||
194 | } | 30 | } |
195 | } | 31 | } |
196 | |||
197 | $themes: props.merge($themes, ( --#{$theme-name}: ( $color: $res ) )); | ||
198 | } | 32 | } |
199 | } | 33 | } |