@payfit/unity-themes 1.0.0 → 1.1.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.
- package/dist/css/unity.css +2 -2
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/index.js +10 -2
- package/dist/esm/utils/cn.d.ts +93 -0
- package/dist/esm/utils/cn.js +11 -0
- package/dist/esm/utils/merge-config.d.ts +217 -0
- package/dist/esm/utils/merge-config.js +171 -0
- package/dist/esm/utils/tailwind-merge.d.ts +66 -0
- package/dist/esm/utils/tailwind-merge.js +5 -29
- package/dist/esm/utils/tailwind-variants.d.ts +44 -0
- package/dist/esm/utils/tailwind-variants.js +9 -0
- package/package.json +9 -8
- package/src/index.ts +6 -0
- package/src/scripts/file-headers/unity.ts +1 -1
- package/src/utils/cn.ts +109 -0
- package/src/utils/merge-config.ts +193 -0
- package/src/utils/tailwind-merge.test.ts +440 -43
- package/src/utils/tailwind-merge.ts +69 -26
- package/src/utils/tailwind-variants.ts +53 -0
- package/tokens/colors.json +1 -1
- package/src/generated/tailwind-preset.js +0 -2160
package/dist/css/unity.css
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* LINKS
|
|
12
12
|
* =============================================================================
|
|
13
13
|
*
|
|
14
|
-
* GitHub Repository: https://github.com/PayFit/hr-apps/
|
|
14
|
+
* GitHub Repository: https://github.com/PayFit/hr-apps/blob/master/libs/shared/unity/themes
|
|
15
15
|
* Documentation: https://unity-theme.payfit.io/?path=/docs/1-introduction-1-welcome--docs
|
|
16
16
|
* Issues/Support: https://payfit.atlassian.net/jira/software/c/projects/CEEFRE/boards/623
|
|
17
17
|
*
|
|
@@ -424,7 +424,7 @@
|
|
|
424
424
|
--color-border-primary-focus: var(--uy-color-blue-l5);
|
|
425
425
|
--color-border-primary-active: var(--uy-color-blue-l8);
|
|
426
426
|
--color-border-primary-disabled: var(--uy-color-grayscale-l4);
|
|
427
|
-
--color-border-neutral-high: var(--uy-color-grayscale-
|
|
427
|
+
--color-border-neutral-high: var(--uy-color-grayscale-l7);
|
|
428
428
|
--color-border-neutral-high-enabled: var(--uy-color-grayscale-l8);
|
|
429
429
|
--color-border-neutral-high-hover: var(--uy-color-grayscale-l9);
|
|
430
430
|
--color-border-neutral-high-pressed: var(--uy-color-grayscale-l10);
|
package/dist/esm/index.d.ts
CHANGED
package/dist/esm/index.js
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { classNames as o, clsx as f, cn as m } from "./utils/cn.js";
|
|
2
|
+
import { uyMerge as x } from "./utils/tailwind-merge.js";
|
|
3
|
+
import { uyTv as s } from "./utils/tailwind-variants.js";
|
|
4
|
+
import { twMergeConfig as g } from "./utils/merge-config.js";
|
|
2
5
|
export {
|
|
3
|
-
o as
|
|
6
|
+
o as classNames,
|
|
7
|
+
f as clsx,
|
|
8
|
+
m as cn,
|
|
9
|
+
g as twMergeConfig,
|
|
10
|
+
x as uyMerge,
|
|
11
|
+
s as uyTv
|
|
4
12
|
};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unity-configured class name utility function for merging CSS classes.
|
|
3
|
+
*
|
|
4
|
+
* This is a pre-configured version of tailwind-variants' `cn` function that includes
|
|
5
|
+
* Unity's custom tailwind-merge configuration. It automatically handles Unity's custom
|
|
6
|
+
* class names and resolves conflicts according to Unity design system rules.
|
|
7
|
+
* @param classes - CSS class names to merge
|
|
8
|
+
* @returns Merged and deduplicated class string
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* import { cn } from '@payfit/unity-themes'
|
|
12
|
+
*
|
|
13
|
+
* // Basic usage
|
|
14
|
+
* const className = cn('uy:p-200', 'uy:bg-surface-primary-default')
|
|
15
|
+
* // → 'uy:p-200 uy:bg-surface-primary-default'
|
|
16
|
+
*
|
|
17
|
+
* // Conflict resolution - last class wins
|
|
18
|
+
* const className = cn('uy:bg-surface-primary-default', 'uy:bg-surface-danger-default')
|
|
19
|
+
* // → 'uy:bg-surface-danger-default'
|
|
20
|
+
*
|
|
21
|
+
* // Conditional classes
|
|
22
|
+
* const className = cn(
|
|
23
|
+
* 'uy:px-200 uy:py-100',
|
|
24
|
+
* isActive && 'uy:bg-surface-primary-default',
|
|
25
|
+
* isDisabled && 'uy:bg-surface-neutral-disabled'
|
|
26
|
+
* )
|
|
27
|
+
*
|
|
28
|
+
* // With component props
|
|
29
|
+
* function Button({ variant, size, className: extraClasses, ...props }) {
|
|
30
|
+
* return (
|
|
31
|
+
* <button
|
|
32
|
+
* className={cn(
|
|
33
|
+
* 'uy:px-200 uy:py-100 uy:rounded-100', // base styles
|
|
34
|
+
* variant === 'primary' && 'uy:bg-surface-primary-default',
|
|
35
|
+
* variant === 'secondary' && 'uy:bg-surface-neutral-default',
|
|
36
|
+
* size === 'large' && 'uy:px-300 uy:py-150',
|
|
37
|
+
* extraClasses // allow override
|
|
38
|
+
* )}
|
|
39
|
+
* {...props}
|
|
40
|
+
* />
|
|
41
|
+
* )
|
|
42
|
+
* }
|
|
43
|
+
* ```
|
|
44
|
+
* @description
|
|
45
|
+
* - Automatically merges conflicting Unity classes using Unity's design system rules
|
|
46
|
+
* - Supports all Unity design tokens: semantic colors, primitive colors, spacing, typography, etc.
|
|
47
|
+
* - Handles conditional classes (falsy values are ignored)
|
|
48
|
+
* - Compatible with standard Tailwind classes alongside Unity classes
|
|
49
|
+
* - Removes duplicate classes and resolves conflicts intelligently
|
|
50
|
+
* @see {@link uyMerge} for the underlying merge function
|
|
51
|
+
* @see {@link twMergeConfig} for the Unity merge configuration details
|
|
52
|
+
*/
|
|
53
|
+
export declare const cn: (...classes: string[]) => import('tailwind-variants').CnReturn;
|
|
54
|
+
/**
|
|
55
|
+
* Alias for {@link cn} - Unity-configured class name utility function.
|
|
56
|
+
*
|
|
57
|
+
* This function is identical to `cn` but provides a more descriptive name
|
|
58
|
+
* for developers who prefer explicit naming conventions.
|
|
59
|
+
* @param classes - CSS class names to merge
|
|
60
|
+
* @returns Merged and deduplicated class string
|
|
61
|
+
* @example
|
|
62
|
+
* ```tsx
|
|
63
|
+
* import { classNames } from '@payfit/unity-themes'
|
|
64
|
+
*
|
|
65
|
+
* const buttonClasses = classNames(
|
|
66
|
+
* 'uy:px-200 uy:py-100',
|
|
67
|
+
* 'uy:bg-surface-primary-default',
|
|
68
|
+
* 'uy:text-content-inverted-default'
|
|
69
|
+
* )
|
|
70
|
+
* ```
|
|
71
|
+
* @see {@link cn} for detailed documentation and examples
|
|
72
|
+
*/
|
|
73
|
+
export declare const classNames: (...classes: string[]) => import('tailwind-variants').CnReturn;
|
|
74
|
+
/**
|
|
75
|
+
* Alias for {@link cn} - Unity-configured class name utility function.
|
|
76
|
+
*
|
|
77
|
+
* This function is identical to `cn` but follows the naming convention
|
|
78
|
+
* popularized by the `clsx` library for developers familiar with that API.
|
|
79
|
+
* @param classes - CSS class names to merge
|
|
80
|
+
* @returns Merged and deduplicated class string
|
|
81
|
+
* @example
|
|
82
|
+
* ```tsx
|
|
83
|
+
* import { clsx } from '@payfit/unity-themes'
|
|
84
|
+
*
|
|
85
|
+
* const cardClasses = clsx(
|
|
86
|
+
* 'uy:p-300 uy:rounded-200',
|
|
87
|
+
* 'uy:bg-surface-neutral-default',
|
|
88
|
+
* isHighlighted && 'uy:border-border-primary-default'
|
|
89
|
+
* )
|
|
90
|
+
* ```
|
|
91
|
+
* @see {@link cn} for detailed documentation and examples
|
|
92
|
+
*/
|
|
93
|
+
export declare const clsx: (...classes: string[]) => import('tailwind-variants').CnReturn;
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
export declare const twMergeConfig: {
|
|
2
|
+
prefix: string;
|
|
3
|
+
extend: {
|
|
4
|
+
classGroups: {
|
|
5
|
+
'bg-color': {
|
|
6
|
+
bg: ((value: string) => boolean)[];
|
|
7
|
+
}[];
|
|
8
|
+
'text-color': {
|
|
9
|
+
text: ((value: string) => boolean)[];
|
|
10
|
+
}[];
|
|
11
|
+
'border-color': {
|
|
12
|
+
border: ((value: string) => boolean)[];
|
|
13
|
+
}[];
|
|
14
|
+
'outline-color': {
|
|
15
|
+
outline: ((value: string) => boolean)[];
|
|
16
|
+
}[];
|
|
17
|
+
'ring-color': {
|
|
18
|
+
ring: ((value: string) => boolean)[];
|
|
19
|
+
}[];
|
|
20
|
+
'ring-offset-color': {
|
|
21
|
+
'ring-offset': ((value: string) => boolean)[];
|
|
22
|
+
}[];
|
|
23
|
+
'divide-color': {
|
|
24
|
+
divide: ((value: string) => boolean)[];
|
|
25
|
+
}[];
|
|
26
|
+
'text-decoration-color': {
|
|
27
|
+
decoration: ((value: string) => boolean)[];
|
|
28
|
+
}[];
|
|
29
|
+
'gradient-color-from': {
|
|
30
|
+
from: ((value: string) => boolean)[];
|
|
31
|
+
}[];
|
|
32
|
+
'gradient-color-via': {
|
|
33
|
+
via: ((value: string) => boolean)[];
|
|
34
|
+
}[];
|
|
35
|
+
'gradient-color-to': {
|
|
36
|
+
to: ((value: string) => boolean)[];
|
|
37
|
+
}[];
|
|
38
|
+
p: {
|
|
39
|
+
p: string[];
|
|
40
|
+
}[];
|
|
41
|
+
px: {
|
|
42
|
+
px: string[];
|
|
43
|
+
}[];
|
|
44
|
+
py: {
|
|
45
|
+
py: string[];
|
|
46
|
+
}[];
|
|
47
|
+
ps: {
|
|
48
|
+
ps: string[];
|
|
49
|
+
}[];
|
|
50
|
+
pe: {
|
|
51
|
+
pe: string[];
|
|
52
|
+
}[];
|
|
53
|
+
pt: {
|
|
54
|
+
pt: string[];
|
|
55
|
+
}[];
|
|
56
|
+
pr: {
|
|
57
|
+
pr: string[];
|
|
58
|
+
}[];
|
|
59
|
+
pb: {
|
|
60
|
+
pb: string[];
|
|
61
|
+
}[];
|
|
62
|
+
pl: {
|
|
63
|
+
pl: string[];
|
|
64
|
+
}[];
|
|
65
|
+
m: {
|
|
66
|
+
m: string[];
|
|
67
|
+
}[];
|
|
68
|
+
mx: {
|
|
69
|
+
mx: string[];
|
|
70
|
+
}[];
|
|
71
|
+
my: {
|
|
72
|
+
my: string[];
|
|
73
|
+
}[];
|
|
74
|
+
ms: {
|
|
75
|
+
ms: string[];
|
|
76
|
+
}[];
|
|
77
|
+
me: {
|
|
78
|
+
me: string[];
|
|
79
|
+
}[];
|
|
80
|
+
mt: {
|
|
81
|
+
mt: string[];
|
|
82
|
+
}[];
|
|
83
|
+
mr: {
|
|
84
|
+
mr: string[];
|
|
85
|
+
}[];
|
|
86
|
+
mb: {
|
|
87
|
+
mb: string[];
|
|
88
|
+
}[];
|
|
89
|
+
ml: {
|
|
90
|
+
ml: string[];
|
|
91
|
+
}[];
|
|
92
|
+
gap: {
|
|
93
|
+
gap: string[];
|
|
94
|
+
}[];
|
|
95
|
+
'gap-x': {
|
|
96
|
+
'gap-x': string[];
|
|
97
|
+
}[];
|
|
98
|
+
'gap-y': {
|
|
99
|
+
'gap-y': string[];
|
|
100
|
+
}[];
|
|
101
|
+
'space-x': {
|
|
102
|
+
'space-x': string[];
|
|
103
|
+
}[];
|
|
104
|
+
'space-y': {
|
|
105
|
+
'space-y': string[];
|
|
106
|
+
}[];
|
|
107
|
+
'scroll-p': {
|
|
108
|
+
'scroll-p': string[];
|
|
109
|
+
}[];
|
|
110
|
+
'scroll-px': {
|
|
111
|
+
'scroll-px': string[];
|
|
112
|
+
}[];
|
|
113
|
+
'scroll-py': {
|
|
114
|
+
'scroll-py': string[];
|
|
115
|
+
}[];
|
|
116
|
+
'scroll-ps': {
|
|
117
|
+
'scroll-ps': string[];
|
|
118
|
+
}[];
|
|
119
|
+
'scroll-pe': {
|
|
120
|
+
'scroll-pe': string[];
|
|
121
|
+
}[];
|
|
122
|
+
'scroll-pt': {
|
|
123
|
+
'scroll-pt': string[];
|
|
124
|
+
}[];
|
|
125
|
+
'scroll-pr': {
|
|
126
|
+
'scroll-pr': string[];
|
|
127
|
+
}[];
|
|
128
|
+
'scroll-pb': {
|
|
129
|
+
'scroll-pb': string[];
|
|
130
|
+
}[];
|
|
131
|
+
'scroll-pl': {
|
|
132
|
+
'scroll-pl': string[];
|
|
133
|
+
}[];
|
|
134
|
+
'scroll-m': {
|
|
135
|
+
'scroll-m': string[];
|
|
136
|
+
}[];
|
|
137
|
+
'scroll-mx': {
|
|
138
|
+
'scroll-mx': string[];
|
|
139
|
+
}[];
|
|
140
|
+
'scroll-my': {
|
|
141
|
+
'scroll-my': string[];
|
|
142
|
+
}[];
|
|
143
|
+
'scroll-ms': {
|
|
144
|
+
'scroll-ms': string[];
|
|
145
|
+
}[];
|
|
146
|
+
'scroll-me': {
|
|
147
|
+
'scroll-me': string[];
|
|
148
|
+
}[];
|
|
149
|
+
'scroll-mt': {
|
|
150
|
+
'scroll-mt': string[];
|
|
151
|
+
}[];
|
|
152
|
+
'scroll-mr': {
|
|
153
|
+
'scroll-mr': string[];
|
|
154
|
+
}[];
|
|
155
|
+
'scroll-mb': {
|
|
156
|
+
'scroll-mb': string[];
|
|
157
|
+
}[];
|
|
158
|
+
'scroll-ml': {
|
|
159
|
+
'scroll-ml': string[];
|
|
160
|
+
}[];
|
|
161
|
+
typography: {
|
|
162
|
+
typography: string[];
|
|
163
|
+
}[];
|
|
164
|
+
'font-size': {
|
|
165
|
+
text: string[];
|
|
166
|
+
}[];
|
|
167
|
+
rounded: {
|
|
168
|
+
rounded: string[];
|
|
169
|
+
}[];
|
|
170
|
+
'rounded-s': {
|
|
171
|
+
'rounded-s': string[];
|
|
172
|
+
}[];
|
|
173
|
+
'rounded-e': {
|
|
174
|
+
'rounded-e': string[];
|
|
175
|
+
}[];
|
|
176
|
+
'rounded-t': {
|
|
177
|
+
'rounded-t': string[];
|
|
178
|
+
}[];
|
|
179
|
+
'rounded-r': {
|
|
180
|
+
'rounded-r': string[];
|
|
181
|
+
}[];
|
|
182
|
+
'rounded-b': {
|
|
183
|
+
'rounded-b': string[];
|
|
184
|
+
}[];
|
|
185
|
+
'rounded-l': {
|
|
186
|
+
'rounded-l': string[];
|
|
187
|
+
}[];
|
|
188
|
+
'rounded-ss': {
|
|
189
|
+
'rounded-ss': string[];
|
|
190
|
+
}[];
|
|
191
|
+
'rounded-se': {
|
|
192
|
+
'rounded-se': string[];
|
|
193
|
+
}[];
|
|
194
|
+
'rounded-ee': {
|
|
195
|
+
'rounded-ee': string[];
|
|
196
|
+
}[];
|
|
197
|
+
'rounded-es': {
|
|
198
|
+
'rounded-es': string[];
|
|
199
|
+
}[];
|
|
200
|
+
'rounded-tl': {
|
|
201
|
+
'rounded-tl': string[];
|
|
202
|
+
}[];
|
|
203
|
+
'rounded-tr': {
|
|
204
|
+
'rounded-tr': string[];
|
|
205
|
+
}[];
|
|
206
|
+
'rounded-br': {
|
|
207
|
+
'rounded-br': string[];
|
|
208
|
+
}[];
|
|
209
|
+
'rounded-bl': {
|
|
210
|
+
'rounded-bl': string[];
|
|
211
|
+
}[];
|
|
212
|
+
shadow: {
|
|
213
|
+
shadow: string[];
|
|
214
|
+
}[];
|
|
215
|
+
};
|
|
216
|
+
};
|
|
217
|
+
};
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { validators as l } from "tailwind-merge";
|
|
2
|
+
const r = [
|
|
3
|
+
"0",
|
|
4
|
+
"25",
|
|
5
|
+
"50",
|
|
6
|
+
"75",
|
|
7
|
+
"100",
|
|
8
|
+
"125",
|
|
9
|
+
"150",
|
|
10
|
+
"200",
|
|
11
|
+
"250",
|
|
12
|
+
"300",
|
|
13
|
+
"400",
|
|
14
|
+
"500",
|
|
15
|
+
"600",
|
|
16
|
+
"800",
|
|
17
|
+
"1000"
|
|
18
|
+
], d = [
|
|
19
|
+
"h1",
|
|
20
|
+
"h2",
|
|
21
|
+
"h3",
|
|
22
|
+
"h4",
|
|
23
|
+
"overline",
|
|
24
|
+
"subtitle",
|
|
25
|
+
"display-title",
|
|
26
|
+
"display-body",
|
|
27
|
+
"body",
|
|
28
|
+
"body-strong",
|
|
29
|
+
"body-small",
|
|
30
|
+
"body-small-strong",
|
|
31
|
+
"body-large",
|
|
32
|
+
"body-large-strong",
|
|
33
|
+
"action",
|
|
34
|
+
"action-small",
|
|
35
|
+
"action-large"
|
|
36
|
+
], t = [
|
|
37
|
+
"50",
|
|
38
|
+
"75",
|
|
39
|
+
"100",
|
|
40
|
+
"200",
|
|
41
|
+
"300",
|
|
42
|
+
"400",
|
|
43
|
+
"500",
|
|
44
|
+
"600",
|
|
45
|
+
"800",
|
|
46
|
+
"1000",
|
|
47
|
+
"1200",
|
|
48
|
+
"1400",
|
|
49
|
+
"1600"
|
|
50
|
+
], o = [
|
|
51
|
+
"0",
|
|
52
|
+
"25",
|
|
53
|
+
"50",
|
|
54
|
+
"75",
|
|
55
|
+
"100",
|
|
56
|
+
"125",
|
|
57
|
+
"150",
|
|
58
|
+
"200",
|
|
59
|
+
"300",
|
|
60
|
+
"400",
|
|
61
|
+
"xs",
|
|
62
|
+
"sm",
|
|
63
|
+
"md",
|
|
64
|
+
"lg",
|
|
65
|
+
"xl",
|
|
66
|
+
"circle",
|
|
67
|
+
"pill"
|
|
68
|
+
], n = ["canvas", "raising", "floating", "flying", "soaring"], s = (e) => !!(/^[a-z]+-l\d+$/.test(e) || /^(?:canvas|surface|content|border|utility)-.+$/.test(e)), c = {
|
|
69
|
+
prefix: "uy",
|
|
70
|
+
extend: {
|
|
71
|
+
classGroups: {
|
|
72
|
+
// Colors - Use pattern matching for maintainability
|
|
73
|
+
// Matches primitive colors like: grayscale-l0, red-l1, blue-l12, etc.
|
|
74
|
+
// Matches semantic colors like: surface-primary-default, content-neutral-low, border-danger-default, etc.
|
|
75
|
+
"bg-color": [{ bg: [l.isArbitraryValue, s] }],
|
|
76
|
+
"text-color": [{ text: [l.isArbitraryValue, s] }],
|
|
77
|
+
"border-color": [{ border: [l.isArbitraryValue, s] }],
|
|
78
|
+
"outline-color": [
|
|
79
|
+
{ outline: [l.isArbitraryValue, s] }
|
|
80
|
+
],
|
|
81
|
+
"ring-color": [{ ring: [l.isArbitraryValue, s] }],
|
|
82
|
+
"ring-offset-color": [
|
|
83
|
+
{ "ring-offset": [l.isArbitraryValue, s] }
|
|
84
|
+
],
|
|
85
|
+
"divide-color": [{ divide: [l.isArbitraryValue, s] }],
|
|
86
|
+
"text-decoration-color": [
|
|
87
|
+
{ decoration: [l.isArbitraryValue, s] }
|
|
88
|
+
],
|
|
89
|
+
"gradient-color-from": [
|
|
90
|
+
{ from: [l.isArbitraryValue, s] }
|
|
91
|
+
],
|
|
92
|
+
"gradient-color-via": [
|
|
93
|
+
{ via: [l.isArbitraryValue, s] }
|
|
94
|
+
],
|
|
95
|
+
"gradient-color-to": [
|
|
96
|
+
{ to: [l.isArbitraryValue, s] }
|
|
97
|
+
],
|
|
98
|
+
// Spacing - Padding
|
|
99
|
+
p: [{ p: r }],
|
|
100
|
+
px: [{ px: r }],
|
|
101
|
+
py: [{ py: r }],
|
|
102
|
+
ps: [{ ps: r }],
|
|
103
|
+
pe: [{ pe: r }],
|
|
104
|
+
pt: [{ pt: r }],
|
|
105
|
+
pr: [{ pr: r }],
|
|
106
|
+
pb: [{ pb: r }],
|
|
107
|
+
pl: [{ pl: r }],
|
|
108
|
+
// Spacing - Margin
|
|
109
|
+
m: [{ m: r }],
|
|
110
|
+
mx: [{ mx: r }],
|
|
111
|
+
my: [{ my: r }],
|
|
112
|
+
ms: [{ ms: r }],
|
|
113
|
+
me: [{ me: r }],
|
|
114
|
+
mt: [{ mt: r }],
|
|
115
|
+
mr: [{ mr: r }],
|
|
116
|
+
mb: [{ mb: r }],
|
|
117
|
+
ml: [{ ml: r }],
|
|
118
|
+
// Spacing - Gap
|
|
119
|
+
gap: [{ gap: r }],
|
|
120
|
+
"gap-x": [{ "gap-x": r }],
|
|
121
|
+
"gap-y": [{ "gap-y": r }],
|
|
122
|
+
// Spacing - Space between
|
|
123
|
+
"space-x": [{ "space-x": r }],
|
|
124
|
+
"space-y": [{ "space-y": r }],
|
|
125
|
+
// Spacing - Scroll padding
|
|
126
|
+
"scroll-p": [{ "scroll-p": r }],
|
|
127
|
+
"scroll-px": [{ "scroll-px": r }],
|
|
128
|
+
"scroll-py": [{ "scroll-py": r }],
|
|
129
|
+
"scroll-ps": [{ "scroll-ps": r }],
|
|
130
|
+
"scroll-pe": [{ "scroll-pe": r }],
|
|
131
|
+
"scroll-pt": [{ "scroll-pt": r }],
|
|
132
|
+
"scroll-pr": [{ "scroll-pr": r }],
|
|
133
|
+
"scroll-pb": [{ "scroll-pb": r }],
|
|
134
|
+
"scroll-pl": [{ "scroll-pl": r }],
|
|
135
|
+
// Spacing - Scroll margin
|
|
136
|
+
"scroll-m": [{ "scroll-m": r }],
|
|
137
|
+
"scroll-mx": [{ "scroll-mx": r }],
|
|
138
|
+
"scroll-my": [{ "scroll-my": r }],
|
|
139
|
+
"scroll-ms": [{ "scroll-ms": r }],
|
|
140
|
+
"scroll-me": [{ "scroll-me": r }],
|
|
141
|
+
"scroll-mt": [{ "scroll-mt": r }],
|
|
142
|
+
"scroll-mr": [{ "scroll-mr": r }],
|
|
143
|
+
"scroll-mb": [{ "scroll-mb": r }],
|
|
144
|
+
"scroll-ml": [{ "scroll-ml": r }],
|
|
145
|
+
// Typography
|
|
146
|
+
typography: [{ typography: d }],
|
|
147
|
+
"font-size": [{ text: t }],
|
|
148
|
+
// Border radius
|
|
149
|
+
rounded: [{ rounded: o }],
|
|
150
|
+
"rounded-s": [{ "rounded-s": o }],
|
|
151
|
+
"rounded-e": [{ "rounded-e": o }],
|
|
152
|
+
"rounded-t": [{ "rounded-t": o }],
|
|
153
|
+
"rounded-r": [{ "rounded-r": o }],
|
|
154
|
+
"rounded-b": [{ "rounded-b": o }],
|
|
155
|
+
"rounded-l": [{ "rounded-l": o }],
|
|
156
|
+
"rounded-ss": [{ "rounded-ss": o }],
|
|
157
|
+
"rounded-se": [{ "rounded-se": o }],
|
|
158
|
+
"rounded-ee": [{ "rounded-ee": o }],
|
|
159
|
+
"rounded-es": [{ "rounded-es": o }],
|
|
160
|
+
"rounded-tl": [{ "rounded-tl": o }],
|
|
161
|
+
"rounded-tr": [{ "rounded-tr": o }],
|
|
162
|
+
"rounded-br": [{ "rounded-br": o }],
|
|
163
|
+
"rounded-bl": [{ "rounded-bl": o }],
|
|
164
|
+
// Shadows
|
|
165
|
+
shadow: [{ shadow: n }]
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
export {
|
|
170
|
+
c as twMergeConfig
|
|
171
|
+
};
|
|
@@ -1 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unity-configured tailwind-merge function for intelligent CSS class merging.
|
|
3
|
+
*
|
|
4
|
+
* This is a pre-configured version of tailwind-merge that includes Unity's custom
|
|
5
|
+
* class definitions and merge rules. It automatically handles Unity's design tokens
|
|
6
|
+
* including semantic colors, primitive colors, spacing values, typography classes,
|
|
7
|
+
* border radius, shadows, and more.
|
|
8
|
+
* @param classes - CSS class names to merge
|
|
9
|
+
* @returns Merged and deduplicated class string with conflicts resolved
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* import { uyMerge } from '@payfit/unity-themes'
|
|
13
|
+
*
|
|
14
|
+
* // Basic conflict resolution - last class wins
|
|
15
|
+
* const className = uyMerge('uy:bg-surface-primary-default', 'uy:bg-surface-danger-default')
|
|
16
|
+
* // → 'uy:bg-surface-danger-default'
|
|
17
|
+
*
|
|
18
|
+
* // Spacing conflicts
|
|
19
|
+
* const className = uyMerge('uy:p-100', 'uy:px-200', 'uy:py-300')
|
|
20
|
+
* // → 'uy:p-100 uy:px-200 uy:py-300' (px/py don't conflict with p)
|
|
21
|
+
*
|
|
22
|
+
* const className = uyMerge('uy:p-100', 'uy:p-200')
|
|
23
|
+
* // → 'uy:p-200' (direct conflict resolved)
|
|
24
|
+
*
|
|
25
|
+
* // Typography conflicts
|
|
26
|
+
* const className = uyMerge('uy:typography-h1', 'uy:typography-body')
|
|
27
|
+
* // → 'uy:typography-body'
|
|
28
|
+
*
|
|
29
|
+
* // Complex semantic colors
|
|
30
|
+
* const className = uyMerge(
|
|
31
|
+
* 'uy:bg-surface-primary-default-default',
|
|
32
|
+
* 'uy:bg-surface-primary-default-hover'
|
|
33
|
+
* )
|
|
34
|
+
* // → 'uy:bg-surface-primary-default-hover'
|
|
35
|
+
*
|
|
36
|
+
* // Mixed with standard Tailwind (no conflicts)
|
|
37
|
+
* const className = uyMerge('flex items-center', 'uy:bg-surface-primary-default', 'justify-center')
|
|
38
|
+
* // → 'flex items-center uy:bg-surface-primary-default justify-center'
|
|
39
|
+
*
|
|
40
|
+
* // Responsive and state variants
|
|
41
|
+
* const className = uyMerge(
|
|
42
|
+
* 'uy:bg-surface-neutral-default',
|
|
43
|
+
* 'uy:hover:bg-surface-primary-hover',
|
|
44
|
+
* 'uy:md:bg-surface-secondary-default'
|
|
45
|
+
* )
|
|
46
|
+
* // → 'uy:bg-surface-neutral-default uy:hover:bg-surface-primary-hover uy:md:bg-surface-secondary-default'
|
|
47
|
+
* ```
|
|
48
|
+
* @description
|
|
49
|
+
* **Supported Unity Features:**
|
|
50
|
+
* - **Primitive Colors**: `grayscale-l0`, `red-l5`, `blue-l12`, etc. (pattern: `{color}-l{number}`)
|
|
51
|
+
* - **Semantic Colors**: `surface-primary-default`, `content-neutral-low`, `border-danger-default`, etc.
|
|
52
|
+
* - **Spacing**: All Unity spacing values (`0`, `25`, `50`, `75`, `100`, `125`, `150`, `200`, `250`, `300`, `400`, `500`, `600`, `800`, `1000`)
|
|
53
|
+
* - **Typography**: `h1`, `h2`, `body`, `action`, etc. (generated class names without `-sm` variants)
|
|
54
|
+
* - **Border Radius**: Numeric (`0`, `25`, `50`, etc.) and semantic (`xs`, `sm`, `md`, `lg`, `xl`, `circle`, `pill`)
|
|
55
|
+
* - **Shadows**: Unity shadow values (`canvas`, `raising`, `floating`, `flying`, `soaring`)
|
|
56
|
+
* - **All Utilities**: `bg-*`, `text-*`, `border-*`, `outline-*`, `ring-*`, `divide-*`, `decoration-*`, gradients, etc.
|
|
57
|
+
*
|
|
58
|
+
* **Merge Rules:**
|
|
59
|
+
* - Conflicting classes within the same group are resolved (last one wins)
|
|
60
|
+
* - Non-conflicting classes are preserved
|
|
61
|
+
* - Unity classes don't conflict with standard Tailwind classes
|
|
62
|
+
* - Responsive and state variants are handled correctly
|
|
63
|
+
* - Pattern matching automatically supports new Unity design tokens
|
|
64
|
+
* @see {@link twMergeConfig} for the complete Unity merge configuration
|
|
65
|
+
* @see {@link https://github.com/dcastil/tailwind-merge Tailwind Merge Documentation}
|
|
66
|
+
*/
|
|
1
67
|
export declare const uyMerge: (...classLists: import('tailwind-merge').ClassNameValue[]) => string;
|
|
@@ -1,32 +1,8 @@
|
|
|
1
|
-
import { createTailwindMerge as e, mergeConfigs as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
extend: {
|
|
6
|
-
classGroups: {
|
|
7
|
-
shadow: [
|
|
8
|
-
{ shadow: ["floating", "raising", "flying", "soaring", "canvas"] }
|
|
9
|
-
],
|
|
10
|
-
rounded: [
|
|
11
|
-
{
|
|
12
|
-
rounded: [
|
|
13
|
-
"0",
|
|
14
|
-
"25",
|
|
15
|
-
"50",
|
|
16
|
-
"75",
|
|
17
|
-
"100",
|
|
18
|
-
"125",
|
|
19
|
-
"150",
|
|
20
|
-
"200",
|
|
21
|
-
"300",
|
|
22
|
-
"400"
|
|
23
|
-
]
|
|
24
|
-
}
|
|
25
|
-
]
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
})
|
|
1
|
+
import { createTailwindMerge as e, mergeConfigs as r, getDefaultConfig as o } from "tailwind-merge";
|
|
2
|
+
import { twMergeConfig as g } from "./merge-config.js";
|
|
3
|
+
const f = e(
|
|
4
|
+
() => r(o(), g)
|
|
29
5
|
);
|
|
30
6
|
export {
|
|
31
|
-
|
|
7
|
+
f as uyMerge
|
|
32
8
|
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { VariantProps } from 'tailwind-variants';
|
|
2
|
+
/**
|
|
3
|
+
* Unity-configured tailwind-variants TV function for creating component variants.
|
|
4
|
+
*
|
|
5
|
+
* This is a pre-configured version of tailwind-variants' `createTV` function that includes
|
|
6
|
+
* Unity's custom tailwind-merge configuration. It automatically handles Unity's custom
|
|
7
|
+
* class names including semantic colors, spacing values, typography classes, and more.
|
|
8
|
+
* @example
|
|
9
|
+
* ```tsx
|
|
10
|
+
* import { uyTv } from '@payfit/unity-themes'
|
|
11
|
+
*
|
|
12
|
+
* const button = uyTv({
|
|
13
|
+
* base: 'uy:px-200 uy:py-100 uy:rounded-100',
|
|
14
|
+
* variants: {
|
|
15
|
+
* variant: {
|
|
16
|
+
* primary: 'uy:bg-surface-primary-default uy:text-content-inverted-default',
|
|
17
|
+
* secondary: 'uy:bg-surface-neutral-default uy:text-content-neutral-default',
|
|
18
|
+
* },
|
|
19
|
+
* size: {
|
|
20
|
+
* small: 'uy:text-75 uy:px-150 uy:py-75',
|
|
21
|
+
* large: 'uy:text-200 uy:px-300 uy:py-150',
|
|
22
|
+
* }
|
|
23
|
+
* },
|
|
24
|
+
* defaultVariants: {
|
|
25
|
+
* variant: 'primary',
|
|
26
|
+
* size: 'small'
|
|
27
|
+
* }
|
|
28
|
+
* })
|
|
29
|
+
*
|
|
30
|
+
* // Usage in component
|
|
31
|
+
* <button className={button({ variant: 'secondary', size: 'large' })}>
|
|
32
|
+
* Click me
|
|
33
|
+
* </button>
|
|
34
|
+
* ```
|
|
35
|
+
* @description
|
|
36
|
+
* - Automatically merges conflicting Unity classes (e.g., `uy:bg-surface-primary` + `uy:bg-surface-danger` → `uy:bg-surface-danger`)
|
|
37
|
+
* - Supports all Unity design tokens: colors, spacing, typography, shadows, border radius
|
|
38
|
+
* - Handles responsive and state variants correctly
|
|
39
|
+
* - Compatible with standard Tailwind classes alongside Unity classes
|
|
40
|
+
* @see {@link https://www.tailwind-variants.org/ Tailwind Variants Documentation}
|
|
41
|
+
* @see {@link twMergeConfig} for the Unity merge configuration details
|
|
42
|
+
*/
|
|
43
|
+
export declare const uyTv: import('tailwind-variants').CreateTV;
|
|
44
|
+
export type { VariantProps };
|