@payfit/unity-themes 0.0.0-alpha.9 → 1.0.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 (78) hide show
  1. package/README.md +70 -54
  2. package/dist/css/unity.css +749 -0
  3. package/dist/esm/index.d.ts +1 -0
  4. package/dist/esm/index.js +4 -0
  5. package/dist/esm/scripts/actions/append-animations.d.ts +3 -0
  6. package/dist/esm/scripts/build.d.ts +1 -0
  7. package/dist/esm/scripts/file-headers/unity.d.ts +2 -0
  8. package/dist/esm/scripts/formats/generators/header-generator.d.ts +2 -0
  9. package/dist/esm/scripts/formats/processors/grid-processor.d.ts +2 -0
  10. package/dist/esm/scripts/formats/processors/typography-processor.d.ts +2 -0
  11. package/dist/esm/scripts/formats/unity-theme.d.ts +3 -0
  12. package/dist/esm/scripts/formats/utils.d.ts +3 -0
  13. package/dist/esm/scripts/transforms/oklch.d.ts +4 -0
  14. package/dist/esm/scripts/transforms/tailwind-animation-token.d.ts +6 -0
  15. package/dist/esm/scripts/transforms/tailwind-color-token.d.ts +6 -0
  16. package/dist/esm/scripts/transforms/tailwind-grid-token.d.ts +6 -0
  17. package/dist/esm/scripts/transforms/tailwind-spacing-token.d.ts +4 -0
  18. package/dist/esm/scripts/transforms/tailwind-text-token.d.ts +4 -0
  19. package/dist/esm/scripts/transforms/tailwind-typography-token.d.ts +6 -0
  20. package/dist/esm/scripts/types.d.ts +21 -0
  21. package/dist/esm/utils/tailwind-merge.d.ts +1 -0
  22. package/dist/esm/utils/tailwind-merge.js +32 -0
  23. package/package.json +51 -38
  24. package/{dist/esm/tailwind-preset.mjs → src/generated/tailwind-preset.js} +1166 -714
  25. package/src/index.ts +1 -0
  26. package/src/scripts/actions/append-animations.ts +73 -0
  27. package/src/scripts/build.ts +150 -0
  28. package/src/scripts/file-headers/unity.ts +31 -0
  29. package/src/scripts/formats/generators/header-generator.ts +31 -0
  30. package/src/scripts/formats/processors/grid-processor.test.ts +378 -0
  31. package/src/scripts/formats/processors/grid-processor.ts +64 -0
  32. package/src/scripts/formats/processors/typography-processor.test.ts +111 -0
  33. package/src/scripts/formats/processors/typography-processor.ts +48 -0
  34. package/src/scripts/formats/unity-theme.test.ts +400 -0
  35. package/src/scripts/formats/unity-theme.ts +91 -0
  36. package/src/scripts/formats/utils.test.ts +264 -0
  37. package/src/scripts/formats/utils.ts +15 -0
  38. package/src/scripts/transforms/oklch.test.ts +166 -0
  39. package/src/scripts/transforms/oklch.ts +19 -0
  40. package/src/scripts/transforms/tailwind-animation-token.test.ts +108 -0
  41. package/src/scripts/transforms/tailwind-animation-token.ts +51 -0
  42. package/src/scripts/transforms/tailwind-color-token.test.ts +286 -0
  43. package/src/scripts/transforms/tailwind-color-token.ts +13 -0
  44. package/src/scripts/transforms/tailwind-grid-token.test.ts +92 -0
  45. package/src/scripts/transforms/tailwind-grid-token.ts +23 -0
  46. package/src/scripts/transforms/tailwind-spacing-token.test.ts +306 -0
  47. package/src/scripts/transforms/tailwind-spacing-token.ts +11 -0
  48. package/src/scripts/transforms/tailwind-text-token.test.ts +310 -0
  49. package/src/scripts/transforms/tailwind-text-token.ts +17 -0
  50. package/src/scripts/transforms/tailwind-typography-token.test.ts +49 -0
  51. package/src/scripts/transforms/tailwind-typography-token.ts +16 -0
  52. package/src/scripts/types.ts +30 -0
  53. package/src/utils/tailwind-merge.test.ts +64 -0
  54. package/src/utils/tailwind-merge.ts +34 -0
  55. package/tokens/animations.json +86 -0
  56. package/tokens/colors.json +1207 -0
  57. package/tokens/layout.json +51 -0
  58. package/tokens/radii.json +63 -0
  59. package/tokens/shadows.json +45 -0
  60. package/tokens/sizes.json +26 -0
  61. package/tokens/spacings.json +80 -0
  62. package/tokens/text.json +70 -0
  63. package/tokens/typography.json +311 -0
  64. package/dist/cjs/tailwind-preset.d.ts +0 -2
  65. package/dist/cjs/tailwind-preset.js +0 -1
  66. package/dist/esm/tailwind-preset.d.mts +0 -2
  67. package/dist/images/PayFit-Logo.svg +0 -4
  68. package/dist/images/breakpoints.png +0 -0
  69. package/dist/images/colors.gif +0 -0
  70. package/dist/images/elevation.gif +0 -0
  71. package/dist/images/layout.png +0 -0
  72. package/dist/images/radii.gif +0 -0
  73. package/dist/images/remote-work.png +0 -0
  74. package/dist/images/sizing.gif +0 -0
  75. package/dist/images/spacing.png +0 -0
  76. package/dist/images/typography.gif +0 -0
  77. package/dist/images/unity-themes-cover.jpg +0 -0
  78. package/dist/images/unity-themes-diagram.png +0 -0
package/README.md CHANGED
@@ -1,101 +1,117 @@
1
1
  # Unity Themes
2
2
 
3
- The Unity themes package is a TailwindCSS preset that converts all the design tokens of the Unity design system and implements them as TailwindCSS utility classes. This is one of the foundational parts of the unity design system and is heavily used by the components package.
3
+ The Unity themes package provides a comprehensive design system using TailwindCSS 4, converting all the design tokens of the Unity design system into TailwindCSS utility classes. This is the foundational part of the unity design system and is heavily used by the components package and other unity packages.
4
4
 
5
- ### Usage
5
+ > **Note**: This is version 1.x of Unity Themes, built for TailwindCSS 4. If you're migrating from v0.x, see [MIGRATIONS.md](./docs/files/MIGRATIONS.md). For legacy documentation, see [README-v0.md](./docs/files/README-v0.md).
6
+
7
+ ## Installation
6
8
 
7
9
  Install and configure this package by following these steps:
8
10
 
9
- 1. Install the package in your project
11
+ 1. **Install the package and dependencies**
10
12
 
11
13
  ```bash
14
+ yarn add tailwindcss @fontsource/{inter,source-serif-4}
12
15
  yarn add @payfit/unity-themes
13
16
  ```
14
17
 
15
- 2. Import the package and add the preset to your Tailwind CSS configuration file (`tailwind.config.js`):
18
+ 2. **Set up TailwindCSS in your project**
16
19
 
17
- ```javascript
18
- const unityPreset = require('@payfit/unity-themes')
20
+ You need to configure TailwindCSS 4 in your project. This can be done using either the Vite plugin or PostCSS plugin:
19
21
 
20
- module.exports = {
21
- presets: [unityPreset],
22
- }
23
- ```
22
+ - [Install TailwindCSS v4 in a Vite Project](https://tailwindcss.com/docs/installation/using-vite)
23
+ - [Install TailwindCSS v4 using PostCSS](https://tailwindcss.com/docs/installation/using-postcss)
24
24
 
25
- 3. Make sure you are including the `@tailwind` directives in your main CSS file:
25
+ 3. **Import Unity Themes in your main CSS file**
26
26
 
27
- ```postcss
27
+ ```css
28
28
  /* /path/to/your/main/styles.css */
29
- @import '@fontsource/inter';
30
- @import '@fontsource/inter/500.css';
31
- @import '@fontsource/inter/600.css';
32
- @import '@fontsource/inter/700.css';
33
- @import '@fontsource/source-serif-4';
34
- @import '@fontsource/source-serif-4/500.css';
35
- @import '@fontsource/source-serif-4/600.css';
36
- @import '@fontsource/source-serif-4/700.css';
37
- @tailwind base;
38
- @tailwind components;
39
- @tailwind utilities;
29
+ @import '@payfit/unity-themes/css/unity.css';
40
30
  ```
41
31
 
42
- 4. Use the utility classes in you elements!
32
+ That's it! The Unity CSS file includes all font imports and TailwindCSS configuration.
33
+
34
+ 4. **Use the utility classes in your elements**
43
35
 
44
36
  ```html
45
- <button class="uy-bg-surface-primary uy-text-surface-inverted">
37
+ <button class="uy:bg-surface-primary uy:text-surface-inverted">
46
38
  hello!
47
39
  </button>
48
40
  ```
49
41
 
50
- ### Architecture
42
+ ## JavaScript Utilities
51
43
 
52
- The preset is generated from a set of design token files that follow the Design Token Format Community Group (DTCG) using [Style dictionary](https://v4.styledictionary.com/).
44
+ If you need to use JavaScript utilities (like `uyMerge` for class merging), import them normally:
53
45
 
54
- ![Diagram explaining the build process of the unity-themes package. It grabs design token files in <root>/tokens, parses them with style-dictionary to create a tailwind preset in typescript format, and then transpiles this preset to commonJS and ESM using Vite](./public/images/unity-themes-diagram.png)
46
+ ```javascript
47
+ import { uyMerge } from '@payfit/unity-themes'
55
48
 
56
- The scripts in the `src` folder create a new style dictionary format that parses the design tokens and generates a TypeScript file that exports the preset.
49
+ const className = uyMerge('uy:bg-red-l1', 'uy:bg-blue-l2') // 'uy:bg-blue-500'
50
+ ```
57
51
 
58
- ### Build Process
52
+ ## Usage
59
53
 
60
- Build the final preset files using the `build` target:
54
+ Use Unity utility classes with the `uy:` prefix:
61
55
 
62
- ```bash
63
- yarn nx run unity-themes:build
56
+ ```html
57
+ <button
58
+ class="uy:bg-surface-primary uy:text-surface-inverted uy:hover:bg-surface-secondary"
59
+ >
60
+ Hello Unity!
61
+ </button>
64
62
  ```
65
63
 
66
- The build process is divided in two stages:
64
+ ### Class Syntax
67
65
 
68
- 1. **Pre-build:** The scripts in the `src` folder parse the design token files and generate the preset as a TypeScript file in `src/generated` folder (_DO NOT COMMIT THIS FILE!_).
66
+ Unity classes use the `uy:` prefix and the prefix goes before any modifiers:
69
67
 
70
- 2. **Build:** The preset file is compiled into JavaScript and bundled into a single file using Vite.
71
-
72
- The generated artifacts include the compiled JavaScript file and any other necessary files for the package to function properly.
68
+ ```html
69
+ <div class="uy:bg-red-l1 uy:hover:bg-red-l2 uy:md:text-lg"></div>
70
+ ```
73
71
 
74
- ### Testing
72
+ ### CSS properties
75
73
 
76
- To run the unit tests for this package, use the following command:
74
+ Access design tokens directly via CSS custom properties:
77
75
 
78
- ```bash
79
- yarn nx run unity-themes:test
76
+ ```jsx
77
+ const MyComponent = ({ isHighlighted }) => {
78
+ const bgColor = isHighlighted ? 'var(--color-grayscale-l9)' : 'transparent'
79
+ return (
80
+ <div className="uy:transition-colors" style={{ backgroundColor: bgColor }}>
81
+ Custom styling with design tokens
82
+ </div>
83
+ )
84
+ }
80
85
  ```
81
86
 
82
- ### Design tokens
87
+ ## Documentation
83
88
 
84
- The design token files are located under the `tokens/` directory, at the project's root. These files were generated from [Unity's design system library in Figma](https://www.figma.com/design/poaMyU7abAgL9VRhx4ygyy/Unity-DS-%3E-Components-Library?node-id=0-1&t=rSxQTgD4jTGskNmh-1).
89
+ - **[Architecture](./docs/files/ARCHITECTURE.md)**: Technical details, build process, and internal structure
90
+ - **[Migrations](./docs/files/MIGRATIONS.md)**: Complete guide for migrating from v0.x to v1.x
91
+ - **[Legacy v0.x](./docs/files/README-v0.md)**: Documentation for the previous version
85
92
 
86
- You can update the tokens from Figma to the themes package using a Figma plugin like the [Design tokens Plugin](https://www.figma.com/community/plugin/888356646278934516/design-tokens). We recommend that you export each token category (colors, spacings, font sizes, etc.) as separated files, like in the example below:
93
+ ## Design Tokens
94
+
95
+ Design tokens are sourced from [Unity's Figma design system](https://www.figma.com/design/poaMyU7abAgL9VRhx4ygyy/Unity-DS-%3E-Components-Library?node-id=0-1&t=rSxQTgD4jTGskNmh-1) and organized in the `tokens/` directory:
87
96
 
88
97
  ```shell
89
- <root>
90
- └── tokens
91
- ├── colors.json
92
- ├── spcings.json
93
- ├── ...
94
- └── text.json
98
+ tokens/
99
+ ├── colors.json # Color palette and semantic colors
100
+ ├── typography.json # Font families, sizes, and text styles
101
+ ├── spacings.json # Spacing scale and layout values
102
+ ├── shadows.json # Box shadow definitions
103
+ ├── radii.json # Border radius values
104
+ ├── layout.json # Grid and container sizes
105
+ ├── sizes.json # Component and element sizes
106
+ └── text.json # Text-specific tokens
95
107
  ```
96
108
 
97
- ### Notes
109
+ ## Development
98
110
 
99
- The scripts in the `src/` use the `.mts` format because it allows for better integration with the style dictionary v4.x (which is [only exported as an ES module](https://v4.styledictionary.com/version-4/migration/#es-modules-instead-of-commonjs)) format and provides additional features like stronger typing on the generating scripts.
111
+ ```bash
112
+ # Build the package
113
+ yarn nx run unity-themes:build
100
114
 
101
- In the case of this package, this is not an issue because, even though the scripts are esm modules, the final Artifacts generated in the build process are not (in fact, the package exports both CJS + ESM modules). Additionally, we don't directly import the build scripts directly on other files, and they are not meant to be used outside the package, so the module system compatibility is not a concern.
115
+ # Run tests
116
+ yarn nx run unity-themes:test
117
+ ```