@payfit/unity-themes 2.55.22 → 2.56.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 (52) hide show
  1. package/dist/esm/scripts/style-dictionary-config.d.ts +14 -0
  2. package/package.json +14 -5
  3. package/skills/unity-themes/SKILL.md +45 -0
  4. package/src/agent-references/manifest.json +16 -0
  5. package/src/agent-references/tokens-catalog.json +13891 -0
  6. package/dist/esm/scripts/agent-references/color-reference.d.ts +0 -37
  7. package/src/agent-references/README.mdx +0 -25
  8. package/src/agent-references/primitive-colors.mdx +0 -18
  9. package/src/agent-references/semantic-border-colors.mdx +0 -16
  10. package/src/agent-references/semantic-content-colors.mdx +0 -16
  11. package/src/agent-references/semantic-surface-colors.mdx +0 -16
  12. package/src/agent-references/semantic-utility-colors.mdx +0 -16
  13. package/src/components/unity-theme-provider.stories.tsx +0 -532
  14. package/src/components/unity-theme-provider.test.tsx +0 -150
  15. package/src/components/unity-theme-provider.tsx +0 -72
  16. package/src/index.ts +0 -15
  17. package/src/scripts/actions/append-animations.ts +0 -73
  18. package/src/scripts/actions/compose-multi-theme.ts +0 -59
  19. package/src/scripts/agent-references/color-reference.test.ts +0 -140
  20. package/src/scripts/agent-references/color-reference.ts +0 -348
  21. package/src/scripts/build.ts +0 -420
  22. package/src/scripts/file-headers/unity.ts +0 -31
  23. package/src/scripts/formats/processors/grid-processor.test.ts +0 -378
  24. package/src/scripts/formats/processors/grid-processor.ts +0 -64
  25. package/src/scripts/formats/processors/typography-processor.test.ts +0 -111
  26. package/src/scripts/formats/processors/typography-processor.ts +0 -48
  27. package/src/scripts/formats/unity-theme.test.ts +0 -329
  28. package/src/scripts/formats/unity-theme.ts +0 -54
  29. package/src/scripts/formats/utils.test.ts +0 -264
  30. package/src/scripts/formats/utils.ts +0 -15
  31. package/src/scripts/transforms/oklch.test.ts +0 -166
  32. package/src/scripts/transforms/oklch.ts +0 -19
  33. package/src/scripts/transforms/tailwind-animation-token.test.ts +0 -108
  34. package/src/scripts/transforms/tailwind-animation-token.ts +0 -51
  35. package/src/scripts/transforms/tailwind-color-token.test.ts +0 -304
  36. package/src/scripts/transforms/tailwind-color-token.ts +0 -17
  37. package/src/scripts/transforms/tailwind-grid-token.test.ts +0 -114
  38. package/src/scripts/transforms/tailwind-grid-token.ts +0 -27
  39. package/src/scripts/transforms/tailwind-spacing-token.test.ts +0 -315
  40. package/src/scripts/transforms/tailwind-spacing-token.ts +0 -24
  41. package/src/scripts/transforms/tailwind-text-token.test.ts +0 -328
  42. package/src/scripts/transforms/tailwind-text-token.ts +0 -30
  43. package/src/scripts/transforms/tailwind-typography-token.test.ts +0 -55
  44. package/src/scripts/transforms/tailwind-typography-token.ts +0 -20
  45. package/src/scripts/types.ts +0 -30
  46. package/src/scripts/utils/prefix-transform.test.ts +0 -137
  47. package/src/scripts/utils/prefix-transform.ts +0 -16
  48. package/src/utils/cn.ts +0 -109
  49. package/src/utils/merge-config.ts +0 -194
  50. package/src/utils/tailwind-merge.test.ts +0 -462
  51. package/src/utils/tailwind-merge.ts +0 -77
  52. package/src/utils/tailwind-variants.ts +0 -53
@@ -1,166 +0,0 @@
1
- import type {
2
- Config,
3
- PlatformConfig,
4
- TransformedToken,
5
- } from 'style-dictionary/types'
6
-
7
- import Color from 'colorjs.io'
8
- import { beforeEach, describe, expect, it, vi } from 'vitest'
9
-
10
- import { filter, transform } from './oklch.js'
11
-
12
- describe('oklch transform', () => {
13
- const createMockToken = (value: string, type = 'color'): TransformedToken =>
14
- ({
15
- name: 'test-token',
16
- value,
17
- $value: value,
18
- type,
19
- $type: type,
20
- path: [],
21
- original: {},
22
- filePath: '',
23
- isSource: false,
24
- }) as TransformedToken
25
-
26
- const createMockConfig = (usesDtcg = false): Config => ({
27
- usesDtcg,
28
- platforms: {},
29
- source: [],
30
- include: [],
31
- })
32
-
33
- const createMockPlatformConfig = (): PlatformConfig => ({
34
- transforms: [],
35
- buildPath: '',
36
- files: [],
37
- })
38
-
39
- describe('filter', () => {
40
- it('should return true for color tokens with usesDtcg false', () => {
41
- const token = createMockToken('#000000', 'color')
42
- const config = createMockConfig(false)
43
-
44
- const result = filter(token, config)
45
-
46
- expect(result).toBe(true)
47
- })
48
-
49
- it('should return true for color tokens with usesDtcg true', () => {
50
- const token = createMockToken('#000000', 'color')
51
- const config = createMockConfig(true)
52
-
53
- const result = filter(token, config)
54
-
55
- expect(result).toBe(true)
56
- })
57
-
58
- it('should return false for non-color tokens with usesDtcg false', () => {
59
- const token = createMockToken('1rem', 'spacing')
60
- const config = createMockConfig(false)
61
-
62
- const result = filter(token, config)
63
-
64
- expect(result).toBe(false)
65
- })
66
-
67
- it('should return false for non-color tokens with usesDtcg true', () => {
68
- const token = createMockToken('1rem', 'spacing')
69
- const config = createMockConfig(true)
70
-
71
- const result = filter(token, config)
72
-
73
- expect(result).toBe(false)
74
- })
75
-
76
- it('should handle different token types', () => {
77
- const testCases = [
78
- { type: 'color', expected: true },
79
- { type: 'spacing', expected: false },
80
- { type: 'typography', expected: false },
81
- { type: 'border', expected: false },
82
- { type: 'shadow', expected: false },
83
- ]
84
-
85
- testCases.forEach(({ type, expected }) => {
86
- const token = createMockToken('test-value', type)
87
- const config = createMockConfig(false)
88
-
89
- const result = filter(token, config)
90
-
91
- expect(result).toBe(expected)
92
- })
93
- })
94
- })
95
-
96
- describe('transform', () => {
97
- beforeEach(() => {
98
- vi.clearAllMocks()
99
- })
100
-
101
- it('should convert color to OKLCH format with usesDtcg false', () => {
102
- const token = createMockToken('#ff0000', 'color')
103
- const config = createMockPlatformConfig()
104
- const options = createMockConfig(false)
105
-
106
- const result = transform(token, config, options)
107
-
108
- expect(result).toBe('oklch(62.796% 0.25768 29.234)')
109
- })
110
-
111
- it('should convert color to OKLCH format with usesDtcg true', () => {
112
- const token = createMockToken('#ff0000', 'color')
113
- const config = createMockPlatformConfig()
114
- const options = createMockConfig(true)
115
-
116
- const result = transform(token, config, options)
117
-
118
- expect(result).toBe('oklch(62.796% 0.25768 29.234)')
119
- })
120
-
121
- it('should handle different color formats', () => {
122
- const testCases = [
123
- { value: '#ff0000', expected: 'oklch(62.796% 0.25768 29.234)' },
124
- { value: 'rgb(0, 255, 0)', expected: 'oklch(86.644% 0.29483 142.5)' },
125
- {
126
- value: 'hsl(240, 100%, 50%)',
127
- expected: 'oklch(45.201% 0.31321 264.05)',
128
- },
129
- {
130
- value: 'rgba(255, 0, 0, 0.5)',
131
- expected: 'oklch(62.796% 0.25768 29.234 / 0.5)',
132
- },
133
- ]
134
-
135
- testCases.forEach(({ value, expected }) => {
136
- const token = createMockToken(value, 'color')
137
- const config = createMockPlatformConfig()
138
- const options = createMockConfig(false)
139
-
140
- const result = transform(token, config, options)
141
-
142
- expect(result).toBe(expected)
143
- })
144
- })
145
-
146
- it('should handle color with alpha channel', () => {
147
- const token = createMockToken('rgba(255, 0, 0, 0.8)', 'color')
148
- const config = createMockPlatformConfig()
149
- const options = createMockConfig(false)
150
-
151
- const result = transform(token, config, options)
152
-
153
- expect(result).toBe('oklch(62.796% 0.25768 29.234 / 0.8)')
154
- })
155
-
156
- it('should handle named colors', () => {
157
- const token = createMockToken('red', 'color')
158
- const config = createMockPlatformConfig()
159
- const options = createMockConfig(false)
160
-
161
- const result = transform(token, config, options)
162
-
163
- expect(result).toBe('oklch(62.796% 0.25768 29.234)')
164
- })
165
- })
166
- })
@@ -1,19 +0,0 @@
1
- import type { Token } from 'style-dictionary'
2
- import type { Config, PlatformConfig } from 'style-dictionary/types'
3
-
4
- import Color from 'colorjs.io'
5
-
6
- export function filter(token: Token, options: Config): boolean {
7
- const tokenType = options.usesDtcg ? token.$type : token.type
8
- return tokenType === 'color'
9
- }
10
-
11
- export function transform(
12
- token: Token,
13
- _config: PlatformConfig,
14
- options: Config,
15
- ): string {
16
- const tokenValue = (options.usesDtcg ? token.$value : token.value) as string
17
- const tokenColorValue = new Color(tokenValue)
18
- return tokenColorValue.to('oklch').toString()
19
- }
@@ -1,108 +0,0 @@
1
- import type { Config, TransformedToken } from 'style-dictionary/types'
2
-
3
- import { describe, expect, it } from 'vitest'
4
-
5
- import { filter, transform } from './tailwind-animation-token.js'
6
-
7
- const createMockToken = (
8
- path: string[],
9
- type: string,
10
- value: unknown,
11
- usesDtcg = true,
12
- ): TransformedToken =>
13
- ({
14
- name: path.join('-'),
15
- value,
16
- type,
17
- path,
18
- original: {},
19
- filePath: '',
20
- isSource: false,
21
- ...(usesDtcg ? { $type: type, $value: value } : {}),
22
- }) as TransformedToken
23
-
24
- const createMockConfig = (): Config => ({
25
- platforms: {},
26
- source: [],
27
- include: [],
28
- })
29
-
30
- describe('tailwind/v4/animation', () => {
31
- describe('filter', () => {
32
- it('should return true for tokens with $type animation', () => {
33
- const token = createMockToken(
34
- ['animate', 'fade', 'in'],
35
- 'animation',
36
- 'fade-in',
37
- )
38
- const config = createMockConfig()
39
-
40
- expect(filter(token, config)).toBeTruthy()
41
- })
42
- it('should return false for tokens without $type animation', () => {
43
- const token = createMockToken(
44
- ['color', 'primary', 'default'],
45
- 'color',
46
- '#f00',
47
- )
48
- const config = createMockConfig()
49
-
50
- expect(filter(token, config)).toBeFalsy()
51
- })
52
-
53
- it('should handle non-DTCG tokens', () => {
54
- const token = createMockToken(
55
- ['animate', 'fade', 'in'],
56
- 'animation',
57
- 'fade-in',
58
- false,
59
- )
60
- const config = createMockConfig()
61
-
62
- expect(filter(token, { ...config, usesDtcg: false })).toBeTruthy()
63
- })
64
- })
65
-
66
- describe('transform', () => {
67
- it('should process animation tokens correctly', () => {
68
- const token = createMockToken(['animate', 'fade', 'in'], 'animation', {
69
- name: 'spin',
70
- duration: '2s',
71
- timingFunction: 'linear',
72
- })
73
- const config = createMockConfig()
74
-
75
- const output = transform(token, config, {})
76
-
77
- expect(output).toEqual('2s linear spin')
78
- })
79
- })
80
-
81
- it('should handle optional delay', () => {
82
- const token = createMockToken(['animate', 'fade', 'in'], 'animation', {
83
- name: 'spin',
84
- duration: '2s',
85
- timingFunction: 'linear',
86
- delay: '3s',
87
- })
88
- const config = createMockConfig()
89
-
90
- const output = transform(token, config, {})
91
-
92
- expect(output).toEqual('2s linear 3s spin')
93
- })
94
-
95
- it('should handle optional iterationCount', () => {
96
- const token = createMockToken(['animate', 'fade', 'in'], 'animation', {
97
- name: 'spin',
98
- duration: '2s',
99
- timingFunction: 'linear',
100
- iterationCount: 'infinite',
101
- })
102
- const config = createMockConfig()
103
-
104
- const output = transform(token, config, {})
105
-
106
- expect(output).toEqual('2s linear infinite spin')
107
- })
108
- })
@@ -1,51 +0,0 @@
1
- import type { Token } from 'style-dictionary'
2
- import type { Config, NameTransform } from 'style-dictionary/types'
3
-
4
- type Transformer = NameTransform['transform']
5
-
6
- type AnimationTokenValue = {
7
- name: string
8
- duration: string
9
- timingFunction: string
10
- delay?: string
11
- iterationCount?: string
12
- }
13
-
14
- export function filter(token: Token, options: Config): boolean {
15
- const tokenType = options.usesDtcg ? token.$type : token.type
16
- return tokenType === 'animation'
17
- }
18
-
19
- export const transform: Transformer = (token, config, options) => {
20
- const tokenValue = (
21
- options.usesDtcg ? token.$value : token.value
22
- ) as AnimationTokenValue
23
-
24
- if (typeof tokenValue !== 'object') {
25
- // already transformed to string
26
- return tokenValue
27
- }
28
-
29
- const {
30
- name: animationName,
31
- duration,
32
- timingFunction,
33
- delay,
34
- iterationCount,
35
- } = tokenValue
36
-
37
- const animationShorthand = [duration, timingFunction]
38
-
39
- if (delay) {
40
- animationShorthand.push(delay)
41
- }
42
- if (iterationCount) {
43
- animationShorthand.push(iterationCount)
44
- }
45
- animationShorthand.push(animationName)
46
-
47
- return animationShorthand
48
- .join(' ')
49
- .replace(/\s{2,}/g, '')
50
- .trim()
51
- }
@@ -1,304 +0,0 @@
1
- import type { Config, TransformedToken } from 'style-dictionary/types'
2
-
3
- import { describe, expect, it } from 'vitest'
4
-
5
- import { filter, transform } from './tailwind-color-token.js'
6
-
7
- describe('tailwind color token transform', () => {
8
- const createMockToken = (path: string[]): TransformedToken =>
9
- ({
10
- name: 'test-token',
11
- value: '#000000',
12
- type: 'color',
13
- path,
14
- original: {},
15
- filePath: '',
16
- isSource: false,
17
- }) as TransformedToken
18
-
19
- const createMockConfig = (): Config => ({
20
- platforms: {},
21
- source: [],
22
- include: [],
23
- })
24
-
25
- describe('filter', () => {
26
- it('should return true for tokens with color as first path element', () => {
27
- const token = createMockToken(['color', 'primary', 'default'])
28
- const config = createMockConfig()
29
-
30
- const result = filter(token, config)
31
-
32
- expect(result).toBe(true)
33
- })
34
-
35
- it('should return false for tokens without color as first path element', () => {
36
- const testCases = [
37
- ['spacing', '1'],
38
- ['typography', 'heading', 'h1'],
39
- ['border', 'width', 'thin'],
40
- ['shadow', 'small'],
41
- ['breakpoint', 'mobile'],
42
- ]
43
-
44
- testCases.forEach(path => {
45
- const token = createMockToken(path)
46
- const config = createMockConfig()
47
-
48
- const result = filter(token, config)
49
-
50
- expect(result).toBe(false)
51
- })
52
- })
53
-
54
- it('should return false for empty path', () => {
55
- const token = createMockToken([])
56
- const config = createMockConfig()
57
-
58
- const result = filter(token, config)
59
-
60
- expect(result).toBe(false)
61
- })
62
-
63
- it('should return false for single element path that is not color', () => {
64
- const token = createMockToken(['spacing'])
65
- const config = createMockConfig()
66
-
67
- const result = filter(token, config)
68
-
69
- expect(result).toBe(false)
70
- })
71
-
72
- it('should handle case sensitivity', () => {
73
- const testCases = [
74
- { path: ['Color', 'primary'], expected: false },
75
- { path: ['COLOR', 'primary'], expected: false },
76
- { path: ['color', 'primary'], expected: true },
77
- ]
78
-
79
- testCases.forEach(({ path, expected }) => {
80
- const token = createMockToken(path)
81
- const config = createMockConfig()
82
-
83
- const result = filter(token, config)
84
-
85
- expect(result).toBe(expected)
86
- })
87
- })
88
- })
89
-
90
- describe('transform', () => {
91
- it('should join path elements with hyphens, excluding default', () => {
92
- const token = createMockToken(['color', 'primary', 'default'])
93
- const config = createMockConfig()
94
-
95
- const result = transform(token, config, {})
96
-
97
- expect(result).toBe('color-primary')
98
- })
99
-
100
- it('should handle path without default', () => {
101
- const token = createMockToken(['color', 'primary', 'hover'])
102
- const config = createMockConfig()
103
-
104
- const result = transform(token, config, {})
105
-
106
- expect(result).toBe('color-primary-hover')
107
- })
108
-
109
- it('should handle path with multiple default occurrences', () => {
110
- const token = createMockToken(['color', 'default', 'primary', 'default'])
111
- const config = createMockConfig()
112
-
113
- const result = transform(token, config, {})
114
-
115
- expect(result).toBe('color-primary')
116
- })
117
-
118
- it('should handle path with only color and default', () => {
119
- const token = createMockToken(['color', 'default'])
120
- const config = createMockConfig()
121
-
122
- const result = transform(token, config, {})
123
-
124
- expect(result).toBe('color')
125
- })
126
-
127
- it('should handle path with only color', () => {
128
- const token = createMockToken(['color'])
129
- const config = createMockConfig()
130
-
131
- const result = transform(token, config, {})
132
-
133
- expect(result).toBe('color')
134
- })
135
-
136
- it('should handle complex color paths', () => {
137
- const testCases = [
138
- { path: ['color', 'gray', '100'], expected: 'color-gray-100' },
139
- {
140
- path: ['color', 'blue', '500', 'hover'],
141
- expected: 'color-blue-500-hover',
142
- },
143
- {
144
- path: ['color', 'red', 'default', 'active'],
145
- expected: 'color-red-active',
146
- },
147
- {
148
- path: ['color', 'green', 'default', 'default', 'focus'],
149
- expected: 'color-green-focus',
150
- },
151
- ]
152
-
153
- testCases.forEach(({ path, expected }) => {
154
- const token = createMockToken(path)
155
- const config = createMockConfig()
156
-
157
- const result = transform(token, config, {})
158
-
159
- expect(result).toBe(expected)
160
- })
161
- })
162
-
163
- it('should handle path with special characters', () => {
164
- const testCases = [
165
- {
166
- path: ['color', 'primary', 'with-dash'],
167
- expected: 'color-primary-with-dash',
168
- },
169
- {
170
- path: ['color', 'primary', 'with_underscore'],
171
- expected: 'color-primary-with_underscore',
172
- },
173
- {
174
- path: ['color', 'primary', 'with.dot'],
175
- expected: 'color-primary-with.dot',
176
- },
177
- ]
178
-
179
- testCases.forEach(({ path, expected }) => {
180
- const token = createMockToken(path)
181
- const config = createMockConfig()
182
-
183
- const result = transform(token, config, {})
184
-
185
- expect(result).toBe(expected)
186
- })
187
- })
188
-
189
- it('should handle path with numbers', () => {
190
- const testCases = [
191
- { path: ['color', 'gray', '100'], expected: 'color-gray-100' },
192
- { path: ['color', 'blue', '500'], expected: 'color-blue-500' },
193
- { path: ['color', 'red', '1000'], expected: 'color-red-1000' },
194
- ]
195
-
196
- testCases.forEach(({ path, expected }) => {
197
- const token = createMockToken(path)
198
- const config = createMockConfig()
199
-
200
- const result = transform(token, config, {})
201
-
202
- expect(result).toBe(expected)
203
- })
204
- })
205
-
206
- it('should handle path with mixed content', () => {
207
- const testCases = [
208
- {
209
- path: ['color', 'primary', 'default', 'hover', 'active'],
210
- expected: 'color-primary-hover-active',
211
- },
212
- {
213
- path: ['color', 'secondary', 'default', 'focus', 'default'],
214
- expected: 'color-secondary-focus',
215
- },
216
- {
217
- path: ['color', 'tertiary', 'default', 'default', 'default'],
218
- expected: 'color-tertiary',
219
- },
220
- ]
221
-
222
- testCases.forEach(({ path, expected }) => {
223
- const token = createMockToken(path)
224
- const config = createMockConfig()
225
-
226
- const result = transform(token, config, {})
227
-
228
- expect(result).toBe(expected)
229
- })
230
- })
231
-
232
- it('should handle edge cases', () => {
233
- const testCases = [
234
- { path: ['color', 'default', 'default', 'default'], expected: 'color' },
235
- {
236
- path: ['color', 'primary', 'default', 'default'],
237
- expected: 'color-primary',
238
- },
239
- {
240
- path: ['color', 'default', 'primary', 'default'],
241
- expected: 'color-primary',
242
- },
243
- {
244
- path: ['color', 'default', 'default', 'primary'],
245
- expected: 'color-primary',
246
- },
247
- ]
248
-
249
- testCases.forEach(({ path, expected }) => {
250
- const token = createMockToken(path)
251
- const config = createMockConfig()
252
-
253
- const result = transform(token, config, {})
254
-
255
- expect(result).toBe(expected)
256
- })
257
- })
258
-
259
- it('should handle empty path elements', () => {
260
- const token = createMockToken(['color', '', 'primary', 'default'])
261
- const config = createMockConfig()
262
-
263
- const result = transform(token, config, {})
264
-
265
- expect(result).toBe('color--primary')
266
- })
267
-
268
- it('should handle path with whitespace', () => {
269
- const token = createMockToken(['color', 'primary', ' ', 'default'])
270
- const config = createMockConfig()
271
-
272
- const result = transform(token, config, {})
273
-
274
- expect(result).toBe('color-primary- ')
275
- })
276
-
277
- it('should handle path with uppercase', () => {
278
- const token = createMockToken(['color', 'PRIMARY', 'default'])
279
- const config = createMockConfig()
280
-
281
- const result = transform(token, config, {})
282
-
283
- expect(result).toBe('color-primary')
284
- })
285
-
286
- it('should prepend prefix when config.prefix is set', () => {
287
- const token = createMockToken(['color', 'primary', 'default'])
288
- const config = { ...createMockConfig(), prefix: 'uy' }
289
-
290
- const result = transform(token, config, {})
291
-
292
- expect(result).toBe('uy-color-primary')
293
- })
294
-
295
- it('should not prepend prefix when config.prefix is undefined', () => {
296
- const token = createMockToken(['color', 'blue', '500'])
297
- const config = createMockConfig()
298
-
299
- const result = transform(token, config, {})
300
-
301
- expect(result).toBe('color-blue-500')
302
- })
303
- })
304
- })
@@ -1,17 +0,0 @@
1
- import type { Token } from 'style-dictionary'
2
- import type { NameTransform } from 'style-dictionary/types'
3
-
4
- import { prefixTransform } from '../utils/prefix-transform'
5
-
6
- type Transformer = NameTransform['transform']
7
-
8
- export function filter(token: Token): boolean {
9
- return token.path[0] === 'color'
10
- }
11
-
12
- export const tailwindColorTokenNameTransform: Transformer = token => {
13
- const ignoreDefault = (nameToken: string) => !nameToken.includes('default')
14
- return [...token.path.filter(ignoreDefault)].join('-').toLowerCase()
15
- }
16
-
17
- export const transform = prefixTransform(tailwindColorTokenNameTransform)