@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.
Files changed (52) hide show
  1. package/dist/esm/scripts/style-dictionary-config.d.ts +14 -0
  2. package/package.json +20 -11
  3. package/skills/unity-themes/SKILL.md +41 -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,420 +0,0 @@
1
- import fs from 'fs'
2
- import path from 'path'
3
-
4
- import StyleDictionary from 'style-dictionary'
5
- import {
6
- logBrokenReferenceLevels,
7
- logVerbosityLevels,
8
- logWarningLevels,
9
- } from 'style-dictionary/enums'
10
-
11
- import { appendAnimations } from './actions/append-animations.js'
12
- import { composeMultiThemeCss } from './actions/compose-multi-theme.js'
13
- import {
14
- unityFileHeader,
15
- name as unityFileHeaderName,
16
- } from './file-headers/unity.js'
17
- import {
18
- unityThemeFormat,
19
- name as unityThemeFormatName,
20
- } from './formats/unity-theme.js'
21
- import * as oklchTransformer from './transforms/oklch.js'
22
- import * as tailwindAnimationTokenTransformer from './transforms/tailwind-animation-token.js'
23
- import * as tailwindColorTokenTransformer from './transforms/tailwind-color-token.js'
24
- import * as tailwindGridTokenTransformer from './transforms/tailwind-grid-token.js'
25
- import * as tailwindSpacingTokenTransformer from './transforms/tailwind-spacing-token.js'
26
- import * as tailwindTextTokenTransformer from './transforms/tailwind-text-token.js'
27
- import * as tailwindTypographyTokenTransformer from './transforms/tailwind-typography-token.js'
28
- import { writeColorAgentReferences } from './agent-references/color-reference.js'
29
-
30
- // ---------------------------------------------------------------------------
31
- // Register extensions (shared by all SD instances)
32
- // ---------------------------------------------------------------------------
33
-
34
- StyleDictionary.registerFormat({
35
- name: unityThemeFormatName,
36
- format: unityThemeFormat,
37
- })
38
-
39
- StyleDictionary.registerTransform({
40
- name: 'color/oklch',
41
- type: 'value',
42
- transitive: true,
43
- filter: oklchTransformer.filter,
44
- transform: oklchTransformer.transform,
45
- })
46
-
47
- StyleDictionary.registerTransform({
48
- name: 'name/tailwind/v4/typography',
49
- type: 'name',
50
- transitive: true,
51
- filter: tailwindTypographyTokenTransformer.filter,
52
- transform: tailwindTypographyTokenTransformer.transform,
53
- })
54
-
55
- StyleDictionary.registerTransform({
56
- name: 'name/tailwind/v4/grid',
57
- type: 'name',
58
- transitive: true,
59
- filter: tailwindGridTokenTransformer.filter,
60
- transform: tailwindGridTokenTransformer.transform,
61
- })
62
-
63
- StyleDictionary.registerTransform({
64
- name: 'name/tailwind/v4/text',
65
- type: 'name',
66
- transitive: true,
67
- filter: tailwindTextTokenTransformer.filter,
68
- transform: tailwindTextTokenTransformer.transform,
69
- })
70
-
71
- StyleDictionary.registerTransform({
72
- name: 'name/tailwind/v4/color',
73
- type: 'name',
74
- transitive: true,
75
- filter: tailwindColorTokenTransformer.filter,
76
- transform: tailwindColorTokenTransformer.transform,
77
- })
78
-
79
- StyleDictionary.registerTransform({
80
- name: 'name/tailwind/v4/spacing',
81
- type: 'name',
82
- transitive: true,
83
- filter: tailwindSpacingTokenTransformer.filter,
84
- transform: tailwindSpacingTokenTransformer.transform,
85
- })
86
-
87
- StyleDictionary.registerTransform({
88
- name: 'tailwind/v4/animations/shorthand',
89
- type: 'value',
90
- transitive: true,
91
- filter: tailwindAnimationTokenTransformer.filter,
92
- transform: tailwindAnimationTokenTransformer.transform,
93
- })
94
-
95
- StyleDictionary.registerFileHeader({
96
- name: unityFileHeaderName,
97
- fileHeader: unityFileHeader,
98
- })
99
-
100
- // ---------------------------------------------------------------------------
101
- // Shared config
102
- // ---------------------------------------------------------------------------
103
-
104
- const sharedTransforms = [
105
- 'attribute/cti',
106
- 'name/kebab',
107
- 'name/tailwind/v4/text',
108
- 'name/tailwind/v4/typography',
109
- 'name/tailwind/v4/color',
110
- 'name/tailwind/v4/spacing',
111
- 'name/tailwind/v4/grid',
112
- 'color/oklch',
113
- 'fontFamily/css',
114
- 'typography/css/shorthand',
115
- 'shadow/css/shorthand',
116
- 'cubicBezier/css',
117
- 'tailwind/v4/animations/shorthand',
118
- ]
119
-
120
- const sharedLogConfig = {
121
- warnings: logWarningLevels.warn,
122
- verbosity: logVerbosityLevels.verbose,
123
- errors: {
124
- brokenReferences: logBrokenReferenceLevels.throw,
125
- },
126
- } as const
127
-
128
- const BUILD_PATH = './dist/css/'
129
- const OUTPUT_FILE = 'unity.css'
130
- const ANIMATIONS_PATH = './assets/animations/'
131
- const DIST_FONTS_PATH = './dist/css/fonts/'
132
- const DIST_ASSETS_FONTS_PATH = './dist/css/assets/fonts/'
133
- const GENERATED_FONTS_CSS_PATH = './dist/css/generated/proprietary-fonts.css'
134
- const AGENT_REFERENCES_PATH = './src/agent-references'
135
- const PREFIX = 'uy'
136
-
137
- // ---------------------------------------------------------------------------
138
- // Logging helpers
139
- // ---------------------------------------------------------------------------
140
-
141
- const color = {
142
- cyan: (s: string) => `\x1b[36m${s}\x1b[0m`,
143
- green: (s: string) => `\x1b[32m${s}\x1b[0m`,
144
- yellow: (s: string) => `\x1b[33m${s}\x1b[0m`,
145
- red: (s: string) => `\x1b[31m${s}\x1b[0m`,
146
- dim: (s: string) => `\x1b[2m${s}\x1b[0m`,
147
- bold: (s: string) => `\x1b[1m${s}\x1b[0m`,
148
- } as const
149
-
150
- function logStep(step: number, total: number, message: string) {
151
- console.log(`${color.cyan(`[${step}/${total}]`)} ${color.bold(message)}`)
152
- }
153
-
154
- function logDetail(message: string) {
155
- console.log(` ${color.dim('→')} ${message}`)
156
- }
157
-
158
- // ---------------------------------------------------------------------------
159
- // Build
160
- // ---------------------------------------------------------------------------
161
-
162
- const TOTAL_STEPS = 7
163
-
164
- async function build() {
165
- const startTime = performance.now()
166
- console.log(color.bold('\n🏗 Unity Themes — Build\n'))
167
-
168
- // 1. Initialize SD instances
169
- logStep(1, TOTAL_STEPS, 'Initializing Style Dictionary instances')
170
- logDetail(
171
- `Legacy — tokens/common + tokens/legacy → ${color.yellow(':root')}`,
172
- )
173
-
174
- const legacySD = new StyleDictionary({
175
- source: ['./tokens/common/**/*.json', './tokens/legacy/**/*.json'],
176
- platforms: {
177
- css: {
178
- transforms: sharedTransforms,
179
- prefix: PREFIX,
180
- buildPath: BUILD_PATH,
181
- files: [
182
- {
183
- destination: '_legacy.css',
184
- format: 'css/variables',
185
- options: {
186
- selector: ':root, [data-uy-theme="legacy"]',
187
- outputReferences: true,
188
- showFileHeader: false,
189
- },
190
- },
191
- ],
192
- },
193
- },
194
- log: sharedLogConfig,
195
- })
196
-
197
- // 2. Rebrand SD — css/variables with [data-uy-theme="rebrand"] selector
198
- logDetail(
199
- `Rebrand — tokens/common + tokens/rebrand → ${color.yellow(
200
- '[data-uy-theme="rebrand"]',
201
- )}`,
202
- )
203
- const rebrandSD = new StyleDictionary({
204
- source: ['./tokens/common/**/*.json', './tokens/rebrand/**/*.json'],
205
- platforms: {
206
- css: {
207
- transforms: sharedTransforms,
208
- prefix: PREFIX,
209
- buildPath: BUILD_PATH,
210
- files: [
211
- {
212
- destination: '_rebrand.css',
213
- format: 'css/variables',
214
- options: {
215
- selector: '[data-uy-theme="rebrand"]',
216
- outputReferences: true,
217
- showFileHeader: false,
218
- },
219
- },
220
- ],
221
- },
222
- },
223
- log: sharedLogConfig,
224
- })
225
-
226
- // 3. Theme SD — css/unity-theme format for @theme block + utilities
227
- logDetail(`TW theme — → ${color.yellow('@theme')}`)
228
- const themeSD = new StyleDictionary({
229
- source: [
230
- './tokens/common/**/*.json',
231
- './tokens/legacy/**/*.json',
232
- './tokens/rebrand/**/*.json',
233
- ],
234
- platforms: {
235
- css: {
236
- transforms: sharedTransforms,
237
- prefix: PREFIX,
238
- buildPath: BUILD_PATH,
239
- files: [
240
- {
241
- destination: '_theme.css',
242
- format: unityThemeFormatName,
243
- options: {
244
- prefix: PREFIX,
245
- selector: '@theme',
246
- outputReferences: true,
247
- showFileHeader: false,
248
- },
249
- },
250
- ],
251
- },
252
- },
253
- log: sharedLogConfig,
254
- })
255
-
256
- // Fonts SD — built-in css/fonts format + copy_assets action
257
- logDetail(
258
- `Fonts — tokens/common/font-assets.json → ${color.yellow(
259
- 'generated/proprietary-fonts.css',
260
- )}`,
261
- )
262
- const fontsSD = new StyleDictionary({
263
- source: ['./tokens/common/font-assets.json'],
264
- platforms: {
265
- css: {
266
- buildPath: BUILD_PATH,
267
- actions: ['copy_assets'],
268
- files: [
269
- {
270
- destination: 'generated/proprietary-fonts.css',
271
- format: 'css/fonts.css',
272
- options: {
273
- showFileHeader: false,
274
- },
275
- },
276
- ],
277
- },
278
- },
279
- log: sharedLogConfig,
280
- })
281
-
282
- // 2. Build fonts css + copy assets, then format theme outputs in-memory
283
- logStep(2, TOTAL_STEPS, 'Building font assets and formatting tokens')
284
- const formatStart = performance.now()
285
-
286
- const [legacyOutputs, rebrandOutputs, themeOutputs] = await Promise.all([
287
- legacySD.formatPlatform('css'),
288
- rebrandSD.formatPlatform('css'),
289
- themeSD.formatPlatform('css'),
290
- fontsSD.buildPlatform('css'),
291
- ])
292
-
293
- // normalize copied assets path from dist/css/assets/fonts to dist/css/fonts
294
- if (!fs.existsSync(DIST_ASSETS_FONTS_PATH)) {
295
- throw new Error(`Missing copied font assets at ${DIST_ASSETS_FONTS_PATH}`)
296
- }
297
- fs.rmSync(DIST_FONTS_PATH, { recursive: true, force: true })
298
- fs.cpSync(DIST_ASSETS_FONTS_PATH, DIST_FONTS_PATH, {
299
- recursive: true,
300
- filter: source => !source.includes(`${path.sep}LICENSES${path.sep}`),
301
- })
302
- fs.rmSync('./dist/css/assets/', { recursive: true, force: true })
303
-
304
- if (!fs.existsSync(GENERATED_FONTS_CSS_PATH)) {
305
- throw new Error(`Missing generated font CSS at ${GENERATED_FONTS_CSS_PATH}`)
306
- }
307
- const generatedFontsCss = fs.readFileSync(GENERATED_FONTS_CSS_PATH, 'utf8')
308
- fs.writeFileSync(
309
- GENERATED_FONTS_CSS_PATH,
310
- generatedFontsCss.replaceAll('},`@font-face`', '}\n\n@font-face'),
311
- 'utf8',
312
- )
313
-
314
- const legacyCss =
315
- typeof legacyOutputs[0]?.output === 'string' ? legacyOutputs[0].output : ''
316
- const rebrandCss =
317
- typeof rebrandOutputs[0]?.output === 'string'
318
- ? rebrandOutputs[0].output
319
- : ''
320
- const themeCss =
321
- typeof themeOutputs[0]?.output === 'string' ? themeOutputs[0].output : ''
322
-
323
- const formatDuration = (performance.now() - formatStart).toFixed(0)
324
- logDetail(
325
- `Legacy CSS: ${color.green(`${legacyCss.split('\n').length} lines`)}`,
326
- )
327
- logDetail(
328
- `Rebrand CSS: ${color.green(`${rebrandCss.split('\n').length} lines`)}`,
329
- )
330
- logDetail(
331
- `Theme CSS: ${color.green(`${themeCss.split('\n').length} lines`)}`,
332
- )
333
- logDetail(color.dim(`Formatted in ${formatDuration}ms`))
334
-
335
- // 3. Generate header + custom variants
336
- logStep(3, TOTAL_STEPS, 'Generating file header and font imports')
337
- const headerLines = unityFileHeader()
338
- const header = [
339
- '/**',
340
- ...headerLines.map(l => ` * ${l}`),
341
- ' */\n',
342
- '@import "@fontsource/inter";',
343
- '@import "@fontsource/inter/500.css";',
344
- '@import "@fontsource/inter/600.css";',
345
- '@import "@fontsource/inter/700.css";',
346
- '@import "@fontsource/source-serif-4";',
347
- '@import "@fontsource/source-serif-4/500.css";',
348
- '@import "@fontsource/source-serif-4/600.css";',
349
- '@import "@fontsource/source-serif-4/700.css";',
350
- '@import "@fontsource/roboto-mono";',
351
- '@import "./generated/proprietary-fonts.css";',
352
- `@import "tailwindcss" prefix(${PREFIX});`,
353
- ].join('\n')
354
-
355
- logStep(4, TOTAL_STEPS, 'Registering custom variants')
356
- const customVariants = [
357
- '@custom-variant theme-legacy (&:where([data-uy-theme="legacy"], [data-uy-theme="legacy"] *));',
358
- '@custom-variant theme-rebrand (&:where([data-uy-theme="rebrand"], [data-uy-theme="rebrand"] *));',
359
- ].join('\n')
360
- logDetail('theme-legacy → [data-uy-theme="legacy"]')
361
- logDetail('theme-rebrand → [data-uy-theme="rebrand"]')
362
-
363
- // 5. Compose and write
364
- logStep(5, TOTAL_STEPS, 'Composing multi-theme CSS')
365
- const outputPath = path.join(BUILD_PATH, OUTPUT_FILE)
366
- logDetail(`Output: ${color.yellow(outputPath)}`)
367
-
368
- await composeMultiThemeCss({
369
- legacyCss,
370
- rebrandCss,
371
- themeCss,
372
- header,
373
- customVariants,
374
- outputPath,
375
- })
376
-
377
- // 6. Generate static references + append animation keyframes
378
- logStep(6, TOTAL_STEPS, 'Generating agent references and animations')
379
- logDetail(`Agent references: ${color.yellow(AGENT_REFERENCES_PATH)}`)
380
- logDetail(`Animations source: ${color.yellow(ANIMATIONS_PATH)}`)
381
-
382
- const legacyDict = await legacySD.getPlatformTokens('css')
383
- writeColorAgentReferences({
384
- legacyTokens: legacyDict.allTokens,
385
- outputDir: AGENT_REFERENCES_PATH,
386
- })
387
- appendAnimations(
388
- legacyDict,
389
- {
390
- animationsPath: ANIMATIONS_PATH,
391
- buildPath: BUILD_PATH,
392
- files: [{ destination: OUTPUT_FILE }],
393
- },
394
- {}, // kept for SD compatibility
395
- )
396
-
397
- // Done
398
- const totalDuration = (performance.now() - startTime).toFixed(0)
399
- logStep(7, TOTAL_STEPS, 'Build verification')
400
- const outputStat = fs.statSync(outputPath)
401
- logDetail(
402
- `File size: ${color.green(`${(outputStat.size / 1024).toFixed(1)} KB`)}`,
403
- )
404
- logDetail(`Total time: ${color.green(`${totalDuration}ms`)}`)
405
-
406
- console.log(`\n${color.green('✅ Build completed successfully')}\n`)
407
- }
408
-
409
- build().catch((error: unknown) => {
410
- console.error(`\n${color.red('❌ Build failed')}\n`)
411
- if (error instanceof Error) {
412
- console.error(color.red(`Error: ${error.message}`))
413
- if (error.stack) {
414
- console.error(color.dim(error.stack))
415
- }
416
- } else {
417
- console.error(error)
418
- }
419
- process.exit(1)
420
- })
@@ -1,31 +0,0 @@
1
- export const name = 'unity/theme'
2
-
3
- export function unityFileHeader() {
4
- return [
5
- ` =============================================================================
6
- * Unity Themes: Default Theme
7
- * =============================================================================
8
- *
9
- * @file unity.css
10
- * @description Auto-generated CSS styles for Unity
11
- * @copyright Copyright (c) 2025 PayFit. All rights reserved.
12
- *
13
- * =============================================================================
14
- * LINKS
15
- * =============================================================================
16
- *
17
- * GitHub Repository: https://github.com/PayFit/hr-apps/blob/master/libs/shared/unity/themes
18
- * Documentation: https://unity-theme.payfit.io/?path=/docs/1-introduction-1-welcome--docs
19
- * Issues/Support: https://payfit.atlassian.net/jira/software/c/projects/CEEFRE/boards/623
20
- *
21
- * =============================================================================
22
- * NOTICE
23
- * =============================================================================
24
- *
25
- * This file is auto-generated. Manual changes to this file will be overwritten
26
- * when the build process runs again. To customize styles, please refer to the
27
- * source files or documentation.
28
- *
29
- * Generated by: ${process.env.npm_package_name} ${process.env.npm_package_version}`,
30
- ]
31
- }