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