matcha-theme 1.0.2 → 1.0.4

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,3 +1,31 @@
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
+ $matchaPalettes: (
6
+ "red": $red,
7
+ "pink": $pink,
8
+ "purple": $purple,
9
+ "deep-purple": $deep-purple,
10
+ "indigo": $indigo,
11
+ "blue": $blue,
12
+ "light-blue": $light-blue,
13
+ "cyan": $cyan,
14
+ "teal": $teal,
15
+ "green": $green,
16
+ "light-green": $light-green,
17
+ "lime": $lime,
18
+ "yellow": $yellow,
19
+ "amber": $amber,
20
+ "orange": $orange,
21
+ "deep-orange": $deep-orange,
22
+ "brown": $brown,
23
+ "grey": $grey,
24
+ "blue-grey": $blue-grey
25
+ );
26
+
27
+ // Hues Palette Colors
28
+ $index: 0;
1
29
  // -------------------------------------------------------------------------------------------------------------------
2
30
  // @ Text color levels generator
3
31
  // -------------------------------------------------------------------------------------------------------------------
@@ -42,12 +70,30 @@
42
70
  }
43
71
  }
44
72
  }
73
+ @mixin _generate-classes($prefix, $color-map, $saturation) {
74
+ // .primary-500
75
+ // .primary-600-bg
76
+ // .primary-700-fg
77
+ $background: map-get($color-map, $saturation);
78
+ $contrast: map-get($color-map, #{$saturation}-contrast);
79
+
80
+ .#{$prefix}-#{$saturation} {
81
+ background: $background;
82
+ color: $contrast;
83
+ }
84
+ .#{$prefix}-#{$saturation}-bg {
85
+ background: $background;
86
+ }
87
+ .#{$prefix}-#{$saturation}-fg {
88
+ color: $background;
89
+ }
90
+ }
45
91
 
46
92
  // -------------------------------------------------------------------------------------------------------------------
47
93
  // @ Static color classes generator
48
94
  // -------------------------------------------------------------------------------------------------------------------
49
- @mixin _generate-static-color-classes($colorName, $color, $contrastColor, $hue) {
50
- $colorSelector: unquote(".#{$colorName}#{$hue}");
95
+ @mixin _generate-static-color-classes($colorName, $color, $contrastColor, $saturation) {
96
+ $colorSelector: unquote(".#{$colorName}#{$saturation}");
51
97
 
52
98
  #{$colorSelector}-bg {
53
99
  background-color: $color !important;
@@ -80,25 +126,29 @@
80
126
  }
81
127
  }
82
128
 
83
- @mixin colors-classes-static($palettes) {
129
+ @mixin colors-classes-static($matchaPalettes) {
84
130
  $light-contrasting-classes: ();
85
131
  $dark-contrasting-classes: ();
86
132
 
87
- @each $paletteName, $palette in $palettes {
133
+ @each $paletteName, $palette in $matchaPalettes {
134
+ // $contrasts: map-get($red, "contrast");
135
+ // $contrasts = all contrast colors of $red palette
88
136
  $contrasts: map-get($palette, "contrast");
89
137
 
90
- @each $hue in $matchaHues {
91
- $color: map-get($palette, $hue);
92
- $contrast: map-get($contrasts, $hue);
138
+ @each $saturation in $saturationLevels {
139
+ // $color: map-get($red, 500)
140
+ // $contrast: map-get($contrasts, 500); 500 contrast color of $red palette
141
+ $color: map-get($palette, $saturation);
142
+ $contrast: map-get($contrasts, $saturation);
93
143
 
94
144
  @if ($color != null and $contrast != null) {
95
- @include _generate-static-color-classes($paletteName, $color, $contrast, "-#{$hue}");
145
+ @include _generate-static-color-classes($paletteName, $color, $contrast, "-#{$saturation}");
96
146
 
97
147
  // If the contrast color is dark
98
148
  @if (rgba(black, 1) ==rgba($contrast, 1)) {
99
149
  $dark-contrasting-classes: append(
100
150
  $dark-contrasting-classes,
101
- unquote(".#{$paletteName}-#{$hue}"),
151
+ unquote(".#{$paletteName}-#{$saturation}"),
102
152
  "comma"
103
153
  );
104
154
  }
@@ -107,14 +157,23 @@
107
157
  @else {
108
158
  $light-contrasting-classes: append(
109
159
  $light-contrasting-classes,
110
- unquote(".#{$paletteName}-#{$hue}"),
160
+ unquote(".#{$paletteName}-#{$saturation}"),
111
161
  "comma"
112
162
  );
113
163
  }
114
164
 
115
165
  // Run the generator one more time for default values (500)
116
166
  // if we are not working with primary, accent or warn palettes
117
- @if ($hue ==500 and $paletteName != "primary" and $paletteName != "accent" and $paletteName != "warn") {
167
+ @if (
168
+ $saturation
169
+ ==500 and
170
+ $paletteName !=
171
+ "primary" and
172
+ $paletteName !=
173
+ "accent" and
174
+ $paletteName !=
175
+ "warn"
176
+ ) {
118
177
  // Generate color classes
119
178
  @include _generate-static-color-classes($paletteName, $color, $contrast, "");
120
179
 
@@ -140,33 +199,6 @@
140
199
  }
141
200
  }
142
201
  }
143
-
144
- // Run the generator again for the selected default hue values for
145
- // primary, accent and warn palettes
146
- //
147
- // We are doing this because the default hue value can be changed
148
- // by the user when the Material theme being generated.
149
- @if ($paletteName == "primary" or $paletteName == "accent" or $paletteName == "warn") {
150
- // Get the color and the contrasting color for the selected
151
- // default hue
152
- $color: map-get($palette, "default");
153
- $contrast: map-get($palette, "default-contrast");
154
-
155
- // Generate color classes
156
- @include _generate-static-color-classes($paletteName, $color, $contrast, "");
157
-
158
- // Add color to the correct list depending on the contrasting color
159
-
160
- // If the contrast color is dark
161
- @if (rgba(black, 1) ==rgba($contrast, 1)) {
162
- $dark-contrasting-classes: append($dark-contrasting-classes, unquote(".#{$paletteName}"), "comma");
163
- }
164
-
165
- // if the contrast color is light
166
- @else {
167
- $light-contrasting-classes: append($light-contrasting-classes, unquote(".#{$paletteName}"), "comma");
168
- }
169
- }
170
202
  }
171
203
 
172
204
  // Generate contrasting colors
@@ -174,32 +206,35 @@
174
206
  @include _generate-text-color-levels($light-contrasting-classes, "light");
175
207
  }
176
208
 
209
+ @include colors-classes-static($matchaPalettes);
177
210
  // -------------------------------------------------------------------------------------------------------------------
178
211
  // @ Dynamic color classes generator
179
212
  // -------------------------------------------------------------------------------------------------------------------
180
213
  @mixin _generate-dynamic-color-classes($attribute, $colorLevel, $colorName, $background, $foreground) {
181
214
  $color: unquote("-#{$colorName}");
182
- $selectors: (".#{$attribute}#{$color}", ".matcha-#{$attribute}#{$color}", ".matcha-#{$attribute}-graphic#{$color}");
215
+ $selector: ".#{$attribute}#{$color}"; // .background-yellow
216
+ $baseClassName: (".base-#{$colorName}"); // .base-yellow
183
217
 
184
- @each $selector in $selectors {
185
- #{$selector} {
186
- #{$attribute}: map-get($colorLevel, $colorName) !important;
218
+ #{$selector} {
219
+ #{$attribute}: map-get($colorLevel, $colorName) !important;
220
+ &-alpha {
221
+ background: map-get($colorLevel, ("#{$colorName}-alpha")) !important;
222
+ }
223
+ }
187
224
 
188
- &-alpha {
189
- #{$attribute}: map-get($colorLevel, ("#{$colorName}-alpha")) !important;
190
- }
225
+ #{$baseClassName} {
226
+ &-alpha {
227
+ background: map-get($colorLevel, ("#{$colorName}-alpha")) !important;
191
228
  }
192
229
  }
193
230
 
194
231
  @if ($colorName != yellow or $colorName != amber) {
195
- $baseClassName: (".base-#{$colorName}");
196
232
  #{$baseClassName} {
197
233
  background: map-get($background, $colorName);
198
234
  color: map-get($foreground, text-inverse);
199
235
  }
200
236
  }
201
237
  @if ($colorName == yellow or $colorName == amber) {
202
- $baseClassName: (".base-#{$colorName}");
203
238
  #{$baseClassName} {
204
239
  background: map-get($background, $colorName);
205
240
  color: map-get($foreground, static-dark-text);
@@ -207,22 +242,6 @@
207
242
  }
208
243
  }
209
244
 
210
- @mixin _generate-classes($prefix, $color-map, $saturation) {
211
- $background: map-get($color-map, $saturation);
212
- $contrast: map-get($color-map, #{$saturation}-contrast);
213
-
214
- .#{$prefix}-#{$saturation} {
215
- background: $background;
216
- color: $contrast;
217
- }
218
- .#{$prefix}-#{$saturation}-bg {
219
- background: $background;
220
- }
221
- .#{$prefix}-#{$saturation}-fg {
222
- color: $background;
223
- }
224
- }
225
-
226
245
  @mixin colors-classes-dynamic($theme) {
227
246
  $is-dark: map-get($theme, isdark);
228
247
  $primary: map-get($theme, primary);
@@ -231,6 +250,11 @@
231
250
  $background: map-get($theme, background);
232
251
  $foreground: map-get($theme, foreground);
233
252
 
253
+ $themePalette: (
254
+ "primary": $primary,
255
+ "accent": $accent,
256
+ "warn": $warn
257
+ );
234
258
  $colorNames: red, pink, purple, deep-purple, indigo, blue, light-blue, cyan, teal, green, light-green, lime, yellow,
235
259
  amber, orange, deep-orange, primary, accent, warn;
236
260
  $attributes: (
@@ -241,28 +265,52 @@
241
265
  stroke: $background
242
266
  );
243
267
 
244
- .primary,
245
- .base-primary {
246
- background: map-get($primary, default);
247
- color: map-get($primary, default-contrast);
268
+ @each $saturation in $saturationLevels {
269
+ // generate classes for all saturation levels of primary, accent and warn palettes
270
+ @include _generate-classes("primary", $primary, $saturation);
271
+ @include _generate-classes("accent", $accent, $saturation);
272
+ @include _generate-classes("warn", $warn, $saturation);
248
273
  }
249
274
 
250
- .accent,
251
- .base-accent {
252
- background: map-get($accent, default);
253
- color: map-get($accent, default-contrast);
275
+ @each $paletteName, $palette in $themePalette {
276
+ // generate
277
+ .base-#{$paletteName},
278
+ .#{$paletteName} {
279
+ background: map-get($palette, default);
280
+ color: map-get($palette, default-contrast);
281
+ }
282
+ .#{$paletteName}-bg {
283
+ background: map-get($palette, default) !important;
284
+ }
285
+ .#{$paletteName}-fg {
286
+ color: map-get($palette, default) !important;
287
+ }
288
+ .background-#{$paletteName}-alpha,
289
+ .base-#{$paletteName}-alpha {
290
+ background: rgba(map-get($palette, default), 0.2);
291
+ }
254
292
  }
255
293
 
256
- .warn,
257
- .base-warn {
258
- background: map-get($warn, default);
259
- color: map-get($warn, default-contrast);
294
+ .base-surface {
295
+ background: map-get($background, card);
296
+ color: map-get($foreground, text);
297
+ &-alpha {
298
+ background: rgba(map-get($background, card), 0.5) !important;
299
+ }
260
300
  }
261
-
262
- @each $saturation in $matchaHues {
263
- @include _generate-classes("primary", $primary, $saturation);
264
- @include _generate-classes("accent", $accent, $saturation);
265
- @include _generate-classes("warn", $warn, $saturation);
301
+ .base-fg {
302
+ background: map-get($foreground, text);
303
+ color: map-get($foreground, text-inverse);
304
+ &-alpha {
305
+ background: rgba(map-get($foreground, text), 0.2) !important;
306
+ }
307
+ }
308
+ .base-bg {
309
+ background: map-get($background, background);
310
+ color: map-get($foreground, text);
311
+ &-alpha {
312
+ background: rgba(map-get($background, background), 0.5) !important;
313
+ }
266
314
  }
267
315
 
268
316
  .background-transparent,
@@ -295,123 +343,75 @@
295
343
  #{$attribute}: map-get($background, card-alpha-inverse) !important;
296
344
  }
297
345
  }
298
-
299
- .primary-bg {
300
- background: map-get($primary, default) !important;
301
- }
302
- .primary-fg {
303
- color: map-get($primary, default) !important;
304
- }
305
- .background-primary-alpha {
306
- background: rgba(map-get($primary, default), 0.2);
307
- }
308
- .accent-bg {
309
- background: map-get($accent, default) !important;
310
- }
311
- .accent-fg {
312
- color: map-get($accent, default) !important;
313
- }
314
- .background-accent-alpha {
315
- background: rgba(map-get($accent, default), 0.2);
316
- }
317
-
318
- .warn-bg {
319
- background: map-get($warn, default) !important;
320
- }
321
- .warn-fg {
322
- color: map-get($warn, default) !important;
323
- }
324
- .background-warn-alpha {
325
- background: rgba(map-get($warn, default), 0.2);
326
- }
327
-
328
- .#{$attribute}-primary,
329
- .matcha-#{$attribute}-primary {
346
+ .#{$attribute}-primary {
330
347
  #{$attribute}: map-get($primary, default) !important;
331
348
  }
332
349
 
333
- .#{$attribute}-accent,
334
- .matcha-#{$attribute}-accent {
350
+ .#{$attribute}-accent {
335
351
  #{$attribute}: map-get($accent, default) !important;
336
352
  }
337
353
 
338
- .#{$attribute}-warn,
339
- .matcha-#{$attribute}-warn {
354
+ .#{$attribute}-warn {
340
355
  #{$attribute}: map-get($warn, default) !important;
341
356
  }
342
357
 
343
- .#{$attribute}-error,
344
- .matcha-#{$attribute}-error {
358
+ .#{$attribute}-error {
345
359
  #{$attribute}: map-get($background, error) !important;
346
360
  }
347
361
 
348
- .#{$attribute}-info,
349
- .matcha-#{$attribute}-info {
362
+ .#{$attribute}-info {
350
363
  #{$attribute}: map-get($background, info) !important;
351
364
  }
352
365
 
353
- .#{$attribute}-success,
354
- .matcha-#{$attribute}-success {
366
+ .#{$attribute}-success {
355
367
  #{$attribute}: map-get($background, success) !important;
356
368
  }
357
369
 
358
- .#{$attribute}-warning,
359
- .matcha-#{$attribute}-warning {
370
+ .#{$attribute}-warning {
360
371
  #{$attribute}: map-get($background, warning) !important;
361
372
  }
362
373
 
363
374
  .#{$attribute}-foreground,
364
375
  .#{$attribute}-fg,
365
376
  .#{$attribute}-base,
366
- .#{$attribute}-text,
367
- .matcha-#{$attribute}-foreground,
368
- .matcha-#{$attribute}-fg,
369
- .matcha-#{$attribute}-base,
370
- .matcha-#{$attribute}-text {
377
+ .#{$attribute}-text {
371
378
  #{$attribute}: map-get($foreground, text) !important;
372
379
  }
373
380
 
374
381
  .#{$attribute}-fg-inverse,
375
382
  .#{$attribute}-base-inverse,
376
- .matcha-#{$attribute}-text-inverse {
383
+ .#{$attribute}-text-inverse {
377
384
  #{$attribute}: map-get($foreground, text-inverse) !important;
378
385
  }
379
386
 
380
- .#{$attribute}-surface,
381
- .matcha-#{$attribute}-dialog,
382
- .matcha-#{$attribute}-card {
387
+ .#{$attribute}-surface {
383
388
  #{$attribute}: map-get($background, card) !important;
384
389
  }
385
390
 
386
- .#{$attribute}-surface-alpha,
387
- .matcha-#{$attribute}-surface-alpha,
388
- .matcha-#{$attribute}-card-alpha {
391
+ .#{$attribute}-surface-alpha {
389
392
  #{$attribute}: map-get($background, card-alpha) !important;
390
393
  }
391
394
 
392
- .#{$attribute}-hover,
393
- .matcha-#{$attribute}-hover,
394
- .matcha-#{$attribute}-placeholder {
395
+ .#{$attribute}-placeholder {
395
396
  #{$attribute}: map-get($foreground, placeholder) !important;
397
+ &-alpha {
398
+ background: rgba(map-get($foreground, placeholder), 0.2) !important;
399
+ }
396
400
  }
397
401
 
398
- .#{$attribute}-label,
399
- .matcha-#{$attribute}-label {
402
+ .#{$attribute}-label {
400
403
  #{$attribute}: map-get($foreground, label) !important;
401
404
  }
402
405
 
403
- .#{$attribute}-disabled,
404
- .matcha-#{$attribute}-disabled {
406
+ .#{$attribute}-disabled {
405
407
  #{$attribute}: map-get($background, disabled) !important;
406
408
  }
407
409
 
408
- .#{$attribute}-disabled-icon,
409
- .matcha-#{$attribute}-disabled-icon {
410
+ .#{$attribute}-disabled-icon {
410
411
  #{$attribute}: map-get($foreground, disabled-icon) !important;
411
412
  }
412
413
 
413
- .#{$attribute}-selected,
414
- .matcha-#{$attribute}-selected {
414
+ .#{$attribute}-selected {
415
415
  #{$attribute}: map-get($background, selected-button) !important;
416
416
  }
417
417