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