-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_theme-config.scss
211 lines (203 loc) · 5.16 KB
/
_theme-config.scss
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
/*
* FILE: _theme-config.scss
*
* This file serves as the central hub for design tokens in the project.
* It imports raw design tokens (e.g., colors, spacing, typography) and
* processes them using various formatting and conversion functions.
* The processed tokens are then consolidated into a centralized `$theme`
* map, providing a consistent source of truth across the project.
*
* VARIABLES:
* - $theme: A map consolidating all processed tokens.
* - $groups: Defines token groups with keys, prefixes, and properties.
* - $class-type-prefixes: Defines prefixes for different class types.
*
* The $groups map is crucial for organizing tokens, generating CSS custom
* properties, creating utility classes, and retrieving values using the `get`
* function in the `10-functions/_theme-accessor.scss` file. Each group includes:
* - key: Identifies the token group (e.g., "palette", "theme").
* - prefix: Generates CSS variable names (e.g., "color", "space").
* - properties: Specifies CSS properties for utility classes and retrieval.
*/
// Import design tokens
@use "./viewport" as viewport;
@use "./box-shadow" as shadow;
@use "./color-palette" as palette;
@use "./color-theme" as color;
@use "./spacing" as spacing;
@use "./step-size" as step-size;
@use "./font-size" as font-size;
@use "./font-family.scss" as font-family;
@use "./font-weight.scss" as font-weight;
@use "./line-height" as line-height;
@use "./letter-spacing" as letter-spacing;
@use "./radius.scss" as radius;
@use "./measure" as measure;
@use "./space-gutter" as space-gutter;
@use "./space-region" as space-region;
// Import functions
@use "../10-functions/process-token" as *;
@use "../10-functions/process-clamp" as *;
// Import helper functions
@use "../10-functions/helpers/handle-list" as help-lst;
@use "../10-functions/helpers/handle-string" as help-str;
@use "../10-functions/helpers/handle-number" as help-num;
@use "../10-functions/helpers/provide-value" as help-pvd;
// Format token items
$viewport: processToken(viewport.$token);
$palette: processToken(palette.$token);
$shadow: processToken(shadow.$token);
$color: processToken(color.$token);
$spacing: processToken(processClamp(spacing.$token, $viewport));
$step-size: processToken(processClamp(step-size.$token, $viewport));
$font-size: processToken(font-size.$token);
$font-family: processToken(font-family.$token);
$font-weight: processToken(font-weight.$token);
$line-height: processToken(line-height.$token);
$letter-spacing: processToken(letter-spacing.$token);
$radius: processToken(radius.$token);
$measure: processToken(measure.$token);
$space-gutter: processToken(space-gutter.$token);
$space-region: processToken(space-region.$token);
// Unit of measurement used in the theme
$unit: "rem";
// Consolidate tokens into a centralized map
$theme: (
"layout": (
"base-max": #{map-get($viewport, "max")}#{$unit},
),
"breakpoints": (
"mobile": #{map-get($viewport, "min")}#{$unit},
"tablet": #{map-get($viewport, "mid")}#{$unit},
"desktop": #{map-get($viewport, "lrg")}#{$unit},
"widescreen": #{map-get($viewport, "max")}#{$unit},
),
"palette": $palette,
"shadow": $shadow,
"theme": $color,
"spacing": $spacing,
"step-size": $step-size,
"text-size": $font-size,
"font-family": $font-family,
"font-weight": $font-weight,
"line-height": $line-height,
"letter-spacing": $letter-spacing,
"radius": $radius,
"measure": $measure,
"space-gutter": $space-gutter,
"space-region": $space-region,
);
// Define token groups
$groups: (
(
key: "palette",
prefix: "color",
properties: (
"color",
"background-color",
),
),
(
key: "shadow",
prefix: "shade",
properties: (
"box-shadow",
),
),
(
key: "theme",
prefix: "color",
properties: (
"color",
"background-color",
"box-shadow",
),
),
(
key: "spacing",
prefix: "space",
properties:
join(
help-lst.prefixItems("margin", help-pvd.logicalSuffixes()),
help-lst.prefixItems("padding", help-pvd.logicalSuffixes()),
comma
),
),
(
key: "space-gutter",
prefix: "space-gutter",
properties: (),
),
(
key: "space-region",
prefix: "space-region",
properties: (),
),
(
key: "step-size",
prefix: "step-size",
properties: (
"font-size",
),
),
(
key: "text-size",
prefix: "text-size",
properties: (
"font-size",
),
),
(
key: "font-family",
prefix: "font",
properties: (
"font-family",
),
),
(
key: "font-weight",
prefix: "font",
properties: (
"font-weight",
),
),
(
key: "line-height",
prefix: "leading",
properties: (
"line-height",
),
),
(
key: "letter-spacing",
prefix: "kerning",
properties: (
"letter-spacing",
),
),
(
key: "radius",
prefix: "radius",
properties: (
"border-radius",
),
),
(
key: "measure",
prefix: "measure",
properties: (
"max-inline-size",
),
),
(
key: "layout",
prefix: "layout",
properties: (),
)
);
// Define class type prefixes
$class-type-prefixes: (
layouts: "l-",
components: "",
utilities: "u-",
);