@codeleap/styles 5.8.1 → 5.8.3

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 (69) hide show
  1. package/package.json +9 -15
  2. package/package.json.bak +8 -14
  3. package/src/classes/Cacher.ts +169 -0
  4. package/src/classes/StaleControl.ts +125 -0
  5. package/src/classes/StyleCache.ts +116 -0
  6. package/src/classes/StylePersistor.ts +62 -0
  7. package/src/{lib → classes}/StyleRegistry.ts +7 -12
  8. package/src/classes/index.ts +2 -0
  9. package/src/classes/tests/Cache.spec.ts +371 -0
  10. package/src/classes/tests/StaleControl.spec.ts +175 -0
  11. package/src/classes/tests/StyleCache.spec.ts +452 -0
  12. package/src/classes/tests/StylePersistor.spec.ts +231 -0
  13. package/src/{lib/constants.ts → constants.ts} +1 -0
  14. package/src/hooks/index.ts +4 -0
  15. package/src/hooks/tests/useCompositionStyles.spec.ts +107 -0
  16. package/src/hooks/tests/useStyleObserver.spec.ts +89 -0
  17. package/src/hooks/useCompositionStyles.ts +33 -0
  18. package/src/hooks/useNestedStylesByKey.ts +13 -0
  19. package/src/hooks/useStyleObserver.ts +19 -0
  20. package/src/hooks/useTheme.ts +16 -0
  21. package/src/index.ts +9 -5
  22. package/src/lib/createStyles.ts +10 -1
  23. package/src/lib/createTheme.ts +22 -13
  24. package/src/lib/index.ts +1 -10
  25. package/src/lib/tests/createStyles.spec.ts +151 -0
  26. package/src/tests/colors/baseColors.ts +166 -0
  27. package/src/tests/colors/darkMode.ts +232 -0
  28. package/src/tests/colors/lightMode.ts +285 -0
  29. package/src/tests/measures.ts +31 -0
  30. package/src/tests/theme.ts +58 -0
  31. package/src/theme/generateColorScheme.ts +53 -0
  32. package/src/theme/index.ts +3 -0
  33. package/src/theme/tests/generateColorScheme.spec.ts +118 -0
  34. package/src/theme/tests/themeStore.spec.ts +698 -0
  35. package/src/theme/tests/validateTheme.spec.ts +173 -0
  36. package/src/{lib → theme}/themeStore.ts +68 -3
  37. package/src/{lib → theme}/validateTheme.ts +13 -0
  38. package/src/tools/colors.ts +83 -39
  39. package/src/tools/deepClone.ts +10 -0
  40. package/src/tools/deepmerge.ts +10 -0
  41. package/src/{lib → tools}/hashKey.ts +7 -0
  42. package/src/tools/index.ts +6 -1
  43. package/src/tools/minifier.ts +38 -0
  44. package/src/tools/tests/colors.spec.ts +233 -0
  45. package/src/tools/tests/deepClone.spec.ts +102 -0
  46. package/src/tools/tests/deepmerge.spec.ts +155 -0
  47. package/src/tools/tests/hashKey.spec.ts +69 -0
  48. package/src/tools/tests/minifier.spec.ts +173 -0
  49. package/src/types/store.ts +2 -2
  50. package/src/types/style.ts +3 -3
  51. package/src/types/theme.ts +4 -4
  52. package/src/{lib/utils.ts → utils.ts} +3 -3
  53. package/src/{lib → variants}/borderCreator.ts +2 -2
  54. package/src/{lib → variants}/createAppVariants.ts +1 -1
  55. package/src/{lib → variants}/dynamicVariants.ts +1 -1
  56. package/src/variants/index.ts +6 -0
  57. package/src/{lib → variants}/spacing.ts +37 -24
  58. package/src/variants/tests/borderCreator.spec.ts +180 -0
  59. package/src/variants/tests/dynamicVariants.spec.ts +194 -0
  60. package/src/variants/tests/spacing.spec.ts +177 -0
  61. package/src/lib/Cacher.ts +0 -112
  62. package/src/lib/StaleControl.ts +0 -73
  63. package/src/lib/StyleCache.ts +0 -81
  64. package/src/lib/StylePersistor.ts +0 -28
  65. package/src/lib/hooks.ts +0 -60
  66. package/src/lib/minifier.ts +0 -20
  67. /package/src/{lib → tools}/multiplierProperty.ts +0 -0
  68. /package/src/{lib → variants}/defaultVariants.ts +0 -0
  69. /package/src/{lib → variants}/mediaQuery.ts +0 -0
@@ -0,0 +1,285 @@
1
+ import colors from './baseColors'
2
+
3
+ export default {
4
+ ...colors,
5
+ buttonRegularPrimaryBgDefault: colors.primarySolid800,
6
+ buttonRegularQuaternaryBgDefault: colors.neutralWhiteTransparent0,
7
+ buttonRegularPrimaryBgPressed: colors.primarySolid700,
8
+ buttonRegularPrimaryBgHover: colors.primarySolid700,
9
+ buttonRegularPrimaryBgDisabled: colors.primarySolid50,
10
+ buttonRegularQuaternaryLabelDefault: colors.primarySolid800,
11
+ buttonRegularQuaternaryIconDefault: colors.primarySolid800,
12
+ buttonRegularQuaternaryIconPressed: colors.primarySolid800,
13
+ buttonRegularQuaternaryIconHover: colors.primarySolid800,
14
+ buttonRegularQuaternaryIconDisabled: colors.neutralBlackTransparent200,
15
+ buttonRegularSecondaryBgDefault: colors.primarySolid100,
16
+ buttonRegularSecondaryBgPressed: colors.primarySolid200,
17
+ buttonRegularSecondaryBgHover: colors.primarySolid200,
18
+ buttonRegularSecondaryBgDisabled: colors.primarySolid50,
19
+ buttonRegularSecondaryLabelDefault: colors.primarySolid800,
20
+ buttonRegularSecondaryLabelHover: colors.primarySolid800,
21
+ buttonRegularSecondaryLabelPressed: colors.primarySolid800,
22
+ buttonRegularSecondaryLabelDisabled: colors.neutralBlackTransparent200,
23
+ buttonRegularSecondaryIconDefault: colors.primarySolid800,
24
+ buttonRegularSecondaryIconPressed: colors.primarySolid800,
25
+ buttonRegularSecondaryIconHover: colors.primarySolid800,
26
+ buttonRegularSecondaryIconDisabled: colors.neutralBlackTransparent200,
27
+ buttonRegularPrimaryLabelDefault: colors.neutralSolid0,
28
+ buttonRegularPrimaryLabelHover: colors.neutralSolid0,
29
+ buttonRegularPrimaryLabelPressed: colors.neutralSolid0,
30
+ buttonRegularPrimaryLabelDisabled: colors.neutralSolid0,
31
+ buttonRegularPrimaryIconDefault: colors.neutralSolid0,
32
+ buttonRegularPrimaryIconPressed: colors.neutralSolid0,
33
+ buttonRegularPrimaryIconHover: colors.neutralSolid0,
34
+ buttonRegularPrimaryIconDisabled: colors.neutralSolid0,
35
+ buttonRegularPrimaryStrokePressed: colors.primarySolid500,
36
+ buttonRegularSecondaryStrokePressed: colors.primarySolid500,
37
+ buttonRegularTerciaryLabelDefault: colors.primarySolid800,
38
+ buttonRegularTerciaryLabelHover: colors.primarySolid800,
39
+ buttonRegularTerciaryLabelPressed: colors.primarySolid800,
40
+ buttonRegularTerciaryLabelDisabled: colors.neutralBlackTransparent200,
41
+ buttonRegularTerciaryStrokePressed: colors.primarySolid500,
42
+ buttonRegularTerciaryBgHover: colors.primarySolid100,
43
+ buttonRegularTerciaryBgPressed: colors.primarySolid100,
44
+ buttonRegularTerciaryIconDefault: colors.primarySolid800,
45
+ buttonRegularTerciaryIconPressed: colors.primarySolid800,
46
+ buttonRegularTerciaryIconHover: colors.primarySolid800,
47
+ buttonRegularTerciaryIconDisabled: colors.neutralBlackTransparent200,
48
+ buttonRegularTerciaryStrokeDefault: colors.neutralSolid400,
49
+ buttonRegularTerciaryStrokeHover: colors.neutralSolid400,
50
+ buttonRegularTerciaryStrokeDisabled: colors.neutralSolid300,
51
+ tagBgDefault: colors.neutralSolid300,
52
+ tagBgHover: colors.neutralSolid400,
53
+ tagBgPressed: colors.neutralSolid400,
54
+ tagBgDisabled: colors.neutralSolid200,
55
+ tagStrokeFocus: colors.primarySolid500,
56
+ tagLabelDefault: colors.neutralSolid500,
57
+ tagLabelHover: colors.neutralSolid500,
58
+ tagLabelPressed: colors.neutralSolid500,
59
+ tagLabelDisabled: colors.neutralSolid400,
60
+ tagIconDefault: colors.neutralSolid500,
61
+ tagIconHover: colors.neutralSolid500,
62
+ tagIconPressed: colors.neutralSolid500,
63
+ tagIconDisabled: colors.neutralSolid400,
64
+ tagBgFocus: colors.neutralSolid300,
65
+ tagLabelFocus: colors.neutralSolid500,
66
+ tagIconFocus: colors.neutralSolid500,
67
+ buttonRegularQuaternaryLabelHover: colors.primarySolid800,
68
+ buttonRegularQuaternaryLabelPressed: colors.primarySolid800,
69
+ buttonRegularQuaternaryLabelDisabled: colors.neutralBlackTransparent200,
70
+ buttonRegularQuaternaryStrokePressed: colors.primarySolid500,
71
+ buttonNeutralSecondaryBgDefault: colors.secondarySolid200,
72
+ buttonNeutralTerciaryBgHover: colors.secondarySolid200,
73
+ buttonNeutralTerciaryBgPressed: colors.secondarySolid200,
74
+ buttonNeutralTerciaryIconDefault: colors.neutralSolid800,
75
+ buttonNeutralTerciaryIconPressed: colors.neutralSolid800,
76
+ buttonNeutralTerciaryIconHover: colors.neutralSolid800,
77
+ buttonNeutralTerciaryIconDisabled: colors.neutralSolid400,
78
+ buttonNeutralTerciaryLabelDefault: colors.neutralSolid800,
79
+ buttonNeutralTerciaryLabelHover: colors.neutralSolid800,
80
+ buttonNeutralTerciaryLabelPressed: colors.neutralSolid800,
81
+ buttonNeutralTerciaryLabelDisabled: colors.neutralSolid400,
82
+ buttonNeutralTerciaryStrokeDefault: colors.neutralSolid400,
83
+ buttonNeutralTerciaryStrokeHover: colors.neutralSolid400,
84
+ buttonNeutralTerciaryStrokePressed: colors.neutralSolid400,
85
+ buttonNeutralTerciaryStrokeDisabled: colors.neutralSolid300,
86
+ buttonNeutralQuaternaryBgDefault: colors.neutralWhiteTransparent0,
87
+ buttonNeutralQuaternaryLabelDefault: colors.neutralSolid800,
88
+ buttonNeutralQuaternaryLabelHover: colors.neutralSolid800,
89
+ buttonNeutralQuaternaryLabelPressed: colors.neutralSolid800,
90
+ buttonNeutralQuaternaryLabelDisabled: colors.neutralSolid400,
91
+ buttonNeutralQuaternaryIconDefault: colors.neutralSolid800,
92
+ buttonNeutralQuaternaryStrokePressed: colors.neutralSolid400,
93
+ buttonNeutralQuaternaryIconHover: colors.neutralSolid800,
94
+ buttonNeutralQuaternaryIconPressed: colors.neutralSolid800,
95
+ buttonNeutralQuaternaryIconDisabled: colors.neutralSolid400,
96
+ buttonNeutralSecondaryIconDefault: colors.neutralSolid800,
97
+ buttonNeutralSecondaryIconPressed: colors.neutralSolid800,
98
+ buttonNeutralSecondaryIconHover: colors.neutralSolid800,
99
+ buttonNeutralSecondaryIconDisabled: colors.neutralSolid400,
100
+ buttonNeutralSecondaryLabelDefault: colors.neutralSolid800,
101
+ buttonNeutralSecondaryBgHover: colors.secondarySolid300,
102
+ buttonNeutralSecondaryStrokePressed: colors.neutralSolid500,
103
+ buttonNeutralSecondaryLabelHover: colors.neutralSolid800,
104
+ buttonNeutralSecondaryLabelPressed: colors.neutralSolid800,
105
+ buttonNeutralSecondaryLabelDisabled: colors.neutralSolid400,
106
+ buttonNeutralSecondaryBgPressed: colors.secondarySolid300,
107
+ buttonNeutralSecondaryBgDisabled: colors.secondarySolid200,
108
+ buttonNegativePrimaryBgDefault: colors.redSolid500,
109
+ buttonNegativePrimaryIconDefault: colors.neutralSolid0,
110
+ buttonNegativePrimaryIconPressed: colors.neutralSolid0,
111
+ buttonNegativePrimaryIconHover: colors.neutralSolid0,
112
+ buttonNegativePrimaryIconDisabled: colors.neutralSolid0,
113
+ buttonNegativePrimaryLabelDefault: colors.neutralSolid0,
114
+ buttonNegativePrimaryLabelHover: colors.neutralSolid0,
115
+ buttonNegativePrimaryLabelPressed: colors.neutralSolid0,
116
+ buttonNegativePrimaryLabelDisabled: colors.neutralSolid0,
117
+ buttonNegativePrimaryBgHover: colors.redSolid300,
118
+ buttonNegativePrimaryBgPressed: colors.redSolid300,
119
+ buttonNegativePrimaryBgDisabled: colors.redSolid50,
120
+ buttonNegativeSecondaryBgDefault: colors.redSolid100,
121
+ buttonNegativeTerciaryBgHover: colors.redSolid50,
122
+ buttonNegativeTerciaryBgPressed: colors.redSolid50,
123
+ buttonNegativeTerciaryIconDefault: colors.redSolid500,
124
+ buttonNegativeTerciaryIconPressed: colors.redSolid500,
125
+ buttonNegativeTerciaryIconHover: colors.redSolid500,
126
+ buttonNegativeTerciaryIconDisabled: colors.redSolid100,
127
+ buttonNegativeTerciaryLabelDefault: colors.redSolid500,
128
+ buttonNegativeTerciaryLabelHover: colors.redSolid500,
129
+ buttonNegativeTerciaryLabelPressed: colors.redSolid500,
130
+ buttonNegativeTerciaryLabelDisabled: colors.redSolid100,
131
+ buttonNegativeTerciaryStrokeDefault: colors.redSolid200,
132
+ buttonNegativeTerciaryStrokeHover: colors.redSolid200,
133
+ buttonNegativeTerciaryStrokePressed: colors.redSolid500,
134
+ buttonNegativeTerciaryStrokeDisabled: colors.redSolid50,
135
+ buttonNegativeQuaternaryBgDefault: colors.neutralWhiteTransparent0,
136
+ buttonNegativeQuaternaryLabelDefault: colors.redSolid500,
137
+ buttonNegativeQuaternaryLabelHover: colors.redSolid500,
138
+ buttonNegativeQuaternaryLabelPressed: colors.redSolid500,
139
+ buttonNegativeQuaternaryLabelDisabled: colors.redSolid100,
140
+ buttonNegativeQuaternaryIconDefault: colors.redSolid300,
141
+ buttonNegativeQuaternaryStrokePressed: colors.redSolid500,
142
+ buttonNegativeQuaternaryIconHover: colors.redSolid300,
143
+ buttonNegativeQuaternaryIconPressed: colors.redSolid300,
144
+ buttonNegativeQuaternaryIconDisabled: colors.redSolid100,
145
+ buttonNegativeSecondaryIconDefault: colors.redSolid500,
146
+ buttonNegativeSecondaryIconPressed: colors.redSolid500,
147
+ buttonNegativeSecondaryIconHover: colors.redSolid500,
148
+ buttonNegativeSecondaryIconDisabled: colors.redSolid100,
149
+ buttonNegativeSecondaryLabelDefault: colors.redSolid500,
150
+ buttonNegativeSecondaryBgHover: colors.redSolid200,
151
+ buttonNegativeSecondaryStrokePressed: colors.redSolid500,
152
+ buttonNegativeSecondaryLabelHover: colors.redSolid500,
153
+ buttonNegativeSecondaryLabelPressed: colors.redSolid500,
154
+ buttonNegativeSecondaryLabelDisabled: colors.redSolid100,
155
+ buttonNegativeSecondaryBgPressed: colors.redSolid200,
156
+ buttonNegativeSecondaryBgDisabled: colors.redSolid50,
157
+ buttonNegativePrimaryStrokePressed: colors.redSolid500,
158
+ fieldBgDefault: colors.neutralSolid0,
159
+ fieldBgHover: colors.neutralSolid0,
160
+ fieldBgPressed: colors.neutralSolid0,
161
+ fieldBgFocus: colors.neutralSolid0,
162
+ fieldBgDisabled: colors.neutralSolid0,
163
+ fieldLabelRegularDefault: colors.neutralSolid500,
164
+ fieldLabelRegularHover: colors.neutralSolid500,
165
+ fieldLabelRegularPressed: colors.neutralSolid500,
166
+ fieldLabelRegularFocusTyping: colors.neutralSolid800,
167
+ fieldLabelRegularDisabled: colors.neutralSolid400,
168
+ fieldIconDefault: colors.neutralSolid400,
169
+ fieldIconHover: colors.neutralSolid400,
170
+ fieldIconPressed: colors.neutralSolid400,
171
+ fieldIconFocusTyping: colors.neutralSolid400,
172
+ fieldIconDisabled: colors.neutralSolid200,
173
+ fieldBgFocusTyping: colors.neutralSolid0,
174
+ fieldBgTyped: colors.neutralSolid0,
175
+ fieldStrokeRegularDefault: colors.neutralSolid400,
176
+ fieldStrokeRegularHover: colors.primarySolid600,
177
+ fieldStrokeRegularPressed: colors.primarySolid600,
178
+ fieldStrokeRegularFocusTyping: colors.primarySolid600,
179
+ fieldStrokeRegularTyped: colors.neutralSolid400,
180
+ fieldStrokeRegularDisabled: colors.neutralSolid300,
181
+ fieldLabelRegularTyped: colors.neutralSolid800,
182
+ fieldIconTyped: colors.neutralSolid400,
183
+ fieldStrokeNegativeDefault: colors.redSolid300,
184
+ fieldStrokeNegativeHover: colors.redSolid500,
185
+ fieldStrokeNegativePressed: colors.redSolid500,
186
+ fieldStrokeNegativeFocusTyping: colors.redSolid500,
187
+ fieldStrokeNegativeTyped: colors.redSolid300,
188
+ chipRegularBgDefault: colors.neutralSolid200,
189
+ chipRegularBgHover: colors.neutralSolid300,
190
+ chipRegularBgPressed: colors.neutralSolid300,
191
+ chipRegularBgFocus: colors.neutralSolid200,
192
+ chipRegularBgDisabled: colors.neutralSolid200,
193
+ chipRegularStrokeFocus: colors.primarySolid600,
194
+ chipRegularLabelDefault: colors.neutralSolid400,
195
+ chipRegularLabelHover: colors.neutralSolid400,
196
+ chipRegularLabelPressed: colors.neutralSolid400,
197
+ chipRegularLabelFocus: colors.neutralSolid400,
198
+ chipRegularLabelDisabled: colors.neutralSolid400,
199
+ chipRegularIconDefault: colors.neutralSolid500,
200
+ chipRegularIconHover: colors.neutralSolid500,
201
+ chipRegularIconPressed: colors.neutralSolid500,
202
+ chipRegularIconFocus: colors.neutralSolid500,
203
+ chipRegularIconDisabled: colors.neutralSolid400,
204
+ textParagraph: colors.neutralSolid600,
205
+ textCaption: colors.neutralSolid500,
206
+ textHeadingRegular: colors.neutralSolid800,
207
+ textHeadingHighlighted: colors.neutralSolid1000,
208
+ textLink: colors.primarySolid800,
209
+ textHeadingSubtle: colors.neutralSolid600,
210
+ rowBgDefault: colors.neutralSolid0,
211
+ rowBgHover: colors.secondaryTransparent200,
212
+ rowBgPressed: colors.secondaryTransparent200,
213
+ rowBgDisabled: colors.neutralWhiteTransparent0,
214
+ rowStrokeBottom: colors.neutralBlackTransparent100,
215
+ rowLabelDefault: colors.neutralSolid800,
216
+ rowLabelHover: colors.neutralSolid800,
217
+ rowLabelPressed: colors.neutralSolid800,
218
+ rowLabelDisabled: colors.neutralSolid400,
219
+ rowIconDefault: colors.neutralSolid500,
220
+ rowIconHover: colors.neutralSolid500,
221
+ rowIconPressed: colors.neutralSolid500,
222
+ rowIconDisabled: colors.neutralSolid300,
223
+ chipSelectedBgDefault: colors.neutralSolid200,
224
+ chipSelectedBgHover: colors.neutralSolid300,
225
+ chipSelectedBgPressed: colors.neutralSolid300,
226
+ chipSelectedBgFocus: colors.primarySolid100,
227
+ chipSelectedBgDisabled: colors.neutralSolid200,
228
+ chipSelectedStrokeFocus: colors.primarySolid600,
229
+ chipSelectedLabelDefault: colors.neutralSolid400,
230
+ chipSelectedLabelHover: colors.neutralSolid400,
231
+ chipSelectedLabelPressed: colors.neutralSolid400,
232
+ chipSelectedLabelFocus: colors.neutralSolid400,
233
+ chipSelectedLabelDisabled: colors.neutralSolid400,
234
+ chipSelectedIconDefault: colors.neutralSolid500,
235
+ chipSelectedIconHover: colors.neutralSolid500,
236
+ chipSelectedIconPressed: colors.neutralSolid500,
237
+ chipSelectedIconFocus: colors.neutralSolid500,
238
+ chipSelectedIconDisabled: colors.neutralSolid400,
239
+ bg: colors.secondarySolid100,
240
+ progressElipseDefault: colors.primarySolid600,
241
+ progressLineDefault: colors.primarySolid600,
242
+ progressLabelDefault: colors.neutralSolid400,
243
+ progressLabelDisabled: colors.neutralSolid400,
244
+ progressLineDisabled: colors.neutralSolid200,
245
+ progressElipseDisabled: colors.neutralSolid300,
246
+ buttonRegularTerciaryBgDefault: colors.neutralWhiteTransparent0,
247
+ buttonRegularTerciaryBgDisabled: colors.neutralWhiteTransparent0,
248
+ buttonRegularQuaternaryBgHover: colors.primarySolid100,
249
+ buttonRegularQuaternaryBgPressed: colors.primarySolid100,
250
+ buttonRegularQuaternaryBgDisabled: colors.neutralWhiteTransparent0,
251
+ buttonNeutralTerciaryBgDefault: colors.neutralWhiteTransparent0,
252
+ buttonNeutralTerciaryBgDisabled: colors.neutralWhiteTransparent0,
253
+ buttonNeutralQuaternaryBgHover: colors.secondarySolid200,
254
+ buttonNeutralQuaternaryBgPressed: colors.secondarySolid200,
255
+ buttonNeutralQuaternaryBgDisabled: colors.neutralWhiteTransparent0,
256
+ buttonNegativeTerciaryBgDefault: colors.neutralWhiteTransparent0,
257
+ buttonNegativeTerciaryBgDisabled: colors.neutralWhiteTransparent0,
258
+ buttonNegativeQuaternaryBgHover: colors.redSolid50,
259
+ buttonNegativeQuaternaryBgPressed: colors.redSolid50,
260
+ buttonNegativeQuaternaryBgDisabled: colors.neutralWhiteTransparent0,
261
+ chipSelectedStrokeDefault: colors.primarySolid600,
262
+ chipSelectedStrokeHover: colors.primarySolid600,
263
+ chipSelectedStrokePressed: colors.primarySolid600,
264
+ chipSelectedNegativeBgDefault: colors.redTransparent100,
265
+ chipSelectedNegativeBgHover: colors.redTransparent200,
266
+ chipSelectedNegativeBgPressed: colors.redTransparent200,
267
+ chipSelectedNegativeBgFocus: colors.redTransparent100,
268
+ chipSelectedNegativeStrokeDefault: colors.neutralSolid0,
269
+ chipSelectedNegativeStrokeHover: colors.neutralSolid0,
270
+ chipSelectedNegativeStrokePressed: colors.neutralSolid0,
271
+ chipSelectedNegativeStrokeFocus: colors.primarySolid500,
272
+ chipSelectedNegativeLabelDefault: colors.redSolid500,
273
+ chipSelectedNegativeLabelHover: colors.redSolid500,
274
+ chipSelectedNegativeLabelPressed: colors.redSolid500,
275
+ chipSelectedNegativeLabelFocus: colors.redSolid500,
276
+ chipSelectedNegativeIconDefault: colors.redSolid300,
277
+ chipSelectedNegativeIconHover: colors.redSolid300,
278
+ chipSelectedNegativeIconPressed: colors.redSolid300,
279
+ chipSelectedNegativeIconFocus: colors.redSolid300,
280
+ fieldLabelNegativeDefault: colors.redSolid500,
281
+ fieldLabelNegativeHover: colors.redSolid500,
282
+ fieldLabelNegativePressed: colors.redSolid500,
283
+ fieldLabelNegativeFocusTyping: colors.redSolid500,
284
+ fieldLabelNegativeTyped: colors.redSolid700,
285
+ }
@@ -0,0 +1,31 @@
1
+ export default {
2
+ 'radius': {
3
+ 'none': 0,
4
+ 'small': 4,
5
+ 'base': 8,
6
+ 'medium': 16,
7
+ 'large': 24,
8
+ 'xlarge': 32,
9
+ 'infinite': 100000000
10
+ },
11
+ 'size': {
12
+ 'xxsmall': 12,
13
+ 'xsmall': 16,
14
+ 'small': 24,
15
+ 'medium': 32,
16
+ 'large': 48,
17
+ 'xlarge': 56
18
+ },
19
+ 'stroke': {
20
+ 'default': 1,
21
+ 'medium': 2,
22
+ 'large': 3,
23
+ 'xlarge': 4
24
+ },
25
+ 'letterSpacing': {
26
+ 'negative': -1,
27
+ 'none': 0,
28
+ 'tiny': 1,
29
+ 'small': 2
30
+ }
31
+ }
@@ -0,0 +1,58 @@
1
+
2
+ import measures from './measures'
3
+ import baseColors from './colors/baseColors'
4
+ import lightMode from './colors/lightMode'
5
+ import darkMode from './colors/darkMode'
6
+ import { createTheme } from '../lib'
7
+ import { validateTheme } from '../theme'
8
+
9
+ export const mockTheme = () => {
10
+ return createTheme(
11
+ validateTheme({
12
+ baseColors,
13
+ colors: lightMode,
14
+ alternateColors: {
15
+ dark: { ...lightMode, ...darkMode },
16
+ },
17
+ baseSpacing: 8,
18
+ radius: measures.radius,
19
+ stroke: measures.stroke,
20
+ size: measures.size,
21
+ effects: {},
22
+ typography: {
23
+ fonts: {
24
+ Inter: {
25
+ normal: {
26
+ '100': 'Inter-Thin',
27
+ '200': 'Inter-ExtraLight',
28
+ '300': 'Inter-Light',
29
+ '400': 'Inter-Regular',
30
+ '500': 'Inter-Medium',
31
+ '600': 'Inter-SemiBold',
32
+ '700': 'Inter-Bold',
33
+ '800': 'Inter-ExtraBold',
34
+ },
35
+ },
36
+ },
37
+ defaults: {
38
+ fontWeight: '400',
39
+ fontFamily: 'Inter',
40
+ fontStyle: 'normal',
41
+ fontSize: 16,
42
+ lineHeight: 24,
43
+ letterSpacing: 0.5,
44
+ } as unknown,
45
+ },
46
+ icons: {},
47
+ presets: {},
48
+ values: {},
49
+ isBrowser: true,
50
+ }),
51
+ {
52
+ set: (name, colorSchema) => {},
53
+ get: (name) => null,
54
+ },
55
+ )
56
+ }
57
+
58
+ export type MockedTheme = ReturnType<typeof mockTheme>
@@ -0,0 +1,53 @@
1
+ import { colorTools } from '../tools'
2
+ import { ColorMap } from '../types'
3
+
4
+ const lightnesses = [95, 85, 75, 60, 45, 30, 27, 21, 16, 10]
5
+
6
+ const defaultLightnessMap = Object.fromEntries(
7
+ lightnesses.map((l, i) => {
8
+ const step = ((i + 1) * 100).toString()
9
+ return [step, l]
10
+ }),
11
+ )
12
+
13
+ const alphas = [0.05, 0.10, 0.20, 0.30, 0.40, 0.50, 0.60, 0.70, 0.80, 0.90]
14
+
15
+ const defaultAlphasMap = Object.fromEntries(
16
+ alphas.map((a, i) => {
17
+ const step = ((i + 1) * 100).toString()
18
+ return [step, a]
19
+ }),
20
+ )
21
+
22
+ /**
23
+ * Generates a complete color scheme from an anchor color.
24
+ * Creates solid variants with different lightness and transparent variants.
25
+ *
26
+ * @param {string} anchorHex - Base hex color for the scheme
27
+ * @param {string} prefix - Prefix for generated color names
28
+ * @param {object} lightnesses - Custom lightness mapping
29
+ * @param {object} alphas - Custom alpha mapping
30
+ * @returns {ColorMap} Complete color scheme object
31
+ */
32
+ export function generateColorScheme(
33
+ anchorHex: string,
34
+ prefix = 'primary',
35
+ lightnesses:typeof defaultLightnessMap = defaultLightnessMap,
36
+ alphas: typeof defaultAlphasMap = defaultAlphasMap,
37
+ ): ColorMap {
38
+ const { h, s } = colorTools.hexToHSL(anchorHex)
39
+ const baseRGB = colorTools.hexToRGB(anchorHex)
40
+
41
+ const scheme: ColorMap = {}
42
+
43
+ Object.entries(lightnesses).forEach(([step, lightness]) => {
44
+ const rgb = colorTools.hslToRGB(h, s, lightness)
45
+ scheme[`${prefix}Solid${step}`] = `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, 1.00)`
46
+ })
47
+
48
+ Object.entries(alphas).forEach(([step, alpha]) => {
49
+ scheme[`${prefix}Transparent${step}`] = `rgba(${baseRGB.r}, ${baseRGB.g}, ${baseRGB.b}, ${alpha.toFixed(2)})`
50
+ })
51
+
52
+ return scheme
53
+ }
@@ -0,0 +1,3 @@
1
+ export * from './themeStore'
2
+ export * from './validateTheme'
3
+ export * from './generateColorScheme'
@@ -0,0 +1,118 @@
1
+ import { describe, expect, test } from 'bun:test'
2
+ import { generateColorScheme } from '../generateColorScheme'
3
+ import { colorTools } from '../../tools'
4
+
5
+ describe('generateColorScheme', () => {
6
+ test('should generate solid and transparent variants from anchor color', () => {
7
+ const result = generateColorScheme('#4080c0', 'primary')
8
+
9
+ expect(Object.keys(result)).toHaveLength(20)
10
+
11
+ for (let i = 1; i <= 10; i++) {
12
+ const step = i * 100
13
+ expect(result).toHaveProperty(`primarySolid${step}`)
14
+ expect(result[`primarySolid${step}`]).toMatch(/^rgba\(\d+, \d+, \d+, 1\.00\)$/)
15
+ }
16
+
17
+ for (let i = 1; i <= 10; i++) {
18
+ const step = i * 100
19
+ expect(result).toHaveProperty(`primaryTransparent${step}`)
20
+ expect(result[`primaryTransparent${step}`]).toMatch(/^rgba\(\d+, \d+, \d+, 0\.\d{2}\)$/)
21
+ }
22
+ })
23
+
24
+ test('should use custom prefix', () => {
25
+ const result = generateColorScheme('#4080c0', 'accent')
26
+
27
+ expect(result).toHaveProperty('accentSolid100')
28
+ expect(result).toHaveProperty('accentTransparent100')
29
+ expect(result).not.toHaveProperty('primarySolid100')
30
+ })
31
+
32
+ test('should use custom lightness and alpha mappings', () => {
33
+ const customLightnesses = { '100': 90, '200': 80 }
34
+ const customAlphas = { '100': 0.1, '200': 0.2 }
35
+
36
+ const result = generateColorScheme('#4080c0', 'primary', customLightnesses, customAlphas)
37
+
38
+ expect(Object.keys(result)).toHaveLength(4)
39
+ expect(result).toHaveProperty('primarySolid100')
40
+ expect(result).toHaveProperty('primarySolid200')
41
+ expect(result).toHaveProperty('primaryTransparent100')
42
+ expect(result).toHaveProperty('primaryTransparent200')
43
+ })
44
+
45
+ test('should generate correct color values for known input', () => {
46
+ const result = generateColorScheme('#ff0000', 'red') // Vermelho puro
47
+
48
+ const hsl = colorTools.hexToHSL('#ff0000')
49
+ expect(hsl.h).toBe(0)
50
+ expect(hsl.s).toBe(100)
51
+
52
+ const solidColor = result['redSolid100']
53
+ expect(solidColor).toMatch(/^rgba\(\d+, \d+, \d+, 1\.00\)$/)
54
+ })
55
+
56
+ test('should handle edge cases with black color', () => {
57
+ const result = generateColorScheme('#000000', 'black')
58
+
59
+ for (let i = 1; i <= 10; i++) {
60
+ const step = i * 100
61
+ const color = result[`blackSolid${step}`]
62
+ expect(color).toMatch(/^rgba\(\d+, \d+, \d+, 1\.00\)$/)
63
+
64
+ const [r, g, b] = color.match(/\d+/g)!.map(Number)
65
+
66
+ expect(r).toBe(g)
67
+ expect(g).toBe(b)
68
+ }
69
+ })
70
+
71
+ test('should handle edge cases with white color', () => {
72
+ const result = generateColorScheme('#ffffff', 'white')
73
+
74
+ for (let i = 1; i <= 10; i++) {
75
+ const step = i * 100
76
+ const color = result[`whiteSolid${step}`]
77
+ expect(color).toMatch(/^rgba\(\d+, \d+, \d+, 1\.00\)$/)
78
+
79
+ const [r, g, b] = color.match(/\d+/g)!.map(Number)
80
+
81
+ expect(r).toBe(g)
82
+ expect(g).toBe(b)
83
+ }
84
+ })
85
+
86
+ test('should generate alpha values in correct order', () => {
87
+ const result = generateColorScheme('#4080c0', 'test')
88
+
89
+ const alphaValues = []
90
+ for (let i = 1; i <= 10; i++) {
91
+ const step = i * 100
92
+ const color = result[`testTransparent${step}`]
93
+ const alpha = parseFloat(color.match(/[\d.]+\)$/)?.[0]?.replace(')', '') || '0')
94
+ alphaValues.push(alpha)
95
+ }
96
+
97
+ for (let i = 0; i < alphaValues.length - 1; i++) {
98
+ expect(alphaValues[i]).toBeLessThan(alphaValues[i + 1])
99
+ }
100
+ })
101
+
102
+ test('should generate lightness values in correct order', () => {
103
+ const result = generateColorScheme('#4080c0', 'test')
104
+
105
+ const lightnessValues = []
106
+ for (let i = 1; i <= 10; i++) {
107
+ const step = i * 100
108
+ const color = result[`testSolid${step}`]
109
+ const [r, g, b] = color.match(/\d+/g)!.map(Number)
110
+ const hsl = colorTools.rgbToHSL({ r, g, b })
111
+ lightnessValues.push(hsl.l)
112
+ }
113
+
114
+ for (let i = 0; i < lightnessValues.length - 1; i++) {
115
+ expect(lightnessValues[i]).toBeGreaterThan(lightnessValues[i + 1])
116
+ }
117
+ })
118
+ })