@udixio/theme 2.0.0 → 2.1.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.
Files changed (54) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/bin.cjs +1 -1
  3. package/dist/bin.js +1 -1
  4. package/dist/browser.cjs +3 -2
  5. package/dist/browser.js +24 -23
  6. package/dist/color/color.api.d.ts +5 -1
  7. package/dist/color/color.api.d.ts.map +1 -1
  8. package/dist/color/color.d.ts +1 -0
  9. package/dist/color/color.d.ts.map +1 -1
  10. package/dist/color/color.manager.d.ts +1 -2
  11. package/dist/color/color.manager.d.ts.map +1 -1
  12. package/dist/color/default-color.d.ts +5 -1
  13. package/dist/color/default-color.d.ts.map +1 -1
  14. package/dist/{font.plugin-DZtMajJV.js → font.plugin-B2IbI3Qs.js} +1 -1
  15. package/dist/{font.plugin-BZ-TTeTo.cjs → font.plugin-Czq_-M7T.cjs} +1 -1
  16. package/dist/{load-from-path-DZ35yiXK.cjs → load-from-path-Bvj18-eg.cjs} +2 -2
  17. package/dist/{load-from-path-Dobe0beV.js → load-from-path-CjLV8qqN.js} +1 -1
  18. package/dist/loader/loader.d.ts.map +1 -1
  19. package/dist/{loader-C8LnOoqg.cjs → loader-DuLiOKuW.cjs} +1171 -463
  20. package/dist/{loader-BS_Esfwg.js → loader-Dy9GSe3X.js} +1191 -483
  21. package/dist/node.cjs +4 -3
  22. package/dist/node.js +26 -25
  23. package/dist/palette/palette.d.ts.map +1 -1
  24. package/dist/variant/variant.d.ts +2 -0
  25. package/dist/variant/variant.d.ts.map +1 -1
  26. package/dist/variant/variants/expressive.variant.d.ts.map +1 -1
  27. package/dist/variant/variants/index.d.ts +1 -1
  28. package/dist/variant/variants/neutral.variant.d.ts.map +1 -1
  29. package/dist/variant/variants/tonal-spot.variant.d.ts.map +1 -1
  30. package/dist/variant/variants/udixio.variant.d.ts +3 -0
  31. package/dist/variant/variants/udixio.variant.d.ts.map +1 -0
  32. package/dist/variant/variants/vibrant.variant.d.ts.map +1 -1
  33. package/package.json +1 -1
  34. package/src/app.module.ts +1 -1
  35. package/src/color/color.api.ts +24 -3
  36. package/src/color/color.manager.ts +4 -16
  37. package/src/color/color.module.ts +2 -2
  38. package/src/color/color.ts +4 -0
  39. package/src/color/default-color.ts +34 -68
  40. package/src/context/context.module.ts +1 -1
  41. package/src/loader/loader.ts +0 -4
  42. package/src/palette/palette.module.ts +2 -2
  43. package/src/palette/palette.ts +1 -2
  44. package/src/plugin/plugin.module.ts +1 -1
  45. package/src/variant/variant.ts +3 -0
  46. package/src/variant/variants/expressive.variant.ts +2 -0
  47. package/src/variant/variants/index.ts +2 -2
  48. package/src/variant/variants/neutral.variant.ts +2 -0
  49. package/src/variant/variants/tonal-spot.variant.ts +2 -0
  50. package/src/variant/variants/udixio.variant.ts +846 -0
  51. package/src/variant/variants/vibrant.variant.ts +2 -0
  52. package/dist/variant/variants/fidelity.variant.d.ts +0 -3
  53. package/dist/variant/variants/fidelity.variant.d.ts.map +0 -1
  54. package/src/variant/variants/fidelity.variant.ts +0 -46
@@ -0,0 +1,846 @@
1
+ import { getPiecewiseHue, getRotatedHue, variant, Variant } from '../variant';
2
+ import {
3
+ calculateToneAdjustmentPercentage,
4
+ DynamicColorKey,
5
+ getCurve,
6
+ tMaxC,
7
+ tMinC,
8
+ } from '../../color/color.utils';
9
+ import { Hct } from '../../material-color-utilities/htc';
10
+ import {
11
+ AddColorsOptions,
12
+ capitalizeFirstLetter,
13
+ Color,
14
+ ColorApi,
15
+ ColorFromPalette,
16
+ ColorManager,
17
+ getInitialToneFromBackground,
18
+ } from '../../color';
19
+ import { Contrast } from '@material/material-color-utilities';
20
+ import { toneDeltaPair } from '../../material-color-utilities';
21
+ import { Context } from '../../context';
22
+ import { API } from '../../API';
23
+
24
+ const surfaceContainerToneDelta = 2.5;
25
+
26
+ const inverseTone = (tone: number) => {
27
+ return 100 - tone;
28
+ };
29
+
30
+ const surfaceContainerTone = (
31
+ layer: number,
32
+ api: Pick<API, 'palettes' | 'context'>,
33
+ ) => {
34
+ const t = surfaceContainerToneDelta * layer * (1 + api.context.contrastLevel);
35
+ if (api.context.isDark) {
36
+ return t * 1.5;
37
+ } else {
38
+ if (Hct.isYellow(api.palettes.get('neutral').hue)) {
39
+ return 100 - t - surfaceContainerToneDelta;
40
+ }
41
+ return 100 - t;
42
+ }
43
+ };
44
+
45
+ const highestSurface = (
46
+ context: Context,
47
+ colorService: ColorManager | ColorApi,
48
+ ): Color => {
49
+ if (colorService instanceof ColorApi) {
50
+ return colorService.get('surface');
51
+ } else {
52
+ return colorService.get('surface');
53
+ }
54
+ };
55
+
56
+ export const udixioVariant: Variant = variant({
57
+ name: 'udixio',
58
+ palettes: {
59
+ primary: ({ sourceColor }) => ({
60
+ hue: sourceColor.hue,
61
+ chroma: sourceColor.chroma,
62
+ }),
63
+ secondary: ({ sourceColor }) => ({
64
+ hue: sourceColor.hue,
65
+ chroma: sourceColor.chroma / 1.4,
66
+ }),
67
+ tertiary: ({ sourceColor }) => ({
68
+ hue: getRotatedHue(
69
+ sourceColor,
70
+ [0, 20, 71, 161, 333, 360],
71
+ [-40, 48, -32, 40, -32],
72
+ ),
73
+ chroma: sourceColor.chroma,
74
+ }),
75
+ neutral: ({ sourceColor }) => {
76
+ return {
77
+ hue: sourceColor.hue,
78
+ chroma: 5,
79
+ };
80
+ },
81
+ neutralVariant: ({ sourceColor }) => {
82
+ const neutral = 5;
83
+ return {
84
+ hue: sourceColor.hue,
85
+ chroma: neutral * 1.7,
86
+ };
87
+ },
88
+ error: ({ sourceColor }) => {
89
+ const errorHue = getPiecewiseHue(
90
+ sourceColor,
91
+ [0, 3, 13, 23, 33, 43, 153, 273, 360],
92
+ [12, 22, 32, 12, 22, 32, 22, 12],
93
+ );
94
+ return {
95
+ hue: errorHue,
96
+ chroma: 60,
97
+ };
98
+ },
99
+ },
100
+ customPalettes: ({ sourceColor }, colorHct) => ({
101
+ hue: colorHct.hue,
102
+ chroma: sourceColor.chroma,
103
+ }),
104
+
105
+ colorsFromCustomPalette: (key: string) => {
106
+ const colorKey = key as DynamicColorKey;
107
+ // const colorDimKey = (colorKey + 'Dim') as DynamicColorKey;
108
+ const ColorKey = capitalizeFirstLetter(key);
109
+ const onColorKey = ('on' + ColorKey) as DynamicColorKey;
110
+ const colorContainerKey = (colorKey + 'Container') as DynamicColorKey;
111
+ const onColorContainerKey = ('on' +
112
+ ColorKey +
113
+ 'Container') as DynamicColorKey;
114
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
115
+ // @ts-expect-error
116
+ // const inverseColorKey = ('inverse' + ColorKey) as DynamicColorKey;
117
+ // const colorFixedKey = (colorKey + 'Fixed') as DynamicColorKey;
118
+ // const colorFixedDimKey = (colorKey + 'FixedDim') as DynamicColorKey;
119
+ // const onColorFixedKey = ('on' + ColorKey + 'Fixed') as DynamicColorKey;
120
+ // const onColorFixedVariantKey = ('on' +
121
+ // ColorKey +
122
+ // 'FixedVariant') as DynamicColorKey;
123
+ const colors: AddColorsOptions = ({ palettes, colors, context: ctx }) => ({
124
+ [colorKey]: {
125
+ palette: () => palettes.get(colorKey),
126
+ tone: () => {
127
+ if (ctx.variant.name === 'neutral') {
128
+ return ctx.isDark
129
+ ? tMinC(palettes.get(colorKey), 0, 98)
130
+ : tMaxC(palettes.get(colorKey));
131
+ } else if (ctx.variant.name === 'vibrant') {
132
+ return tMaxC(palettes.get(colorKey), 0, ctx.isDark ? 90 : 98);
133
+ } else {
134
+ return ctx.isDark ? 80 : tMaxC(palettes.get(colorKey));
135
+ }
136
+ },
137
+ isBackground: true,
138
+ background: () => highestSurface(ctx, colors),
139
+ contrastCurve: () => getCurve(4.5),
140
+ adjustTone: () =>
141
+ toneDeltaPair(
142
+ colors.get(colorContainerKey),
143
+ colors.get(colorKey),
144
+ 5,
145
+ 'relative_lighter',
146
+ true,
147
+ 'farther',
148
+ ),
149
+ },
150
+ // [colorDimKey]: {
151
+ // palette: () => palettes.get(colorKey),
152
+ // tone: () => {
153
+ // if (ctx.variant.name === 'neutral') {
154
+ // return 85;
155
+ // } else {
156
+ // return tMaxC(palettes.get(colorKey), 0, 90);
157
+ // }
158
+ // },
159
+ // isBackground: true,
160
+ // background: () => colors.get('surfaceContainerHigh'),
161
+ // contrastCurve: () => getCurve(4.5),
162
+ // adjustTone: () =>
163
+ // toneDeltaPair(
164
+ // colors.get(colorDimKey),
165
+ // colors.get(colorKey),
166
+ // 5,
167
+ // 'darker',
168
+ // true,
169
+ // 'farther',
170
+ // ),
171
+ // },
172
+ [onColorKey]: {
173
+ palette: () => palettes.get(colorKey),
174
+ background: () => colors.get(colorKey),
175
+ contrastCurve: () => getCurve(6),
176
+ },
177
+ [colorContainerKey]: {
178
+ palette: () => palettes.get(colorKey),
179
+ tone: () => {
180
+ if (ctx.variant.name === 'vibrant') {
181
+ return ctx.isDark
182
+ ? tMinC(palettes.get(colorKey), 30, 40)
183
+ : tMaxC(palettes.get(colorKey), 84, 90);
184
+ } else if (ctx.variant.name === 'expressive') {
185
+ return ctx.isDark ? 15 : tMaxC(palettes.get(colorKey), 90, 95);
186
+ } else {
187
+ return ctx.isDark ? 25 : 90;
188
+ }
189
+ },
190
+ isBackground: true,
191
+ background: () => highestSurface(ctx, colors),
192
+ adjustTone: () => undefined,
193
+ contrastCurve: () =>
194
+ ctx.contrastLevel > 0 ? getCurve(1.5) : undefined,
195
+ },
196
+ [onColorContainerKey]: {
197
+ palette: () => palettes.get(colorKey),
198
+ background: () => colors.get(colorContainerKey),
199
+ contrastCurve: () => getCurve(6),
200
+ },
201
+ // [colorFixedKey]: {
202
+ // palette: () => palettes.get(colorKey),
203
+ // tone: () => {
204
+ // return ctx.temp({ isDark: false, contrastLevel: 0 }, () => {
205
+ // const color = colors.get(colorContainerKey);
206
+ // return color.getTone();
207
+ // });
208
+ // },
209
+ // isBackground: true,
210
+ // background: () => highestSurface(ctx, colors),
211
+ // contrastCurve: () =>
212
+ // ctx.contrastLevel > 0 ? getCurve(1.5) : undefined,
213
+ // },
214
+ // [colorFixedDimKey]: {
215
+ // palette: () => palettes.get(colorKey),
216
+ // tone: () => colors.get(colorFixedKey).getTone(),
217
+ // isBackground: true,
218
+ // adjustTone: () =>
219
+ // toneDeltaPair(
220
+ // colors.get(colorFixedDimKey),
221
+ // colors.get(colorFixedKey),
222
+ // 5,
223
+ // 'darker',
224
+ // true,
225
+ // 'exact',
226
+ // ),
227
+ // },
228
+ // [onColorFixedKey]: {
229
+ // palette: () => palettes.get(colorKey),
230
+ // background: () => this.get(colorFixedDimKey),
231
+ // contrastCurve: () => getCurve(7),
232
+ // },
233
+ // [onColorFixedVariantKey]: {
234
+ // palette: () => palettes.get(colorKey),
235
+ // background: () => colors.get(colorFixedDimKey),
236
+ // contrastCurve: () => getCurve(4.5),
237
+ // },
238
+ });
239
+
240
+ return colors;
241
+ },
242
+ colors: ({ colors, context: c, palettes }) => {
243
+ const getColor = (key: DynamicColorKey) => {
244
+ return colors.get(key);
245
+ };
246
+
247
+ return {
248
+ ////////////////////////////////////////////////////////////////
249
+ // Surfaces [S] //
250
+ ////////////////////////////////////////////////////////////////
251
+ surface: {
252
+ palette: () => palettes.get('neutral'),
253
+ tone: () => {
254
+ if (c.isDark) {
255
+ return 2;
256
+ } else {
257
+ return 99;
258
+ }
259
+ },
260
+ isBackground: true,
261
+ },
262
+ // surfaceDim: {
263
+ // palette: () => palettes.get('neutral'),
264
+ // tone: () => {
265
+ // if (c.isDark) {
266
+ // return 4;
267
+ // } else {
268
+ // if (Hct.isYellow(palettes.get('neutral').hue)) {
269
+ // return 90;
270
+ // } else if (c.variant.name === 'vibrant') {
271
+ // return 85;
272
+ // } else {
273
+ // return 87;
274
+ // }
275
+ // }
276
+ // },
277
+ // isBackground: true,
278
+ // chromaMultiplier: () => {
279
+ // if (!c.isDark) {
280
+ // if (c.variant.name === 'neutral') {
281
+ // return 2.5;
282
+ // } else if (c.variant.name === 'tonalSpot') {
283
+ // return 1.7;
284
+ // } else if (c.variant.name === 'expressive') {
285
+ // return Hct.isYellow(palettes.get('neutral').hue) ? 2.7 : 1.75;
286
+ // } else if (c.variant.name === 'vibrant') {
287
+ // return 1.36;
288
+ // }
289
+ // }
290
+ // return 1;
291
+ // },
292
+ // },
293
+ // surfaceBright: {
294
+ // palette: () => palettes.get('neutral'),
295
+ // tone: () => {
296
+ // if (c.isDark) {
297
+ // return 18;
298
+ // } else {
299
+ // if (Hct.isYellow(palettes.get('neutral').hue)) {
300
+ // return 99;
301
+ // } else if (c.variant.name === 'vibrant') {
302
+ // return 97;
303
+ // } else {
304
+ // return 98;
305
+ // }
306
+ // }
307
+ // },
308
+ // isBackground: true,
309
+ // chromaMultiplier: () => {
310
+ // if (c.isDark) {
311
+ // if (c.variant.name === 'neutral') {
312
+ // return 2.5;
313
+ // } else if (c.variant.name === 'tonalSpot') {
314
+ // return 1.7;
315
+ // } else if (c.variant.name === 'expressive') {
316
+ // return Hct.isYellow(palettes.get('neutral').hue) ? 2.7 : 1.75;
317
+ // } else if (c.variant.name === 'vibrant') {
318
+ // return 1.36;
319
+ // }
320
+ // }
321
+ // return 1;
322
+ // },
323
+ // },
324
+ surfaceContainerLowest: {
325
+ palette: () => palettes.get('neutral'),
326
+ tone: () => surfaceContainerTone(0, { palettes, context: c }),
327
+ isBackground: true,
328
+ },
329
+ surfaceContainerLow: {
330
+ palette: () => palettes.get('neutral'),
331
+ tone: () => surfaceContainerTone(1, { palettes, context: c }),
332
+ isBackground: true,
333
+ chromaMultiplier: () => {
334
+ return 1.25;
335
+ },
336
+ },
337
+ surfaceContainer: {
338
+ palette: () => palettes.get('neutral'),
339
+ tone: () => surfaceContainerTone(2, { palettes, context: c }),
340
+ isBackground: true,
341
+ chromaMultiplier: () => {
342
+ return 1.4;
343
+ },
344
+ },
345
+ surfaceContainerHigh: {
346
+ palette: () => palettes.get('neutral'),
347
+ tone: () => surfaceContainerTone(3, { palettes, context: c }),
348
+ isBackground: true,
349
+ chromaMultiplier: () => {
350
+ return 1.5;
351
+ },
352
+ },
353
+ surfaceContainerHighest: {
354
+ palette: () => palettes.get('neutral'),
355
+ tone: () => surfaceContainerTone(4, { palettes, context: c }),
356
+ isBackground: true,
357
+ chromaMultiplier: () => {
358
+ return 1.7;
359
+ },
360
+ },
361
+ onSurface: {
362
+ palette: () => palettes.get('neutral'),
363
+ tone: () => {
364
+ return getInitialToneFromBackground(highestSurface(c, colors));
365
+ },
366
+ chromaMultiplier: () => {
367
+ return 1.7;
368
+ },
369
+ background: () => highestSurface(c, colors),
370
+ contrastCurve: () => (c.isDark ? getCurve(11) : getCurve(9)),
371
+ },
372
+ onSurfaceVariant: {
373
+ palette: () => palettes.get('neutralVariant'),
374
+ chromaMultiplier: () => {
375
+ return 1.7;
376
+ },
377
+ background: () => highestSurface(c, colors),
378
+ contrastCurve: () => (c.isDark ? getCurve(6) : getCurve(4.5)),
379
+ },
380
+ outline: {
381
+ palette: () => palettes.get('neutralVariant'),
382
+ chromaMultiplier: () => {
383
+ return 1.7;
384
+ },
385
+ background: () => highestSurface(c, colors),
386
+ contrastCurve: () => getCurve(3),
387
+ },
388
+ outlineVariant: {
389
+ palette: () => palettes.get('neutralVariant'),
390
+ chromaMultiplier: () => {
391
+ return 1.7;
392
+ },
393
+ background: () => highestSurface(c, colors),
394
+ contrastCurve: () => getCurve(1.5),
395
+ },
396
+ inverseSurface: {
397
+ palette: () => palettes.get('neutral'),
398
+ tone: () => 100 - colors.get('surface').getTone(),
399
+ isBackground: true,
400
+ },
401
+ inverseOnSurface: {
402
+ palette: () => palettes.get('neutral'),
403
+ tone: () => (c.isDark ? 20 : 95),
404
+ background: () => colors.get('inverseSurface'),
405
+ contrastCurve: () => getCurve(7),
406
+ },
407
+ ////////////////////////////////////////////////////////////////
408
+ // Primaries [P] //
409
+ ////////////////////////////////////////////////////////////////
410
+ primary: {
411
+ palette: () => palettes.get('primary'),
412
+ tone: () => {
413
+ return c.sourceColor.tone;
414
+ },
415
+ isBackground: true,
416
+ background: () => highestSurface(c, colors),
417
+ contrastCurve: () => getCurve(4.5),
418
+ adjustTone: () => () => {
419
+ const surfaceTone = colors.get('surface').getTone();
420
+ const primaryTone = (colors.get('primary') as ColorFromPalette)
421
+ .options.tone;
422
+ let selfTone = primaryTone;
423
+ if (Contrast.ratioOfTones(surfaceTone, selfTone) < 3) {
424
+ const ratio = calculateToneAdjustmentPercentage(
425
+ surfaceTone,
426
+ selfTone,
427
+ 3,
428
+ );
429
+ const inverseT = inverseTone(primaryTone);
430
+ selfTone = selfTone + (inverseT - selfTone) * ratio;
431
+ }
432
+ return selfTone;
433
+ },
434
+ },
435
+ // primaryDim: {
436
+ // palette: () => palettes.get('primary'),
437
+ // tone: () => {
438
+ // if (c.variant.name === 'neutral') {
439
+ // return 85;
440
+ // } else if (c.variant.name === 'tonalSpot') {
441
+ // return tMaxC(palettes.get('primary'), 0, 90);
442
+ // } else {
443
+ // return tMaxC(palettes.get('primary'));
444
+ // }
445
+ // },
446
+ // isBackground: true,
447
+ // background: () => getColor('surfaceContainerHigh'),
448
+ // contrastCurve: () => getCurve(4.5),
449
+ // adjustTone: () =>
450
+ // toneDeltaPair(
451
+ // colors.get('primaryDim'),
452
+ // colors.get('primary'),
453
+ // 5,
454
+ // 'darker',
455
+ // true,
456
+ // 'farther',
457
+ // ),
458
+ // },
459
+ onPrimary: {
460
+ palette: () => palettes.get('primary'),
461
+ background: () => colors.get('primary'),
462
+ contrastCurve: () => getCurve(6),
463
+ },
464
+ primaryContainer: {
465
+ palette: () => palettes.get('primary'),
466
+ tone: () => {
467
+ return c.isDark
468
+ ? tMinC(palettes.get('primary'), 35, 93)
469
+ : tMaxC(palettes.get('primary'), 0, 90);
470
+ },
471
+ isBackground: true,
472
+ background: () => highestSurface(c, colors),
473
+ adjustTone: () =>
474
+ c.variant.name == 'fidelity'
475
+ ? toneDeltaPair(
476
+ colors.get('primary'),
477
+ colors.get('primaryContainer'),
478
+ 15,
479
+ 'relative_darker',
480
+ true,
481
+ 'farther',
482
+ )
483
+ : undefined,
484
+ contrastCurve: () => (c.contrastLevel > 0 ? getCurve(1.5) : undefined),
485
+ },
486
+ onPrimaryContainer: {
487
+ palette: () => palettes.get('primary'),
488
+ background: () => colors.get('primaryContainer'),
489
+ contrastCurve: () => getCurve(6),
490
+ },
491
+
492
+ // primaryFixed: {
493
+ // palette: () => palettes.get('primary'),
494
+ // tone: () => {
495
+ // return c.temp(
496
+ // {
497
+ // isDark: false,
498
+ // contrastLevel: 0,
499
+ // },
500
+ // () => {
501
+ // const color = getColor('primaryContainer');
502
+ // return color.getTone();
503
+ // },
504
+ // );
505
+ // },
506
+ // isBackground: true,
507
+ // background: () => highestSurface(c, colors),
508
+ // contrastCurve: () => (c.contrastLevel > 0 ? getCurve(1.5) : undefined),
509
+ // },
510
+
511
+ // primaryFixedDim: {
512
+ // palette: () => palettes.get('primary'),
513
+ // tone: () => colors.get('primaryFixed').getTone(),
514
+ // isBackground: true,
515
+ // adjustTone: () =>
516
+ // toneDeltaPair(
517
+ // getColor('primaryFixedDim'),
518
+ // getColor('primaryFixed'),
519
+ // 5,
520
+ // 'darker',
521
+ // true,
522
+ // 'exact',
523
+ // ),
524
+ // },
525
+
526
+ // onPrimaryFixed: {
527
+ // palette: () => palettes.get('primary'),
528
+ // background: () => colors.get('primaryFixedDim'),
529
+ // contrastCurve: () => getCurve(7),
530
+ // },
531
+
532
+ // onPrimaryFixedVariant: {
533
+ // palette: () => palettes.get('primary'),
534
+ // background: () => colors.get('primaryFixedDim'),
535
+ // contrastCurve: () => getCurve(4.5),
536
+ // },
537
+
538
+ inversePrimary: {
539
+ palette: () => palettes.get('primary'),
540
+ tone: () => tMaxC(palettes.get('primary')),
541
+ background: () => colors.get('inverseSurface'),
542
+ contrastCurve: () => getCurve(6),
543
+ },
544
+ ////////////////////////////////////////////////////////////////
545
+ // Secondaries [Q] //
546
+ ////////////////////////////////////////////////////////////////
547
+ secondary: {
548
+ palette: () => palettes.get('secondary'),
549
+ tone: () => {
550
+ return c.isDark ? 80 : tMaxC(palettes.get('secondary'));
551
+ },
552
+ isBackground: true,
553
+ background: () => highestSurface(c, colors),
554
+ contrastCurve: () => getCurve(4.5),
555
+ adjustTone: () =>
556
+ toneDeltaPair(
557
+ getColor('secondaryContainer'),
558
+ getColor('secondary'),
559
+ 5,
560
+ 'relative_lighter',
561
+ true,
562
+ 'farther',
563
+ ),
564
+ },
565
+ // secondaryDim: {
566
+ // palette: () => palettes.get('secondary'),
567
+ // tone: () => {
568
+ // if (c.variant.name === 'neutral') {
569
+ // return 85;
570
+ // } else {
571
+ // return tMaxC(palettes.get('secondary'), 0, 90);
572
+ // }
573
+ // },
574
+ // isBackground: true,
575
+ // background: () => getColor('surfaceContainerHigh'),
576
+ // contrastCurve: () => getCurve(4.5),
577
+ // adjustTone: () =>
578
+ // toneDeltaPair(
579
+ // getColor('secondaryDim'),
580
+ // getColor('secondary'),
581
+ // 5,
582
+ // 'darker',
583
+ // true,
584
+ // 'farther',
585
+ // ),
586
+ // },
587
+ onSecondary: {
588
+ palette: () => palettes.get('secondary'),
589
+ background: () => getColor('secondary'),
590
+ contrastCurve: () => getCurve(6),
591
+ },
592
+ secondaryContainer: {
593
+ palette: () => palettes.get('secondary'),
594
+ tone: () => {
595
+ return c.isDark ? 25 : 90;
596
+ },
597
+ isBackground: true,
598
+ background: () => highestSurface(c, colors),
599
+ adjustTone: () => undefined,
600
+ contrastCurve: () => (c.contrastLevel > 0 ? getCurve(1.5) : undefined),
601
+ },
602
+ onSecondaryContainer: {
603
+ palette: () => palettes.get('secondary'),
604
+ background: () => getColor('secondaryContainer'),
605
+ contrastCurve: () => getCurve(6),
606
+ },
607
+
608
+ // secondaryFixed: {
609
+ // palette: () => palettes.get('secondary'),
610
+ // tone: () => {
611
+ // return c.temp(
612
+ // {
613
+ // isDark: false,
614
+ // contrastLevel: 0,
615
+ // },
616
+ // () => {
617
+ // const color = getColor('secondaryContainer');
618
+ // return color.getTone();
619
+ // },
620
+ // );
621
+ // },
622
+ // isBackground: true,
623
+ // background: () => highestSurface(c, colors),
624
+ // contrastCurve: () => (c.contrastLevel > 0 ? getCurve(1.5) : undefined),
625
+ // },
626
+
627
+ // secondaryFixedDim: {
628
+ // palette: () => palettes.get('secondary'),
629
+ // tone: () => getColor('secondaryFixed').getTone(),
630
+ // isBackground: true,
631
+ // adjustTone: () =>
632
+ // toneDeltaPair(
633
+ // getColor('secondaryFixedDim'),
634
+ // getColor('secondaryFixed'),
635
+ // 5,
636
+ // 'darker',
637
+ // true,
638
+ // 'exact',
639
+ // ),
640
+ // },
641
+
642
+ // onSecondaryFixed: {
643
+ // palette: () => palettes.get('secondary'),
644
+ // background: () => getColor('secondaryFixedDim'),
645
+ // contrastCurve: () => getCurve(7),
646
+ // },
647
+
648
+ // onSecondaryFixedVariant: {
649
+ // palette: () => palettes.get('secondary'),
650
+ // background: () => getColor('secondaryFixedDim'),
651
+ // contrastCurve: () => getCurve(4.5),
652
+ // },
653
+
654
+ ////////////////////////////////////////////////////////////////
655
+ // Tertiaries [T] //
656
+ ////////////////////////////////////////////////////////////////
657
+ tertiary: {
658
+ palette: () => palettes.get('tertiary'),
659
+ tone: () => {
660
+ return c.isDark
661
+ ? tMaxC(palettes.get('tertiary'), 0, 98)
662
+ : tMaxC(palettes.get('tertiary'));
663
+ },
664
+ isBackground: true,
665
+ background: () => highestSurface(c, colors),
666
+ contrastCurve: () => getCurve(4.5),
667
+ adjustTone: () =>
668
+ toneDeltaPair(
669
+ getColor('tertiaryContainer'),
670
+ getColor('tertiary'),
671
+ 5,
672
+ 'relative_lighter',
673
+ true,
674
+ 'farther',
675
+ ),
676
+ },
677
+ // tertiaryDim: {
678
+ // palette: () => palettes.get('tertiary'),
679
+ // tone: () => {
680
+ // if (c.variant.name === 'tonalSpot') {
681
+ // return tMaxC(palettes.get('tertiary'), 0, 90);
682
+ // } else {
683
+ // return tMaxC(palettes.get('tertiary'));
684
+ // }
685
+ // },
686
+ // isBackground: true,
687
+ // background: () => getColor('surfaceContainerHigh'),
688
+ // contrastCurve: () => getCurve(4.5),
689
+ // adjustTone: () =>
690
+ // toneDeltaPair(
691
+ // getColor('tertiaryDim'),
692
+ // getColor('tertiary'),
693
+ // 5,
694
+ // 'darker',
695
+ // true,
696
+ // 'farther',
697
+ // ),
698
+ // },
699
+ onTertiary: {
700
+ palette: () => palettes.get('tertiary'),
701
+ background: () => getColor('tertiary'),
702
+ contrastCurve: () => getCurve(6),
703
+ },
704
+ tertiaryContainer: {
705
+ palette: () => palettes.get('tertiary'),
706
+ tone: () => {
707
+ return tMaxC(palettes.get('tertiary'), 0, c.isDark ? 93 : 100);
708
+ },
709
+ isBackground: true,
710
+ background: () => highestSurface(c, colors),
711
+ adjustTone: () => undefined,
712
+ contrastCurve: () => (c.contrastLevel > 0 ? getCurve(1.5) : undefined),
713
+ },
714
+ onTertiaryContainer: {
715
+ palette: () => palettes.get('tertiary'),
716
+ background: () => getColor('tertiaryContainer'),
717
+ contrastCurve: () => getCurve(6),
718
+ },
719
+
720
+ // tertiaryFixed: {
721
+ // palette: () => palettes.get('tertiary'),
722
+ // tone: () => {
723
+ // return c.temp(
724
+ // {
725
+ // isDark: false,
726
+ // contrastLevel: 0,
727
+ // },
728
+ // () => {
729
+ // const color = getColor('tertiaryContainer');
730
+ // return color.getTone();
731
+ // },
732
+ // );
733
+ // },
734
+ // isBackground: true,
735
+ // background: () => highestSurface(c, colors),
736
+ // contrastCurve: () => (c.contrastLevel > 0 ? getCurve(1.5) : undefined),
737
+ // },
738
+
739
+ // tertiaryFixedDim: {
740
+ // palette: () => palettes.get('tertiary'),
741
+ // tone: () => getColor('tertiaryFixed').getTone(),
742
+ // isBackground: true,
743
+ // adjustTone: () =>
744
+ // toneDeltaPair(
745
+ // getColor('tertiaryFixedDim'),
746
+ // getColor('tertiaryFixed'),
747
+ // 5,
748
+ // 'darker',
749
+ // true,
750
+ // 'exact',
751
+ // ),
752
+ // },
753
+
754
+ // onTertiaryFixed: {
755
+ // palette: () => palettes.get('tertiary'),
756
+ // background: () => getColor('tertiaryFixedDim'),
757
+ // contrastCurve: () => getCurve(7),
758
+ // },
759
+
760
+ // onTertiaryFixedVariant: {
761
+ // palette: () => palettes.get('tertiary'),
762
+ // background: () => getColor('tertiaryFixedDim'),
763
+ // contrastCurve: () => getCurve(4.5),
764
+ // },
765
+
766
+ ////////////////////////////////////////////////////////////////
767
+ // Errors [E] //
768
+ ////////////////////////////////////////////////////////////////
769
+
770
+ error: {
771
+ palette: () => palettes.get('error'),
772
+ tone: () => {
773
+ return c.isDark
774
+ ? tMinC(palettes.get('error'), 0, 98)
775
+ : tMaxC(palettes.get('error'));
776
+ },
777
+ isBackground: true,
778
+ background: () => highestSurface(c, colors),
779
+ contrastCurve: () => getCurve(4.5),
780
+ adjustTone: () =>
781
+ toneDeltaPair(
782
+ colors.get('errorContainer'),
783
+ colors.get('error'),
784
+ 5,
785
+ 'relative_lighter',
786
+ true,
787
+ 'farther',
788
+ ),
789
+ },
790
+ // errorDim: {
791
+ // palette: () => palettes.get('error'),
792
+ // tone: () => tMinC(palettes.get('error')),
793
+ // isBackground: true,
794
+ // background: () => getColor('surfaceContainerHigh'),
795
+ // contrastCurve: () => getCurve(4.5),
796
+ // adjustTone: () =>
797
+ // toneDeltaPair(
798
+ // getColor('errorDim'),
799
+ // getColor('error'),
800
+ // 5,
801
+ // 'darker',
802
+ // true,
803
+ // 'farther',
804
+ // ),
805
+ // },
806
+ onError: {
807
+ palette: () => palettes.get('error'),
808
+ background: () => colors.get('error'),
809
+ contrastCurve: () => getCurve(6),
810
+ },
811
+ errorContainer: {
812
+ palette: () => palettes.get('error'),
813
+ tone: () => {
814
+ return c.isDark
815
+ ? tMinC(palettes.get('error'), 30, 93)
816
+ : tMaxC(palettes.get('error'), 0, 90);
817
+ },
818
+ isBackground: true,
819
+ background: () => highestSurface(c, colors),
820
+ adjustTone: () => undefined,
821
+ contrastCurve: () => (c.contrastLevel > 0 ? getCurve(1.5) : undefined),
822
+ },
823
+ onErrorContainer: {
824
+ palette: () => palettes.get('error'),
825
+ background: () => colors.get('errorContainer'),
826
+ contrastCurve: () => getCurve(4.5),
827
+ },
828
+
829
+ /////////////////////////////////////////////////////////////////
830
+ // Remapped Colors //
831
+ /////////////////////////////////////////////////////////////////
832
+ surfaceVariant: {
833
+ alias: 'surfaceContainerHighest',
834
+ },
835
+ surfaceTint: {
836
+ alias: 'primary',
837
+ },
838
+ background: {
839
+ alias: 'surface',
840
+ },
841
+ onBackground: {
842
+ alias: 'onSurface',
843
+ },
844
+ };
845
+ },
846
+ });