@mezzanine-ui/system 1.0.0-canary.0 → 1.0.0-canary.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/_system.scss +46 -7
- package/effect/_effect.scss +66 -0
- package/effect/_index.scss +1 -0
- package/effect/constants.d.ts +1 -0
- package/effect/constants.js +3 -0
- package/effect/index.d.ts +2 -0
- package/effect/index.js +1 -0
- package/effect/typings.d.ts +32 -0
- package/package.json +1 -1
- package/palette/_index.scss +3 -1
- package/palette/_palette.scss +3 -203
- package/palette/_primitives.scss +267 -0
- package/palette/_semantic.scss +537 -0
- package/palette/constants.d.ts +1 -1
- package/palette/constants.js +2 -2
- package/palette/index.js +1 -1
- package/palette/typings.d.ts +86 -0
- package/radius/_index.scss +1 -0
- package/radius/_radius.scss +71 -0
- package/radius/constants.d.ts +1 -0
- package/radius/constants.js +3 -0
- package/radius/index.d.ts +3 -0
- package/radius/index.js +2 -0
- package/radius/radius.d.ts +18 -0
- package/radius/radius.js +32 -0
- package/size/_size.scss +6 -1
- package/size/size.d.ts +2 -0
- package/spacing/_index.scss +3 -1
- package/spacing/_primitives.scss +131 -0
- package/spacing/_semantic.scss +541 -0
- package/spacing/_spacing.scss +2 -18
- package/spacing/constants.d.ts +1 -0
- package/spacing/constants.js +2 -1
- package/spacing/index.js +1 -1
- package/spacing/toSpacingCssVar.d.ts +1 -0
- package/spacing/toSpacingCssVar.js +1 -0
- package/spacing/typings.d.ts +81 -0
- package/typography/SF-Mono/SF-Mono-Medium.otf +0 -0
- package/typography/SF-Mono/SF-Mono-Regular.otf +0 -0
- package/typography/SF-Mono/SF-Mono-Semibold.otf +0 -0
- package/typography/_index.scss +4 -1
- package/typography/_primitives.scss +318 -0
- package/typography/_semantic.scss +237 -0
- package/typography/_sf-mono.scss +33 -0
- package/typography/_typography.scss +4 -248
- package/typography/_utils.scss +4 -0
- package/typography/index.js +1 -0
- package/typography/typings.d.ts +9 -1
- package/typography/typings.js +4 -0
- package/palette/_constants.scss +0 -267
- package/palette/_utils.scss +0 -47
|
@@ -0,0 +1,541 @@
|
|
|
1
|
+
@use '../utils/list';
|
|
2
|
+
@use '../utils/map';
|
|
3
|
+
@use './primitives' as primitive;
|
|
4
|
+
|
|
5
|
+
$prefix: mzn-spacing;
|
|
6
|
+
|
|
7
|
+
// 定義所有情境類型
|
|
8
|
+
$semantic-contexts: (size, gap, padding);
|
|
9
|
+
|
|
10
|
+
// 定義 size 的子分類
|
|
11
|
+
$size-categories: (element, container);
|
|
12
|
+
|
|
13
|
+
// 定義 padding 的子分類
|
|
14
|
+
$padding-categories: (horizontal, vertical);
|
|
15
|
+
|
|
16
|
+
// 定義各個分類下的 tones
|
|
17
|
+
$element-tones: (
|
|
18
|
+
hairline,
|
|
19
|
+
tiny,
|
|
20
|
+
tight,
|
|
21
|
+
compact,
|
|
22
|
+
slim,
|
|
23
|
+
narrow,
|
|
24
|
+
base,
|
|
25
|
+
base-fixed,
|
|
26
|
+
gentle,
|
|
27
|
+
relaxed,
|
|
28
|
+
airy,
|
|
29
|
+
roomy,
|
|
30
|
+
loose,
|
|
31
|
+
extra-wide,
|
|
32
|
+
extra-wide-condense,
|
|
33
|
+
expansive,
|
|
34
|
+
extra,
|
|
35
|
+
max
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
$container-tones: (
|
|
39
|
+
collapsed,
|
|
40
|
+
tiny,
|
|
41
|
+
tight,
|
|
42
|
+
slim,
|
|
43
|
+
narrow,
|
|
44
|
+
compact,
|
|
45
|
+
standard,
|
|
46
|
+
balanced,
|
|
47
|
+
broad,
|
|
48
|
+
wide,
|
|
49
|
+
expanded,
|
|
50
|
+
max
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
$horizontal-tones: (
|
|
54
|
+
none,
|
|
55
|
+
micro,
|
|
56
|
+
tiny,
|
|
57
|
+
tiny-fixed,
|
|
58
|
+
tight,
|
|
59
|
+
tight-fixed,
|
|
60
|
+
base,
|
|
61
|
+
base-fixed,
|
|
62
|
+
calm,
|
|
63
|
+
comfort,
|
|
64
|
+
comfort-fixed,
|
|
65
|
+
roomy,
|
|
66
|
+
spacious,
|
|
67
|
+
relaxed,
|
|
68
|
+
airy,
|
|
69
|
+
breath,
|
|
70
|
+
wide,
|
|
71
|
+
max
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
$vertical-tones: (
|
|
75
|
+
none,
|
|
76
|
+
micro,
|
|
77
|
+
tiny,
|
|
78
|
+
tight,
|
|
79
|
+
base,
|
|
80
|
+
calm,
|
|
81
|
+
comfort,
|
|
82
|
+
roomy,
|
|
83
|
+
spacious,
|
|
84
|
+
generous,
|
|
85
|
+
relaxed
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
$semantic-spacings: (
|
|
89
|
+
size: (
|
|
90
|
+
element: (
|
|
91
|
+
hairline: (
|
|
92
|
+
default: primitive.variable(1),
|
|
93
|
+
compact: primitive.variable(1),
|
|
94
|
+
),
|
|
95
|
+
tiny: (
|
|
96
|
+
default: primitive.variable(4),
|
|
97
|
+
compact: primitive.variable(4),
|
|
98
|
+
),
|
|
99
|
+
tight: (
|
|
100
|
+
default: primitive.variable(6),
|
|
101
|
+
compact: primitive.variable(6),
|
|
102
|
+
),
|
|
103
|
+
compact: (
|
|
104
|
+
default: primitive.variable(8),
|
|
105
|
+
compact: primitive.variable(6),
|
|
106
|
+
),
|
|
107
|
+
slim: (
|
|
108
|
+
default: primitive.variable(12),
|
|
109
|
+
compact: primitive.variable(8),
|
|
110
|
+
),
|
|
111
|
+
narrow: (
|
|
112
|
+
default: primitive.variable(14),
|
|
113
|
+
compact: primitive.variable(12),
|
|
114
|
+
),
|
|
115
|
+
base: (
|
|
116
|
+
default: primitive.variable(16),
|
|
117
|
+
compact: primitive.variable(12),
|
|
118
|
+
),
|
|
119
|
+
base-fixed: (
|
|
120
|
+
default: primitive.variable(16),
|
|
121
|
+
compact: primitive.variable(16),
|
|
122
|
+
),
|
|
123
|
+
gentle: (
|
|
124
|
+
default: primitive.variable(20),
|
|
125
|
+
compact: primitive.variable(18),
|
|
126
|
+
),
|
|
127
|
+
relaxed: (
|
|
128
|
+
default: primitive.variable(24),
|
|
129
|
+
compact: primitive.variable(20),
|
|
130
|
+
),
|
|
131
|
+
airy: (
|
|
132
|
+
default: primitive.variable(28),
|
|
133
|
+
compact: primitive.variable(24),
|
|
134
|
+
),
|
|
135
|
+
roomy: (
|
|
136
|
+
default: primitive.variable(32),
|
|
137
|
+
compact: primitive.variable(28),
|
|
138
|
+
),
|
|
139
|
+
loose: (
|
|
140
|
+
default: primitive.variable(36),
|
|
141
|
+
compact: primitive.variable(32),
|
|
142
|
+
),
|
|
143
|
+
extra-wide: (
|
|
144
|
+
default: primitive.variable(40),
|
|
145
|
+
compact: primitive.variable(36),
|
|
146
|
+
),
|
|
147
|
+
extra-wide-condense: (
|
|
148
|
+
default: primitive.variable(40),
|
|
149
|
+
compact: primitive.variable(24),
|
|
150
|
+
),
|
|
151
|
+
expansive: (
|
|
152
|
+
default: primitive.variable(60),
|
|
153
|
+
compact: primitive.variable(24),
|
|
154
|
+
),
|
|
155
|
+
extra: (
|
|
156
|
+
default: primitive.variable(64),
|
|
157
|
+
compact: primitive.variable(48),
|
|
158
|
+
),
|
|
159
|
+
max: (
|
|
160
|
+
default: primitive.variable(80),
|
|
161
|
+
compact: primitive.variable(64),
|
|
162
|
+
),
|
|
163
|
+
),
|
|
164
|
+
container: (
|
|
165
|
+
collapsed: (
|
|
166
|
+
default: primitive.variable(52),
|
|
167
|
+
compact: primitive.variable(52),
|
|
168
|
+
),
|
|
169
|
+
tiny: (
|
|
170
|
+
default: primitive.variable(80),
|
|
171
|
+
compact: primitive.variable(80),
|
|
172
|
+
),
|
|
173
|
+
tight: (
|
|
174
|
+
default: primitive.variable(160),
|
|
175
|
+
compact: primitive.variable(160),
|
|
176
|
+
),
|
|
177
|
+
slim: (
|
|
178
|
+
default: primitive.variable(240),
|
|
179
|
+
compact: primitive.variable(240),
|
|
180
|
+
),
|
|
181
|
+
narrow: (
|
|
182
|
+
default: primitive.variable(320),
|
|
183
|
+
compact: primitive.variable(320),
|
|
184
|
+
),
|
|
185
|
+
compact: (
|
|
186
|
+
default: primitive.variable(360),
|
|
187
|
+
compact: primitive.variable(360),
|
|
188
|
+
),
|
|
189
|
+
standard: (
|
|
190
|
+
default: primitive.variable(400),
|
|
191
|
+
compact: primitive.variable(400),
|
|
192
|
+
),
|
|
193
|
+
balanced: (
|
|
194
|
+
default: primitive.variable(480),
|
|
195
|
+
compact: primitive.variable(480),
|
|
196
|
+
),
|
|
197
|
+
broad: (
|
|
198
|
+
default: primitive.variable(560),
|
|
199
|
+
compact: primitive.variable(560),
|
|
200
|
+
),
|
|
201
|
+
wide: (
|
|
202
|
+
default: primitive.variable(640),
|
|
203
|
+
compact: primitive.variable(640),
|
|
204
|
+
),
|
|
205
|
+
expanded: (
|
|
206
|
+
default: primitive.variable(720),
|
|
207
|
+
compact: primitive.variable(720),
|
|
208
|
+
),
|
|
209
|
+
max: (
|
|
210
|
+
default: primitive.variable(960),
|
|
211
|
+
compact: primitive.variable(960),
|
|
212
|
+
),
|
|
213
|
+
),
|
|
214
|
+
),
|
|
215
|
+
gap: (
|
|
216
|
+
none: (
|
|
217
|
+
default: primitive.variable(0),
|
|
218
|
+
compact: primitive.variable(0),
|
|
219
|
+
),
|
|
220
|
+
tiny: (
|
|
221
|
+
default: primitive.variable(2),
|
|
222
|
+
compact: primitive.variable(2),
|
|
223
|
+
),
|
|
224
|
+
tight: (
|
|
225
|
+
default: primitive.variable(4),
|
|
226
|
+
compact: primitive.variable(2),
|
|
227
|
+
),
|
|
228
|
+
tight-fixed: (
|
|
229
|
+
default: primitive.variable(4),
|
|
230
|
+
compact: primitive.variable(4),
|
|
231
|
+
),
|
|
232
|
+
slim: (
|
|
233
|
+
default: primitive.variable(6),
|
|
234
|
+
compact: primitive.variable(4),
|
|
235
|
+
),
|
|
236
|
+
base: (
|
|
237
|
+
default: primitive.variable(8),
|
|
238
|
+
compact: primitive.variable(6),
|
|
239
|
+
),
|
|
240
|
+
calm: (
|
|
241
|
+
default: primitive.variable(12),
|
|
242
|
+
compact: primitive.variable(10),
|
|
243
|
+
),
|
|
244
|
+
comfort: (
|
|
245
|
+
default: primitive.variable(16),
|
|
246
|
+
compact: primitive.variable(14),
|
|
247
|
+
),
|
|
248
|
+
roomy: (
|
|
249
|
+
default: primitive.variable(20),
|
|
250
|
+
compact: primitive.variable(16),
|
|
251
|
+
),
|
|
252
|
+
spacious: (
|
|
253
|
+
default: primitive.variable(24),
|
|
254
|
+
compact: primitive.variable(20),
|
|
255
|
+
),
|
|
256
|
+
loose: (
|
|
257
|
+
default: primitive.variable(40),
|
|
258
|
+
compact: primitive.variable(36),
|
|
259
|
+
),
|
|
260
|
+
),
|
|
261
|
+
padding: (
|
|
262
|
+
horizontal: (
|
|
263
|
+
none: (
|
|
264
|
+
default: primitive.variable(0),
|
|
265
|
+
compact: primitive.variable(0),
|
|
266
|
+
),
|
|
267
|
+
micro: (
|
|
268
|
+
default: primitive.variable(2),
|
|
269
|
+
compact: primitive.variable(2),
|
|
270
|
+
),
|
|
271
|
+
tiny: (
|
|
272
|
+
default: primitive.variable(4),
|
|
273
|
+
compact: primitive.variable(2),
|
|
274
|
+
),
|
|
275
|
+
tiny-fixed: (
|
|
276
|
+
default: primitive.variable(4),
|
|
277
|
+
compact: primitive.variable(4),
|
|
278
|
+
),
|
|
279
|
+
tight: (
|
|
280
|
+
default: primitive.variable(6),
|
|
281
|
+
compact: primitive.variable(4),
|
|
282
|
+
),
|
|
283
|
+
tight-fixed: (
|
|
284
|
+
default: primitive.variable(6),
|
|
285
|
+
compact: primitive.variable(6),
|
|
286
|
+
),
|
|
287
|
+
base: (
|
|
288
|
+
default: primitive.variable(8),
|
|
289
|
+
compact: primitive.variable(4),
|
|
290
|
+
),
|
|
291
|
+
base-fixed: (
|
|
292
|
+
default: primitive.variable(8),
|
|
293
|
+
compact: primitive.variable(8),
|
|
294
|
+
),
|
|
295
|
+
cozy: (
|
|
296
|
+
default: primitive.variable(10),
|
|
297
|
+
compact: primitive.variable(8),
|
|
298
|
+
),
|
|
299
|
+
comfort: (
|
|
300
|
+
default: primitive.variable(12),
|
|
301
|
+
compact: primitive.variable(10),
|
|
302
|
+
),
|
|
303
|
+
comfort-fixed: (
|
|
304
|
+
default: primitive.variable(12),
|
|
305
|
+
compact: primitive.variable(12),
|
|
306
|
+
),
|
|
307
|
+
roomy: (
|
|
308
|
+
default: primitive.variable(14),
|
|
309
|
+
compact: primitive.variable(12),
|
|
310
|
+
),
|
|
311
|
+
spacious: (
|
|
312
|
+
default: primitive.variable(16),
|
|
313
|
+
compact: primitive.variable(14),
|
|
314
|
+
),
|
|
315
|
+
relaxed: (
|
|
316
|
+
default: primitive.variable(24),
|
|
317
|
+
compact: primitive.variable(20),
|
|
318
|
+
),
|
|
319
|
+
airy: (
|
|
320
|
+
default: primitive.variable(28),
|
|
321
|
+
compact: primitive.variable(24),
|
|
322
|
+
),
|
|
323
|
+
breath: (
|
|
324
|
+
default: primitive.variable(32),
|
|
325
|
+
compact: primitive.variable(28),
|
|
326
|
+
),
|
|
327
|
+
wide: (
|
|
328
|
+
default: primitive.variable(40),
|
|
329
|
+
compact: primitive.variable(36),
|
|
330
|
+
),
|
|
331
|
+
max: (
|
|
332
|
+
default: primitive.variable(48),
|
|
333
|
+
compact: primitive.variable(40),
|
|
334
|
+
),
|
|
335
|
+
),
|
|
336
|
+
vertical: (
|
|
337
|
+
none: (
|
|
338
|
+
default: primitive.variable(0),
|
|
339
|
+
compact: primitive.variable(0),
|
|
340
|
+
),
|
|
341
|
+
micro: (
|
|
342
|
+
default: primitive.variable(2),
|
|
343
|
+
compact: primitive.variable(2),
|
|
344
|
+
),
|
|
345
|
+
tiny: (
|
|
346
|
+
default: primitive.variable(4),
|
|
347
|
+
compact: primitive.variable(2),
|
|
348
|
+
),
|
|
349
|
+
tight: (
|
|
350
|
+
default: primitive.variable(6),
|
|
351
|
+
compact: primitive.variable(4),
|
|
352
|
+
),
|
|
353
|
+
base: (
|
|
354
|
+
default: primitive.variable(8),
|
|
355
|
+
compact: primitive.variable(4),
|
|
356
|
+
),
|
|
357
|
+
calm: (
|
|
358
|
+
default: primitive.variable(10),
|
|
359
|
+
compact: primitive.variable(6),
|
|
360
|
+
),
|
|
361
|
+
comfort: (
|
|
362
|
+
default: primitive.variable(12),
|
|
363
|
+
compact: primitive.variable(8),
|
|
364
|
+
),
|
|
365
|
+
roomy: (
|
|
366
|
+
default: primitive.variable(14),
|
|
367
|
+
compact: primitive.variable(10),
|
|
368
|
+
),
|
|
369
|
+
spacious: (
|
|
370
|
+
default: primitive.variable(16),
|
|
371
|
+
compact: primitive.variable(12),
|
|
372
|
+
),
|
|
373
|
+
generous: (
|
|
374
|
+
default: primitive.variable(20),
|
|
375
|
+
compact: primitive.variable(14),
|
|
376
|
+
),
|
|
377
|
+
relaxed: (
|
|
378
|
+
default: primitive.variable(24),
|
|
379
|
+
compact: primitive.variable(16),
|
|
380
|
+
),
|
|
381
|
+
),
|
|
382
|
+
),
|
|
383
|
+
);
|
|
384
|
+
|
|
385
|
+
// 驗證 context 是否有效
|
|
386
|
+
@function is-valid-context($context) {
|
|
387
|
+
@return list.index($semantic-contexts, $context) != null;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
// 驗證 category 是否對該 context 有效
|
|
391
|
+
@function is-valid-category($context, $category) {
|
|
392
|
+
@if $context == size {
|
|
393
|
+
@return list.index($size-categories, $category) != null;
|
|
394
|
+
} @else if $context == padding {
|
|
395
|
+
@return list.index($padding-categories, $category) != null;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
// gap 沒有 category
|
|
399
|
+
@return false;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
// 驗證 tone 是否對該 context/category 有效
|
|
403
|
+
@function is-valid-tone($context, $category, $tone, $spacings: $semantic-spacings) {
|
|
404
|
+
@if not is-valid-context($context) {
|
|
405
|
+
@return false;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
$context-map: map.get($spacings, $context);
|
|
409
|
+
|
|
410
|
+
@if not $context-map {
|
|
411
|
+
@return false;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
// gap 沒有 category,直接檢查 tone
|
|
415
|
+
@if $context == gap {
|
|
416
|
+
@return map.has-key($context-map, $tone);
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
// size 和 padding 需要先檢查 category
|
|
420
|
+
@if not $category {
|
|
421
|
+
@return false;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
$category-map: map.get($context-map, $category);
|
|
425
|
+
|
|
426
|
+
@if not $category-map {
|
|
427
|
+
@return false;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
@return map.has-key($category-map, $tone);
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
// 取得特定 context 的所有 categories(僅適用於 size 和 padding)
|
|
434
|
+
@function get-context-categories($context) {
|
|
435
|
+
@if $context == size {
|
|
436
|
+
@return $size-categories;
|
|
437
|
+
} @else if $context == padding {
|
|
438
|
+
@return $padding-categories;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
@return ();
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
// 取得特定 context/category 的所有 tones
|
|
445
|
+
@function get-tones($context, $category: null) {
|
|
446
|
+
@if $context == gap {
|
|
447
|
+
@return map.keys(map.get($semantic-spacings, gap));
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
@if $context == size and $category == element {
|
|
451
|
+
@return $element-tones;
|
|
452
|
+
} @else if $context == size and $category == container {
|
|
453
|
+
@return $container-tones;
|
|
454
|
+
} @else if $context == padding and $category == horizontal {
|
|
455
|
+
@return $horizontal-tones;
|
|
456
|
+
} @else if $context == padding and $category == vertical {
|
|
457
|
+
@return $vertical-tones;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
@return ();
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
// 取得 CSS 變數名稱
|
|
464
|
+
// size: --mzn-spacing-size-element-base
|
|
465
|
+
// gap: --mzn-spacing-gap-base
|
|
466
|
+
// padding: --mzn-spacing-padding-horizontal-base
|
|
467
|
+
@function get-var-name($context, $category, $tone: null) {
|
|
468
|
+
// gap 沒有 category,tone 在第二個參數
|
|
469
|
+
@if $context == gap {
|
|
470
|
+
@return --#{$prefix}-#{$context}-#{$category};
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
// size 和 padding 有 category
|
|
474
|
+
@return --#{$prefix}-#{$context}-#{$category}-#{$tone};
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
// 使用 CSS 變數引用 spacing
|
|
478
|
+
@function variable($context, $category, $tone: null) {
|
|
479
|
+
@if not is-valid-context($context) {
|
|
480
|
+
@error 'Invalid context "#{$context}". Valid contexts are: #{$semantic-contexts}';
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
@return var(#{get-var-name($context, $category, $tone)});
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
// 檢查 spacing 值是否已定義
|
|
487
|
+
@function is-spacing-defined($value) {
|
|
488
|
+
@return $value != null;
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
// 生成所有 semantic spacing CSS 變數
|
|
492
|
+
// mode: 'default' 或 'compact'
|
|
493
|
+
@mixin variables($mode: default, $spacings: ()) {
|
|
494
|
+
@include primitive.variables();
|
|
495
|
+
|
|
496
|
+
$spacings: map.deep-merge($semantic-spacings, $spacings);
|
|
497
|
+
|
|
498
|
+
@each $context, $context-value in $spacings {
|
|
499
|
+
@if not is-valid-context($context) {
|
|
500
|
+
@error 'Invalid context "#{$context}" in semantic spacings map. Valid contexts are: #{$semantic-contexts}';
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
@if $context == gap {
|
|
504
|
+
@each $tone, $modes in $context-value {
|
|
505
|
+
@if not is-valid-tone($context, null, $tone, $spacings) {
|
|
506
|
+
$valid-tones: get-tones($context);
|
|
507
|
+
|
|
508
|
+
@error 'Invalid tone "#{$tone}" for context "#{$context}". Valid tones are: #{$valid-tones}';
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
$spacing: map.get($modes, $mode);
|
|
512
|
+
|
|
513
|
+
@if is-spacing-defined($spacing) {
|
|
514
|
+
#{get-var-name($context, $tone)}: #{$spacing};
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
} @else {
|
|
518
|
+
@each $category, $category-value in $context-value {
|
|
519
|
+
@if not is-valid-category($context, $category) {
|
|
520
|
+
$valid-categories: get-context-categories($context);
|
|
521
|
+
|
|
522
|
+
@error 'Invalid category "#{$category}" for context "#{$context}". Valid categories are: #{$valid-categories}';
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
@each $tone, $modes in $category-value {
|
|
526
|
+
@if not is-valid-tone($context, $category, $tone, $spacings) {
|
|
527
|
+
$valid-tones: get-tones($context, $category);
|
|
528
|
+
|
|
529
|
+
@error 'Invalid tone "#{$tone}" for context "#{$context}" and category "#{$category}". Valid tones are: #{$valid-tones}';
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
$spacing: map.get($modes, $mode);
|
|
533
|
+
|
|
534
|
+
@if is-spacing-defined($spacing) {
|
|
535
|
+
#{get-var-name($context, $category, $tone)}: #{$spacing};
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
}
|
package/spacing/_spacing.scss
CHANGED
|
@@ -1,20 +1,4 @@
|
|
|
1
|
-
@
|
|
2
|
-
@use '../typography/utils' as utils-typography;
|
|
3
|
-
|
|
4
|
-
$prefix: mzn-spacing;
|
|
5
|
-
// The spacing level starts from 1.
|
|
6
|
-
$default-levels: (4px, 8px, 12px, 16px, 24px, 32px, 40px, 48px, 64px, 96px, 160px);
|
|
7
|
-
|
|
8
|
-
@mixin variables($levels: $default-levels) {
|
|
9
|
-
// Use `index` as level since list of sass starts with 1.
|
|
10
|
-
@for $level from 1 through list.length($levels) {
|
|
11
|
-
$size: list.nth($levels, $level);
|
|
12
|
-
$size: utils-typography.px-to-rem($size);
|
|
13
|
-
|
|
14
|
-
--#{$prefix}-#{$level}: #{$size};
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
1
|
+
/* @deprecated */
|
|
18
2
|
@function level($level) {
|
|
19
|
-
@return
|
|
3
|
+
@return 0;
|
|
20
4
|
}
|
package/spacing/constants.d.ts
CHANGED
package/spacing/constants.js
CHANGED
package/spacing/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { spacingPrefix } from './constants.js';
|
|
1
|
+
export { spacingPrefix, spacingPrimitivePrefix } from './constants.js';
|
|
2
2
|
export { toSpacingCssVar } from './toSpacingCssVar.js';
|
package/spacing/typings.d.ts
CHANGED
|
@@ -1 +1,82 @@
|
|
|
1
|
+
/** @deprecated */
|
|
1
2
|
export type SpacingLevel = number;
|
|
3
|
+
/**
|
|
4
|
+
* Spacing primitive scales - 間距原始級距(對應 px 值)
|
|
5
|
+
*/
|
|
6
|
+
export type SpacingScale = 0 | 1 | 2 | 4 | 6 | 8 | 10 | 12 | 14 | 16 | 18 | 20 | 24 | 28 | 32 | 36 | 40 | 48 | 52 | 56 | 60 | 64 | 80 | 160 | 240 | 320 | 360 | 400 | 480 | 560 | 640 | 720 | 960 | 1140;
|
|
7
|
+
/**
|
|
8
|
+
* Spacing primitives configuration
|
|
9
|
+
*/
|
|
10
|
+
export type SpacingPrimitives = Partial<Record<SpacingScale, string | number>>;
|
|
11
|
+
/**
|
|
12
|
+
* Spacing semantic contexts - 語意化間距的使用情境
|
|
13
|
+
*/
|
|
14
|
+
export type SpacingContext = 'size' | 'gap' | 'padding';
|
|
15
|
+
/**
|
|
16
|
+
* Spacing mode - 間距模式
|
|
17
|
+
*/
|
|
18
|
+
export type SpacingMode = 'default' | 'compact';
|
|
19
|
+
/**
|
|
20
|
+
* Size categories - 尺寸分類
|
|
21
|
+
*/
|
|
22
|
+
export type SizeCategory = 'element' | 'container';
|
|
23
|
+
/**
|
|
24
|
+
* Padding categories - 內邊距分類
|
|
25
|
+
*/
|
|
26
|
+
export type PaddingCategory = 'horizontal' | 'vertical';
|
|
27
|
+
/**
|
|
28
|
+
* Element size tones - 元素尺寸調性
|
|
29
|
+
*/
|
|
30
|
+
export type ElementTone = 'hairline' | 'tiny' | 'tight' | 'compact' | 'slim' | 'narrow' | 'base' | 'base-fixed' | 'gentle' | 'relaxed' | 'airy' | 'roomy' | 'loose' | 'extra-wide' | 'extra-wide-condense' | 'expansive' | 'extra' | 'max';
|
|
31
|
+
/**
|
|
32
|
+
* Container size tones - 容器尺寸調性
|
|
33
|
+
*/
|
|
34
|
+
export type ContainerTone = 'collapsed' | 'tiny' | 'tight' | 'slim' | 'narrow' | 'compact' | 'standard' | 'balanced' | 'broad' | 'wide' | 'expanded' | 'max';
|
|
35
|
+
/**
|
|
36
|
+
* Gap tones - 間隙調性
|
|
37
|
+
*/
|
|
38
|
+
export type GapTone = 'none' | 'micro' | 'tiny' | 'tight' | 'compact' | 'base' | 'base-fixed' | 'comfortable' | 'roomy' | 'spacious' | 'relaxed' | 'airy' | 'generous' | 'breath' | 'wide';
|
|
39
|
+
/**
|
|
40
|
+
* Horizontal padding tones - 水平內邊距調性
|
|
41
|
+
*/
|
|
42
|
+
export type HorizontalPaddingTone = 'none' | 'micro' | 'tiny' | 'tiny-fixed' | 'tight' | 'tight-fixed' | 'base' | 'base-fixed' | 'calm' | 'comfort' | 'comfort-fixed' | 'roomy' | 'spacious' | 'relaxed' | 'airy' | 'breath' | 'wide' | 'max';
|
|
43
|
+
/**
|
|
44
|
+
* Vertical padding tones - 垂直內邊距調性
|
|
45
|
+
*/
|
|
46
|
+
export type VerticalPaddingTone = 'none' | 'micro' | 'tiny' | 'tight' | 'base' | 'calm' | 'comfort' | 'roomy' | 'spacious' | 'generous' | 'relaxed';
|
|
47
|
+
/**
|
|
48
|
+
* Category 與對應 Tone 的映射型別
|
|
49
|
+
*/
|
|
50
|
+
export type SpacingToneMap = {
|
|
51
|
+
size: {
|
|
52
|
+
element: ElementTone;
|
|
53
|
+
container: ContainerTone;
|
|
54
|
+
};
|
|
55
|
+
gap: GapTone;
|
|
56
|
+
padding: {
|
|
57
|
+
horizontal: HorizontalPaddingTone;
|
|
58
|
+
vertical: VerticalPaddingTone;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* 取得特定 context 的 tone 型別
|
|
63
|
+
* @example
|
|
64
|
+
* type GapT = SpacingToneFor<'gap'>; // GapTone
|
|
65
|
+
*/
|
|
66
|
+
export type SpacingToneFor<C extends SpacingContext> = SpacingToneMap[C] extends infer T ? T extends {
|
|
67
|
+
element: any;
|
|
68
|
+
} ? never : T : never;
|
|
69
|
+
/**
|
|
70
|
+
* 取得特定 context + category 的 tone 型別
|
|
71
|
+
* @example
|
|
72
|
+
* type EleTone = SpacingCategoryToneFor<'size', 'element'>; // ElementTone
|
|
73
|
+
*/
|
|
74
|
+
export type SpacingCategoryToneFor<C extends SpacingContext, Cat extends C extends 'size' ? SizeCategory : C extends 'padding' ? PaddingCategory : never> = C extends 'size' ? Cat extends SizeCategory ? SpacingToneMap['size'][Cat] : never : C extends 'padding' ? Cat extends PaddingCategory ? SpacingToneMap['padding'][Cat] : never : never;
|
|
75
|
+
/**
|
|
76
|
+
* Semantic spacing 完整型別 - context + category + tone 組合
|
|
77
|
+
* @example
|
|
78
|
+
* const spacing1: SemanticSpacing = 'size-element-base';
|
|
79
|
+
* const spacing2: SemanticSpacing = 'gap-comfortable';
|
|
80
|
+
* const spacing3: SemanticSpacing = 'padding-horizontal-calm';
|
|
81
|
+
*/
|
|
82
|
+
export type SemanticSpacing = `size-element-${ElementTone}` | `size-container-${ContainerTone}` | `gap-${GapTone}` | `padding-horizontal-${HorizontalPaddingTone}` | `padding-vertical-${VerticalPaddingTone}`;
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/typography/_index.scss
CHANGED