@rakeyshgidwani/roger-ui-bank-theme-stan-design 0.1.3 → 0.1.5
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/CHANGELOG.md +1 -1
- package/dist/index.d.ts +131 -131
- package/dist/index.esm.js +148 -148
- package/dist/index.js +148 -148
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- package/src/components/ui/accessibility-demo.tsx +271 -0
- package/src/components/ui/advanced-component-architecture-demo.tsx +916 -0
- package/src/components/ui/advanced-transition-system-demo.tsx +670 -0
- package/src/components/ui/advanced-transition-system.tsx +395 -0
- package/src/components/ui/animation/animated-container.tsx +166 -0
- package/src/components/ui/animation/index.ts +19 -0
- package/src/components/ui/animation/staggered-container.tsx +68 -0
- package/src/components/ui/animation-demo.tsx +250 -0
- package/src/components/ui/badge.tsx +33 -0
- package/src/components/ui/battery-conscious-animation-demo.tsx +568 -0
- package/src/components/ui/border-radius-shadow-demo.tsx +187 -0
- package/src/components/ui/button.tsx +36 -0
- package/src/components/ui/card.tsx +207 -0
- package/src/components/ui/checkbox.tsx +30 -0
- package/src/components/ui/color-preview.tsx +411 -0
- package/src/components/ui/data-display/chart.tsx +653 -0
- package/src/components/ui/data-display/data-grid-simple.tsx +76 -0
- package/src/components/ui/data-display/data-grid.tsx +680 -0
- package/src/components/ui/data-display/list.tsx +456 -0
- package/src/components/ui/data-display/table.tsx +482 -0
- package/src/components/ui/data-display/timeline.tsx +441 -0
- package/src/components/ui/data-display/tree.tsx +602 -0
- package/src/components/ui/data-display/types.ts +536 -0
- package/src/components/ui/enterprise-mobile-experience-demo.tsx +749 -0
- package/src/components/ui/enterprise-mobile-experience.tsx +464 -0
- package/src/components/ui/feedback/alert.tsx +157 -0
- package/src/components/ui/feedback/progress.tsx +292 -0
- package/src/components/ui/feedback/skeleton.tsx +185 -0
- package/src/components/ui/feedback/toast.tsx +280 -0
- package/src/components/ui/feedback/types.ts +125 -0
- package/src/components/ui/font-preview.tsx +288 -0
- package/src/components/ui/form-demo.tsx +553 -0
- package/src/components/ui/hardware-acceleration-demo.tsx +547 -0
- package/src/components/ui/input.tsx +35 -0
- package/src/components/ui/label.tsx +16 -0
- package/src/components/ui/layout-demo.tsx +367 -0
- package/src/components/ui/layouts/adaptive-layout.tsx +139 -0
- package/src/components/ui/layouts/desktop-layout.tsx +224 -0
- package/src/components/ui/layouts/index.ts +10 -0
- package/src/components/ui/layouts/mobile-layout.tsx +162 -0
- package/src/components/ui/layouts/tablet-layout.tsx +197 -0
- package/src/components/ui/mobile-form-validation.tsx +451 -0
- package/src/components/ui/mobile-input-demo.tsx +201 -0
- package/src/components/ui/mobile-input.tsx +281 -0
- package/src/components/ui/mobile-skeleton-loading-demo.tsx +638 -0
- package/src/components/ui/navigation/breadcrumb.tsx +158 -0
- package/src/components/ui/navigation/index.ts +36 -0
- package/src/components/ui/navigation/menu.tsx +374 -0
- package/src/components/ui/navigation/navigation-demo.tsx +324 -0
- package/src/components/ui/navigation/pagination.tsx +272 -0
- package/src/components/ui/navigation/sidebar.tsx +383 -0
- package/src/components/ui/navigation/stepper.tsx +303 -0
- package/src/components/ui/navigation/tabs.tsx +205 -0
- package/src/components/ui/navigation/types.ts +299 -0
- package/src/components/ui/overlay/backdrop.tsx +81 -0
- package/src/components/ui/overlay/focus-manager.tsx +143 -0
- package/src/components/ui/overlay/index.ts +36 -0
- package/src/components/ui/overlay/modal.tsx +270 -0
- package/src/components/ui/overlay/overlay-manager.tsx +110 -0
- package/src/components/ui/overlay/popover.tsx +462 -0
- package/src/components/ui/overlay/portal.tsx +79 -0
- package/src/components/ui/overlay/tooltip.tsx +303 -0
- package/src/components/ui/overlay/types.ts +196 -0
- package/src/components/ui/performance-demo.tsx +596 -0
- package/src/components/ui/semantic-input-system-demo.tsx +502 -0
- package/src/components/ui/semantic-input-system-demo.tsx.disabled +873 -0
- package/src/components/ui/tablet-layout.tsx +192 -0
- package/src/components/ui/theme-customizer.tsx +386 -0
- package/src/components/ui/theme-preview.tsx +310 -0
- package/src/components/ui/theme-switcher.tsx +264 -0
- package/src/components/ui/theme-toggle.tsx +38 -0
- package/src/components/ui/token-demo.tsx +195 -0
- package/src/components/ui/touch-demo.tsx +462 -0
- package/src/components/ui/touch-friendly-interface-demo.tsx +519 -0
- package/src/components/ui/touch-friendly-interface.tsx +296 -0
- package/src/hooks/index.ts +190 -0
- package/src/hooks/use-accessibility-support.ts +518 -0
- package/src/hooks/use-adaptive-layout.ts +289 -0
- package/src/hooks/use-advanced-patterns.ts +294 -0
- package/src/hooks/use-advanced-transition-system.ts +393 -0
- package/src/hooks/use-animation-profile.ts +288 -0
- package/src/hooks/use-battery-animations.ts +384 -0
- package/src/hooks/use-battery-conscious-loading.ts +475 -0
- package/src/hooks/use-battery-optimization.ts +330 -0
- package/src/hooks/use-battery-status.ts +299 -0
- package/src/hooks/use-component-performance.ts +344 -0
- package/src/hooks/use-device-loading-states.ts +459 -0
- package/src/hooks/use-device.tsx +110 -0
- package/src/hooks/use-enterprise-mobile-experience.ts +488 -0
- package/src/hooks/use-form-feedback.ts +403 -0
- package/src/hooks/use-form-performance.ts +513 -0
- package/src/hooks/use-frame-rate.ts +251 -0
- package/src/hooks/use-gestures.ts +338 -0
- package/src/hooks/use-hardware-acceleration.ts +341 -0
- package/src/hooks/use-input-accessibility.ts +455 -0
- package/src/hooks/use-input-performance.ts +506 -0
- package/src/hooks/use-layout-performance.ts +319 -0
- package/src/hooks/use-loading-accessibility.ts +535 -0
- package/src/hooks/use-loading-performance.ts +473 -0
- package/src/hooks/use-memory-usage.ts +287 -0
- package/src/hooks/use-mobile-form-layout.ts +464 -0
- package/src/hooks/use-mobile-form-validation.ts +518 -0
- package/src/hooks/use-mobile-keyboard-optimization.ts +472 -0
- package/src/hooks/use-mobile-layout.ts +302 -0
- package/src/hooks/use-mobile-optimization.ts +406 -0
- package/src/hooks/use-mobile-skeleton.ts +402 -0
- package/src/hooks/use-mobile-touch.ts +414 -0
- package/src/hooks/use-performance-throttling.ts +348 -0
- package/src/hooks/use-performance.ts +316 -0
- package/src/hooks/use-reusable-architecture.ts +414 -0
- package/src/hooks/use-semantic-input-types.ts +357 -0
- package/src/hooks/use-semantic-input.ts +565 -0
- package/src/hooks/use-tablet-layout.ts +384 -0
- package/src/hooks/use-touch-friendly-input.ts +524 -0
- package/src/hooks/use-touch-friendly-interface.ts +331 -0
- package/src/hooks/use-touch-optimization.ts +375 -0
- package/src/index.ts +279 -279
- package/src/lib/utils.ts +6 -0
- package/src/themes/README.md +272 -0
- package/src/themes/ThemeContext.tsx +31 -0
- package/src/themes/ThemeProvider.tsx +232 -0
- package/src/themes/accessibility/index.ts +27 -0
- package/src/themes/accessibility.ts +259 -0
- package/src/themes/aria-patterns.ts +420 -0
- package/src/themes/base-themes.ts +55 -0
- package/src/themes/colorManager.ts +380 -0
- package/src/themes/examples/dark-theme.ts +154 -0
- package/src/themes/examples/minimal-theme.ts +108 -0
- package/src/themes/focus-management.ts +701 -0
- package/src/themes/fontLoader.ts +201 -0
- package/src/themes/high-contrast.ts +621 -0
- package/src/themes/index.ts +19 -0
- package/src/themes/inheritance.ts +227 -0
- package/src/themes/keyboard-navigation.ts +550 -0
- package/src/themes/motion-reduction.ts +662 -0
- package/src/themes/navigation.ts +238 -0
- package/src/themes/screen-reader.ts +645 -0
- package/src/themes/systemThemeDetector.ts +182 -0
- package/src/themes/themeCSSUpdater.ts +262 -0
- package/src/themes/themePersistence.ts +238 -0
- package/src/themes/themes/default.ts +586 -0
- package/src/themes/themes/harvey.ts +554 -0
- package/src/themes/themes/stan-design.ts +683 -0
- package/src/themes/types.ts +460 -0
- package/src/themes/useSystemTheme.ts +48 -0
- package/src/themes/useTheme.ts +87 -0
- package/src/themes/validation.ts +462 -0
- package/src/tokens/index.ts +34 -0
- package/src/tokens/tokenExporter.ts +397 -0
- package/src/tokens/tokenGenerator.ts +276 -0
- package/src/tokens/tokenManager.ts +248 -0
- package/src/tokens/tokenValidator.ts +543 -0
- package/src/tokens/types.ts +78 -0
- package/src/utils/bundle-analyzer.ts +260 -0
- package/src/utils/bundle-splitting.ts +483 -0
- package/src/utils/lazy-loading.ts +441 -0
- package/src/utils/performance-monitor.ts +513 -0
- package/src/utils/tree-shaking.ts +274 -0
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import { useTheme } from '../../../themes/useTheme';
|
|
3
|
+
import { ProgressProps, ProgressStep } from './types';
|
|
4
|
+
|
|
5
|
+
// Default color fallbacks for when theme is not available
|
|
6
|
+
const getDefaultColors = () => ({
|
|
7
|
+
surface: { background: '#ffffff', surface: '#f3f4f6', border: '#d1d5db', divider: '#e5e7eb' },
|
|
8
|
+
text: { primary: '#111827', secondary: '#6b7280', muted: '#9ca3af', inverse: '#ffffff', onPrimary: '#ffffff', onSecondary: '#ffffff', onSurface: '#111827' },
|
|
9
|
+
interactive: { hover: '#f3f4f6', active: '#e5e7eb', focus: '#3b82f6', disabled: '#d1d5db' },
|
|
10
|
+
primary: { 500: '#3b82f6' },
|
|
11
|
+
semantic: { success: '#10b981', warning: '#f59e0b', error: '#ef4444', info: '#3b82f6' }
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
// Linear Progress Component
|
|
15
|
+
const LinearProgress: React.FC<ProgressProps> = ({
|
|
16
|
+
value,
|
|
17
|
+
max = 100,
|
|
18
|
+
min = 0,
|
|
19
|
+
animated = true,
|
|
20
|
+
striped = false,
|
|
21
|
+
color,
|
|
22
|
+
size = 'md',
|
|
23
|
+
className = ''
|
|
24
|
+
}) => {
|
|
25
|
+
// Note: theme and colors not needed as we're using semantic CSS classes
|
|
26
|
+
|
|
27
|
+
const percentage = Math.min(Math.max(((value - min) / (max - min)) * 100, 0), 100);
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<div className={`progress__container progress__container--${size} ${className}`}>
|
|
31
|
+
<div
|
|
32
|
+
className={`progress__bar ${animated ? 'progress__bar--animated' : ''} ${striped ? 'progress__bar--striped' : ''} ${color ? `progress__bar--${color}` : ''}`}
|
|
33
|
+
style={{ width: `${percentage}%` }}
|
|
34
|
+
/>
|
|
35
|
+
</div>
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// Circular Progress Component
|
|
40
|
+
const CircularProgress: React.FC<ProgressProps> = ({
|
|
41
|
+
value,
|
|
42
|
+
max = 100,
|
|
43
|
+
min = 0,
|
|
44
|
+
animated = true,
|
|
45
|
+
color,
|
|
46
|
+
size = 'md',
|
|
47
|
+
thickness = 4,
|
|
48
|
+
trackColor,
|
|
49
|
+
progressColor,
|
|
50
|
+
className = ''
|
|
51
|
+
}) => {
|
|
52
|
+
const { getTheme } = useTheme();
|
|
53
|
+
const themeConfig = getTheme('stan-design');
|
|
54
|
+
const colors = themeConfig?.colors || getDefaultColors();
|
|
55
|
+
|
|
56
|
+
const percentage = Math.min(Math.max(((value - min) / (max - min)) * 100, 0), 100);
|
|
57
|
+
const radius = 50 - (thickness / 2);
|
|
58
|
+
const circumference = 2 * Math.PI * radius;
|
|
59
|
+
const strokeDasharray = circumference;
|
|
60
|
+
const strokeDashoffset = circumference - (percentage / 100) * circumference;
|
|
61
|
+
|
|
62
|
+
return (
|
|
63
|
+
<div className={`progress__circular progress__circular--${size} ${className}`}>
|
|
64
|
+
<svg className="progress__circle" viewBox="0 0 100 100">
|
|
65
|
+
{/* Track */}
|
|
66
|
+
<circle
|
|
67
|
+
cx="50"
|
|
68
|
+
cy="50"
|
|
69
|
+
r={radius}
|
|
70
|
+
className="progress__circle-track"
|
|
71
|
+
stroke={trackColor || colors.surface.border}
|
|
72
|
+
strokeWidth={thickness}
|
|
73
|
+
/>
|
|
74
|
+
{/* Progress */}
|
|
75
|
+
<circle
|
|
76
|
+
cx="50"
|
|
77
|
+
cy="50"
|
|
78
|
+
r={radius}
|
|
79
|
+
className={`progress__circle-progress ${animated ? 'progress__circle-progress--animated' : ''}`}
|
|
80
|
+
stroke={progressColor || color || colors.primary[500]}
|
|
81
|
+
strokeWidth={thickness}
|
|
82
|
+
strokeDasharray={strokeDasharray}
|
|
83
|
+
strokeDashoffset={strokeDashoffset}
|
|
84
|
+
/>
|
|
85
|
+
</svg>
|
|
86
|
+
{/* Center text */}
|
|
87
|
+
<div className="progress__circle-label">
|
|
88
|
+
{Math.round(percentage)}%
|
|
89
|
+
</div>
|
|
90
|
+
</div>
|
|
91
|
+
);
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
// Steps Progress Component
|
|
95
|
+
const StepsProgress: React.FC<ProgressProps & { steps?: ProgressStep[] }> = ({
|
|
96
|
+
steps = [],
|
|
97
|
+
className = ''
|
|
98
|
+
}) => {
|
|
99
|
+
// Note: size and colors not needed as we're using semantic CSS classes
|
|
100
|
+
|
|
101
|
+
const getStatusIcon = (status: ProgressStep['status']) => {
|
|
102
|
+
switch (status) {
|
|
103
|
+
case 'completed':
|
|
104
|
+
return (
|
|
105
|
+
<svg className="progress__step-icon" fill="currentColor" viewBox="0 0 20 20">
|
|
106
|
+
<path fillRule="evenodd" d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z" clipRule="evenodd" />
|
|
107
|
+
</svg>
|
|
108
|
+
);
|
|
109
|
+
case 'active':
|
|
110
|
+
return (
|
|
111
|
+
<svg className="progress__step-icon" fill="currentColor" viewBox="0 0 20 20">
|
|
112
|
+
<path fillRule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm1-12a1 1 0 10-2 0v4a1 1 0 00.293.707l2.828 2.829a1 1 0 101.415-1.415L11 9.586V6z" clipRule="evenodd" />
|
|
113
|
+
</svg>
|
|
114
|
+
);
|
|
115
|
+
case 'error':
|
|
116
|
+
return (
|
|
117
|
+
<svg className="progress__step-icon" fill="currentColor" viewBox="0 0 20 20">
|
|
118
|
+
<path fillRule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z" clipRule="evenodd" />
|
|
119
|
+
</svg>
|
|
120
|
+
);
|
|
121
|
+
case 'pending':
|
|
122
|
+
default:
|
|
123
|
+
return (
|
|
124
|
+
<svg className="progress__step-icon" fill="currentColor" viewBox="0 0 20 20">
|
|
125
|
+
<path fillRule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm1-12a1 1 0 10-2 0v4a1 1 0 00.293.707l2.828 2.829a1 1 0 101.415-1.415L11 9.586V6z" clipRule="evenodd" />
|
|
126
|
+
</svg>
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
if (steps.length === 0) {
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return (
|
|
136
|
+
<div className={`progress__steps ${className}`}>
|
|
137
|
+
{steps.map((step, index) => (
|
|
138
|
+
<div key={index} className="progress__step">
|
|
139
|
+
{/* Step indicator */}
|
|
140
|
+
<div
|
|
141
|
+
className={`progress__step-indicator progress__step-indicator--${step.status}`}
|
|
142
|
+
>
|
|
143
|
+
{getStatusIcon(step.status)}
|
|
144
|
+
</div>
|
|
145
|
+
|
|
146
|
+
{/* Step connector */}
|
|
147
|
+
{index < steps.length - 1 && (
|
|
148
|
+
<div
|
|
149
|
+
className={`progress__step-connector ${step.status === 'completed' ? 'progress__step-connector--completed' : ''}`}
|
|
150
|
+
/>
|
|
151
|
+
)}
|
|
152
|
+
|
|
153
|
+
{/* Step label */}
|
|
154
|
+
<div className={`progress__step-label progress__step-label--${step.status}`}>
|
|
155
|
+
<div className="progress__step-title">
|
|
156
|
+
{step.label}
|
|
157
|
+
</div>
|
|
158
|
+
{step.description && (
|
|
159
|
+
<div className="progress__step-description">
|
|
160
|
+
{step.description}
|
|
161
|
+
</div>
|
|
162
|
+
)}
|
|
163
|
+
</div>
|
|
164
|
+
</div>
|
|
165
|
+
))}
|
|
166
|
+
</div>
|
|
167
|
+
);
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
// Main Progress Component
|
|
171
|
+
export const Progress: React.FC<ProgressProps> = ({
|
|
172
|
+
value,
|
|
173
|
+
max = 100,
|
|
174
|
+
min = 0,
|
|
175
|
+
label,
|
|
176
|
+
showLabel = false,
|
|
177
|
+
showValue = false,
|
|
178
|
+
showPercentage = false,
|
|
179
|
+
animated = true,
|
|
180
|
+
striped = false,
|
|
181
|
+
color,
|
|
182
|
+
size = 'md',
|
|
183
|
+
variant = 'linear',
|
|
184
|
+
thickness,
|
|
185
|
+
trackColor,
|
|
186
|
+
progressColor,
|
|
187
|
+
indeterminate = false,
|
|
188
|
+
onComplete,
|
|
189
|
+
className = '',
|
|
190
|
+
theme = 'stan-design'
|
|
191
|
+
}) => {
|
|
192
|
+
const { getTheme } = useTheme();
|
|
193
|
+
const themeConfig = getTheme(theme);
|
|
194
|
+
const colors = themeConfig?.colors || getDefaultColors();
|
|
195
|
+
|
|
196
|
+
const [currentValue, setCurrentValue] = useState(value);
|
|
197
|
+
|
|
198
|
+
useEffect(() => {
|
|
199
|
+
setCurrentValue(value);
|
|
200
|
+
|
|
201
|
+
if (value >= max && onComplete) {
|
|
202
|
+
onComplete();
|
|
203
|
+
}
|
|
204
|
+
}, [value, max, onComplete]);
|
|
205
|
+
|
|
206
|
+
useEffect(() => {
|
|
207
|
+
if (indeterminate) {
|
|
208
|
+
const interval = setInterval(() => {
|
|
209
|
+
setCurrentValue(prev => {
|
|
210
|
+
if (prev >= max) return min;
|
|
211
|
+
return prev + (max - min) / 20;
|
|
212
|
+
});
|
|
213
|
+
}, 100);
|
|
214
|
+
|
|
215
|
+
return () => clearInterval(interval);
|
|
216
|
+
}
|
|
217
|
+
}, [indeterminate, min, max]);
|
|
218
|
+
|
|
219
|
+
const renderProgress = () => {
|
|
220
|
+
switch (variant) {
|
|
221
|
+
case 'circular':
|
|
222
|
+
return (
|
|
223
|
+
<CircularProgress
|
|
224
|
+
value={currentValue}
|
|
225
|
+
max={max}
|
|
226
|
+
min={min}
|
|
227
|
+
animated={animated}
|
|
228
|
+
color={color}
|
|
229
|
+
size={size}
|
|
230
|
+
thickness={thickness}
|
|
231
|
+
trackColor={trackColor}
|
|
232
|
+
progressColor={progressColor}
|
|
233
|
+
className={className}
|
|
234
|
+
/>
|
|
235
|
+
);
|
|
236
|
+
case 'steps':
|
|
237
|
+
return (
|
|
238
|
+
<StepsProgress
|
|
239
|
+
value={currentValue}
|
|
240
|
+
max={max}
|
|
241
|
+
min={min}
|
|
242
|
+
size={size}
|
|
243
|
+
className={className}
|
|
244
|
+
/>
|
|
245
|
+
);
|
|
246
|
+
case 'linear':
|
|
247
|
+
default:
|
|
248
|
+
return (
|
|
249
|
+
<LinearProgress
|
|
250
|
+
value={currentValue}
|
|
251
|
+
max={max}
|
|
252
|
+
min={min}
|
|
253
|
+
animated={animated}
|
|
254
|
+
striped={striped}
|
|
255
|
+
color={color}
|
|
256
|
+
size={size}
|
|
257
|
+
thickness={thickness}
|
|
258
|
+
trackColor={trackColor}
|
|
259
|
+
progressColor={progressColor}
|
|
260
|
+
className={className}
|
|
261
|
+
/>
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
return (
|
|
267
|
+
<div className="w-full">
|
|
268
|
+
{/* Label and Value Display */}
|
|
269
|
+
{(showLabel || showValue || showPercentage) && (
|
|
270
|
+
<div className="flex justify-between items-center mb-2">
|
|
271
|
+
{showLabel && label && (
|
|
272
|
+
<span className="text-sm font-medium" style={{ color: colors.text.primary }}>
|
|
273
|
+
{label}
|
|
274
|
+
</span>
|
|
275
|
+
)}
|
|
276
|
+
{(showValue || showPercentage) && (
|
|
277
|
+
<span className="text-sm" style={{ color: colors.text.secondary }}>
|
|
278
|
+
{showValue && `${currentValue}/${max}`}
|
|
279
|
+
{showValue && showPercentage && ' - '}
|
|
280
|
+
{showPercentage && `${Math.round(((currentValue - min) / (max - min)) * 100)}%`}
|
|
281
|
+
</span>
|
|
282
|
+
)}
|
|
283
|
+
</div>
|
|
284
|
+
)}
|
|
285
|
+
|
|
286
|
+
{/* Progress Component */}
|
|
287
|
+
{renderProgress()}
|
|
288
|
+
</div>
|
|
289
|
+
);
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
export default Progress;
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SkeletonProps, SkeletonTextProps, SkeletonAvatarProps, SkeletonButtonProps } from './types';
|
|
3
|
+
|
|
4
|
+
// Base Skeleton Component
|
|
5
|
+
const BaseSkeleton: React.FC<SkeletonProps> = ({
|
|
6
|
+
width,
|
|
7
|
+
height,
|
|
8
|
+
variant = 'rectangular',
|
|
9
|
+
animation = 'pulse',
|
|
10
|
+
className = '',
|
|
11
|
+
size = 'md'
|
|
12
|
+
}) => {
|
|
13
|
+
// Note: theme and colors not needed as we're using semantic CSS classes
|
|
14
|
+
|
|
15
|
+
const getDefaultDimensions = () => {
|
|
16
|
+
if (width && height) return { width, height };
|
|
17
|
+
|
|
18
|
+
switch (variant) {
|
|
19
|
+
case 'circular':
|
|
20
|
+
switch (size) {
|
|
21
|
+
case 'sm': return { width: '2rem', height: '2rem' };
|
|
22
|
+
case 'lg': return { width: '4rem', height: '4rem' };
|
|
23
|
+
default: return { width: '3rem', height: '3rem' };
|
|
24
|
+
}
|
|
25
|
+
case 'text':
|
|
26
|
+
switch (size) {
|
|
27
|
+
case 'sm': return { width: '100%', height: '0.875rem' };
|
|
28
|
+
case 'lg': return { width: '100%', height: '1.25rem' };
|
|
29
|
+
default: return { width: '100%', height: '1rem' };
|
|
30
|
+
}
|
|
31
|
+
case 'rectangular':
|
|
32
|
+
case 'rounded':
|
|
33
|
+
default:
|
|
34
|
+
switch (size) {
|
|
35
|
+
case 'sm': return { width: '100%', height: '2rem' };
|
|
36
|
+
case 'lg': return { width: '100%', height: '4rem' };
|
|
37
|
+
default: return { width: '100%', height: '3rem' };
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const dimensions = getDefaultDimensions();
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<div
|
|
46
|
+
className={`skeleton__base skeleton__base--${variant} skeleton__base--${animation} skeleton__base--${size} ${className}`}
|
|
47
|
+
style={{
|
|
48
|
+
width: dimensions.width,
|
|
49
|
+
height: dimensions.height
|
|
50
|
+
}}
|
|
51
|
+
aria-busy="true"
|
|
52
|
+
role="progressbar"
|
|
53
|
+
aria-label="Loading content"
|
|
54
|
+
/>
|
|
55
|
+
);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
// Skeleton Text Component
|
|
59
|
+
export const SkeletonText: React.FC<SkeletonTextProps> = ({
|
|
60
|
+
lines = 3,
|
|
61
|
+
lineHeight,
|
|
62
|
+
lastLineWidth,
|
|
63
|
+
spacing = 2,
|
|
64
|
+
className = '',
|
|
65
|
+
...props
|
|
66
|
+
}) => {
|
|
67
|
+
const getLineHeight = () => {
|
|
68
|
+
if (lineHeight) return lineHeight;
|
|
69
|
+
switch (props.size) {
|
|
70
|
+
case 'sm': return '0.875rem';
|
|
71
|
+
case 'lg': return '1.25rem';
|
|
72
|
+
default: return '1rem';
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const getLastLineWidth = () => {
|
|
77
|
+
if (lastLineWidth) return lastLineWidth;
|
|
78
|
+
return '75%';
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
return (
|
|
82
|
+
<div className={`skeleton__text skeleton__text--spacing-${spacing} ${className}`}>
|
|
83
|
+
{Array.from({ length: lines }).map((_, index) => (
|
|
84
|
+
<div
|
|
85
|
+
key={index}
|
|
86
|
+
className={`skeleton__text-line skeleton__text-line--${props.size || 'md'} skeleton__base--${props.animation || 'pulse'} ${
|
|
87
|
+
index === lines - 1 ? 'skeleton__text-line--last' : ''
|
|
88
|
+
}`}
|
|
89
|
+
style={{
|
|
90
|
+
width: index === lines - 1 ? getLastLineWidth() : '100%',
|
|
91
|
+
height: getLineHeight()
|
|
92
|
+
}}
|
|
93
|
+
aria-busy="true"
|
|
94
|
+
/>
|
|
95
|
+
))}
|
|
96
|
+
</div>
|
|
97
|
+
);
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
// Skeleton Avatar Component
|
|
101
|
+
export const SkeletonAvatar: React.FC<SkeletonAvatarProps> = ({
|
|
102
|
+
size = 'md',
|
|
103
|
+
shape = 'circular',
|
|
104
|
+
className = '',
|
|
105
|
+
...props
|
|
106
|
+
}) => {
|
|
107
|
+
return (
|
|
108
|
+
<div
|
|
109
|
+
className={`skeleton__avatar skeleton__avatar--${size} skeleton__avatar--${shape} skeleton__base--${props.animation || 'pulse'} ${className}`}
|
|
110
|
+
aria-busy="true"
|
|
111
|
+
role="progressbar"
|
|
112
|
+
aria-label="Loading avatar"
|
|
113
|
+
/>
|
|
114
|
+
);
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
// Skeleton Button Component
|
|
118
|
+
export const SkeletonButton: React.FC<SkeletonButtonProps> = ({
|
|
119
|
+
size = 'md',
|
|
120
|
+
variant = 'contained',
|
|
121
|
+
fullWidth = false,
|
|
122
|
+
className = '',
|
|
123
|
+
...props
|
|
124
|
+
}) => {
|
|
125
|
+
return (
|
|
126
|
+
<div
|
|
127
|
+
className={`skeleton__button skeleton__button--${size} skeleton__button--${variant} ${
|
|
128
|
+
fullWidth ? 'skeleton__button--full-width' : ''
|
|
129
|
+
} skeleton__base--${props.animation || 'pulse'} ${className}`}
|
|
130
|
+
aria-busy="true"
|
|
131
|
+
role="progressbar"
|
|
132
|
+
aria-label="Loading button"
|
|
133
|
+
/>
|
|
134
|
+
);
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
// Main Skeleton Component
|
|
138
|
+
export const Skeleton: React.FC<SkeletonProps> = ({
|
|
139
|
+
width,
|
|
140
|
+
height,
|
|
141
|
+
variant = 'rectangular',
|
|
142
|
+
animation = 'pulse',
|
|
143
|
+
rows = 1,
|
|
144
|
+
spacing = 2,
|
|
145
|
+
show = true,
|
|
146
|
+
className = '',
|
|
147
|
+
theme = 'stan-design',
|
|
148
|
+
size = 'md'
|
|
149
|
+
}) => {
|
|
150
|
+
if (!show) {
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (rows > 1) {
|
|
155
|
+
return (
|
|
156
|
+
<div className={`skeleton__container skeleton__container--spacing-${spacing} ${className}`}>
|
|
157
|
+
{Array.from({ length: rows }).map((_, index) => (
|
|
158
|
+
<BaseSkeleton
|
|
159
|
+
key={index}
|
|
160
|
+
width={width}
|
|
161
|
+
height={height}
|
|
162
|
+
variant={variant}
|
|
163
|
+
animation={animation}
|
|
164
|
+
size={size}
|
|
165
|
+
theme={theme}
|
|
166
|
+
/>
|
|
167
|
+
))}
|
|
168
|
+
</div>
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return (
|
|
173
|
+
<BaseSkeleton
|
|
174
|
+
width={width}
|
|
175
|
+
height={height}
|
|
176
|
+
variant={variant}
|
|
177
|
+
animation={animation}
|
|
178
|
+
size={size}
|
|
179
|
+
theme={theme}
|
|
180
|
+
className={className}
|
|
181
|
+
/>
|
|
182
|
+
);
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
export default Skeleton;
|