@umituz/web-design-system 2.9.0 → 3.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/package.json +1 -1
- package/src/domain/tokens/responsive-map.tokens.ts +216 -233
- package/src/domain/types/component.types.ts +1 -2
- package/src/infrastructure/constants/index.ts +5 -0
- package/src/infrastructure/constants/size-variant.constants.ts +12 -1
- package/src/infrastructure/utils/responsive.utils.ts +0 -1
- package/src/presentation/atoms/Badge.tsx +4 -3
- package/src/presentation/atoms/Hide.tsx +1 -1
- package/src/presentation/atoms/Icon.tsx +5 -3
- package/src/presentation/atoms/Input.tsx +4 -3
- package/src/presentation/atoms/Show.tsx +1 -1
- package/src/presentation/atoms/Spinner.tsx +4 -3
- package/src/presentation/molecules/Avatar.tsx +4 -3
- package/src/presentation/organisms/DataTable.tsx +4 -3
- package/src/presentation/organisms/Grid.tsx +0 -1
package/package.json
CHANGED
|
@@ -1,245 +1,228 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Responsive Design Tokens
|
|
3
|
-
* @description Centralized
|
|
2
|
+
* Responsive Design Tokens (Formula-Based)
|
|
3
|
+
* @description Centralized responsive scale generation using formulas
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* All responsive values are generated dynamically from base values and formulas.
|
|
6
|
+
* This provides ZERO code duplication and single source of truth.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
8
|
+
* To modify responsive behavior:
|
|
9
|
+
* 1. Change base values (BASE_* constants)
|
|
10
|
+
* 2. Modify formula functions (*Formula)
|
|
11
|
+
* 3. Entire system updates automatically
|
|
10
12
|
*/
|
|
11
13
|
|
|
12
14
|
import type { SizeVariant, Breakpoint } from '../types';
|
|
13
15
|
import { SPACING_SCALE } from '../../infrastructure/constants/spacing.constants';
|
|
14
|
-
import { TEXT_SIZES } from '../../infrastructure/constants/typography.constants';
|
|
16
|
+
import { TEXT_SIZES, type TextSizeKey } from '../../infrastructure/constants/typography.constants';
|
|
17
|
+
import { BREAKPOINT_ORDER } from '../../infrastructure/constants/breakpoint.constants';
|
|
15
18
|
|
|
16
19
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
20
|
+
* Type for scale generation formula
|
|
21
|
+
* Input: base value for size variant, current breakpoint
|
|
22
|
+
* Output: spacing scale index (as number, will be converted to string)
|
|
19
23
|
*/
|
|
20
|
-
|
|
24
|
+
type ScaleFormula = (base: number, breakpoint: Breakpoint) => number;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Type for generator result
|
|
28
|
+
*/
|
|
29
|
+
type ResponsiveScale = Record<SizeVariant, Partial<Record<Breakpoint, string>>>;
|
|
30
|
+
|
|
31
|
+
// ============================================================================
|
|
32
|
+
// BASE VALUES - Single source of truth for size variants
|
|
33
|
+
// ============================================================================
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Base spacing values for each size variant
|
|
37
|
+
* Defines the starting point for responsive spacing calculation
|
|
38
|
+
*/
|
|
39
|
+
const SPACING_BASES: Record<SizeVariant, number> = {
|
|
40
|
+
xs: 1, // SPACING_SCALE['1'] = 4px
|
|
41
|
+
sm: 2, // SPACING_SCALE['2'] = 8px
|
|
42
|
+
md: 3, // SPACING_SCALE['3'] = 12px
|
|
43
|
+
lg: 4, // SPACING_SCALE['4'] = 16px
|
|
44
|
+
xl: 5, // SPACING_SCALE['5'] = 20px
|
|
45
|
+
'2xl': 6, // SPACING_SCALE['6'] = 24px
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Base icon size values for each size variant
|
|
50
|
+
*/
|
|
51
|
+
const ICON_BASES: Record<SizeVariant, number> = {
|
|
52
|
+
xs: 4,
|
|
53
|
+
sm: 5,
|
|
54
|
+
md: 6,
|
|
55
|
+
lg: 8,
|
|
56
|
+
xl: 10,
|
|
57
|
+
'2xl': 12,
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Base container size values (for icon wrappers)
|
|
62
|
+
*/
|
|
63
|
+
const CONTAINER_BASES: Record<SizeVariant, number> = {
|
|
64
|
+
xs: 6,
|
|
65
|
+
sm: 8,
|
|
66
|
+
md: 10,
|
|
67
|
+
lg: 12,
|
|
68
|
+
xl: 14,
|
|
69
|
+
'2xl': 16,
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Base gap/spacing values for layout
|
|
74
|
+
*/
|
|
75
|
+
const GAP_BASES: Record<SizeVariant, number> = {
|
|
76
|
+
xs: 1,
|
|
77
|
+
sm: 2,
|
|
78
|
+
md: 3,
|
|
79
|
+
lg: 4,
|
|
80
|
+
xl: 5,
|
|
81
|
+
'2xl': 6,
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
// ============================================================================
|
|
85
|
+
// FORMULAS - Define responsive behavior for each token type
|
|
86
|
+
// ============================================================================
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Spacing formula for padding, margin, gap
|
|
90
|
+
* Progression: xs/sm→base, md/lg→base+1, xl→base+2, 2xl→base+3
|
|
91
|
+
*/
|
|
92
|
+
const spacingFormula: ScaleFormula = (base, bp) => {
|
|
93
|
+
const bpIndex = BREAKPOINT_ORDER.indexOf(bp);
|
|
94
|
+
if (bpIndex <= 1) return base; // xs, sm
|
|
95
|
+
if (bpIndex <= 3) return base + 1; // md, lg
|
|
96
|
+
if (bpIndex === 4) return base + 2; // xl
|
|
97
|
+
return base + 3; // 2xl
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Icon size formula
|
|
102
|
+
* Progression: More gradual increase across breakpoints
|
|
103
|
+
*/
|
|
104
|
+
const iconFormula: ScaleFormula = (base, bp) => {
|
|
105
|
+
if (bp === 'xs') return base - 1;
|
|
106
|
+
if (bp === 'sm') return base;
|
|
107
|
+
if (bp === 'md') return base + 1;
|
|
108
|
+
if (bp === 'lg') return base + 2;
|
|
109
|
+
if (bp === 'xl') return base + 3;
|
|
110
|
+
return base + 3; // 2xl
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Container size formula (for icon wrappers)
|
|
115
|
+
* Consistent size increase
|
|
116
|
+
*/
|
|
117
|
+
const containerFormula: ScaleFormula = (base, bp) => {
|
|
118
|
+
const bpIndex = BREAKPOINT_ORDER.indexOf(bp);
|
|
119
|
+
if (bpIndex <= 3) return base + 2; // xs, sm, md, lg
|
|
120
|
+
if (bpIndex === 4) return base + 2; // xl
|
|
121
|
+
return base + 2; // 2xl
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Gap formula for layout spacing
|
|
126
|
+
*/
|
|
127
|
+
const gapFormula: ScaleFormula = (base, bp) => {
|
|
128
|
+
const bpIndex = BREAKPOINT_ORDER.indexOf(bp);
|
|
129
|
+
if (bpIndex <= 1) return base; // xs, sm
|
|
130
|
+
if (bpIndex <= 3) return base + 1; // md, lg
|
|
131
|
+
if (bpIndex === 4) return base + 1; // xl
|
|
132
|
+
return base + 2; // 2xl
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
// ============================================================================
|
|
136
|
+
// GENERATORS - Create responsive scales dynamically
|
|
137
|
+
// ============================================================================
|
|
21
138
|
|
|
22
139
|
/**
|
|
23
|
-
*
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
'
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
Partial<Record<
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
sm: SPACING_SCALE['9'],
|
|
113
|
-
md: SPACING_SCALE['10'],
|
|
114
|
-
lg: SPACING_SCALE['12'],
|
|
115
|
-
xl: SPACING_SCALE['14'],
|
|
116
|
-
'2xl': SPACING_SCALE['16'],
|
|
117
|
-
},
|
|
118
|
-
} as const;
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Container/icon wrapper size (for rounded containers that hold icons)
|
|
122
|
-
*/
|
|
123
|
-
export const RESPONSIVE_CONTAINER_SIZE: Record<
|
|
124
|
-
SizeVariant,
|
|
125
|
-
Partial<Record<Breakpoint, SpacingScale>>
|
|
126
|
-
> = {
|
|
127
|
-
xs: {
|
|
128
|
-
xs: SPACING_SCALE['6'],
|
|
129
|
-
sm: SPACING_SCALE['8'],
|
|
130
|
-
md: SPACING_SCALE['8'],
|
|
131
|
-
lg: SPACING_SCALE['10'],
|
|
132
|
-
xl: SPACING_SCALE['10'],
|
|
133
|
-
'2xl': SPACING_SCALE['12'],
|
|
134
|
-
},
|
|
135
|
-
sm: {
|
|
136
|
-
xs: SPACING_SCALE['8'],
|
|
137
|
-
sm: SPACING_SCALE['10'],
|
|
138
|
-
md: SPACING_SCALE['10'],
|
|
139
|
-
lg: SPACING_SCALE['12'],
|
|
140
|
-
xl: SPACING_SCALE['12'],
|
|
141
|
-
'2xl': SPACING_SCALE['14'],
|
|
142
|
-
},
|
|
143
|
-
md: {
|
|
144
|
-
xs: SPACING_SCALE['10'],
|
|
145
|
-
sm: SPACING_SCALE['12'],
|
|
146
|
-
md: SPACING_SCALE['12'],
|
|
147
|
-
lg: SPACING_SCALE['14'],
|
|
148
|
-
xl: SPACING_SCALE['14'],
|
|
149
|
-
'2xl': SPACING_SCALE['16'],
|
|
150
|
-
},
|
|
151
|
-
lg: {
|
|
152
|
-
xs: SPACING_SCALE['12'],
|
|
153
|
-
sm: SPACING_SCALE['14'],
|
|
154
|
-
md: SPACING_SCALE['14'],
|
|
155
|
-
lg: SPACING_SCALE['16'],
|
|
156
|
-
xl: SPACING_SCALE['16'],
|
|
157
|
-
'2xl': SPACING_SCALE['20'],
|
|
158
|
-
},
|
|
159
|
-
xl: {
|
|
160
|
-
xs: SPACING_SCALE['14'],
|
|
161
|
-
sm: SPACING_SCALE['16'],
|
|
162
|
-
md: SPACING_SCALE['16'],
|
|
163
|
-
lg: SPACING_SCALE['20'],
|
|
164
|
-
xl: SPACING_SCALE['20'],
|
|
165
|
-
'2xl': SPACING_SCALE['24'],
|
|
166
|
-
},
|
|
167
|
-
} as const;
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* Text size scale (Tailwind text utilities)
|
|
171
|
-
*/
|
|
172
|
-
export const RESPONSIVE_TEXT_SIZE: Record<
|
|
173
|
-
SizeVariant,
|
|
174
|
-
Partial<Record<'mobile' | 'tablet', string>>
|
|
175
|
-
> = {
|
|
176
|
-
xs: {
|
|
177
|
-
mobile: TEXT_SIZES.xs,
|
|
178
|
-
tablet: `sm:${TEXT_SIZES.xs}`,
|
|
179
|
-
},
|
|
180
|
-
sm: {
|
|
181
|
-
mobile: TEXT_SIZES.xs,
|
|
182
|
-
tablet: `sm:${TEXT_SIZES.sm}`,
|
|
183
|
-
},
|
|
184
|
-
md: {
|
|
185
|
-
mobile: TEXT_SIZES.sm,
|
|
186
|
-
tablet: `sm:${TEXT_SIZES.base}`,
|
|
187
|
-
},
|
|
188
|
-
lg: {
|
|
189
|
-
mobile: TEXT_SIZES.base,
|
|
190
|
-
tablet: `sm:${TEXT_SIZES.lg}`,
|
|
191
|
-
},
|
|
192
|
-
xl: {
|
|
193
|
-
mobile: TEXT_SIZES.lg,
|
|
194
|
-
tablet: `sm:${TEXT_SIZES.xl}`,
|
|
195
|
-
},
|
|
196
|
-
} as const;
|
|
197
|
-
|
|
198
|
-
/**
|
|
199
|
-
* Gap/Spacing between elements (space-y-*, space-x-*, gap-*)
|
|
200
|
-
*/
|
|
201
|
-
export const RESPONSIVE_GAP: Record<
|
|
202
|
-
SizeVariant,
|
|
203
|
-
Partial<Record<Breakpoint, SpacingScale>>
|
|
204
|
-
> = {
|
|
205
|
-
xs: {
|
|
206
|
-
xs: SPACING_SCALE['1'],
|
|
207
|
-
sm: SPACING_SCALE['2'],
|
|
208
|
-
md: SPACING_SCALE['2'],
|
|
209
|
-
lg: SPACING_SCALE['3'],
|
|
210
|
-
xl: SPACING_SCALE['3'],
|
|
211
|
-
'2xl': SPACING_SCALE['4'],
|
|
212
|
-
},
|
|
213
|
-
sm: {
|
|
214
|
-
xs: SPACING_SCALE['2'],
|
|
215
|
-
sm: SPACING_SCALE['3'],
|
|
216
|
-
md: SPACING_SCALE['3'],
|
|
217
|
-
lg: SPACING_SCALE['4'],
|
|
218
|
-
xl: SPACING_SCALE['4'],
|
|
219
|
-
'2xl': SPACING_SCALE['5'],
|
|
220
|
-
},
|
|
221
|
-
md: {
|
|
222
|
-
xs: SPACING_SCALE['3'],
|
|
223
|
-
sm: SPACING_SCALE['4'],
|
|
224
|
-
md: SPACING_SCALE['4'],
|
|
225
|
-
lg: SPACING_SCALE['5'],
|
|
226
|
-
xl: SPACING_SCALE['5'],
|
|
227
|
-
'2xl': SPACING_SCALE['6'],
|
|
228
|
-
},
|
|
229
|
-
lg: {
|
|
230
|
-
xs: SPACING_SCALE['4'],
|
|
231
|
-
sm: SPACING_SCALE['5'],
|
|
232
|
-
md: SPACING_SCALE['5'],
|
|
233
|
-
lg: SPACING_SCALE['6'],
|
|
234
|
-
xl: SPACING_SCALE['6'],
|
|
235
|
-
'2xl': SPACING_SCALE['8'],
|
|
236
|
-
},
|
|
237
|
-
xl: {
|
|
238
|
-
xs: SPACING_SCALE['5'],
|
|
239
|
-
sm: SPACING_SCALE['6'],
|
|
240
|
-
md: SPACING_SCALE['6'],
|
|
241
|
-
lg: SPACING_SCALE['8'],
|
|
242
|
-
xl: SPACING_SCALE['8'],
|
|
243
|
-
'2xl': SPACING_SCALE['10'],
|
|
244
|
-
},
|
|
245
|
-
} as const;
|
|
140
|
+
* Generate responsive scale for any token type
|
|
141
|
+
* @param bases - Base values for each size variant
|
|
142
|
+
* @param formula - Formula to calculate value at each breakpoint
|
|
143
|
+
* @returns Complete responsive scale object
|
|
144
|
+
*/
|
|
145
|
+
function generateResponsiveScale(
|
|
146
|
+
bases: Record<SizeVariant, number>,
|
|
147
|
+
formula: ScaleFormula
|
|
148
|
+
): ResponsiveScale {
|
|
149
|
+
const result: Partial<ResponsiveScale> = {};
|
|
150
|
+
|
|
151
|
+
for (const size of Object.keys(bases) as SizeVariant[]) {
|
|
152
|
+
const base = bases[size];
|
|
153
|
+
result[size] = {};
|
|
154
|
+
|
|
155
|
+
for (const bp of BREAKPOINT_ORDER) {
|
|
156
|
+
const scaleIndex = formula(base, bp);
|
|
157
|
+
const scaleKey = scaleIndex.toString() as keyof typeof SPACING_SCALE;
|
|
158
|
+
|
|
159
|
+
// Validate and get spacing scale value
|
|
160
|
+
if (scaleKey in SPACING_SCALE) {
|
|
161
|
+
result[size]![bp] = SPACING_SCALE[scaleKey];
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return result as ResponsiveScale;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Generate responsive text sizes
|
|
171
|
+
* Text sizes use string literals, not spacing scale
|
|
172
|
+
*/
|
|
173
|
+
function generateResponsiveTextSizes() {
|
|
174
|
+
const textSizeKeys: Record<SizeVariant, { mobile: TextSizeKey; tablet: TextSizeKey }> = {
|
|
175
|
+
xs: { mobile: 'xs', tablet: 'xs' },
|
|
176
|
+
sm: { mobile: 'xs', tablet: 'sm' },
|
|
177
|
+
md: { mobile: 'sm', tablet: 'base' },
|
|
178
|
+
lg: { mobile: 'base', tablet: 'lg' },
|
|
179
|
+
xl: { mobile: 'lg', tablet: 'xl' },
|
|
180
|
+
'2xl': { mobile: 'xl', tablet: '2xl' },
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
const result: Partial<Record<SizeVariant, Partial<Record<'mobile' | 'tablet', string>>>> = {};
|
|
184
|
+
|
|
185
|
+
for (const size of Object.keys(textSizeKeys) as SizeVariant[]) {
|
|
186
|
+
const keys = textSizeKeys[size];
|
|
187
|
+
result[size] = {
|
|
188
|
+
mobile: TEXT_SIZES[keys.mobile],
|
|
189
|
+
tablet: `sm:${TEXT_SIZES[keys.tablet]}`,
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
return result as Record<SizeVariant, Partial<Record<'mobile' | 'tablet', string>>>;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// ============================================================================
|
|
197
|
+
// EXPORTS - All responsive tokens (one line each!)
|
|
198
|
+
// ============================================================================
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Responsive spacing scale for padding, margin, space-*, gap-*
|
|
202
|
+
*/
|
|
203
|
+
export const RESPONSIVE_SPACING = generateResponsiveScale(SPACING_BASES, spacingFormula);
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Responsive icon sizes (height/width)
|
|
207
|
+
*/
|
|
208
|
+
export const RESPONSIVE_ICON_SIZE = generateResponsiveScale(ICON_BASES, iconFormula);
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Responsive container sizes for icon wrappers
|
|
212
|
+
*/
|
|
213
|
+
export const RESPONSIVE_CONTAINER_SIZE = generateResponsiveScale(CONTAINER_BASES, containerFormula);
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Responsive gap/spacing for layouts
|
|
217
|
+
*/
|
|
218
|
+
export const RESPONSIVE_GAP = generateResponsiveScale(GAP_BASES, gapFormula);
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Responsive text sizes (mobile + tablet)
|
|
222
|
+
*/
|
|
223
|
+
export const RESPONSIVE_TEXT_SIZE = generateResponsiveTextSizes();
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Type exports
|
|
227
|
+
*/
|
|
228
|
+
export type SpacingScale = keyof typeof SPACING_SCALE;
|
|
@@ -4,9 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import type { ReactNode } from 'react';
|
|
7
|
-
|
|
7
|
+
export type { SizeVariant } from '../../infrastructure/constants/size-variant.constants';
|
|
8
8
|
|
|
9
|
-
export { type SizeVariant } from '../../infrastructure/constants/size-variant.constants';
|
|
10
9
|
export type ColorVariant = 'primary' | 'secondary' | 'success' | 'warning' | 'destructive';
|
|
11
10
|
export type ColorScheme = 'light' | 'dark';
|
|
12
11
|
|
|
@@ -16,6 +16,7 @@ export const SIZE_VARIANTS = {
|
|
|
16
16
|
md: 'md',
|
|
17
17
|
lg: 'lg',
|
|
18
18
|
xl: 'xl',
|
|
19
|
+
'2xl': '2xl',
|
|
19
20
|
} as const;
|
|
20
21
|
|
|
21
22
|
/**
|
|
@@ -28,10 +29,20 @@ export type SizeVariantKey = keyof typeof SIZE_VARIANTS;
|
|
|
28
29
|
*/
|
|
29
30
|
export type SizeVariant = typeof SIZE_VARIANTS[SizeVariantKey];
|
|
30
31
|
|
|
32
|
+
/**
|
|
33
|
+
* Common size combinations used by components
|
|
34
|
+
* These prevent repeating Extract<SizeVariant, '...'> in every component
|
|
35
|
+
*/
|
|
36
|
+
export type SmallSizes = Extract<SizeVariant, 'xs' | 'sm'>;
|
|
37
|
+
export type MediumSizes = Extract<SizeVariant, 'sm' | 'md' | 'lg'>;
|
|
38
|
+
export type RegularSizes = Extract<SizeVariant, 'sm' | 'md' | 'lg' | 'xl'>;
|
|
39
|
+
export type ExtendedSizes = Extract<SizeVariant, 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl'>;
|
|
40
|
+
export type AllSizes = SizeVariant;
|
|
41
|
+
|
|
31
42
|
/**
|
|
32
43
|
* Size variant order (for sorting/comparison)
|
|
33
44
|
*/
|
|
34
|
-
export const SIZE_VARIANT_ORDER: SizeVariant[] = ['xs', 'sm', 'md', 'lg', 'xl'];
|
|
45
|
+
export const SIZE_VARIANT_ORDER: SizeVariant[] = ['xs', 'sm', 'md', 'lg', 'xl', '2xl'];
|
|
35
46
|
|
|
36
47
|
/**
|
|
37
48
|
* Get the next larger size variant
|
|
@@ -5,11 +5,12 @@
|
|
|
5
5
|
|
|
6
6
|
import { forwardRef, type HTMLAttributes } from 'react';
|
|
7
7
|
import { cn } from '../../infrastructure/utils';
|
|
8
|
-
import type { BaseProps, ColorVariant
|
|
8
|
+
import type { BaseProps, ColorVariant } from '../../domain/types';
|
|
9
|
+
import type { MediumSizes } from '../../infrastructure/constants';
|
|
9
10
|
|
|
10
11
|
export interface BadgeProps extends HTMLAttributes<HTMLDivElement>, BaseProps {
|
|
11
12
|
variant?: ColorVariant;
|
|
12
|
-
size?:
|
|
13
|
+
size?: MediumSizes;
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
const variantStyles: Record<ColorVariant, string> = {
|
|
@@ -20,7 +21,7 @@ const variantStyles: Record<ColorVariant, string> = {
|
|
|
20
21
|
destructive: 'bg-destructive text-destructive-foreground border-destructive',
|
|
21
22
|
};
|
|
22
23
|
|
|
23
|
-
const sizeStyles: Record<
|
|
24
|
+
const sizeStyles: Record<MediumSizes, string> = {
|
|
24
25
|
sm: 'px-2 py-0.5 text-xs',
|
|
25
26
|
md: 'px-2.5 py-1 text-sm',
|
|
26
27
|
lg: 'px-3 py-1.5 text-base',
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { useBreakpoint } from '../hooks/useMediaQuery';
|
|
7
|
-
import type {
|
|
7
|
+
import type { HideProps } from '../../domain/types/breakpoint.types';
|
|
8
8
|
import type { BaseProps } from '../../domain/types';
|
|
9
9
|
|
|
10
10
|
export interface HideComponentProps extends BaseProps, HideProps {
|
|
@@ -5,18 +5,20 @@
|
|
|
5
5
|
|
|
6
6
|
import { forwardRef, type SVGAttributes } from 'react';
|
|
7
7
|
import { cn } from '../../infrastructure/utils';
|
|
8
|
-
import type { BaseProps
|
|
8
|
+
import type { BaseProps } from '../../domain/types';
|
|
9
|
+
import type { ExtendedSizes } from '../../infrastructure/constants';
|
|
9
10
|
|
|
10
11
|
export interface IconProps extends SVGAttributes<SVGSVGElement>, BaseProps {
|
|
11
|
-
size?:
|
|
12
|
+
size?: ExtendedSizes;
|
|
12
13
|
}
|
|
13
14
|
|
|
14
|
-
const sizeStyles: Record<
|
|
15
|
+
const sizeStyles: Record<ExtendedSizes, string> = {
|
|
15
16
|
xs: 'h-3 w-3',
|
|
16
17
|
sm: 'h-4 w-4',
|
|
17
18
|
md: 'h-5 w-5',
|
|
18
19
|
lg: 'h-6 w-6',
|
|
19
20
|
xl: 'h-8 w-8',
|
|
21
|
+
'2xl': 'h-10 w-10',
|
|
20
22
|
};
|
|
21
23
|
|
|
22
24
|
export const Icon = forwardRef<SVGSVGElement, IconProps>(
|
|
@@ -5,14 +5,15 @@
|
|
|
5
5
|
|
|
6
6
|
import { forwardRef, type InputHTMLAttributes } from 'react';
|
|
7
7
|
import { cn } from '../../infrastructure/utils';
|
|
8
|
-
import type { BaseProps
|
|
8
|
+
import type { BaseProps } from '../../domain/types';
|
|
9
|
+
import type { MediumSizes } from '../../infrastructure/constants';
|
|
9
10
|
|
|
10
11
|
export interface InputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'size'>, BaseProps {
|
|
11
12
|
error?: boolean;
|
|
12
|
-
size?:
|
|
13
|
+
size?: MediumSizes;
|
|
13
14
|
}
|
|
14
15
|
|
|
15
|
-
const sizeStyles: Record<
|
|
16
|
+
const sizeStyles: Record<MediumSizes, string> = {
|
|
16
17
|
sm: 'h-8 px-3 text-sm',
|
|
17
18
|
md: 'h-9 px-3 text-sm',
|
|
18
19
|
lg: 'h-10 px-4 text-base',
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { useBreakpoint } from '../hooks/useMediaQuery';
|
|
7
|
-
import type {
|
|
7
|
+
import type { ShowProps } from '../../domain/types/breakpoint.types';
|
|
8
8
|
import type { BaseProps } from '../../domain/types';
|
|
9
9
|
|
|
10
10
|
export interface ShowComponentProps extends BaseProps, ShowProps {
|
|
@@ -5,13 +5,14 @@
|
|
|
5
5
|
|
|
6
6
|
import { forwardRef, type HTMLAttributes } from 'react';
|
|
7
7
|
import { cn } from '../../infrastructure/utils';
|
|
8
|
-
import type { BaseProps
|
|
8
|
+
import type { BaseProps } from '../../domain/types';
|
|
9
|
+
import type { RegularSizes } from '../../infrastructure/constants';
|
|
9
10
|
|
|
10
11
|
export interface SpinnerProps extends HTMLAttributes<HTMLDivElement>, BaseProps {
|
|
11
|
-
size?:
|
|
12
|
+
size?: RegularSizes;
|
|
12
13
|
}
|
|
13
14
|
|
|
14
|
-
const sizeStyles: Record<
|
|
15
|
+
const sizeStyles: Record<RegularSizes, string> = {
|
|
15
16
|
sm: 'h-4 w-4 border-2',
|
|
16
17
|
md: 'h-6 w-6 border-2',
|
|
17
18
|
lg: 'h-8 w-8 border-3',
|
|
@@ -5,13 +5,14 @@
|
|
|
5
5
|
|
|
6
6
|
import { forwardRef, type HTMLAttributes, type ComponentPropsWithoutRef } from 'react';
|
|
7
7
|
import { cn } from '../../infrastructure/utils';
|
|
8
|
-
import type { BaseProps
|
|
8
|
+
import type { BaseProps } from '../../domain/types';
|
|
9
|
+
import type { ExtendedSizes } from '../../infrastructure/constants';
|
|
9
10
|
|
|
10
11
|
export interface AvatarProps extends HTMLAttributes<HTMLDivElement>, BaseProps {
|
|
11
|
-
size?:
|
|
12
|
+
size?: ExtendedSizes;
|
|
12
13
|
}
|
|
13
14
|
|
|
14
|
-
const sizeStyles: Record<
|
|
15
|
+
const sizeStyles: Record<ExtendedSizes, string> = {
|
|
15
16
|
xs: 'h-6 w-6 text-xs',
|
|
16
17
|
sm: 'h-8 w-8 text-sm',
|
|
17
18
|
md: 'h-10 w-10 text-base',
|
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
import { Button } from '../atoms/Button';
|
|
19
19
|
import { ChevronLeft, ChevronRight, ChevronsLeft, ChevronsRight } from 'lucide-react';
|
|
20
20
|
import type { BaseProps, SizeVariant, ColorVariant } from '../../domain/types';
|
|
21
|
+
import type { MediumSizes } from '../../infrastructure/constants';
|
|
21
22
|
|
|
22
23
|
export interface Column<T> {
|
|
23
24
|
id: string;
|
|
@@ -32,7 +33,7 @@ export interface DataTableProps<T> extends BaseProps {
|
|
|
32
33
|
data: T[];
|
|
33
34
|
columns: Column<T>[];
|
|
34
35
|
caption?: string;
|
|
35
|
-
size?:
|
|
36
|
+
size?: MediumSizes;
|
|
36
37
|
variant?: ColorVariant;
|
|
37
38
|
sortable?: boolean;
|
|
38
39
|
paginated?: boolean;
|
|
@@ -110,13 +111,13 @@ export function DataTable<T extends Record<string, unknown>>({
|
|
|
110
111
|
return value as React.ReactNode;
|
|
111
112
|
};
|
|
112
113
|
|
|
113
|
-
const sizeStyles = {
|
|
114
|
+
const sizeStyles: Record<MediumSizes, string> = {
|
|
114
115
|
sm: 'text-xs',
|
|
115
116
|
md: 'text-sm',
|
|
116
117
|
lg: 'text-base',
|
|
117
118
|
};
|
|
118
119
|
|
|
119
|
-
const paddingStyles = {
|
|
120
|
+
const paddingStyles: Record<MediumSizes, string> = {
|
|
120
121
|
sm: 'px-2 py-2',
|
|
121
122
|
md: 'px-4 py-3',
|
|
122
123
|
lg: 'px-6 py-4',
|