@umituz/web-design-system 2.8.0 → 3.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.
- package/package.json +1 -1
- package/src/domain/tokens/responsive-map.tokens.ts +216 -235
- package/src/domain/types/component.types.ts +2 -1
- package/src/infrastructure/constants/index.ts +30 -0
- package/src/infrastructure/constants/size-variant.constants.ts +63 -0
- package/src/infrastructure/constants/spacing.constants.ts +92 -0
- package/src/infrastructure/constants/typography.constants.ts +101 -0
package/package.json
CHANGED
|
@@ -1,243 +1,224 @@
|
|
|
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';
|
|
15
|
+
import { SPACING_SCALE } from '../../infrastructure/constants/spacing.constants';
|
|
16
|
+
import { TEXT_SIZES, type TextSizeKey } from '../../infrastructure/constants/typography.constants';
|
|
17
|
+
import { BREAKPOINT_ORDER } from '../../infrastructure/constants/breakpoint.constants';
|
|
13
18
|
|
|
14
19
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
lg
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
/**
|
|
197
|
-
*
|
|
198
|
-
*/
|
|
199
|
-
export const
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
xs: '3',
|
|
221
|
-
sm: '4',
|
|
222
|
-
md: '4',
|
|
223
|
-
lg: '5',
|
|
224
|
-
xl: '5',
|
|
225
|
-
'2xl': '6',
|
|
226
|
-
},
|
|
227
|
-
lg: {
|
|
228
|
-
xs: '4',
|
|
229
|
-
sm: '5',
|
|
230
|
-
md: '5',
|
|
231
|
-
lg: '6',
|
|
232
|
-
xl: '6',
|
|
233
|
-
'2xl': '8',
|
|
234
|
-
},
|
|
235
|
-
xl: {
|
|
236
|
-
xs: '5',
|
|
237
|
-
sm: '6',
|
|
238
|
-
md: '6',
|
|
239
|
-
lg: '8',
|
|
240
|
-
xl: '8',
|
|
241
|
-
'2xl': '10',
|
|
242
|
-
},
|
|
243
|
-
} as const;
|
|
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)
|
|
23
|
+
*/
|
|
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
|
+
};
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Base icon size values for each size variant
|
|
49
|
+
*/
|
|
50
|
+
const ICON_BASES: Record<SizeVariant, number> = {
|
|
51
|
+
xs: 4,
|
|
52
|
+
sm: 5,
|
|
53
|
+
md: 6,
|
|
54
|
+
lg: 8,
|
|
55
|
+
xl: 10,
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Base container size values (for icon wrappers)
|
|
60
|
+
*/
|
|
61
|
+
const CONTAINER_BASES: Record<SizeVariant, number> = {
|
|
62
|
+
xs: 6,
|
|
63
|
+
sm: 8,
|
|
64
|
+
md: 10,
|
|
65
|
+
lg: 12,
|
|
66
|
+
xl: 14,
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Base gap/spacing values for layout
|
|
71
|
+
*/
|
|
72
|
+
const GAP_BASES: Record<SizeVariant, number> = {
|
|
73
|
+
xs: 1,
|
|
74
|
+
sm: 2,
|
|
75
|
+
md: 3,
|
|
76
|
+
lg: 4,
|
|
77
|
+
xl: 5,
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
// ============================================================================
|
|
81
|
+
// FORMULAS - Define responsive behavior for each token type
|
|
82
|
+
// ============================================================================
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Spacing formula for padding, margin, gap
|
|
86
|
+
* Progression: xs/sm→base, md/lg→base+1, xl→base+2, 2xl→base+3
|
|
87
|
+
*/
|
|
88
|
+
const spacingFormula: ScaleFormula = (base, bp) => {
|
|
89
|
+
const bpIndex = BREAKPOINT_ORDER.indexOf(bp);
|
|
90
|
+
if (bpIndex <= 1) return base; // xs, sm
|
|
91
|
+
if (bpIndex <= 3) return base + 1; // md, lg
|
|
92
|
+
if (bpIndex === 4) return base + 2; // xl
|
|
93
|
+
return base + 3; // 2xl
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Icon size formula
|
|
98
|
+
* Progression: More gradual increase across breakpoints
|
|
99
|
+
*/
|
|
100
|
+
const iconFormula: ScaleFormula = (base, bp) => {
|
|
101
|
+
const bpIndex = BREAKPOINT_ORDER.indexOf(bp);
|
|
102
|
+
if (bp === 'xs') return base - 1;
|
|
103
|
+
if (bp === 'sm') return base;
|
|
104
|
+
if (bp === 'md') return base + 1;
|
|
105
|
+
if (bp === 'lg') return base + 2;
|
|
106
|
+
if (bp === 'xl') return base + 3;
|
|
107
|
+
return base + 3; // 2xl
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Container size formula (for icon wrappers)
|
|
112
|
+
* Consistent size increase
|
|
113
|
+
*/
|
|
114
|
+
const containerFormula: ScaleFormula = (base, bp) => {
|
|
115
|
+
const bpIndex = BREAKPOINT_ORDER.indexOf(bp);
|
|
116
|
+
if (bpIndex <= 3) return base + 2; // xs, sm, md, lg
|
|
117
|
+
if (bpIndex === 4) return base + 2; // xl
|
|
118
|
+
return base + 2; // 2xl
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Gap formula for layout spacing
|
|
123
|
+
*/
|
|
124
|
+
const gapFormula: ScaleFormula = (base, bp) => {
|
|
125
|
+
const bpIndex = BREAKPOINT_ORDER.indexOf(bp);
|
|
126
|
+
if (bpIndex <= 1) return base; // xs, sm
|
|
127
|
+
if (bpIndex <= 3) return base + 1; // md, lg
|
|
128
|
+
if (bpIndex === 4) return base + 1; // xl
|
|
129
|
+
return base + 2; // 2xl
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
// ============================================================================
|
|
133
|
+
// GENERATORS - Create responsive scales dynamically
|
|
134
|
+
// ============================================================================
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Generate responsive scale for any token type
|
|
138
|
+
* @param bases - Base values for each size variant
|
|
139
|
+
* @param formula - Formula to calculate value at each breakpoint
|
|
140
|
+
* @returns Complete responsive scale object
|
|
141
|
+
*/
|
|
142
|
+
function generateResponsiveScale(
|
|
143
|
+
bases: Record<SizeVariant, number>,
|
|
144
|
+
formula: ScaleFormula
|
|
145
|
+
): ResponsiveScale {
|
|
146
|
+
const result: Partial<ResponsiveScale> = {};
|
|
147
|
+
|
|
148
|
+
for (const size of Object.keys(bases) as SizeVariant[]) {
|
|
149
|
+
const base = bases[size];
|
|
150
|
+
result[size] = {};
|
|
151
|
+
|
|
152
|
+
for (const bp of BREAKPOINT_ORDER) {
|
|
153
|
+
const scaleIndex = formula(base, bp);
|
|
154
|
+
const scaleKey = scaleIndex.toString() as keyof typeof SPACING_SCALE;
|
|
155
|
+
|
|
156
|
+
// Validate and get spacing scale value
|
|
157
|
+
if (scaleKey in SPACING_SCALE) {
|
|
158
|
+
result[size]![bp] = SPACING_SCALE[scaleKey];
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
return result as ResponsiveScale;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Generate responsive text sizes
|
|
168
|
+
* Text sizes use string literals, not spacing scale
|
|
169
|
+
*/
|
|
170
|
+
function generateResponsiveTextSizes() {
|
|
171
|
+
const textSizeKeys: Record<SizeVariant, { mobile: TextSizeKey; tablet: TextSizeKey }> = {
|
|
172
|
+
xs: { mobile: 'xs', tablet: 'xs' },
|
|
173
|
+
sm: { mobile: 'xs', tablet: 'sm' },
|
|
174
|
+
md: { mobile: 'sm', tablet: 'base' },
|
|
175
|
+
lg: { mobile: 'base', tablet: 'lg' },
|
|
176
|
+
xl: { mobile: 'lg', tablet: 'xl' },
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
const result: Partial<Record<SizeVariant, Partial<Record<'mobile' | 'tablet', string>>>> = {};
|
|
180
|
+
|
|
181
|
+
for (const size of Object.keys(textSizeKeys) as SizeVariant[]) {
|
|
182
|
+
const keys = textSizeKeys[size];
|
|
183
|
+
result[size] = {
|
|
184
|
+
mobile: TEXT_SIZES[keys.mobile],
|
|
185
|
+
tablet: `sm:${TEXT_SIZES[keys.tablet]}`,
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
return result as Record<SizeVariant, Partial<Record<'mobile' | 'tablet', string>>>;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// ============================================================================
|
|
193
|
+
// EXPORTS - All responsive tokens (one line each!)
|
|
194
|
+
// ============================================================================
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Responsive spacing scale for padding, margin, space-*, gap-*
|
|
198
|
+
*/
|
|
199
|
+
export const RESPONSIVE_SPACING = generateResponsiveScale(SPACING_BASES, spacingFormula);
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Responsive icon sizes (height/width)
|
|
203
|
+
*/
|
|
204
|
+
export const RESPONSIVE_ICON_SIZE = generateResponsiveScale(ICON_BASES, iconFormula);
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Responsive container sizes for icon wrappers
|
|
208
|
+
*/
|
|
209
|
+
export const RESPONSIVE_CONTAINER_SIZE = generateResponsiveScale(CONTAINER_BASES, containerFormula);
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Responsive gap/spacing for layouts
|
|
213
|
+
*/
|
|
214
|
+
export const RESPONSIVE_GAP = generateResponsiveScale(GAP_BASES, gapFormula);
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Responsive text sizes (mobile + tablet)
|
|
218
|
+
*/
|
|
219
|
+
export const RESPONSIVE_TEXT_SIZE = generateResponsiveTextSizes();
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Type exports
|
|
223
|
+
*/
|
|
224
|
+
export type SpacingScale = keyof typeof SPACING_SCALE;
|
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import type { ReactNode } from 'react';
|
|
7
|
+
import type { SizeVariant } from '../../infrastructure/constants/size-variant.constants';
|
|
7
8
|
|
|
8
|
-
export type SizeVariant
|
|
9
|
+
export { type SizeVariant } from '../../infrastructure/constants/size-variant.constants';
|
|
9
10
|
export type ColorVariant = 'primary' | 'secondary' | 'success' | 'warning' | 'destructive';
|
|
10
11
|
export type ColorScheme = 'light' | 'dark';
|
|
11
12
|
|
|
@@ -21,3 +21,33 @@ export {
|
|
|
21
21
|
isBreakpointGreaterThan,
|
|
22
22
|
isBreakpointLessThan,
|
|
23
23
|
} from './breakpoint.constants';
|
|
24
|
+
|
|
25
|
+
export {
|
|
26
|
+
SPACING_SCALE,
|
|
27
|
+
COMMON_SPACING,
|
|
28
|
+
SIZE_SPACING,
|
|
29
|
+
type SpacingScaleKey,
|
|
30
|
+
type SpacingScale,
|
|
31
|
+
isValidSpacing,
|
|
32
|
+
} from './spacing.constants';
|
|
33
|
+
|
|
34
|
+
export {
|
|
35
|
+
SIZE_VARIANTS,
|
|
36
|
+
SIZE_VARIANT_ORDER,
|
|
37
|
+
getNextSizeVariant,
|
|
38
|
+
getPrevSizeVariant,
|
|
39
|
+
type SizeVariantKey,
|
|
40
|
+
type SizeVariant,
|
|
41
|
+
isValidSizeVariant,
|
|
42
|
+
} from './size-variant.constants';
|
|
43
|
+
|
|
44
|
+
export {
|
|
45
|
+
TEXT_SIZES,
|
|
46
|
+
FONT_WEIGHTS,
|
|
47
|
+
COMMON_TEXT_SIZES,
|
|
48
|
+
TEXT_SIZE_BY_VARIANT,
|
|
49
|
+
type TextSizeKey,
|
|
50
|
+
type TextSize,
|
|
51
|
+
type FontWeightKey,
|
|
52
|
+
type FontWeight,
|
|
53
|
+
} from './typography.constants';
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Size Variant Constants
|
|
3
|
+
* @description Size variants used throughout the design system
|
|
4
|
+
*
|
|
5
|
+
* All size variant values are defined here to provide consistency
|
|
6
|
+
* and prevent hardcoded strings in components.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Size variants available in the design system
|
|
11
|
+
* Ordered from smallest to largest
|
|
12
|
+
*/
|
|
13
|
+
export const SIZE_VARIANTS = {
|
|
14
|
+
xs: 'xs',
|
|
15
|
+
sm: 'sm',
|
|
16
|
+
md: 'md',
|
|
17
|
+
lg: 'lg',
|
|
18
|
+
xl: 'xl',
|
|
19
|
+
} as const;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Type for size variant keys
|
|
23
|
+
*/
|
|
24
|
+
export type SizeVariantKey = keyof typeof SIZE_VARIANTS;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Type for size variant values
|
|
28
|
+
*/
|
|
29
|
+
export type SizeVariant = typeof SIZE_VARIANTS[SizeVariantKey];
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Size variant order (for sorting/comparison)
|
|
33
|
+
*/
|
|
34
|
+
export const SIZE_VARIANT_ORDER: SizeVariant[] = ['xs', 'sm', 'md', 'lg', 'xl'];
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Get the next larger size variant
|
|
38
|
+
*/
|
|
39
|
+
export function getNextSizeVariant(current: SizeVariant): SizeVariant | null {
|
|
40
|
+
const index = SIZE_VARIANT_ORDER.indexOf(current);
|
|
41
|
+
if (index === -1 || index === SIZE_VARIANT_ORDER.length - 1) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
return SIZE_VARIANT_ORDER[index + 1];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Get the next smaller size variant
|
|
49
|
+
*/
|
|
50
|
+
export function getPrevSizeVariant(current: SizeVariant): SizeVariant | null {
|
|
51
|
+
const index = SIZE_VARIANT_ORDER.indexOf(current);
|
|
52
|
+
if (index <= 0) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
return SIZE_VARIANT_ORDER[index - 1];
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Validate if a value is a valid size variant
|
|
60
|
+
*/
|
|
61
|
+
export function isValidSizeVariant(value: string): value is SizeVariant {
|
|
62
|
+
return Object.values(SIZE_VARIANTS).includes(value as SizeVariant);
|
|
63
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Spacing Constants
|
|
3
|
+
* @description Tailwind CSS spacing scale values
|
|
4
|
+
* @see https://tailwindcss.com/docs/customizing-spacing
|
|
5
|
+
*
|
|
6
|
+
* All spacing values used in the design system are defined here.
|
|
7
|
+
* This provides a single source of truth for spacing scale.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Tailwind CSS spacing scale
|
|
12
|
+
* Each value represents a spacing unit that maps to a specific pixel value
|
|
13
|
+
* Format: Key is the spacing class name, value is the unit number (as string for Tailwind class construction)
|
|
14
|
+
*/
|
|
15
|
+
export const SPACING_SCALE = {
|
|
16
|
+
'0': '0', // 0px
|
|
17
|
+
'0.5': '0.5', // 2px
|
|
18
|
+
'1': '1', // 4px
|
|
19
|
+
'1.5': '1.5', // 6px
|
|
20
|
+
'2': '2', // 8px
|
|
21
|
+
'2.5': '2.5', // 10px
|
|
22
|
+
'3': '3', // 12px
|
|
23
|
+
'3.5': '3.5', // 14px
|
|
24
|
+
'4': '4', // 16px
|
|
25
|
+
'5': '5', // 20px
|
|
26
|
+
'6': '6', // 24px
|
|
27
|
+
'7': '7', // 28px
|
|
28
|
+
'8': '8', // 32px
|
|
29
|
+
'9': '9', // 36px
|
|
30
|
+
'10': '10', // 40px
|
|
31
|
+
'11': '11', // 44px
|
|
32
|
+
'12': '12', // 48px
|
|
33
|
+
'14': '14', // 56px
|
|
34
|
+
'16': '16', // 64px
|
|
35
|
+
'20': '20', // 80px
|
|
36
|
+
'24': '24', // 96px
|
|
37
|
+
'28': '28', // 112px
|
|
38
|
+
'32': '32', // 128px
|
|
39
|
+
'36': '36', // 144px
|
|
40
|
+
'40': '40', // 160px
|
|
41
|
+
'44': '44', // 176px
|
|
42
|
+
'48': '48', // 192px
|
|
43
|
+
'52': '52', // 208px
|
|
44
|
+
'56': '56', // 224px
|
|
45
|
+
'60': '60', // 240px
|
|
46
|
+
'64': '64', // 256px
|
|
47
|
+
'72': '72', // 288px
|
|
48
|
+
'80': '80', // 320px
|
|
49
|
+
'96': '96', // 384px
|
|
50
|
+
} as const;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Type for spacing scale keys
|
|
54
|
+
*/
|
|
55
|
+
export type SpacingScaleKey = keyof typeof SPACING_SCALE;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Type for spacing scale values (string format for Tailwind classes)
|
|
59
|
+
*/
|
|
60
|
+
export type SpacingScale = `${SpacingScaleKey}`;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Common spacing values used throughout the design system
|
|
64
|
+
* These are frequently used spacing values
|
|
65
|
+
*/
|
|
66
|
+
export const COMMON_SPACING = {
|
|
67
|
+
xs: SPACING_SCALE['1'],
|
|
68
|
+
sm: SPACING_SCALE['2'],
|
|
69
|
+
md: SPACING_SCALE['4'],
|
|
70
|
+
lg: SPACING_SCALE['6'],
|
|
71
|
+
xl: SPACING_SCALE['8'],
|
|
72
|
+
'2xl': SPACING_SCALE['12'],
|
|
73
|
+
} as const;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Spacing scale for component sizing
|
|
77
|
+
*/
|
|
78
|
+
export const SIZE_SPACING = {
|
|
79
|
+
xs: SPACING_SCALE['3'],
|
|
80
|
+
sm: SPACING_SCALE['4'],
|
|
81
|
+
md: SPACING_SCALE['5'],
|
|
82
|
+
lg: SPACING_SCALE['6'],
|
|
83
|
+
xl: SPACING_SCALE['8'],
|
|
84
|
+
'2xl': SPACING_SCALE['10'],
|
|
85
|
+
} as const;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Validate if a value is a valid spacing scale
|
|
89
|
+
*/
|
|
90
|
+
export function isValidSpacing(value: string): value is SpacingScale {
|
|
91
|
+
return Object.keys(SPACING_SCALE).includes(value);
|
|
92
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typography Constants
|
|
3
|
+
* @description Typography scale values for the design system
|
|
4
|
+
*
|
|
5
|
+
* All font size and text utility values are defined here.
|
|
6
|
+
* This provides consistency with Tailwind's default typography scale.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Text size utilities (Tailwind text classes)
|
|
11
|
+
*/
|
|
12
|
+
export const TEXT_SIZES = {
|
|
13
|
+
xs: 'text-xs', // 0.75rem (12px)
|
|
14
|
+
sm: 'text-sm', // 0.875rem (14px)
|
|
15
|
+
base: 'text-base', // 1rem (16px)
|
|
16
|
+
lg: 'text-lg', // 1.125rem (18px)
|
|
17
|
+
xl: 'text-xl', // 1.25rem (20px)
|
|
18
|
+
'2xl': 'text-2xl', // 1.5rem (24px)
|
|
19
|
+
'3xl': 'text-3xl', // 1.875rem (30px)
|
|
20
|
+
'4xl': 'text-4xl', // 2.25rem (36px)
|
|
21
|
+
'5xl': 'text-5xl', // 3rem (48px)
|
|
22
|
+
'6xl': 'text-6xl', // 3.75rem (60px)
|
|
23
|
+
'7xl': 'text-7xl', // 4.5rem (72px)
|
|
24
|
+
'8xl': 'text-8xl', // 6rem (96px)
|
|
25
|
+
'9xl': 'text-9xl', // 8rem (128px)
|
|
26
|
+
} as const;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Type for text size keys
|
|
30
|
+
*/
|
|
31
|
+
export type TextSizeKey = keyof typeof TEXT_SIZES;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Type for text size values
|
|
35
|
+
*/
|
|
36
|
+
export type TextSize = typeof TEXT_SIZES[TextSizeKey];
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Font weight utilities
|
|
40
|
+
*/
|
|
41
|
+
export const FONT_WEIGHTS = {
|
|
42
|
+
thin: 'font-thin', // 100
|
|
43
|
+
extralight: 'font-extralight', // 200
|
|
44
|
+
light: 'font-light', // 300
|
|
45
|
+
normal: 'font-normal', // 400
|
|
46
|
+
medium: 'font-medium', // 500
|
|
47
|
+
semibold: 'font-semibold', // 600
|
|
48
|
+
bold: 'font-bold', // 700
|
|
49
|
+
extrabold: 'font-extrabold', // 800
|
|
50
|
+
black: 'font-black', // 900
|
|
51
|
+
} as const;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Type for font weight keys
|
|
55
|
+
*/
|
|
56
|
+
export type FontWeightKey = keyof typeof FONT_WEIGHTS;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Type for font weight values
|
|
60
|
+
*/
|
|
61
|
+
export type FontWeight = typeof FONT_WEIGHTS[FontWeightKey];
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Common text sizes for different element types
|
|
65
|
+
*/
|
|
66
|
+
export const COMMON_TEXT_SIZES = {
|
|
67
|
+
caption: TEXT_SIZES.xs,
|
|
68
|
+
small: TEXT_SIZES.sm,
|
|
69
|
+
body: TEXT_SIZES.base,
|
|
70
|
+
subtitle: TEXT_SIZES.lg,
|
|
71
|
+
title: TEXT_SIZES.xl,
|
|
72
|
+
heading: TEXT_SIZES['2xl'],
|
|
73
|
+
display: TEXT_SIZES['4xl'],
|
|
74
|
+
} as const;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Text sizes by size variant
|
|
78
|
+
* Maps size variants to appropriate text sizes
|
|
79
|
+
*/
|
|
80
|
+
export const TEXT_SIZE_BY_VARIANT = {
|
|
81
|
+
xs: {
|
|
82
|
+
mobile: TEXT_SIZES.xs,
|
|
83
|
+
tablet: TEXT_SIZES.xs,
|
|
84
|
+
},
|
|
85
|
+
sm: {
|
|
86
|
+
mobile: TEXT_SIZES.xs,
|
|
87
|
+
tablet: TEXT_SIZES.sm,
|
|
88
|
+
},
|
|
89
|
+
md: {
|
|
90
|
+
mobile: TEXT_SIZES.sm,
|
|
91
|
+
tablet: TEXT_SIZES.base,
|
|
92
|
+
},
|
|
93
|
+
lg: {
|
|
94
|
+
mobile: TEXT_SIZES.base,
|
|
95
|
+
tablet: TEXT_SIZES.lg,
|
|
96
|
+
},
|
|
97
|
+
xl: {
|
|
98
|
+
mobile: TEXT_SIZES.lg,
|
|
99
|
+
tablet: TEXT_SIZES.xl,
|
|
100
|
+
},
|
|
101
|
+
} as const;
|