@inchurch/matcha-theme 20.278.0 → 21.1.0

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.
@@ -1,323 +1,147 @@
1
- // Saturation Levels
2
- $saturationLevels: 50, 100, 200, 300, 400, 500, 600, 700, 800, 900, A100, A200, A400, A700;
3
-
4
- // Hues Palette Colors
5
- $index: 0;
6
-
7
- // -------------------------------------------------------------------------------------------------------------------
8
- // @ Text color levels generator
9
- // -------------------------------------------------------------------------------------------------------------------
10
- @mixin _generate-text-color-levels($classes, $contrast) {
11
- @if ($contrast =="dark") {
12
- #{$classes} {
13
-
14
- &.secondary-text,
15
- .secondary-text {
16
- color: rgba(0, 0, 0, 0.54) !important;
17
- }
18
-
19
- &.hint-text,
20
- .hint-text,
21
- &.disabled-text,
22
- .disabled-text {
23
- color: rgba(0, 0, 0, 0.38) !important;
24
- }
25
-
26
- &.divider,
27
- .divider {
28
- color: rgba(0, 0, 0, 0.12) !important;
29
- }
30
- }
31
- }
32
-
33
- @else {
34
- #{$classes} {
35
-
36
- &.secondary-text,
37
- .secondary-text {
38
- color: rgba(255, 255, 255, 0.7) !important;
39
- }
40
-
41
- &.hint-text,
42
- .hint-text,
43
- &.disabled-text,
44
- .disabled-text {
45
- color: rgba(255, 255, 255, 0.5) !important;
46
- }
47
-
48
- &.divider,
49
- .divider {
50
- color: rgba(255, 255, 255, 0.12) !important;
51
- }
52
- }
53
- }
54
- }
55
-
56
- // -------------------------------------------------------------------------------------------------------------------
57
- // @ Static color classes generator
58
- // -------------------------------------------------------------------------------------------------------------------
59
- @mixin _generate-static-color-classes($colorName, $color, $contrastColor, $saturation) {
60
- $colorSelector: unquote(".#{$colorName}#{$saturation}");
61
-
62
- #{$colorSelector} {
63
- background-color: $color !important;
64
- color: $contrastColor !important;
65
-
66
- &[disabled] {
67
- background-color: rgba($color, 0.12) !important;
68
- color: rgba($contrastColor, 0.26) !important;
69
- }
70
- }
71
-
72
- #{$colorSelector}-bg {
73
- background-color: $color !important;
74
- }
75
-
76
- #{$colorSelector}-fg {
77
- color: $color !important;
78
- }
79
-
80
- @if ($saturation =="-500") {
81
- $colorSelectorDefault: unquote(".#{$colorName}");
82
-
83
- #{$colorSelectorDefault}-bg {
84
- background-color: $color !important;
85
- }
86
-
87
- #{$colorSelectorDefault}-fg {
88
- color: $color !important;
89
- }
90
- }
91
- }
92
-
93
- @mixin colors-classes-static($theme) {
94
- $palettes: getAllPalettes($theme);
95
- $light-contrasting-classes: (
96
- );
97
- $dark-contrasting-classes: (
98
- );
99
-
100
- @each $paletteName, $palette in $palettes {
101
- // $contrasts: map-get($red, "contrast");
102
- // $contrasts = all contrast colors of $red palette
103
- $contrasts: map-get($palette, "contrast");
104
-
105
- @each $saturation in $saturationLevels {
106
- // $color: map-get($red, 500)
107
- // $contrast: map-get($contrasts, 500); 500 contrast color of $red palette
108
- $color: map-get($palette, $saturation);
109
- $contrast: map-get($contrasts, $saturation);
110
-
111
- @if ($color !=null and $contrast !=null) {
112
- @include _generate-static-color-classes($paletteName, $color, $contrast, "-#{$saturation}");
113
-
114
- // If the contrast color is dark
115
- @if (rgba(black, 1)==rgba($contrast, 1)) {
116
- $dark-contrasting-classes: append($dark-contrasting-classes,
117
- unquote(".#{$paletteName}-#{$saturation}"),
118
- "comma"
119
- );
120
- }
121
-
122
- // if the contrast color is light
123
- @else {
124
- $light-contrasting-classes: append($light-contrasting-classes,
125
- unquote(".#{$paletteName}-#{$saturation}"),
126
- "comma"
127
- );
1
+ // Shade-classes SÓ das primitivas do Figma ($matcha-primitives — gerado de
2
+ // tokens/matcha/primitives/colors.json pelo gen-primitives). Cada classe consome
3
+ // var(--matcha-prim-{família}-{shade}); o contraste é computado em build a partir
4
+ // do hex da primitiva (mode-independent — primitiva é valor fixo). Famílias não-paleta
5
+ // (common/brand/neutral) ficam de fora. Substitui a antiga matriz Material 21×14
6
+ // (getAllPalettes/$theme), que gerava "todas as cores" — agora só o que existe no Figma.
7
+ @mixin colors-classes-static($theme: ()) {
8
+ // theme-agnóstico: classes consomem var(--matcha-prim-*). $theme vestigial (default ()).
9
+ $-skip: ("common", "brand", "neutral");
10
+
11
+ @each $family, $shades in $matcha-primitives {
12
+ @if not index($-skip, $family) {
13
+ @each $shade, $hex in $shades {
14
+ .#{$family}-#{$shade} {
15
+ background-color: var(--matcha-prim-#{$family}-#{$shade}) !important;
16
+ color: matcha-contrast-on($hex) !important;
17
+ }
18
+
19
+ .#{$family}-#{$shade}-bg {
20
+ background-color: var(--matcha-prim-#{$family}-#{$shade}) !important;
21
+ }
22
+
23
+ .#{$family}-#{$shade}-fg {
24
+ color: var(--matcha-prim-#{$family}-#{$shade}) !important;
25
+ }
128
26
  }
129
27
  }
130
28
  }
131
29
  }
132
30
 
133
- // Generate contrasting colors
134
- @include _generate-text-color-levels($dark-contrasting-classes, "dark");
135
- @include _generate-text-color-levels($light-contrasting-classes, "light");
136
- }
137
-
138
31
  // -------------------------------------------------------------------------------------------------------------------
139
32
  // @ Dynamic color classes generator
140
33
  // -------------------------------------------------------------------------------------------------------------------
141
- @mixin colors-classes-dynamic($theme) {
142
- $primary: map-get($theme, primary);
143
- $accent: map-get($theme, accent);
144
- $danger: map-get($theme, danger);
145
- $success: map-get($theme, success);
146
- $warn: map-get($theme, warn);
147
- $info: map-get($theme, info);
148
- $background: map-get($theme, background);
149
- $foreground: map-get($theme, foreground);
150
-
151
- $color-functions: (
152
- red: getRed,
153
- pink: getPink,
154
- purple: getPurple,
155
- deep-purple: getDeepPurple,
156
- indigo: getIndigo,
157
- blue: getBlue,
158
- light-blue: getLightBlue,
159
- cyan: getCyan,
160
- teal: getTeal,
161
- green: getGreen,
162
- light-green: getLightGreen,
163
- lime: getLime,
164
- yellow: getYellow,
165
- amber: getAmber,
166
- orange: getOrange,
167
- deep-orange: getDeepOrange,
168
- brown: getBrown,
169
- grey: getGrey,
170
- blue-grey: getBlueGrey,
171
- primary: getPrimary,
172
- accent: getAccent,
173
- danger: getDanger,
174
- warn: getWarn,
175
- success: getSuccess,
176
- info: getInfo,
177
- disabled: getDisabled,
178
- );
34
+ @mixin colors-classes-dynamic($theme: ()) {
35
+ // theme-agnóstico: classes consomem var(--matcha-color-*). $theme vestigial (default ()).
36
+ // Inclui colors-classes-static (linha abaixo) — app.theme chama SÓ este (sem dup).
37
+
38
+ // Nomes de cor que viram utility classes. TODOS (semânticas + paleta) consomem
39
+ // var(--matcha-color-*). As cores de paleta agora têm tokens emitidos no tema
40
+ // (ver _emit-tokens — base/alpha/contrast mode-flipped), então o caminho
41
+ // compile-time getRed($theme)/Material foi eliminado aqui. Value-preserving.
42
+ $color-names: "red", "pink", "purple", "deep-purple", "indigo", "blue", "light-blue", "cyan", "teal",
43
+ "green", "light-green", "lime", "yellow", "amber", "orange", "deep-orange", "brown", "grey", "blue-grey",
44
+ "primary", "accent", "danger", "warn", "success", "info", "disabled";
179
45
 
180
46
  @include colors-classes-static($theme);
181
47
 
182
- .color-unset {
183
- color: map-get($foreground, foreground);
184
-
185
- .ripple {
186
- background: map-get($foreground, foreground);
187
- }
188
- }
189
-
190
- @each $colorName, $colorFn in $color-functions {
191
- // When a DS token exists for this semantic color (accent, primary, danger, etc.),
192
- // utility classes consume var(--matcha-color-*) so Figma changes propagate at runtime.
193
- // Palette colors (red, blue, green, etc.) keep their static values.
194
- $is-semantic: index((primary, accent, danger, warn, success, info, disabled), $colorName) != null;
195
-
48
+ @each $colorName in $color-names {
196
49
  .background-#{$colorName}-alpha {
197
- @if $is-semantic {
198
- background: var(--matcha-color-#{$colorName}-alpha, #{call(#{$colorFn}Alpha, $theme)});
199
- } @else {
200
- background: call(#{$colorFn}Alpha, $theme);
201
- }
50
+ background: var(--matcha-color-#{$colorName}-alpha);
202
51
  }
203
52
 
204
53
  .#{$colorName} .ripple {
205
- background: call(#{$colorFn}Alpha, $theme)
54
+ background: var(--matcha-color-#{$colorName}-alpha);
206
55
  }
207
56
 
208
57
  .background-#{$colorName} {
209
- @if $is-semantic {
210
- background: var(--matcha-color-#{$colorName}, #{call(#{$colorFn}, $theme)});
211
- } @else {
212
- background: call(#{$colorFn}, $theme);
213
- }
58
+ background: var(--matcha-color-#{$colorName});
214
59
  }
215
60
 
216
61
  .border-color-#{$colorName} {
217
- @if $is-semantic {
218
- border-color: var(--matcha-color-#{$colorName}, #{call(#{$colorFn}, $theme)});
219
- } @else {
220
- border-color: call(#{$colorFn}, $theme);
221
- }
62
+ border-color: var(--matcha-color-#{$colorName});
222
63
  }
223
64
 
224
65
  .color-#{$colorName} {
225
- @if $is-semantic {
226
- color: var(--matcha-color-#{$colorName}, #{call(#{$colorFn}, $theme)}) !important;
227
- } @else {
228
- color: call(#{$colorFn}, $theme) !important;
229
- }
66
+ color: var(--matcha-color-#{$colorName}) !important;
230
67
  }
231
68
 
232
69
  .fill-#{$colorName} {
233
- @if $is-semantic {
234
- fill: var(--matcha-color-#{$colorName}, #{call(#{$colorFn}, $theme)});
235
- } @else {
236
- fill: call(#{$colorFn}, $theme);
237
- }
70
+ fill: var(--matcha-color-#{$colorName});
238
71
  }
239
72
 
240
73
  .stroke-#{$colorName} {
241
- @if $is-semantic {
242
- stroke: var(--matcha-color-#{$colorName}, #{call(#{$colorFn}, $theme)});
243
- } @else {
244
- stroke: call(#{$colorFn}, $theme);
245
- }
74
+ stroke: var(--matcha-color-#{$colorName});
246
75
  }
247
76
 
248
77
  .color-#{$colorName}-alpha {
249
- color: call(#{$colorFn}Alpha, $theme) !important
78
+ color: var(--matcha-color-#{$colorName}-alpha) !important;
250
79
  }
251
80
 
252
81
  .#{$colorName}-alpha {
253
- background: call(#{$colorFn}Alpha, $theme);
254
- color: call(#{$colorFn}, $theme);
82
+ background: var(--matcha-color-#{$colorName}-alpha);
83
+ color: var(--matcha-color-#{$colorName});
255
84
  }
256
85
 
257
86
  .#{$colorName} {
258
- @if $is-semantic {
259
- background: var(--matcha-color-#{$colorName}, #{call(#{$colorFn}, $theme)});
260
- color: var(--matcha-color-#{$colorName}-contrast, #{call(#{$colorFn}Contrast, $theme)});
261
- } @else {
262
- background: call(#{$colorFn}, $theme);
263
- color: call(#{$colorFn}Contrast, $theme);
264
- }
87
+ background: var(--matcha-color-#{$colorName});
88
+ color: var(--matcha-color-#{$colorName}-contrast);
265
89
  }
266
90
  }
267
91
 
268
92
  .background-basic-alpha {
269
- background: var(--matcha-color-fg-alpha, #{getForegroundAlpha($theme)});
93
+ background: var(--matcha-color-fg-alpha);
270
94
  }
271
95
 
272
96
  .basic .ripple {
273
- background: var(--matcha-color-fg-alpha, #{getForegroundAlpha($theme)});
97
+ background: var(--matcha-color-fg-alpha);
274
98
  }
275
99
 
276
100
  .background-basic {
277
- background: var(--matcha-color-surface, #{getSurface($theme)});
101
+ background: var(--matcha-color-surface);
278
102
  }
279
103
 
280
104
  .border-color-basic {
281
- border-color: var(--matcha-color-fg, #{getForeground($theme)});
105
+ border-color: var(--matcha-color-fg);
282
106
  }
283
107
 
284
108
  .color-basic {
285
- color: var(--matcha-color-fg, #{getForeground($theme)}) !important;
109
+ color: var(--matcha-color-fg) !important;
286
110
  }
287
111
 
288
112
  .fill-basic {
289
- fill: var(--matcha-color-surface, #{getSurface($theme)});
113
+ fill: var(--matcha-color-surface);
290
114
  }
291
115
 
292
116
  .stroke-basic {
293
- stroke: var(--matcha-color-fg, #{getForeground($theme)});
117
+ stroke: var(--matcha-color-fg);
294
118
  }
295
119
 
296
120
  .color-basic-alpha {
297
- color: var(--matcha-color-fg-alpha, #{getForegroundAlpha($theme)}) !important;
121
+ color: var(--matcha-color-fg-alpha) !important;
298
122
  }
299
123
 
300
124
  .basic-alpha {
301
- background: var(--matcha-color-fg-alpha, #{getForegroundAlpha($theme)});
302
- color: var(--matcha-color-fg, #{getForeground($theme)});
125
+ background: var(--matcha-color-fg-alpha);
126
+ color: var(--matcha-color-fg);
303
127
  }
304
128
 
305
129
  .basic {
306
- background: var(--matcha-color-surface, #{getSurface($theme)});
307
- color: var(--matcha-color-fg, #{getForeground($theme)});
130
+ background: var(--matcha-color-surface);
131
+ color: var(--matcha-color-fg);
308
132
  }
309
133
 
310
134
  // Semantic surface & foreground aliases (used throughout templates)
311
- .background-fg { background: var(--matcha-color-fg, #{getForeground($theme)}); }
312
- .background-bg { background: var(--matcha-color-surface-bg, #{getBackground($theme)}); }
313
- .background-bg-alpha { background: var(--matcha-color-surface-bg-alpha, #{getBackgroundAlpha($theme)}); }
314
- .background-surface { background: var(--matcha-color-surface, #{getSurface($theme)}); }
315
- .background-surface-alpha { background: var(--matcha-color-surface-card-alpha, #{getSurfaceAlpha($theme)}); }
316
- .background-hint { background: var(--matcha-color-hint, #{getGrey($theme)}); }
317
- .color-fg { color: var(--matcha-color-fg, #{getForeground($theme)}) !important; }
318
- .color-hint { color: var(--matcha-color-hint, #{getGrey($theme)}) !important; }
319
- .color-label { color: var(--matcha-color-text-label, #{getBlueGrey($theme)}) !important; }
320
- .color-placeholder { color: var(--matcha-color-text-placeholder, #{getBlueGrey($theme)}) !important; }
135
+ .background-fg { background: var(--matcha-color-fg); }
136
+ .background-bg { background: var(--matcha-color-surface-bg); }
137
+ .background-bg-alpha { background: var(--matcha-color-surface-bg-alpha); }
138
+ .background-surface { background: var(--matcha-color-surface); }
139
+ .background-surface-alpha { background: var(--matcha-color-surface-card-alpha); }
140
+ .background-hint { background: var(--matcha-color-hint); }
141
+ .color-fg { color: var(--matcha-color-fg) !important; }
142
+ .color-hint { color: var(--matcha-color-hint) !important; }
143
+ .color-label { color: var(--matcha-color-text-label) !important; }
144
+ .color-placeholder { color: var(--matcha-color-text-placeholder) !important; }
321
145
 
322
146
  .color-unset {
323
147
  color: unset;
@@ -338,68 +162,65 @@ $attributes: (
338
162
  @each $attribute in $attributes {
339
163
  @if ($attribute !="color") {
340
164
  .#{$attribute}-bg {
341
- #{$attribute}: getBackground($theme) !important;
165
+ #{$attribute}: var(--matcha-color-surface-bg) !important;
342
166
  }
343
167
 
344
168
  .#{$attribute}-bg-alpha {
345
- #{$attribute}: getBackgroundAlpha($theme) !important;
169
+ #{$attribute}: var(--matcha-color-surface-bg-alpha) !important;
346
170
  }
347
171
 
348
172
  .#{$attribute}-bg-inverse {
349
- #{$attribute}: getBackgroundInverse($theme) !important;
173
+ #{$attribute}: var(--matcha-color-surface-bg-inverse) !important;
350
174
  }
351
175
 
352
176
  .#{$attribute}-bg-alpha-inverse {
353
- #{$attribute}: getBackgroundAlphaInverse($theme) !important;
177
+ #{$attribute}: var(--matcha-color-surface-bg-inverse-alpha) !important;
354
178
  }
355
179
 
356
180
  .#{$attribute}-surface-inverse {
357
- #{$attribute}: getSurfaceInverse($theme) !important;
358
- }
359
-
360
- .#{$attribute}-surface-alpha-inverse {
361
- #{$attribute}: getSurfaceAlphaInverse($theme) !important;
181
+ #{$attribute}: var(--matcha-color-surface-card-inverse) !important;
362
182
  }
363
183
  }
364
184
 
365
185
  .#{$attribute}-fg,
366
186
  .#{$attribute}-base,
367
187
  .#{$attribute}-text {
368
- #{$attribute}: getForeground($theme) !important;
188
+ #{$attribute}: var(--matcha-color-fg) !important;
369
189
  }
370
190
 
371
191
  .#{$attribute}-fg-inverse,
372
192
  .#{$attribute}-base-inverse,
373
193
  .#{$attribute}-text-inverse {
374
- #{$attribute}: getForegroundInverse($theme) !important;
194
+ #{$attribute}: var(--matcha-color-fg-inverse) !important;
375
195
  }
376
196
 
377
197
  .#{$attribute}-surface {
378
- #{$attribute}: getSurface($theme) !important;
198
+ #{$attribute}: var(--matcha-color-surface) !important;
379
199
  }
380
200
 
381
201
  .#{$attribute}-surface-alpha {
382
- #{$attribute}: getSurfaceAlpha($theme) !important;
202
+ #{$attribute}: var(--matcha-color-surface-card-alpha) !important;
383
203
  }
384
204
 
385
205
  .#{$attribute}-placeholder {
386
- #{$attribute}: getGrey($theme) !important;
206
+ #{$attribute}: var(--matcha-color-text-placeholder) !important;
387
207
 
388
208
  &-alpha {
389
- background: rgba(getGrey($theme), 0.2) !important;
209
+ // placeholder-alpha (raro/legado) — usa o token grey-alpha runtime.
210
+ background: var(--matcha-color-grey-alpha) !important;
390
211
  }
391
212
  }
392
213
 
393
214
  .#{$attribute}-label {
394
- #{$attribute}: getBlueGrey($theme) !important;
215
+ #{$attribute}: var(--matcha-color-text-label) !important;
395
216
  }
396
217
 
397
218
  .#{$attribute}-disabled {
398
- #{$attribute}: getDisabled($theme) !important;
219
+ #{$attribute}: var(--matcha-color-disabled) !important;
399
220
  }
400
221
 
401
222
  .#{$attribute}-disabled-icon {
402
- #{$attribute}: getDisabledContrast($theme) !important;
223
+ #{$attribute}: var(--matcha-color-interaction-disabled-fg) !important;
403
224
  }
404
225
  }
405
226
  }
@@ -49,12 +49,8 @@
49
49
  #{map-get(_get-ambient-map($color, $opacity), $zValue)};
50
50
  }
51
51
 
52
- @mixin _theme-elevation($zValue, $theme, $opacity: $elevation-opacity) {
53
- $foreground: map-get($theme, foreground);
54
- $elevation-color: map-get($foreground, elevation);
55
- $elevation-color-or-default: if($elevation-color ==null, $elevation-color, $elevation-color);
56
-
57
- @include elevation($zValue, $elevation-color-or-default, $opacity);
52
+ @mixin _theme-elevation($zValue, $elevation-color, $opacity: $elevation-opacity) {
53
+ @include elevation($zValue, $elevation-color, $opacity);
58
54
  }
59
55
 
60
56
  // Applies the elevation to an element in a manner that allows
@@ -93,10 +89,14 @@
93
89
 
94
90
  // Css class generator for shadows
95
91
  // $_elevation-prefix: "matcha-elevation-z";
96
- @mixin elevation-theme($theme) {
92
+ @mixin elevation-theme($is-dark: false) {
93
+ // API nova: recebe SÓ o modo. Cor da sombra preservada por modo
94
+ // (light #1A2C1E / dark black — valores que vinham de foreground.elevation).
95
+ $elevation-color: if($is-dark, black, #1A2C1E);
96
+
97
97
  @for $zValue from 0 through 24 {
98
98
  .#{$_elevation-prefix}#{$zValue} {
99
- @include _theme-elevation($zValue, $theme);
99
+ @include _theme-elevation($zValue, $elevation-color);
100
100
  }
101
101
  }
102
102
  }