@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,328 +0,0 @@
1
- import type { Token } from 'style-dictionary'
2
- import type { Config, PlatformConfig } from 'style-dictionary/types'
3
-
4
- import { describe, expect, it } from 'vitest'
5
-
6
- import { filter, transform } from './tailwind-text-token.js'
7
-
8
- describe('tailwind text token transform', () => {
9
- const createMockToken = (path: string[]): Token =>
10
- ({
11
- name: 'test-token',
12
- value: '400 1rem/1.5 Inter',
13
- type: 'typography',
14
- path,
15
- original: {},
16
- filePath: '',
17
- isSource: false,
18
- }) as Token
19
-
20
- const createMockConfig = (): Config => ({
21
- platforms: {},
22
- source: [],
23
- include: [],
24
- })
25
-
26
- const createMockPlatformConfig = (): PlatformConfig => ({
27
- transforms: [],
28
- buildPath: '',
29
- files: [],
30
- })
31
-
32
- describe('filter', () => {
33
- it('should return true for tokens with text as first path element', () => {
34
- const token = createMockToken(['text', 'heading', 'h1'])
35
- const config = createMockConfig()
36
-
37
- const result = filter(token, config)
38
-
39
- expect(result).toBe(true)
40
- })
41
-
42
- it('should return false for tokens without text as first path element', () => {
43
- const testCases = [
44
- ['color', 'primary', 'default'],
45
- ['spacing', '1', 'base'],
46
- ['typography', 'heading', 'h1'],
47
- ['border', 'width', 'thin'],
48
- ['shadow', 'small'],
49
- ['breakpoint', 'mobile'],
50
- ]
51
-
52
- testCases.forEach(path => {
53
- const token = createMockToken(path)
54
- const config = createMockConfig()
55
-
56
- const result = filter(token, config)
57
-
58
- expect(result).toBe(false)
59
- })
60
- })
61
-
62
- it('should return false for empty path', () => {
63
- const token = createMockToken([])
64
- const config = createMockConfig()
65
-
66
- const result = filter(token, config)
67
-
68
- expect(result).toBe(false)
69
- })
70
-
71
- it('should return false for single element path that is not text', () => {
72
- const token = createMockToken(['color'])
73
- const config = createMockConfig()
74
-
75
- const result = filter(token, config)
76
-
77
- expect(result).toBe(false)
78
- })
79
-
80
- it('should handle case sensitivity', () => {
81
- const testCases = [
82
- { path: ['Text', 'heading'], expected: false },
83
- { path: ['TEXT', 'heading'], expected: false },
84
- { path: ['text', 'heading'], expected: true },
85
- ]
86
-
87
- testCases.forEach(({ path, expected }) => {
88
- const token = createMockToken(path)
89
- const config = createMockConfig()
90
-
91
- const result = filter(token, config)
92
-
93
- expect(result).toBe(expected)
94
- })
95
- })
96
- })
97
-
98
- describe('transform', () => {
99
- it('should return text-{size} when second path element does not contain --', () => {
100
- const token = createMockToken(['text', 'heading'])
101
- const config = createMockPlatformConfig()
102
-
103
- const result = transform(token, config)
104
-
105
- expect(result).toBe('text-heading')
106
- })
107
-
108
- it('should return text-{size}--{suffix} when second path element contains --', () => {
109
- const token = createMockToken(['text', 'heading--large'])
110
- const config = createMockPlatformConfig()
111
-
112
- const result = transform(token, config)
113
-
114
- expect(result).toBe('text-heading--large')
115
- })
116
-
117
- it('should handle path with only text element', () => {
118
- const token = createMockToken(['text'])
119
- const config = createMockPlatformConfig()
120
-
121
- const result = transform(token, config)
122
-
123
- expect(result).toBe('text-undefined')
124
- })
125
-
126
- it('should handle path with text and empty second element', () => {
127
- const token = createMockToken(['text', ''])
128
- const config = createMockPlatformConfig()
129
-
130
- const result = transform(token, config)
131
-
132
- expect(result).toBe('text-')
133
- })
134
-
135
- it('should handle complex text paths without --', () => {
136
- const testCases = [
137
- { path: ['text', 'heading'], expected: 'text-heading' },
138
- { path: ['text', 'body'], expected: 'text-body' },
139
- { path: ['text', 'caption'], expected: 'text-caption' },
140
- { path: ['text', 'label'], expected: 'text-label' },
141
- ]
142
-
143
- testCases.forEach(({ path, expected }) => {
144
- const token = createMockToken(path)
145
- const config = createMockPlatformConfig()
146
-
147
- const result = transform(token, config)
148
-
149
- expect(result).toBe(expected)
150
- })
151
- })
152
-
153
- it('should handle complex text paths with --', () => {
154
- const testCases = [
155
- { path: ['text', 'heading--large'], expected: 'text-heading--large' },
156
- { path: ['text', 'body--small'], expected: 'text-body--small' },
157
- { path: ['text', 'caption--medium'], expected: 'text-caption--medium' },
158
- { path: ['text', 'label--bold'], expected: 'text-label--bold' },
159
- ]
160
-
161
- testCases.forEach(({ path, expected }) => {
162
- const token = createMockToken(path)
163
- const config = createMockPlatformConfig()
164
-
165
- const result = transform(token, config)
166
-
167
- expect(result).toBe(expected)
168
- })
169
- })
170
-
171
- it('should handle text paths with numbers', () => {
172
- const testCases = [
173
- { path: ['text', 'heading-1'], expected: 'text-heading-1' },
174
- { path: ['text', 'body-2'], expected: 'text-body-2' },
175
- {
176
- path: ['text', 'caption-3--large'],
177
- expected: 'text-caption-3--large',
178
- },
179
- ]
180
-
181
- testCases.forEach(({ path, expected }) => {
182
- const token = createMockToken(path)
183
- const config = createMockPlatformConfig()
184
-
185
- const result = transform(token, config)
186
-
187
- expect(result).toBe(expected)
188
- })
189
- })
190
-
191
- it('should handle text paths with special characters', () => {
192
- const testCases = [
193
- {
194
- path: ['text', 'heading-with-dash'],
195
- expected: 'text-heading-with-dash',
196
- },
197
- {
198
- path: ['text', 'body_with_underscore'],
199
- expected: 'text-body_with_underscore',
200
- },
201
- {
202
- path: ['text', 'caption.with.dot'],
203
- expected: 'text-caption.with.dot',
204
- },
205
- {
206
- path: ['text', 'label--with-dash'],
207
- expected: 'text-label--with-dash',
208
- },
209
- ]
210
-
211
- testCases.forEach(({ path, expected }) => {
212
- const token = createMockToken(path)
213
- const config = createMockPlatformConfig()
214
-
215
- const result = transform(token, config)
216
-
217
- expect(result).toBe(expected)
218
- })
219
- })
220
-
221
- it('should handle edge cases with -- at different positions', () => {
222
- const testCases = [
223
- { path: ['text', '--heading'], expected: 'text---heading' },
224
- { path: ['text', 'heading--'], expected: 'text-heading--' },
225
- { path: ['text', '--'], expected: 'text---' },
226
- { path: ['text', '---'], expected: 'text----' },
227
- ]
228
-
229
- testCases.forEach(({ path, expected }) => {
230
- const token = createMockToken(path)
231
- const config = createMockPlatformConfig()
232
-
233
- const result = transform(token, config)
234
-
235
- expect(result).toBe(expected)
236
- })
237
- })
238
-
239
- it('should handle path with whitespace', () => {
240
- const testCases = [
241
- { path: ['text', ' heading'], expected: 'text- heading' },
242
- { path: ['text', 'heading '], expected: 'text-heading ' },
243
- { path: ['text', ' heading '], expected: 'text- heading ' },
244
- { path: ['text', 'heading-- large'], expected: 'text-heading-- large' },
245
- ]
246
-
247
- testCases.forEach(({ path, expected }) => {
248
- const token = createMockToken(path)
249
- const config = createMockPlatformConfig()
250
-
251
- const result = transform(token, config)
252
-
253
- expect(result).toBe(expected)
254
- })
255
- })
256
-
257
- it('should handle path with only -- in second element', () => {
258
- const token = createMockToken(['text', '--'])
259
- const config = createMockPlatformConfig()
260
-
261
- const result = transform(token, config)
262
-
263
- expect(result).toBe('text---')
264
- })
265
-
266
- it('should handle path with empty string after --', () => {
267
- const token = createMockToken(['text', 'heading--'])
268
- const config = createMockPlatformConfig()
269
-
270
- const result = transform(token, config)
271
-
272
- expect(result).toBe('text-heading--')
273
- })
274
-
275
- it('should handle path with empty string before --', () => {
276
- const token = createMockToken(['text', '--large'])
277
- const config = createMockPlatformConfig()
278
-
279
- const result = transform(token, config)
280
-
281
- expect(result).toBe('text---large')
282
- })
283
-
284
- it('should handle path with mixed content and --', () => {
285
- const testCases = [
286
- {
287
- path: ['text', 'heading-large--bold'],
288
- expected: 'text-heading-large--bold',
289
- },
290
- {
291
- path: ['text', 'body-small--italic'],
292
- expected: 'text-body-small--italic',
293
- },
294
- {
295
- path: ['text', 'caption-medium--underline'],
296
- expected: 'text-caption-medium--underline',
297
- },
298
- ]
299
-
300
- testCases.forEach(({ path, expected }) => {
301
- const token = createMockToken(path)
302
- const config = createMockPlatformConfig()
303
-
304
- const result = transform(token, config)
305
-
306
- expect(result).toBe(expected)
307
- })
308
- })
309
-
310
- it('should prepend prefix when config.prefix is set', () => {
311
- const token = createMockToken(['text', 'heading'])
312
- const config = { ...createMockPlatformConfig(), prefix: 'uy' }
313
-
314
- const result = transform(token, config)
315
-
316
- expect(result).toBe('uy-text-heading')
317
- })
318
-
319
- it('should prepend prefix with -- variant when config.prefix is set', () => {
320
- const token = createMockToken(['text', 'heading--large'])
321
- const config = { ...createMockPlatformConfig(), prefix: 'uy' }
322
-
323
- const result = transform(token, config)
324
-
325
- expect(result).toBe('uy-text-heading--large')
326
- })
327
- })
328
- })
@@ -1,30 +0,0 @@
1
- import type { Token } from 'style-dictionary'
2
- import type {
3
- Config,
4
- NameTransform,
5
- PlatformConfig,
6
- } from 'style-dictionary/types'
7
-
8
- import { prefixTransform } from '../utils/prefix-transform'
9
-
10
- type Transformer = NameTransform['transform']
11
-
12
- export function filter(token: Token, options: Config): boolean {
13
- return token.path[0] === 'text'
14
- }
15
-
16
- const tailwindTextTokenNameTransform: Transformer = (
17
- token: Token,
18
- config: PlatformConfig,
19
- ) => {
20
- const path = token.path as string[]
21
-
22
- if (path[1]?.includes('--')) {
23
- const [size, suffix] = path[1].split('--') as [string, string]
24
- return `text-${size}--${suffix}`
25
- }
26
-
27
- return `text-${path[1]}`
28
- }
29
-
30
- export const transform = prefixTransform(tailwindTextTokenNameTransform)
@@ -1,55 +0,0 @@
1
- import type { TransformedToken } from 'style-dictionary/types'
2
-
3
- import { describe, expect, it } from 'vitest'
4
-
5
- import { filter, transform } from './tailwind-typography-token.js'
6
-
7
- describe('tailwind typography token transform', () => {
8
- const createMockToken = (
9
- path: string[],
10
- type = 'typography',
11
- ): TransformedToken =>
12
- ({
13
- name: 'test-token',
14
- value: '400 1rem/1.5 Inter',
15
- $type: type,
16
- path,
17
- original: {},
18
- filePath: '',
19
- isSource: false,
20
- }) as TransformedToken
21
-
22
- describe('filter', () => {
23
- it('should return true for tokens with $type typography', () => {
24
- const token = createMockToken(['typography', 'h1', 'default'])
25
- const result = filter(token)
26
- expect(result).toBe(true)
27
- })
28
-
29
- it('should return false for tokens without $type typography', () => {
30
- const token = createMockToken(['color', 'primary', 'default'], 'color')
31
- const result = filter(token)
32
- expect(result).toBe(false)
33
- })
34
- })
35
-
36
- describe('transform', () => {
37
- it('should reorder the path elements correctly', () => {
38
- const token = createMockToken(['typography', 'h1', 'sm'])
39
- const result = transform(token, {}, {})
40
- expect(result).toBe('typography-sm-h1')
41
- })
42
-
43
- it('should handle "default" breakpoint correctly', () => {
44
- const token = createMockToken(['typography', 'h1', 'default'])
45
- const result = transform(token, {}, {})
46
- expect(result).toBe('typography-default-h1')
47
- })
48
-
49
- it('should prepend prefix when config.prefix is set', () => {
50
- const token = createMockToken(['typography', 'h1', 'sm'])
51
- const result = transform(token, { prefix: 'uy' }, {})
52
- expect(result).toBe('uy-typography-sm-h1')
53
- })
54
- })
55
- })
@@ -1,20 +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.$type === 'typography'
10
- }
11
-
12
- const tailwindTypographyTransform: Transformer = (token, config) => {
13
- const [_category, type, item] = token.path
14
- // Reorders the token path from [typography, h1, sm]
15
- // to the string "typography-sm-h1"
16
- const newPath = ['typography', item, type]
17
- return newPath.join('-')
18
- }
19
-
20
- export const transform = prefixTransform(tailwindTypographyTransform)
@@ -1,30 +0,0 @@
1
- import type {
2
- Config,
3
- LocalOptions,
4
- TransformedToken,
5
- } from 'style-dictionary/types'
6
-
7
- export type TokenWithCTIAttrs = TransformedToken & {
8
- attributes: {
9
- category: string
10
- type: string
11
- item: string
12
- }
13
- }
14
-
15
- export type BreakpointToken = TransformedToken & {
16
- $value: string
17
- $type: 'dimension'
18
- }
19
-
20
- export type TypographyGroup = {
21
- default?: TokenWithCTIAttrs
22
- responsive: Map<string, TokenWithCTIAttrs>
23
- }
24
-
25
- export type ProcessorOptions = Config & LocalOptions
26
-
27
- export type Prefixes = {
28
- classPrefix: string
29
- variablePrefix: string
30
- }
@@ -1,137 +0,0 @@
1
- import type {
2
- Config,
3
- PlatformConfig,
4
- TransformedToken,
5
- } from 'style-dictionary/types'
6
-
7
- import { describe, expect, it, vi } from 'vitest'
8
-
9
- import { prefixTransform } from './prefix-transform.js'
10
-
11
- describe('prefixTransform', () => {
12
- const createMockToken = (): TransformedToken =>
13
- ({
14
- name: 'test-token',
15
- value: '#000000',
16
- type: 'color',
17
- path: ['color', 'primary'],
18
- original: {},
19
- filePath: '',
20
- isSource: false,
21
- }) as TransformedToken
22
-
23
- const createMockConfig = (prefix?: string): PlatformConfig =>
24
- ({
25
- platforms: {},
26
- source: [],
27
- include: [],
28
- prefix,
29
- }) as unknown as PlatformConfig
30
-
31
- const createMockOptions = (): Config =>
32
- ({
33
- platforms: {},
34
- source: [],
35
- include: [],
36
- }) as Config
37
-
38
- describe('without prefix', () => {
39
- it('should return the original transformer value when no prefix is set', () => {
40
- const transformer = vi.fn(() => 'color-primary')
41
- const wrapped = prefixTransform(transformer)
42
-
43
- const result = wrapped(
44
- createMockToken(),
45
- createMockConfig(),
46
- createMockOptions(),
47
- )
48
-
49
- expect(result).toBe('color-primary')
50
- })
51
-
52
- it('should return the original transformer value when prefix is empty string', () => {
53
- const transformer = vi.fn(() => 'color-primary')
54
- const wrapped = prefixTransform(transformer)
55
-
56
- const result = wrapped(
57
- createMockToken(),
58
- createMockConfig(''),
59
- createMockOptions(),
60
- )
61
-
62
- expect(result).toBe('color-primary')
63
- })
64
- })
65
-
66
- describe('with prefix', () => {
67
- it('should prepend the prefix to the transformer value', () => {
68
- const transformer = vi.fn(() => 'color-primary')
69
- const wrapped = prefixTransform(transformer)
70
-
71
- const result = wrapped(
72
- createMockToken(),
73
- createMockConfig('uy'),
74
- createMockOptions(),
75
- )
76
-
77
- expect(result).toBe('uy-color-primary')
78
- })
79
-
80
- it('should work with different prefix values', () => {
81
- const transformer = vi.fn(() => 'spacing-md')
82
- const wrapped = prefixTransform(transformer)
83
-
84
- const result = wrapped(
85
- createMockToken(),
86
- createMockConfig('my-prefix'),
87
- createMockOptions(),
88
- )
89
-
90
- expect(result).toBe('my-prefix-spacing-md')
91
- })
92
- })
93
-
94
- describe('async transformer', () => {
95
- it('should handle a transformer that returns a Promise', async () => {
96
- const transformer = vi.fn(() => Promise.resolve('color-primary'))
97
- const wrapped = prefixTransform(transformer)
98
-
99
- const result = wrapped(
100
- createMockToken(),
101
- createMockConfig('uy'),
102
- createMockOptions(),
103
- )
104
-
105
- expect(result).toBeInstanceOf(Promise)
106
- await expect(result).resolves.toBe('uy-color-primary')
107
- })
108
-
109
- it('should handle a Promise result without prefix', async () => {
110
- const transformer = vi.fn(() => Promise.resolve('color-primary'))
111
- const wrapped = prefixTransform(transformer)
112
-
113
- const result = wrapped(
114
- createMockToken(),
115
- createMockConfig(),
116
- createMockOptions(),
117
- )
118
-
119
- await expect(result).resolves.toBe('color-primary')
120
- })
121
- })
122
-
123
- describe('argument passthrough', () => {
124
- it('should forward all arguments to the wrapped transformer', () => {
125
- const transformer = vi.fn(() => 'result')
126
- const wrapped = prefixTransform(transformer)
127
-
128
- const token = createMockToken()
129
- const config = createMockConfig('uy')
130
- const options = createMockOptions()
131
-
132
- void wrapped(token, config, options)
133
-
134
- expect(transformer).toHaveBeenCalledWith(token, config, options)
135
- })
136
- })
137
- })
@@ -1,16 +0,0 @@
1
- import type { NameTransform } from 'style-dictionary/types'
2
-
3
- type Transformer = NameTransform['transform']
4
-
5
- export const prefixTransform: (transformer: Transformer) => Transformer =
6
- transformer =>
7
- (...args) => {
8
- const [, config] = args
9
- const prefix = config.prefix ? `${config.prefix}-` : ''
10
- const value = transformer(...args)
11
-
12
- if (value instanceof Promise) {
13
- return value.then(val => `${prefix}${val}`)
14
- }
15
- return `${prefix}${value}`
16
- }