@payfit/unity-themes 2.55.21 → 2.55.23
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.
- package/dist/esm/scripts/style-dictionary-config.d.ts +14 -0
- package/package.json +20 -11
- package/skills/unity-themes/SKILL.md +41 -0
- package/src/agent-references/manifest.json +16 -0
- package/src/agent-references/tokens-catalog.json +13891 -0
- package/dist/esm/scripts/agent-references/color-reference.d.ts +0 -37
- package/src/agent-references/README.mdx +0 -25
- package/src/agent-references/primitive-colors.mdx +0 -18
- package/src/agent-references/semantic-border-colors.mdx +0 -16
- package/src/agent-references/semantic-content-colors.mdx +0 -16
- package/src/agent-references/semantic-surface-colors.mdx +0 -16
- package/src/agent-references/semantic-utility-colors.mdx +0 -16
- package/src/components/unity-theme-provider.stories.tsx +0 -532
- package/src/components/unity-theme-provider.test.tsx +0 -150
- package/src/components/unity-theme-provider.tsx +0 -72
- package/src/index.ts +0 -15
- package/src/scripts/actions/append-animations.ts +0 -73
- package/src/scripts/actions/compose-multi-theme.ts +0 -59
- package/src/scripts/agent-references/color-reference.test.ts +0 -140
- package/src/scripts/agent-references/color-reference.ts +0 -348
- package/src/scripts/build.ts +0 -420
- package/src/scripts/file-headers/unity.ts +0 -31
- package/src/scripts/formats/processors/grid-processor.test.ts +0 -378
- package/src/scripts/formats/processors/grid-processor.ts +0 -64
- package/src/scripts/formats/processors/typography-processor.test.ts +0 -111
- package/src/scripts/formats/processors/typography-processor.ts +0 -48
- package/src/scripts/formats/unity-theme.test.ts +0 -329
- package/src/scripts/formats/unity-theme.ts +0 -54
- package/src/scripts/formats/utils.test.ts +0 -264
- package/src/scripts/formats/utils.ts +0 -15
- package/src/scripts/transforms/oklch.test.ts +0 -166
- package/src/scripts/transforms/oklch.ts +0 -19
- package/src/scripts/transforms/tailwind-animation-token.test.ts +0 -108
- package/src/scripts/transforms/tailwind-animation-token.ts +0 -51
- package/src/scripts/transforms/tailwind-color-token.test.ts +0 -304
- package/src/scripts/transforms/tailwind-color-token.ts +0 -17
- package/src/scripts/transforms/tailwind-grid-token.test.ts +0 -114
- package/src/scripts/transforms/tailwind-grid-token.ts +0 -27
- package/src/scripts/transforms/tailwind-spacing-token.test.ts +0 -315
- package/src/scripts/transforms/tailwind-spacing-token.ts +0 -24
- package/src/scripts/transforms/tailwind-text-token.test.ts +0 -328
- package/src/scripts/transforms/tailwind-text-token.ts +0 -30
- package/src/scripts/transforms/tailwind-typography-token.test.ts +0 -55
- package/src/scripts/transforms/tailwind-typography-token.ts +0 -20
- package/src/scripts/types.ts +0 -30
- package/src/scripts/utils/prefix-transform.test.ts +0 -137
- package/src/scripts/utils/prefix-transform.ts +0 -16
- package/src/utils/cn.ts +0 -109
- package/src/utils/merge-config.ts +0 -194
- package/src/utils/tailwind-merge.test.ts +0 -462
- package/src/utils/tailwind-merge.ts +0 -77
- package/src/utils/tailwind-variants.ts +0 -53
|
@@ -1,462 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest'
|
|
2
|
-
|
|
3
|
-
import { uyMerge } from './tailwind-merge'
|
|
4
|
-
|
|
5
|
-
describe('uyMerge', () => {
|
|
6
|
-
describe('Basic functionality', () => {
|
|
7
|
-
it('should merge basic class strings', () => {
|
|
8
|
-
const result = uyMerge('uy:p-4', 'uy:m-2')
|
|
9
|
-
expect(result).toBe('uy:p-4 uy:m-2')
|
|
10
|
-
})
|
|
11
|
-
|
|
12
|
-
it('should handle conflicting classes with last one winning', () => {
|
|
13
|
-
const result = uyMerge('uy:p-4', 'uy:p-8')
|
|
14
|
-
expect(result).toBe('uy:p-8')
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
it('should merge Unity classes with Tailwind classes', () => {
|
|
18
|
-
const result = uyMerge('uy:p-4', 'p-500', 'uy:text-100', 'p-600')
|
|
19
|
-
expect(result).toBe('uy:p-4 p-500 uy:text-100 p-600')
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
it('should handle multiple class types without conflicts', () => {
|
|
23
|
-
const result = uyMerge(
|
|
24
|
-
'uy:p-100 uy:bg-red',
|
|
25
|
-
'uy:m-200 uy:m-100 uy:p-100',
|
|
26
|
-
'uy:rounded-100 uy:m-50',
|
|
27
|
-
'uy:bg-primary-500',
|
|
28
|
-
)
|
|
29
|
-
expect(result).toBe('uy:p-100 uy:rounded-100 uy:m-50 uy:bg-primary-500')
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
it('should resolve conflicts in complex scenarios', () => {
|
|
33
|
-
const result = uyMerge(
|
|
34
|
-
'uy:p-100 uy:m-50 uy:text-primary-500',
|
|
35
|
-
'uy:p-200 uy:bg-secondary-100',
|
|
36
|
-
'uy:m-100 uy:bg-primary-500',
|
|
37
|
-
'uy:md:p-100',
|
|
38
|
-
'uy:md:p-300',
|
|
39
|
-
)
|
|
40
|
-
expect(result).toBe(
|
|
41
|
-
'uy:text-primary-500 uy:p-200 uy:m-100 uy:bg-primary-500 uy:md:p-300',
|
|
42
|
-
)
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
it('should handle conflicting responsive classes', () => {
|
|
46
|
-
const result = uyMerge('uy:sm:p-100', 'uy:sm:p-200')
|
|
47
|
-
expect(result).toBe('uy:sm:p-200')
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
it('should handle hover and focus variants', () => {
|
|
51
|
-
const result = uyMerge(
|
|
52
|
-
'uy:bg-primary-500',
|
|
53
|
-
'uy:hover:bg-primary-600',
|
|
54
|
-
'uy:focus:bg-primary-700',
|
|
55
|
-
)
|
|
56
|
-
expect(result).toBe(
|
|
57
|
-
'uy:bg-primary-500 uy:hover:bg-primary-600 uy:focus:bg-primary-700',
|
|
58
|
-
)
|
|
59
|
-
})
|
|
60
|
-
})
|
|
61
|
-
|
|
62
|
-
describe('Unity Colors', () => {
|
|
63
|
-
describe('Primitive colors', () => {
|
|
64
|
-
it('should merge conflicting primitive background colors', () => {
|
|
65
|
-
const result = uyMerge('uy:bg-grayscale-l0', 'uy:bg-red-l5')
|
|
66
|
-
expect(result).toBe('uy:bg-red-l5')
|
|
67
|
-
})
|
|
68
|
-
|
|
69
|
-
it('should merge conflicting primitive text colors', () => {
|
|
70
|
-
const result = uyMerge('uy:text-blue-l10', 'uy:text-green-l3')
|
|
71
|
-
expect(result).toBe('uy:text-green-l3')
|
|
72
|
-
})
|
|
73
|
-
|
|
74
|
-
it('should merge conflicting primitive border colors', () => {
|
|
75
|
-
const result = uyMerge('uy:border-yellow-l6', 'uy:border-purple-l8')
|
|
76
|
-
expect(result).toBe('uy:border-purple-l8')
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
it('should handle all primitive color utilities', () => {
|
|
80
|
-
const result = uyMerge(
|
|
81
|
-
'uy:bg-red-l1 uy:text-blue-l2 uy:border-green-l3',
|
|
82
|
-
'uy:outline-yellow-l4 uy:ring-purple-l5 uy:divide-cyan-l6',
|
|
83
|
-
'uy:decoration-plum-l7 uy:from-orange-l8 uy:via-teal-l9 uy:to-grayscale-l10',
|
|
84
|
-
)
|
|
85
|
-
expect(result).toBe(
|
|
86
|
-
'uy:bg-red-l1 uy:text-blue-l2 uy:border-green-l3 uy:outline-yellow-l4 uy:ring-purple-l5 uy:divide-cyan-l6 uy:decoration-plum-l7 uy:from-orange-l8 uy:via-teal-l9 uy:to-grayscale-l10',
|
|
87
|
-
)
|
|
88
|
-
})
|
|
89
|
-
})
|
|
90
|
-
|
|
91
|
-
describe('Semantic colors', () => {
|
|
92
|
-
it('should merge conflicting surface colors', () => {
|
|
93
|
-
const result = uyMerge(
|
|
94
|
-
'uy:bg-surface-primary-default',
|
|
95
|
-
'uy:bg-surface-danger-low',
|
|
96
|
-
)
|
|
97
|
-
expect(result).toBe('uy:bg-surface-danger-low')
|
|
98
|
-
})
|
|
99
|
-
|
|
100
|
-
it('should merge conflicting content colors', () => {
|
|
101
|
-
const result = uyMerge(
|
|
102
|
-
'uy:text-content-neutral-default-default',
|
|
103
|
-
'uy:text-content-primary-high',
|
|
104
|
-
)
|
|
105
|
-
expect(result).toBe('uy:text-content-primary-high')
|
|
106
|
-
})
|
|
107
|
-
|
|
108
|
-
it('should merge conflicting border colors', () => {
|
|
109
|
-
const result = uyMerge(
|
|
110
|
-
'uy:border-border-form-enabled',
|
|
111
|
-
'uy:border-border-danger-default',
|
|
112
|
-
)
|
|
113
|
-
expect(result).toBe('uy:border-border-danger-default')
|
|
114
|
-
})
|
|
115
|
-
|
|
116
|
-
it('should handle complex semantic color names', () => {
|
|
117
|
-
const result = uyMerge(
|
|
118
|
-
'uy:bg-surface-primary-default-default',
|
|
119
|
-
'uy:bg-surface-primary-default-hover',
|
|
120
|
-
'uy:bg-surface-primary-default-pressed',
|
|
121
|
-
)
|
|
122
|
-
expect(result).toBe('uy:bg-surface-primary-default-pressed')
|
|
123
|
-
})
|
|
124
|
-
|
|
125
|
-
it('should handle utility colors', () => {
|
|
126
|
-
const result = uyMerge(
|
|
127
|
-
'uy:ring-utility-focus-ring',
|
|
128
|
-
'uy:ring-utility-inverted-focus-ring',
|
|
129
|
-
)
|
|
130
|
-
expect(result).toBe('uy:ring-utility-inverted-focus-ring')
|
|
131
|
-
})
|
|
132
|
-
|
|
133
|
-
it('should handle canvas colors', () => {
|
|
134
|
-
const result = uyMerge(
|
|
135
|
-
'uy:bg-canvas-default',
|
|
136
|
-
'uy:bg-surface-primary-default',
|
|
137
|
-
)
|
|
138
|
-
expect(result).toBe('uy:bg-surface-primary-default')
|
|
139
|
-
})
|
|
140
|
-
})
|
|
141
|
-
|
|
142
|
-
describe('Mixed color types', () => {
|
|
143
|
-
it('should merge primitive and semantic colors', () => {
|
|
144
|
-
const result = uyMerge(
|
|
145
|
-
'uy:bg-grayscale-l0',
|
|
146
|
-
'uy:bg-surface-primary-default',
|
|
147
|
-
)
|
|
148
|
-
expect(result).toBe('uy:bg-surface-primary-default')
|
|
149
|
-
})
|
|
150
|
-
|
|
151
|
-
it('should handle different color utilities without conflicts', () => {
|
|
152
|
-
const result = uyMerge(
|
|
153
|
-
'uy:bg-surface-primary-default',
|
|
154
|
-
'uy:text-content-neutral-low',
|
|
155
|
-
'uy:border-border-form-enabled',
|
|
156
|
-
)
|
|
157
|
-
expect(result).toBe(
|
|
158
|
-
'uy:bg-surface-primary-default uy:text-content-neutral-low uy:border-border-form-enabled',
|
|
159
|
-
)
|
|
160
|
-
})
|
|
161
|
-
})
|
|
162
|
-
})
|
|
163
|
-
|
|
164
|
-
describe('Unity Spacing', () => {
|
|
165
|
-
it('should merge conflicting padding values', () => {
|
|
166
|
-
const result = uyMerge('uy:p-100', 'uy:p-200')
|
|
167
|
-
expect(result).toBe('uy:p-200')
|
|
168
|
-
})
|
|
169
|
-
|
|
170
|
-
it('should merge conflicting margin values', () => {
|
|
171
|
-
const result = uyMerge('uy:m-50', 'uy:m-300')
|
|
172
|
-
expect(result).toBe('uy:m-300')
|
|
173
|
-
})
|
|
174
|
-
|
|
175
|
-
it('should handle directional spacing conflicts', () => {
|
|
176
|
-
const result = uyMerge('uy:px-100 uy:py-200', 'uy:p-300')
|
|
177
|
-
expect(result).toBe('uy:p-300')
|
|
178
|
-
})
|
|
179
|
-
|
|
180
|
-
it('should handle specific directional spacing', () => {
|
|
181
|
-
const result = uyMerge('uy:p-100', 'uy:px-200', 'uy:pt-300')
|
|
182
|
-
expect(result).toBe('uy:p-100 uy:px-200 uy:pt-300')
|
|
183
|
-
})
|
|
184
|
-
|
|
185
|
-
it('should merge gap values', () => {
|
|
186
|
-
const result = uyMerge('uy:gap-100', 'uy:gap-200')
|
|
187
|
-
expect(result).toBe('uy:gap-200')
|
|
188
|
-
})
|
|
189
|
-
|
|
190
|
-
it('should handle gap directional values', () => {
|
|
191
|
-
const result = uyMerge('uy:gap-100', 'uy:gap-x-200', 'uy:gap-y-300')
|
|
192
|
-
expect(result).toBe('uy:gap-100 uy:gap-x-200 uy:gap-y-300')
|
|
193
|
-
})
|
|
194
|
-
|
|
195
|
-
it('should handle space-between values', () => {
|
|
196
|
-
const result = uyMerge('uy:space-x-100', 'uy:space-x-200')
|
|
197
|
-
expect(result).toBe('uy:space-x-200')
|
|
198
|
-
})
|
|
199
|
-
|
|
200
|
-
it('should handle scroll spacing', () => {
|
|
201
|
-
const result = uyMerge('uy:scroll-p-100', 'uy:scroll-p-200')
|
|
202
|
-
expect(result).toBe('uy:scroll-p-200')
|
|
203
|
-
})
|
|
204
|
-
|
|
205
|
-
it('should handle all Unity spacing values', () => {
|
|
206
|
-
const spacingValues = [
|
|
207
|
-
'0',
|
|
208
|
-
'25',
|
|
209
|
-
'50',
|
|
210
|
-
'75',
|
|
211
|
-
'100',
|
|
212
|
-
'125',
|
|
213
|
-
'150',
|
|
214
|
-
'200',
|
|
215
|
-
'250',
|
|
216
|
-
'300',
|
|
217
|
-
'400',
|
|
218
|
-
'500',
|
|
219
|
-
'600',
|
|
220
|
-
'800',
|
|
221
|
-
'1000',
|
|
222
|
-
]
|
|
223
|
-
|
|
224
|
-
spacingValues.forEach(value => {
|
|
225
|
-
const result = uyMerge('uy:p-100', `uy:p-${value}`)
|
|
226
|
-
expect(result).toBe(`uy:p-${value}`)
|
|
227
|
-
})
|
|
228
|
-
})
|
|
229
|
-
})
|
|
230
|
-
|
|
231
|
-
describe('Unity Typography', () => {
|
|
232
|
-
it('should merge conflicting typography classes', () => {
|
|
233
|
-
const result = uyMerge('uy:typography-h1', 'uy:typography-body')
|
|
234
|
-
expect(result).toBe('uy:typography-body')
|
|
235
|
-
})
|
|
236
|
-
|
|
237
|
-
it('should handle all typography variants', () => {
|
|
238
|
-
const typographyClasses = [
|
|
239
|
-
'display-heading',
|
|
240
|
-
'h1',
|
|
241
|
-
'h2',
|
|
242
|
-
'h3',
|
|
243
|
-
'h4',
|
|
244
|
-
'overline',
|
|
245
|
-
'subtitle',
|
|
246
|
-
'display-title',
|
|
247
|
-
'display-body',
|
|
248
|
-
'body',
|
|
249
|
-
'body-strong',
|
|
250
|
-
'body-small',
|
|
251
|
-
'body-small-strong',
|
|
252
|
-
'body-large',
|
|
253
|
-
'body-large-strong',
|
|
254
|
-
'action',
|
|
255
|
-
'action-small',
|
|
256
|
-
'action-large',
|
|
257
|
-
]
|
|
258
|
-
|
|
259
|
-
typographyClasses.forEach(variant => {
|
|
260
|
-
const result = uyMerge('uy:typography-body', `uy:typography-${variant}`)
|
|
261
|
-
expect(result).toBe(`uy:typography-${variant}`)
|
|
262
|
-
})
|
|
263
|
-
})
|
|
264
|
-
|
|
265
|
-
it('should merge font size classes', () => {
|
|
266
|
-
const result = uyMerge('uy:text-100', 'uy:text-400')
|
|
267
|
-
expect(result).toBe('uy:text-400')
|
|
268
|
-
})
|
|
269
|
-
|
|
270
|
-
it('should handle all Unity font sizes', () => {
|
|
271
|
-
const fontSizes = [
|
|
272
|
-
'50',
|
|
273
|
-
'75',
|
|
274
|
-
'100',
|
|
275
|
-
'200',
|
|
276
|
-
'300',
|
|
277
|
-
'400',
|
|
278
|
-
'500',
|
|
279
|
-
'600',
|
|
280
|
-
'800',
|
|
281
|
-
'1000',
|
|
282
|
-
'1200',
|
|
283
|
-
'1400',
|
|
284
|
-
'1600',
|
|
285
|
-
]
|
|
286
|
-
|
|
287
|
-
fontSizes.forEach(size => {
|
|
288
|
-
const result = uyMerge('uy:text-100', `uy:text-${size}`)
|
|
289
|
-
expect(result).toBe(`uy:text-${size}`)
|
|
290
|
-
})
|
|
291
|
-
})
|
|
292
|
-
})
|
|
293
|
-
|
|
294
|
-
describe('Unity Border Radius', () => {
|
|
295
|
-
it('should merge conflicting border radius values', () => {
|
|
296
|
-
const result = uyMerge('uy:rounded-100', 'uy:rounded-200')
|
|
297
|
-
expect(result).toBe('uy:rounded-200')
|
|
298
|
-
})
|
|
299
|
-
|
|
300
|
-
it('should handle semantic border radius values', () => {
|
|
301
|
-
const result = uyMerge('uy:rounded-sm', 'uy:rounded-lg')
|
|
302
|
-
expect(result).toBe('uy:rounded-lg')
|
|
303
|
-
})
|
|
304
|
-
|
|
305
|
-
it('should handle special border radius values', () => {
|
|
306
|
-
const result = uyMerge('uy:rounded-100', 'uy:rounded-circle')
|
|
307
|
-
expect(result).toBe('uy:rounded-circle')
|
|
308
|
-
})
|
|
309
|
-
|
|
310
|
-
it('should handle directional border radius', () => {
|
|
311
|
-
const result = uyMerge(
|
|
312
|
-
'uy:rounded-100',
|
|
313
|
-
'uy:rounded-t-200',
|
|
314
|
-
'uy:rounded-br-300',
|
|
315
|
-
)
|
|
316
|
-
expect(result).toBe('uy:rounded-100 uy:rounded-t-200 uy:rounded-br-300')
|
|
317
|
-
})
|
|
318
|
-
|
|
319
|
-
it('should merge conflicting directional border radius', () => {
|
|
320
|
-
const result = uyMerge('uy:rounded-t-100', 'uy:rounded-t-200')
|
|
321
|
-
expect(result).toBe('uy:rounded-t-200')
|
|
322
|
-
})
|
|
323
|
-
|
|
324
|
-
it('should handle all Unity border radius values', () => {
|
|
325
|
-
const radiusValues = [
|
|
326
|
-
'0',
|
|
327
|
-
'25',
|
|
328
|
-
'50',
|
|
329
|
-
'75',
|
|
330
|
-
'100',
|
|
331
|
-
'125',
|
|
332
|
-
'150',
|
|
333
|
-
'200',
|
|
334
|
-
'300',
|
|
335
|
-
'400',
|
|
336
|
-
'xs',
|
|
337
|
-
'sm',
|
|
338
|
-
'md',
|
|
339
|
-
'lg',
|
|
340
|
-
'xl',
|
|
341
|
-
'circle',
|
|
342
|
-
'pill',
|
|
343
|
-
]
|
|
344
|
-
|
|
345
|
-
radiusValues.forEach(value => {
|
|
346
|
-
const result = uyMerge('uy:rounded-100', `uy:rounded-${value}`)
|
|
347
|
-
expect(result).toBe(`uy:rounded-${value}`)
|
|
348
|
-
})
|
|
349
|
-
})
|
|
350
|
-
})
|
|
351
|
-
|
|
352
|
-
describe('Unity Shadows', () => {
|
|
353
|
-
it('should merge conflicting shadow values', () => {
|
|
354
|
-
const result = uyMerge('uy:shadow-raising', 'uy:shadow-floating')
|
|
355
|
-
expect(result).toBe('uy:shadow-floating')
|
|
356
|
-
})
|
|
357
|
-
|
|
358
|
-
it('should handle all Unity shadow values', () => {
|
|
359
|
-
const shadowValues = [
|
|
360
|
-
'canvas',
|
|
361
|
-
'raising',
|
|
362
|
-
'floating',
|
|
363
|
-
'flying',
|
|
364
|
-
'soaring',
|
|
365
|
-
]
|
|
366
|
-
|
|
367
|
-
shadowValues.forEach(value => {
|
|
368
|
-
const result = uyMerge('uy:shadow-raising', `uy:shadow-${value}`)
|
|
369
|
-
expect(result).toBe(`uy:shadow-${value}`)
|
|
370
|
-
})
|
|
371
|
-
})
|
|
372
|
-
})
|
|
373
|
-
|
|
374
|
-
describe('Responsive and State Variants', () => {
|
|
375
|
-
it('should handle responsive variants with Unity classes', () => {
|
|
376
|
-
const result = uyMerge(
|
|
377
|
-
'uy:bg-surface-primary-default',
|
|
378
|
-
'uy:md:bg-surface-secondary-default',
|
|
379
|
-
'uy:lg:bg-surface-danger-default',
|
|
380
|
-
)
|
|
381
|
-
expect(result).toBe(
|
|
382
|
-
'uy:bg-surface-primary-default uy:md:bg-surface-secondary-default uy:lg:bg-surface-danger-default',
|
|
383
|
-
)
|
|
384
|
-
})
|
|
385
|
-
|
|
386
|
-
it('should merge conflicting responsive variants', () => {
|
|
387
|
-
const result = uyMerge('uy:md:p-100', 'uy:md:p-200')
|
|
388
|
-
expect(result).toBe('uy:md:p-200')
|
|
389
|
-
})
|
|
390
|
-
|
|
391
|
-
it('should handle state variants with Unity colors', () => {
|
|
392
|
-
const result = uyMerge(
|
|
393
|
-
'uy:bg-surface-primary-default',
|
|
394
|
-
'uy:hover:bg-surface-primary-hover',
|
|
395
|
-
'uy:focus:bg-surface-primary-focus',
|
|
396
|
-
)
|
|
397
|
-
expect(result).toBe(
|
|
398
|
-
'uy:bg-surface-primary-default uy:hover:bg-surface-primary-hover uy:focus:bg-surface-primary-focus',
|
|
399
|
-
)
|
|
400
|
-
})
|
|
401
|
-
|
|
402
|
-
it('should merge conflicting state variants', () => {
|
|
403
|
-
const result = uyMerge(
|
|
404
|
-
'uy:hover:bg-surface-primary-default',
|
|
405
|
-
'uy:hover:bg-surface-danger-default',
|
|
406
|
-
)
|
|
407
|
-
expect(result).toBe('uy:hover:bg-surface-danger-default')
|
|
408
|
-
})
|
|
409
|
-
})
|
|
410
|
-
|
|
411
|
-
describe('Edge Cases and Complex Scenarios', () => {
|
|
412
|
-
it('should handle empty strings', () => {
|
|
413
|
-
const result = uyMerge('', 'uy:p-100', '')
|
|
414
|
-
expect(result).toBe('uy:p-100')
|
|
415
|
-
})
|
|
416
|
-
|
|
417
|
-
it('should handle undefined values', () => {
|
|
418
|
-
const result = uyMerge('uy:p-100', undefined, 'uy:m-200')
|
|
419
|
-
expect(result).toBe('uy:p-100 uy:m-200')
|
|
420
|
-
})
|
|
421
|
-
|
|
422
|
-
it('should handle complex real-world scenario', () => {
|
|
423
|
-
const result = uyMerge(
|
|
424
|
-
// Base styles
|
|
425
|
-
'uy:bg-surface-neutral-default-default uy:text-content-neutral-default-default uy:p-200 uy:rounded-100',
|
|
426
|
-
// Conditional styles
|
|
427
|
-
'uy:bg-surface-primary-default uy:text-content-inverted-default',
|
|
428
|
-
// Responsive styles
|
|
429
|
-
'uy:md:p-300 uy:lg:p-400',
|
|
430
|
-
// State styles
|
|
431
|
-
'uy:hover:bg-surface-primary-hover uy:focus:bg-surface-primary-focus',
|
|
432
|
-
// Override styles
|
|
433
|
-
'uy:shadow-floating uy:border-border-primary-default',
|
|
434
|
-
)
|
|
435
|
-
expect(result).toBe(
|
|
436
|
-
'uy:p-200 uy:rounded-100 uy:bg-surface-primary-default uy:text-content-inverted-default uy:md:p-300 uy:lg:p-400 uy:hover:bg-surface-primary-hover uy:focus:bg-surface-primary-focus uy:shadow-floating uy:border-border-primary-default',
|
|
437
|
-
)
|
|
438
|
-
})
|
|
439
|
-
|
|
440
|
-
it('should preserve non-Unity classes', () => {
|
|
441
|
-
const result = uyMerge(
|
|
442
|
-
'flex items-center justify-center',
|
|
443
|
-
'uy:bg-surface-primary-default uy:p-200',
|
|
444
|
-
'absolute top-0 left-0',
|
|
445
|
-
)
|
|
446
|
-
expect(result).toBe(
|
|
447
|
-
'flex items-center justify-center uy:bg-surface-primary-default uy:p-200 absolute top-0 left-0',
|
|
448
|
-
)
|
|
449
|
-
})
|
|
450
|
-
|
|
451
|
-
it('should handle mixed Unity and Tailwind conflicts correctly', () => {
|
|
452
|
-
const result = uyMerge(
|
|
453
|
-
'p-4 uy:p-100', // Different systems, should not conflict
|
|
454
|
-
'bg-red-500 uy:bg-surface-primary-default', // Different systems, should not conflict
|
|
455
|
-
'uy:p-200', // Unity conflict, should override Unity
|
|
456
|
-
)
|
|
457
|
-
expect(result).toBe(
|
|
458
|
-
'p-4 bg-red-500 uy:bg-surface-primary-default uy:p-200',
|
|
459
|
-
)
|
|
460
|
-
})
|
|
461
|
-
})
|
|
462
|
-
})
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createTailwindMerge,
|
|
3
|
-
getDefaultConfig,
|
|
4
|
-
mergeConfigs,
|
|
5
|
-
} from 'tailwind-merge'
|
|
6
|
-
|
|
7
|
-
import { twMergeConfig } from './merge-config'
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Unity-configured tailwind-merge function for intelligent CSS class merging.
|
|
11
|
-
*
|
|
12
|
-
* This is a pre-configured version of tailwind-merge that includes Unity's custom
|
|
13
|
-
* class definitions and merge rules. It automatically handles Unity's design tokens
|
|
14
|
-
* including semantic colors, primitive colors, spacing values, typography classes,
|
|
15
|
-
* border radius, shadows, and more.
|
|
16
|
-
* @param classes - CSS class names to merge
|
|
17
|
-
* @returns Merged and deduplicated class string with conflicts resolved
|
|
18
|
-
* @example
|
|
19
|
-
* ```tsx
|
|
20
|
-
* import { uyMerge } from '@payfit/unity-themes'
|
|
21
|
-
*
|
|
22
|
-
* // Basic conflict resolution - last class wins
|
|
23
|
-
* const className = uyMerge('uy:bg-surface-primary-default', 'uy:bg-surface-danger-default')
|
|
24
|
-
* // → 'uy:bg-surface-danger-default'
|
|
25
|
-
*
|
|
26
|
-
* // Spacing conflicts
|
|
27
|
-
* const className = uyMerge('uy:p-100', 'uy:px-200', 'uy:py-300')
|
|
28
|
-
* // → 'uy:p-100 uy:px-200 uy:py-300' (px/py don't conflict with p)
|
|
29
|
-
*
|
|
30
|
-
* const className = uyMerge('uy:p-100', 'uy:p-200')
|
|
31
|
-
* // → 'uy:p-200' (direct conflict resolved)
|
|
32
|
-
*
|
|
33
|
-
* // Typography conflicts
|
|
34
|
-
* const className = uyMerge('uy:typography-h1', 'uy:typography-body')
|
|
35
|
-
* // → 'uy:typography-body'
|
|
36
|
-
*
|
|
37
|
-
* // Complex semantic colors
|
|
38
|
-
* const className = uyMerge(
|
|
39
|
-
* 'uy:bg-surface-primary-default-default',
|
|
40
|
-
* 'uy:bg-surface-primary-default-hover'
|
|
41
|
-
* )
|
|
42
|
-
* // → 'uy:bg-surface-primary-default-hover'
|
|
43
|
-
*
|
|
44
|
-
* // Mixed with standard Tailwind (no conflicts)
|
|
45
|
-
* const className = uyMerge('flex items-center', 'uy:bg-surface-primary-default', 'justify-center')
|
|
46
|
-
* // → 'flex items-center uy:bg-surface-primary-default justify-center'
|
|
47
|
-
*
|
|
48
|
-
* // Responsive and state variants
|
|
49
|
-
* const className = uyMerge(
|
|
50
|
-
* 'uy:bg-surface-neutral-default',
|
|
51
|
-
* 'uy:hover:bg-surface-primary-hover',
|
|
52
|
-
* 'uy:md:bg-surface-secondary-default'
|
|
53
|
-
* )
|
|
54
|
-
* // → 'uy:bg-surface-neutral-default uy:hover:bg-surface-primary-hover uy:md:bg-surface-secondary-default'
|
|
55
|
-
* ```
|
|
56
|
-
* @description
|
|
57
|
-
* **Supported Unity Features:**
|
|
58
|
-
* - **Primitive Colors**: `grayscale-l0`, `red-l5`, `blue-l12`, etc. (pattern: `{color}-l{number}`)
|
|
59
|
-
* - **Semantic Colors**: `surface-primary-default`, `content-neutral-low`, `border-danger-default`, etc.
|
|
60
|
-
* - **Spacing**: All Unity spacing values (`0`, `25`, `50`, `75`, `100`, `125`, `150`, `200`, `250`, `300`, `400`, `500`, `600`, `800`, `1000`)
|
|
61
|
-
* - **Typography**: `h1`, `h2`, `body`, `action`, etc. (generated class names without `-sm` variants)
|
|
62
|
-
* - **Border Radius**: Numeric (`0`, `25`, `50`, etc.) and semantic (`xs`, `sm`, `md`, `lg`, `xl`, `circle`, `pill`)
|
|
63
|
-
* - **Shadows**: Unity shadow values (`canvas`, `raising`, `floating`, `flying`, `soaring`)
|
|
64
|
-
* - **All Utilities**: `bg-*`, `text-*`, `border-*`, `outline-*`, `ring-*`, `divide-*`, `decoration-*`, gradients, etc.
|
|
65
|
-
*
|
|
66
|
-
* **Merge Rules:**
|
|
67
|
-
* - Conflicting classes within the same group are resolved (last one wins)
|
|
68
|
-
* - Non-conflicting classes are preserved
|
|
69
|
-
* - Unity classes don't conflict with standard Tailwind classes
|
|
70
|
-
* - Responsive and state variants are handled correctly
|
|
71
|
-
* - Pattern matching automatically supports new Unity design tokens
|
|
72
|
-
* @see {@link twMergeConfig} for the complete Unity merge configuration
|
|
73
|
-
* @see {@link https://github.com/dcastil/tailwind-merge Tailwind Merge Documentation}
|
|
74
|
-
*/
|
|
75
|
-
export const uyMerge = createTailwindMerge(() =>
|
|
76
|
-
mergeConfigs(getDefaultConfig(), twMergeConfig),
|
|
77
|
-
)
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import type { VariantProps } from 'tailwind-variants'
|
|
2
|
-
|
|
3
|
-
import { createTV } from 'tailwind-variants'
|
|
4
|
-
|
|
5
|
-
import { twMergeConfig } from './merge-config'
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Unity-configured tailwind-variants TV function for creating component variants.
|
|
9
|
-
*
|
|
10
|
-
* This is a pre-configured version of tailwind-variants' `createTV` function that includes
|
|
11
|
-
* Unity's custom tailwind-merge configuration. It automatically handles Unity's custom
|
|
12
|
-
* class names including semantic colors, spacing values, typography classes, and more.
|
|
13
|
-
* @example
|
|
14
|
-
* ```tsx
|
|
15
|
-
* import { uyTv } from '@payfit/unity-themes'
|
|
16
|
-
*
|
|
17
|
-
* const button = uyTv({
|
|
18
|
-
* base: 'uy:px-200 uy:py-100 uy:rounded-100',
|
|
19
|
-
* variants: {
|
|
20
|
-
* variant: {
|
|
21
|
-
* primary: 'uy:bg-surface-primary-default uy:text-content-inverted-default',
|
|
22
|
-
* secondary: 'uy:bg-surface-neutral-default uy:text-content-neutral-default',
|
|
23
|
-
* },
|
|
24
|
-
* size: {
|
|
25
|
-
* small: 'uy:text-75 uy:px-150 uy:py-75',
|
|
26
|
-
* large: 'uy:text-200 uy:px-300 uy:py-150',
|
|
27
|
-
* }
|
|
28
|
-
* },
|
|
29
|
-
* defaultVariants: {
|
|
30
|
-
* variant: 'primary',
|
|
31
|
-
* size: 'small'
|
|
32
|
-
* }
|
|
33
|
-
* })
|
|
34
|
-
*
|
|
35
|
-
* // Usage in component
|
|
36
|
-
* <button className={button({ variant: 'secondary', size: 'large' })}>
|
|
37
|
-
* Click me
|
|
38
|
-
* </button>
|
|
39
|
-
* ```
|
|
40
|
-
* @description
|
|
41
|
-
* - Automatically merges conflicting Unity classes (e.g., `uy:bg-surface-primary` + `uy:bg-surface-danger` → `uy:bg-surface-danger`)
|
|
42
|
-
* - Supports all Unity design tokens: colors, spacing, typography, shadows, border radius
|
|
43
|
-
* - Handles responsive and state variants correctly
|
|
44
|
-
* - Compatible with standard Tailwind classes alongside Unity classes
|
|
45
|
-
* @see {@link https://www.tailwind-variants.org/ Tailwind Variants Documentation}
|
|
46
|
-
* @see {@link twMergeConfig} for the Unity merge configuration details
|
|
47
|
-
*/
|
|
48
|
-
export const uyTv = createTV({
|
|
49
|
-
twMerge: true,
|
|
50
|
-
twMergeConfig,
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
export type { VariantProps }
|