@udixio/theme 1.3.0 → 2.0.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.
Files changed (139) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/API.d.ts +7 -4
  3. package/dist/API.d.ts.map +1 -1
  4. package/dist/app.container.d.ts +1 -2
  5. package/dist/app.container.d.ts.map +1 -1
  6. package/dist/bin.cjs +1 -1
  7. package/dist/bin.js +1 -1
  8. package/dist/browser.cjs +22 -18
  9. package/dist/browser.js +32 -28
  10. package/dist/color/color.api.d.ts +11 -30
  11. package/dist/color/color.api.d.ts.map +1 -1
  12. package/dist/color/color.d.ts +99 -0
  13. package/dist/color/color.d.ts.map +1 -0
  14. package/dist/color/color.manager.d.ts +9 -17
  15. package/dist/color/color.manager.d.ts.map +1 -1
  16. package/dist/color/color.utils.d.ts +14 -3
  17. package/dist/color/color.utils.d.ts.map +1 -1
  18. package/dist/color/default-color.d.ts.map +1 -1
  19. package/dist/color/index.d.ts +1 -1
  20. package/dist/color/index.d.ts.map +1 -1
  21. package/dist/config/config.interface.d.ts +4 -4
  22. package/dist/config/config.interface.d.ts.map +1 -1
  23. package/dist/context/context.d.ts +41 -0
  24. package/dist/context/context.d.ts.map +1 -0
  25. package/dist/context/context.module.d.ts +3 -0
  26. package/dist/context/context.module.d.ts.map +1 -0
  27. package/dist/context/index.d.ts +3 -0
  28. package/dist/context/index.d.ts.map +1 -0
  29. package/dist/font.plugin-BZ-TTeTo.cjs +227 -0
  30. package/dist/font.plugin-DZtMajJV.js +228 -0
  31. package/dist/index.d.ts +6 -4
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/{load-from-path-BuN8RpOs.cjs → load-from-path-DZ35yiXK.cjs} +2 -2
  34. package/dist/{load-from-path-BSrT4DOj.js → load-from-path-Dobe0beV.js} +1 -1
  35. package/dist/loader/loader.d.ts +1 -1
  36. package/dist/loader/loader.d.ts.map +1 -1
  37. package/dist/{loader-Bc0bstAD.js → loader-BS_Esfwg.js} +1408 -905
  38. package/dist/{loader-YNN5hAF3.cjs → loader-C8LnOoqg.cjs} +1392 -889
  39. package/dist/material-color-utilities/dynamic_color.d.ts +0 -22
  40. package/dist/material-color-utilities/dynamic_color.d.ts.map +1 -1
  41. package/dist/material-color-utilities/toneDeltaPair.d.ts +8 -8
  42. package/dist/material-color-utilities/toneDeltaPair.d.ts.map +1 -1
  43. package/dist/node.cjs +23 -19
  44. package/dist/node.js +34 -30
  45. package/dist/palette/index.d.ts +4 -0
  46. package/dist/palette/index.d.ts.map +1 -0
  47. package/dist/palette/palette.api.d.ts +13 -0
  48. package/dist/palette/palette.api.d.ts.map +1 -0
  49. package/dist/palette/palette.d.ts +33 -0
  50. package/dist/palette/palette.d.ts.map +1 -0
  51. package/dist/palette/palette.manager.d.ts +20 -0
  52. package/dist/palette/palette.manager.d.ts.map +1 -0
  53. package/dist/palette/palette.module.d.ts +3 -0
  54. package/dist/palette/palette.module.d.ts.map +1 -0
  55. package/dist/plugins/font/font.plugin.d.ts +1 -1
  56. package/dist/plugins/font/font.plugin.d.ts.map +1 -1
  57. package/dist/variant/index.d.ts +3 -0
  58. package/dist/variant/index.d.ts.map +1 -0
  59. package/dist/variant/variant.d.ts +29 -0
  60. package/dist/variant/variant.d.ts.map +1 -0
  61. package/dist/variant/variants/expressive.variant.d.ts +2 -0
  62. package/dist/variant/variants/expressive.variant.d.ts.map +1 -0
  63. package/dist/variant/variants/fidelity.variant.d.ts.map +1 -0
  64. package/dist/variant/variants/index.d.ts.map +1 -0
  65. package/dist/variant/variants/neutral.variant.d.ts.map +1 -0
  66. package/dist/variant/variants/tonal-spot.variant.d.ts.map +1 -0
  67. package/dist/variant/variants/vibrant.variant.d.ts.map +1 -0
  68. package/package.json +1 -1
  69. package/src/API.ts +12 -5
  70. package/src/app.container.ts +22 -11
  71. package/src/bootstrap.ts +1 -1
  72. package/src/color/color.api.ts +168 -47
  73. package/src/color/color.manager.ts +38 -181
  74. package/src/color/color.ts +291 -0
  75. package/src/color/color.utils.ts +48 -3
  76. package/src/color/default-color.ts +395 -396
  77. package/src/color/index.ts +1 -1
  78. package/src/config/config.interface.ts +5 -4
  79. package/src/context/context.module.ts +7 -0
  80. package/src/context/context.ts +169 -0
  81. package/src/context/index.ts +2 -0
  82. package/src/index.ts +6 -4
  83. package/src/loader/loader.ts +14 -23
  84. package/src/material-color-utilities/dynamic_color.ts +25 -34
  85. package/src/material-color-utilities/toneDeltaPair.ts +44 -41
  86. package/src/palette/index.ts +3 -0
  87. package/src/palette/palette.api.ts +43 -0
  88. package/src/palette/palette.manager.ts +74 -0
  89. package/src/palette/palette.module.ts +9 -0
  90. package/src/palette/palette.ts +207 -0
  91. package/src/plugins/font/font.plugin.ts +1 -1
  92. package/src/variant/index.ts +2 -0
  93. package/src/variant/variant.ts +81 -0
  94. package/src/{theme → variant}/variants/expressive.variant.ts +31 -29
  95. package/src/variant/variants/fidelity.variant.ts +46 -0
  96. package/src/{theme → variant}/variants/neutral.variant.ts +18 -18
  97. package/src/variant/variants/tonal-spot.variant.ts +35 -0
  98. package/src/{theme → variant}/variants/vibrant.variant.ts +21 -22
  99. package/dist/color/configurable-color.d.ts +0 -31
  100. package/dist/color/configurable-color.d.ts.map +0 -1
  101. package/dist/define-config-B1QPKKY_.js +0 -430
  102. package/dist/define-config-BGgVazsr.cjs +0 -429
  103. package/dist/theme/index.d.ts +0 -8
  104. package/dist/theme/index.d.ts.map +0 -1
  105. package/dist/theme/scheme.d.ts +0 -20
  106. package/dist/theme/scheme.d.ts.map +0 -1
  107. package/dist/theme/scheme.manager.d.ts +0 -31
  108. package/dist/theme/scheme.manager.d.ts.map +0 -1
  109. package/dist/theme/theme.api.d.ts +0 -23
  110. package/dist/theme/theme.api.d.ts.map +0 -1
  111. package/dist/theme/theme.module.d.ts +0 -3
  112. package/dist/theme/theme.module.d.ts.map +0 -1
  113. package/dist/theme/variant.d.ts +0 -36
  114. package/dist/theme/variant.d.ts.map +0 -1
  115. package/dist/theme/variant.manager.d.ts +0 -14
  116. package/dist/theme/variant.manager.d.ts.map +0 -1
  117. package/dist/theme/variants/expressive.variant.d.ts +0 -3
  118. package/dist/theme/variants/expressive.variant.d.ts.map +0 -1
  119. package/dist/theme/variants/fidelity.variant.d.ts.map +0 -1
  120. package/dist/theme/variants/index.d.ts.map +0 -1
  121. package/dist/theme/variants/neutral.variant.d.ts.map +0 -1
  122. package/dist/theme/variants/tonal-spot.variant.d.ts.map +0 -1
  123. package/dist/theme/variants/vibrant.variant.d.ts.map +0 -1
  124. package/src/color/configurable-color.ts +0 -67
  125. package/src/theme/index.ts +0 -7
  126. package/src/theme/scheme.manager.ts +0 -100
  127. package/src/theme/scheme.ts +0 -66
  128. package/src/theme/theme.api.ts +0 -78
  129. package/src/theme/theme.module.ts +0 -11
  130. package/src/theme/variant.manager.ts +0 -58
  131. package/src/theme/variant.ts +0 -53
  132. package/src/theme/variants/fidelity.variant.ts +0 -38
  133. package/src/theme/variants/tonal-spot.variant.ts +0 -35
  134. /package/dist/{theme → variant}/variants/fidelity.variant.d.ts +0 -0
  135. /package/dist/{theme → variant}/variants/index.d.ts +0 -0
  136. /package/dist/{theme → variant}/variants/neutral.variant.d.ts +0 -0
  137. /package/dist/{theme → variant}/variants/tonal-spot.variant.d.ts +0 -0
  138. /package/dist/{theme → variant}/variants/vibrant.variant.d.ts +0 -0
  139. /package/src/{theme → variant}/variants/index.ts +0 -0
@@ -1,75 +1,196 @@
1
- import { ColorOptions, ConfigurableColor } from './configurable-color';
2
- import { ColorManager } from './color.manager';
3
- import { DynamicColorKey } from './color.utils';
1
+ import { Color, ColorOptions } from './color';
2
+ import { ColorManager, highestSurface } from './color.manager';
3
+ import { DynamicColorKey, getCurve, tMaxC, tMinC } from './color.utils';
4
+ import { API } from '../API';
5
+ import { toneDeltaPair } from '../material-color-utilities';
4
6
 
5
- export type AddColors = {
6
- colors?: Record<
7
- DynamicColorKey | string,
8
- | (Partial<ColorOptions> & { alias?: never })
9
- | { alias: string; palette?: never; tone?: never }
10
- >;
11
- fromPalettes?: string[] | string;
12
- };
7
+ function capitalizeFirstLetter(string: string) {
8
+ return string.charAt(0).toUpperCase() + string.slice(1);
9
+ }
13
10
 
14
11
  export type AddColorsOptions =
15
- | AddColors
16
- | ((colorService: ColorApi) => AddColors);
12
+ | ((args: API) => Record<string, ColorOptions>)
13
+ | Record<string, ColorOptions>;
17
14
 
18
15
  export class ColorApi {
19
16
  private readonly colorManager: ColorManager;
17
+ public api?: API;
20
18
 
21
19
  constructor({ colorManager }: { colorManager: ColorManager }) {
22
20
  this.colorManager = colorManager;
23
21
  }
24
22
 
25
- getColors() {
23
+ getAll() {
26
24
  return this.colorManager.getAll();
27
25
  }
28
26
 
29
- addColor(
30
- key: string,
31
- color:
32
- | (Partial<ColorOptions> & { alias?: never })
33
- | { alias: string; palette?: never; tone?: never },
34
- ): ConfigurableColor {
27
+ addColor(key: string, color: ColorOptions): Color {
35
28
  return this.colorManager.createOrUpdate(key, color);
36
29
  }
37
30
 
38
- addColors(args: AddColorsOptions | AddColorsOptions[]) {
39
- if (!Array.isArray(args)) args = [args];
40
- args.forEach((args) => {
41
- if (typeof args === 'function') {
42
- args = args(this);
43
- }
44
- if (args.fromPalettes) {
45
- if (!Array.isArray(args.fromPalettes))
46
- args.fromPalettes = [args.fromPalettes];
47
- args.fromPalettes.map((paletteKey) => {
48
- this.colorManager.addFromPalette(paletteKey);
49
- });
50
- }
51
- if (args.colors) {
52
- Object.keys(args.colors).map((key) =>
53
- this.addColor(key, args.colors![key]),
54
- );
55
- }
56
- });
31
+ addColors(args: AddColorsOptions) {
32
+ if (!this.api)
33
+ throw new Error(
34
+ 'The API is not initialized. Please call bootstrap() before calling addColors().',
35
+ );
36
+
37
+ if (typeof args === 'function') {
38
+ args = args(this.api);
39
+ }
40
+ if (args) {
41
+ Object.entries(args).forEach(([name, colorOption]) => {
42
+ this.addColor(name, colorOption);
43
+ });
44
+ }
57
45
  }
58
46
 
59
- getColor(key: DynamicColorKey | string): ConfigurableColor {
47
+ get(key: DynamicColorKey | string): Color {
60
48
  return this.colorManager.get(key);
61
49
  }
62
50
 
63
- removeColor(key: string): boolean {
51
+ remove(key: string): boolean {
64
52
  return this.colorManager.remove(key);
65
53
  }
66
54
 
67
- updateColor(
68
- key: string,
69
- newColor:
70
- | (Partial<ColorOptions> & { alias?: never })
71
- | { alias: string; palette?: never; tone?: never },
72
- ): ConfigurableColor {
55
+ update(key: string, newColor: ColorOptions): Color {
73
56
  return this.colorManager.createOrUpdate(key, newColor);
74
57
  }
58
+
59
+ addFromCustomPalette(key: string): void {
60
+ const colorKey = key as DynamicColorKey;
61
+ const colorDimKey = (colorKey + 'Dim') as DynamicColorKey;
62
+ const ColorKey = capitalizeFirstLetter(key);
63
+ const onColorKey = ('on' + ColorKey) as DynamicColorKey;
64
+ const colorContainerKey = (colorKey + 'Container') as DynamicColorKey;
65
+ const onColorContainerKey = ('on' +
66
+ ColorKey +
67
+ 'Container') as DynamicColorKey;
68
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
69
+ // @ts-expect-error
70
+ const inverseColorKey = ('inverse' + ColorKey) as DynamicColorKey;
71
+ const colorFixedKey = (colorKey + 'Fixed') as DynamicColorKey;
72
+ const colorFixedDimKey = (colorKey + 'FixedDim') as DynamicColorKey;
73
+ const onColorFixedKey = ('on' + ColorKey + 'Fixed') as DynamicColorKey;
74
+ const onColorFixedVariantKey = ('on' +
75
+ ColorKey +
76
+ 'FixedVariant') as DynamicColorKey;
77
+ const colors: AddColorsOptions = ({ palettes, colors, context: ctx }) => ({
78
+ [colorKey]: {
79
+ palette: () => palettes.get(colorKey),
80
+ tone: () => {
81
+ if (ctx.variant.name === 'neutral') {
82
+ return ctx.isDark
83
+ ? tMinC(palettes.get(colorKey), 0, 98)
84
+ : tMaxC(palettes.get(colorKey));
85
+ } else if (ctx.variant.name === 'vibrant') {
86
+ return tMaxC(palettes.get(colorKey), 0, ctx.isDark ? 90 : 98);
87
+ } else {
88
+ return ctx.isDark ? 80 : tMaxC(palettes.get(colorKey));
89
+ }
90
+ },
91
+ isBackground: true,
92
+ background: () => highestSurface(ctx, this),
93
+ contrastCurve: () => getCurve(4.5),
94
+ adjustTone: () =>
95
+ toneDeltaPair(
96
+ colors.get(colorContainerKey),
97
+ colors.get(colorKey),
98
+ 5,
99
+ 'relative_lighter',
100
+ true,
101
+ 'farther',
102
+ ),
103
+ },
104
+ [colorDimKey]: {
105
+ palette: () => palettes.get(colorKey),
106
+ tone: () => {
107
+ if (ctx.variant.name === 'neutral') {
108
+ return 85;
109
+ } else {
110
+ return tMaxC(palettes.get(colorKey), 0, 90);
111
+ }
112
+ },
113
+ isBackground: true,
114
+ background: () => this.get('surfaceContainerHigh'),
115
+ contrastCurve: () => getCurve(4.5),
116
+ adjustTone: () =>
117
+ toneDeltaPair(
118
+ this.get(colorDimKey),
119
+ this.get(colorKey),
120
+ 5,
121
+ 'darker',
122
+ true,
123
+ 'farther',
124
+ ),
125
+ },
126
+ [onColorKey]: {
127
+ palette: () => palettes.get(colorKey),
128
+ background: () => this.get(colorKey),
129
+ contrastCurve: () => getCurve(6),
130
+ },
131
+ [colorContainerKey]: {
132
+ palette: () => palettes.get(colorKey),
133
+ tone: () => {
134
+ if (ctx.variant.name === 'vibrant') {
135
+ return ctx.isDark
136
+ ? tMinC(palettes.get(colorKey), 30, 40)
137
+ : tMaxC(palettes.get(colorKey), 84, 90);
138
+ } else if (ctx.variant.name === 'expressive') {
139
+ return ctx.isDark ? 15 : tMaxC(palettes.get(colorKey), 90, 95);
140
+ } else {
141
+ return ctx.isDark ? 25 : 90;
142
+ }
143
+ },
144
+ isBackground: true,
145
+ background: () => highestSurface(ctx, this),
146
+ adjustTone: () => undefined,
147
+ contrastCurve: () =>
148
+ ctx.contrastLevel > 0 ? getCurve(1.5) : undefined,
149
+ },
150
+ [onColorContainerKey]: {
151
+ palette: () => palettes.get(colorKey),
152
+ background: () => this.get(colorContainerKey),
153
+ contrastCurve: () => getCurve(6),
154
+ },
155
+ [colorFixedKey]: {
156
+ palette: () => palettes.get(colorKey),
157
+ tone: () => {
158
+ return ctx.temp({ isDark: false, contrastLevel: 0 }, () => {
159
+ const color = this.get(colorContainerKey);
160
+ return color.getTone();
161
+ });
162
+ },
163
+ isBackground: true,
164
+ background: () => highestSurface(ctx, this),
165
+ contrastCurve: () =>
166
+ ctx.contrastLevel > 0 ? getCurve(1.5) : undefined,
167
+ },
168
+ [colorFixedDimKey]: {
169
+ palette: () => palettes.get(colorKey),
170
+ tone: () => this.get(colorFixedKey).getTone(),
171
+ isBackground: true,
172
+ adjustTone: () =>
173
+ toneDeltaPair(
174
+ this.get(colorFixedDimKey),
175
+ this.get(colorFixedKey),
176
+ 5,
177
+ 'darker',
178
+ true,
179
+ 'exact',
180
+ ),
181
+ },
182
+ [onColorFixedKey]: {
183
+ palette: () => palettes.get(colorKey),
184
+ background: () => this.get(colorFixedDimKey),
185
+ contrastCurve: () => getCurve(7),
186
+ },
187
+ [onColorFixedVariantKey]: {
188
+ palette: () => palettes.get(colorKey),
189
+ background: () => this.get(colorFixedDimKey),
190
+ contrastCurve: () => getCurve(4.5),
191
+ },
192
+ });
193
+
194
+ this.addColors(colors);
195
+ }
75
196
  }
@@ -1,67 +1,55 @@
1
- import { DynamicColor, toneDeltaPair } from '../material-color-utilities';
2
- import { Scheme, SchemeManager } from '../theme';
3
-
4
- import { ColorOptions, ConfigurableColor } from './configurable-color';
5
- import { DynamicColorKey, getCurve, tMaxC, tMinC } from './color.utils';
1
+ import {
2
+ Color,
3
+ ColorAlias,
4
+ ColorFromHex,
5
+ ColorFromPalette,
6
+ ColorOptions,
7
+ } from './color';
6
8
  import { ColorApi } from './color.api';
7
-
8
- function capitalizeFirstLetter(string: string) {
9
- return string.charAt(0).toUpperCase() + string.slice(1);
10
- }
9
+ import { Context } from '../context';
11
10
 
12
11
  export const highestSurface = (
13
- s: Scheme,
12
+ context: Context,
14
13
  colorService: ColorManager | ColorApi,
15
- ): DynamicColor => {
14
+ ): Color => {
16
15
  if (colorService instanceof ColorApi) {
17
- return s.isDark
18
- ? colorService.getColor('surfaceBright').getMaterialColor()
19
- : colorService.getColor('surfaceDim').getMaterialColor();
16
+ return context.isDark
17
+ ? colorService.get('surfaceBright')
18
+ : colorService.get('surfaceDim');
20
19
  } else {
21
- return s.isDark
22
- ? colorService.get('surfaceBright').getMaterialColor()
23
- : colorService.get('surfaceDim').getMaterialColor();
20
+ return context.isDark
21
+ ? colorService.get('surfaceBright')
22
+ : colorService.get('surfaceDim');
24
23
  }
25
24
  };
26
25
 
27
26
  export class ColorManager {
28
- private colorMap = new Map<string, ConfigurableColor>();
29
- private readonly schemeManager: SchemeManager;
27
+ private colorMap = new Map<string, Color>();
28
+ private readonly context: Context;
30
29
 
31
- constructor({ schemeManager }: { schemeManager: SchemeManager }) {
32
- this.schemeManager = schemeManager;
30
+ constructor(args: { context: Context }) {
31
+ this.context = args.context;
33
32
  }
34
33
 
35
- createOrUpdate(
36
- key: string,
37
- args:
38
- | (Partial<ColorOptions> & { alias?: never })
39
- | { alias: string; palette?: never; tone?: never },
40
- ): ConfigurableColor {
34
+ createOrUpdate(key: string, args: ColorOptions): Color {
41
35
  let colorEntity = this.colorMap.get(key);
42
- if (!colorEntity) {
43
- const { palette, alias } = args;
44
- if (palette) {
45
- colorEntity = new ConfigurableColor(
46
- { ...args, palette: palette, name: key },
47
- this.schemeManager,
48
- this,
49
- );
50
- this.colorMap.set(key, colorEntity);
51
- } else if (alias) {
52
- colorEntity = new ConfigurableColor(
53
- { ...args, alias: alias, name: key },
54
- this.schemeManager,
55
- this,
56
- );
57
- this.colorMap.set(key, colorEntity);
58
- } else {
59
- throw new Error(`Palette ${palette} does not exist from ${key}`);
60
- }
36
+ if ('alias' in args) {
37
+ colorEntity = new ColorAlias(key, args.alias, this);
38
+ } else if ('hex' in args) {
39
+ colorEntity = new ColorFromHex(key, args.hex);
61
40
  } else {
62
- colorEntity.update({ ...args, name: key });
63
- this.colorMap.set(key, colorEntity);
41
+ try {
42
+ if (colorEntity instanceof ColorFromPalette) {
43
+ colorEntity.update(args);
44
+ } else {
45
+ colorEntity = new ColorFromPalette(key, args, this.context);
46
+ }
47
+ } catch (e) {
48
+ console.error(e);
49
+ throw new Error(`Invalid color options provided for ${key}`);
50
+ }
64
51
  }
52
+ this.colorMap.set(key, colorEntity);
65
53
  return colorEntity;
66
54
  }
67
55
 
@@ -69,7 +57,7 @@ export class ColorManager {
69
57
  return this.colorMap.delete(key);
70
58
  }
71
59
 
72
- public get(key: string): ConfigurableColor {
60
+ public get(key: string): Color {
73
61
  const colorEntity = this.colorMap.get(key);
74
62
  if (colorEntity) {
75
63
  return colorEntity;
@@ -78,138 +66,7 @@ export class ColorManager {
78
66
  }
79
67
  }
80
68
 
81
- public getAll(): ReadonlyMap<string, ConfigurableColor> {
69
+ public getAll(): ReadonlyMap<string, Color> {
82
70
  return this.colorMap;
83
71
  }
84
-
85
- addFromPalette(key: string): void {
86
- const colorKey = key as DynamicColorKey;
87
- const colorDimKey = (colorKey + 'Dim') as DynamicColorKey;
88
- const ColorKey = capitalizeFirstLetter(key);
89
- const onColorKey = ('on' + ColorKey) as DynamicColorKey;
90
- const colorContainerKey = (colorKey + 'Container') as DynamicColorKey;
91
- const onColorContainerKey = ('on' +
92
- ColorKey +
93
- 'Container') as DynamicColorKey;
94
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
95
- // @ts-expect-error
96
- const inverseColorKey = ('inverse' + ColorKey) as DynamicColorKey;
97
- const colorFixedKey = (colorKey + 'Fixed') as DynamicColorKey;
98
- const colorFixedDimKey = (colorKey + 'FixedDim') as DynamicColorKey;
99
- const onColorFixedKey = ('on' + ColorKey + 'Fixed') as DynamicColorKey;
100
- const onColorFixedVariantKey = ('on' +
101
- ColorKey +
102
- 'FixedVariant') as DynamicColorKey;
103
-
104
- this.createOrUpdate(colorKey, {
105
- palette: (s) => s.getPalette(colorKey),
106
- tone: (s) => {
107
- if (s.variant === 'neutral') {
108
- return s.isDark
109
- ? tMinC(s.getPalette(colorKey), 0, 98)
110
- : tMaxC(s.getPalette(colorKey));
111
- } else if (s.variant === 'vibrant') {
112
- return tMaxC(s.getPalette(colorKey), 0, s.isDark ? 90 : 98);
113
- } else {
114
- return s.isDark ? 80 : tMaxC(s.getPalette(colorKey));
115
- }
116
- },
117
- isBackground: true,
118
- background: (s) => highestSurface(s, this),
119
- contrastCurve: (s) => getCurve(4.5),
120
- adjustTone: (s) =>
121
- toneDeltaPair(
122
- this.get(colorContainerKey).getMaterialColor(),
123
- this.get(colorKey).getMaterialColor(),
124
- 5,
125
- 'relative_lighter',
126
- true,
127
- 'farther',
128
- ),
129
- });
130
- this.createOrUpdate(colorDimKey, {
131
- palette: (s) => s.getPalette(colorKey),
132
- tone: (s) => {
133
- if (s.variant === 'neutral') {
134
- return 85;
135
- } else {
136
- return tMaxC(s.getPalette(colorKey), 0, 90);
137
- }
138
- },
139
- isBackground: true,
140
- background: (s) => this.get('surfaceContainerHigh').getMaterialColor(),
141
- contrastCurve: (s) => getCurve(4.5),
142
- adjustTone: (s) =>
143
- toneDeltaPair(
144
- this.get(colorDimKey).getMaterialColor(),
145
- this.get(colorKey).getMaterialColor(),
146
- 5,
147
- 'darker',
148
- true,
149
- 'farther',
150
- ),
151
- });
152
- this.createOrUpdate(onColorKey, {
153
- palette: (s) => s.getPalette(colorKey),
154
- background: (s) => this.get(colorKey).getMaterialColor(),
155
- contrastCurve: (s) => getCurve(6),
156
- });
157
- this.createOrUpdate(colorContainerKey, {
158
- palette: (s) => s.getPalette(colorKey),
159
- tone: (s) => {
160
- if (s.variant === 'vibrant') {
161
- return s.isDark
162
- ? tMinC(s.getPalette(colorKey), 30, 40)
163
- : tMaxC(s.getPalette(colorKey), 84, 90);
164
- } else if (s.variant === 'expressive') {
165
- return s.isDark ? 15 : tMaxC(s.getPalette(colorKey), 90, 95);
166
- } else {
167
- return s.isDark ? 25 : 90;
168
- }
169
- },
170
- isBackground: true,
171
- background: (s) => highestSurface(s, this),
172
- adjustTone: (s) => undefined,
173
- contrastCurve: (s) => (s.contrastLevel > 0 ? getCurve(1.5) : undefined),
174
- });
175
- this.createOrUpdate(onColorContainerKey, {
176
- palette: (s) => s.getPalette(colorKey),
177
- background: (s) => this.get(colorContainerKey).getMaterialColor(),
178
- contrastCurve: (s) => getCurve(6),
179
- });
180
- this.createOrUpdate(colorFixedKey, {
181
- palette: (s) => s.getPalette(colorKey),
182
- tone: (s) => {
183
- const tempS = Object.assign({}, s, { isDark: false, contrastLevel: 0 });
184
- return this.get(colorContainerKey).getMaterialColor().getTone(tempS);
185
- },
186
- isBackground: true,
187
- background: (s) => highestSurface(s, this),
188
- contrastCurve: (s) => (s.contrastLevel > 0 ? getCurve(1.5) : undefined),
189
- });
190
- this.createOrUpdate(colorFixedDimKey, {
191
- palette: (s) => s.getPalette(colorKey),
192
- tone: (s) => this.get(colorFixedKey).getMaterialColor().getTone(s),
193
- isBackground: true,
194
- adjustTone: (s) =>
195
- toneDeltaPair(
196
- this.get(colorFixedDimKey).getMaterialColor(),
197
- this.get(colorFixedKey).getMaterialColor(),
198
- 5,
199
- 'darker',
200
- true,
201
- 'exact',
202
- ),
203
- });
204
- this.createOrUpdate(onColorFixedKey, {
205
- palette: (s) => s.getPalette(colorKey),
206
- background: (s) => this.get(colorFixedDimKey).getMaterialColor(),
207
- contrastCurve: (s) => getCurve(7),
208
- });
209
- this.createOrUpdate(onColorFixedVariantKey, {
210
- palette: (s) => s.getPalette(colorKey),
211
- background: (s) => this.get(colorFixedDimKey).getMaterialColor(),
212
- contrastCurve: (s) => getCurve(4.5),
213
- });
214
- }
215
72
  }