shadcn-glass-ui 1.0.10 → 2.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/CHANGELOG.md +259 -16
- package/README.md +248 -28
- package/context7.json +58 -0
- package/dist/cli/index.cjs +470 -0
- package/dist/cli/index.cjs.map +1 -0
- package/dist/cli/index.d.ts +18 -0
- package/dist/cli/index.js +469 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/components.cjs +4 -4
- package/dist/components.d.ts +153 -22
- package/dist/components.js +2 -2
- package/dist/hooks.cjs +2 -2
- package/dist/index.cjs +872 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +0 -2390
- package/dist/index.js +844 -3
- package/dist/index.js.map +1 -1
- package/dist/r/ai-card-glass.json +5 -12
- package/dist/r/avatar-glass.json +5 -15
- package/dist/r/circular-metric-glass.json +5 -11
- package/dist/r/circular-progress-glass.json +5 -12
- package/dist/r/combobox-glass.json +5 -13
- package/dist/r/flag-alert-glass.json +5 -11
- package/dist/r/flags-section-glass.json +5 -12
- package/dist/r/insight-card-glass.json +17 -0
- package/dist/r/interactive-card.json +5 -12
- package/dist/r/language-bar-glass.json +5 -11
- package/dist/r/metric-card-glass.json +6 -13
- package/dist/r/metrics-grid-glass.json +5 -11
- package/dist/r/modal-glass.json +5 -15
- package/dist/r/popover-glass.json +1 -1
- package/dist/r/progress-glass.json +5 -13
- package/dist/r/registry.json +20 -2
- package/dist/r/segmented-control-glass.json +5 -11
- package/dist/r/sparkline-glass.json +17 -0
- package/dist/r/stepper-glass.json +33 -0
- package/dist/r/tabs-glass.json +4 -9
- package/dist/r/trust-score-card-glass.json +5 -12
- package/dist/r/year-card-glass.json +5 -13
- package/dist/shadcn-glass-ui.css +1 -1
- package/dist/{theme-context-XtasSxRT.cjs → theme-context-CVW50BKW.cjs} +2 -2
- package/dist/{theme-context-XtasSxRT.cjs.map → theme-context-CVW50BKW.cjs.map} +1 -1
- package/dist/themes.cjs +1 -1
- package/dist/trust-score-card-glass-BcZbul0P.js +26895 -0
- package/dist/trust-score-card-glass-BcZbul0P.js.map +1 -0
- package/dist/trust-score-card-glass-r3qM09Jp.cjs +27689 -0
- package/dist/trust-score-card-glass-r3qM09Jp.cjs.map +1 -0
- package/dist/{use-focus-BbpE2qGq.cjs → use-focus-ZE8ozmZE.cjs} +2 -2
- package/dist/{use-focus-BbpE2qGq.cjs.map → use-focus-ZE8ozmZE.cjs.map} +1 -1
- package/dist/{use-wallpaper-tint-CIqtoETa.cjs → use-wallpaper-tint-BuS80tbN.cjs} +2 -2
- package/dist/{use-wallpaper-tint-CIqtoETa.cjs.map → use-wallpaper-tint-BuS80tbN.cjs.map} +1 -1
- package/dist/{utils-CGCOTvxT.js → utils-CcyeqpKQ.js} +1 -1
- package/dist/{utils-CGCOTvxT.js.map → utils-CcyeqpKQ.js.map} +1 -1
- package/dist/{utils-CriE74ig.cjs → utils-DLXayspX.cjs} +2 -2
- package/dist/{utils-CriE74ig.cjs.map → utils-DLXayspX.cjs.map} +1 -1
- package/dist/utils.cjs +1 -1
- package/dist/utils.js +1 -1
- package/docs/AI_IMPROVEMENTS_COMPLETE.md +574 -0
- package/docs/AI_USAGE.md +1328 -0
- package/docs/API_PATTERNS_COMPARISON.md +418 -0
- package/docs/BEST_PRACTICES.md +800 -0
- package/docs/COMPLIANCE_CHECKLIST.md +307 -0
- package/docs/COMPLIANCE_TESTING.md +436 -0
- package/docs/COMPONENTS_CATALOG.md +1076 -0
- package/docs/CSS_VARIABLES_AUDIT.md +306 -0
- package/docs/CSS_VARIABLES_REFACTORING_PLAN.md +330 -0
- package/docs/EXPORTS_MAP.json +875 -0
- package/docs/EXPORTS_STRUCTURE.md +729 -0
- package/docs/GETTING_STARTED.md +655 -0
- package/docs/METRIC_CARD_API_REDESIGN.md +354 -0
- package/docs/PRIMITIVE_MAPPING.md +404 -0
- package/docs/PUBLISHING.md +593 -0
- package/docs/REGISTRY_SUMMARY.md +96 -0
- package/docs/REGISTRY_USAGE.md +339 -0
- package/docs/SECURITY.md +117 -0
- package/docs/THEME_CREATION_GUIDE.md +455 -0
- package/docs/TOKEN_ARCHITECTURE.md +365 -0
- package/docs/announcements/v1.0.5-devto.md +363 -0
- package/docs/announcements/v1.0.5-reddit.md +115 -0
- package/docs/announcements/v1.0.5-twitter.md +70 -0
- package/docs/api/README.md +725 -0
- package/docs/api/functions/ThemeProvider.md +21 -0
- package/docs/api/functions/cn.md +27 -0
- package/docs/api/functions/getNextTheme.md +21 -0
- package/docs/api/functions/getThemeConfig.md +21 -0
- package/docs/api/functions/useFocus.md +53 -0
- package/docs/api/functions/useHover.md +47 -0
- package/docs/api/functions/useResponsive.md +31 -0
- package/docs/api/functions/useTheme.md +15 -0
- package/docs/api/functions/useWallpaperTint.md +36 -0
- package/docs/api/globals.md +139 -0
- package/docs/api/interfaces/AlertGlassProps.md +131 -0
- package/docs/api/interfaces/AvatarGlassProps.md +114 -0
- package/docs/api/interfaces/BadgeGlassProps.md +118 -0
- package/docs/api/interfaces/ButtonGlassProps.md +179 -0
- package/docs/api/interfaces/CheckboxGlassProps.md +125 -0
- package/docs/api/interfaces/DropdownGlassProps.md +123 -0
- package/docs/api/interfaces/DropdownItem.md +53 -0
- package/docs/api/interfaces/GlassCardProps.md +151 -0
- package/docs/api/interfaces/InputGlassProps.md +169 -0
- package/docs/api/interfaces/NotificationGlassProps.md +67 -0
- package/docs/api/interfaces/ProgressGlassProps.md +49 -0
- package/docs/api/interfaces/SkeletonGlassProps.md +41 -0
- package/docs/api/interfaces/SliderGlassProps.md +107 -0
- package/docs/api/interfaces/TabItem.md +25 -0
- package/docs/api/interfaces/ThemeConfig.md +25 -0
- package/docs/api/interfaces/ThemeContextValue.md +47 -0
- package/docs/api/interfaces/ToggleGlassProps.md +59 -0
- package/docs/api/interfaces/TooltipGlassProps.md +119 -0
- package/docs/api/type-aliases/AlertType.md +11 -0
- package/docs/api/type-aliases/AlertVariant.md +11 -0
- package/docs/api/type-aliases/AvatarSize.md +11 -0
- package/docs/api/type-aliases/AvatarStatus.md +13 -0
- package/docs/api/type-aliases/BadgeSize.md +11 -0
- package/docs/api/type-aliases/BadgeVariant.md +11 -0
- package/docs/api/type-aliases/ButtonGlassSize.md +11 -0
- package/docs/api/type-aliases/ButtonGlassVariant.md +11 -0
- package/docs/api/type-aliases/DropdownAlign.md +11 -0
- package/docs/api/type-aliases/GlowType.md +11 -0
- package/docs/api/type-aliases/InputGlassSize.md +11 -0
- package/docs/api/type-aliases/IntensityType.md +11 -0
- package/docs/api/type-aliases/ModalSize.md +11 -0
- package/docs/api/type-aliases/NotificationType.md +11 -0
- package/docs/api/type-aliases/PaddingType.md +11 -0
- package/docs/api/type-aliases/ProgressGradient.md +11 -0
- package/docs/api/type-aliases/ProgressSize.md +11 -0
- package/docs/api/type-aliases/SkeletonVariant.md +11 -0
- package/docs/api/type-aliases/Theme.md +11 -0
- package/docs/api/type-aliases/ToggleGlassSize.md +11 -0
- package/docs/api/type-aliases/TooltipPosition.md +11 -0
- package/docs/api/variables/AICardGlass.md +11 -0
- package/docs/api/variables/AlertGlass.md +11 -0
- package/docs/api/variables/AvatarGlass.md +11 -0
- package/docs/api/variables/BadgeGlass.md +11 -0
- package/docs/api/variables/BaseProgressGlass.md +11 -0
- package/docs/api/variables/ButtonGlass.md +11 -0
- package/docs/api/variables/CareerStatsGlass.md +11 -0
- package/docs/api/variables/CareerStatsHeaderGlass.md +11 -0
- package/docs/api/variables/CheckboxGlass.md +11 -0
- package/docs/api/variables/CircularMetricGlass.md +22 -0
- package/docs/api/variables/CircularProgressGlass.md +11 -0
- package/docs/api/variables/ComboBoxGlass.md +27 -0
- package/docs/api/variables/ContributionMetricsGlass.md +11 -0
- package/docs/api/variables/DropdownGlass.md +11 -0
- package/docs/api/variables/ExpandableHeaderGlass.md +11 -0
- package/docs/api/variables/FlagAlertGlass.md +11 -0
- package/docs/api/variables/FlagsSectionGlass.md +11 -0
- package/docs/api/variables/FormFieldWrapper.md +44 -0
- package/docs/api/variables/GlassCard.md +11 -0
- package/docs/api/variables/HeaderBrandingGlass.md +11 -0
- package/docs/api/variables/HeaderNavGlass.md +11 -0
- package/docs/api/variables/IconButtonGlass.md +11 -0
- package/docs/api/variables/InputGlass.md +11 -0
- package/docs/api/variables/InteractiveCard.md +45 -0
- package/docs/api/variables/LanguageBarGlass.md +11 -0
- package/docs/api/variables/MetricCardGlass.md +11 -0
- package/docs/api/variables/MetricsGridGlass.md +11 -0
- package/docs/api/variables/ModalGlass.md +72 -0
- package/docs/api/variables/NotificationGlass.md +11 -0
- package/docs/api/variables/PopoverGlass.md +11 -0
- package/docs/api/variables/ProfileAvatarGlass.md +11 -0
- package/docs/api/variables/ProfileHeaderGlass.md +11 -0
- package/docs/api/variables/ProgressGlass.md +11 -0
- package/docs/api/variables/ProjectsListGlass.md +11 -0
- package/docs/api/variables/RainbowProgressGlass.md +11 -0
- package/docs/api/variables/RepositoryCardGlass.md +11 -0
- package/docs/api/variables/RepositoryHeaderGlass.md +11 -0
- package/docs/api/variables/RepositoryMetadataGlass.md +11 -0
- package/docs/api/variables/SearchBoxGlass.md +11 -0
- package/docs/api/variables/SegmentedControlGlass.md +11 -0
- package/docs/api/variables/SkeletonGlass.md +11 -0
- package/docs/api/variables/SliderGlass.md +11 -0
- package/docs/api/variables/SortDropdownGlass.md +11 -0
- package/docs/api/variables/StatItemGlass.md +11 -0
- package/docs/api/variables/StatusIndicatorGlass.md +11 -0
- package/docs/api/variables/THEMES.md +11 -0
- package/docs/api/variables/THEME_CONFIG.md +11 -0
- package/docs/api/variables/TabsGlass.md +52 -0
- package/docs/api/variables/ThemeToggleGlass.md +11 -0
- package/docs/api/variables/ToggleGlass.md +11 -0
- package/docs/api/variables/TooltipGlass.md +11 -0
- package/docs/api/variables/TouchTarget.md +35 -0
- package/docs/api/variables/TrustScoreCardGlass.md +11 -0
- package/docs/api/variables/TrustScoreDisplayGlass.md +11 -0
- package/docs/api/variables/UserInfoGlass.md +11 -0
- package/docs/api/variables/UserStatsLineGlass.md +11 -0
- package/docs/api/variables/YearCardGlass.md +11 -0
- package/docs/api/variables/alertVariants.md +21 -0
- package/docs/api/variables/avatarSizes.md +21 -0
- package/docs/api/variables/badgeVariants.md +21 -0
- package/docs/api/variables/buttonGlassVariants.md +21 -0
- package/docs/api/variables/cardIntensity.md +21 -0
- package/docs/api/variables/dropdownAlign.md +21 -0
- package/docs/api/variables/inputVariants.md +21 -0
- package/docs/api/variables/modalSizes.md +21 -0
- package/docs/api/variables/notificationVariants.md +21 -0
- package/docs/api/variables/progressSizes.md +21 -0
- package/docs/api/variables/shadcnAlertVariants.md +21 -0
- package/docs/api/variables/shadcnBadgeVariants.md +21 -0
- package/docs/api/variables/shadcnButtonVariants.md +21 -0
- package/docs/api/variables/skeletonVariants.md +21 -0
- package/docs/api/variables/statusSizes.md +21 -0
- package/docs/api/variables/toggleSizes.md +21 -0
- package/docs/api/variables/tooltipPositions.md +21 -0
- package/docs/design-system/UI_DESIGN.md +628 -0
- package/docs/migration/CSS_VARIABLES_MIGRATION_2.0.md +325 -0
- package/docs/migration/modal-glass-compound-api.md +458 -0
- package/docs/migration/select-to-combobox.md +386 -0
- package/docs/migration/tabs-glass-compound-api.md +579 -0
- package/docs/technical/DEPENDENCIES.md +291 -0
- package/docs/visual-testing-guide.md +324 -0
- package/package.json +16 -3
- package/dist/trust-score-card-glass-CNcQveNY.cjs +0 -8231
- package/dist/trust-score-card-glass-CNcQveNY.cjs.map +0 -1
- package/dist/trust-score-card-glass-CowcDyxH.js +0 -7795
- package/dist/trust-score-card-glass-CowcDyxH.js.map +0 -1
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
# MetricCardGlass API Redesign
|
|
2
|
+
|
|
3
|
+
## Goal
|
|
4
|
+
|
|
5
|
+
Make `MetricCardGlass` fully compatible with **shadcn/ui patterns** and **consistent** with other
|
|
6
|
+
Glass UI library components.
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## 📋 Analysis of Existing Glass UI Patterns
|
|
11
|
+
|
|
12
|
+
### 1. Variant System Pattern
|
|
13
|
+
|
|
14
|
+
All components follow a unified variant system:
|
|
15
|
+
|
|
16
|
+
#### AlertGlass
|
|
17
|
+
|
|
18
|
+
```tsx
|
|
19
|
+
variant?: 'default' | 'destructive' | 'success' | 'warning'
|
|
20
|
+
// ^^^^^^^^ ^^^^^^^^^^^^ shadcn/ui compatible
|
|
21
|
+
// ^^^^^^^^ ^^^^^^^^ Glass UI extensions
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
#### BadgeGlass
|
|
25
|
+
|
|
26
|
+
```tsx
|
|
27
|
+
variant?: 'default' | 'secondary' | 'destructive' | 'outline' | 'success' | 'warning' | 'info'
|
|
28
|
+
// ^^^^^^^^ ^^^^^^^^^^^ ^^^^^^^^^^^^ ^^^^^^^^^ shadcn/ui
|
|
29
|
+
// ^^^^^^^^ ^^^^^^^^ ^^^^^ Glass UI
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
#### ButtonGlass
|
|
33
|
+
|
|
34
|
+
```tsx
|
|
35
|
+
variant?: 'primary' | 'secondary' | 'ghost' | 'destructive' | 'success' | 'text'
|
|
36
|
+
// ^^^^^^^^ ^^^^^^^^^^^ ^^^^^^ ^^^^^^^^^^^^^ shadcn/ui-like
|
|
37
|
+
// ^^^^^^^^^ Glass UI
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
**Conclusion:** Uses `variant` prop with base shadcn/ui variants + extensions.
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
### 2. CSS Variables Pattern
|
|
45
|
+
|
|
46
|
+
All components use CSS variables for styling:
|
|
47
|
+
|
|
48
|
+
```tsx
|
|
49
|
+
// AlertGlass
|
|
50
|
+
const variantStyles: Record<AlertVariant, AlertStyleVars> = {
|
|
51
|
+
default: {
|
|
52
|
+
bg: 'var(--alert-default-bg)',
|
|
53
|
+
border: 'var(--alert-default-border)',
|
|
54
|
+
text: 'var(--alert-default-text)',
|
|
55
|
+
},
|
|
56
|
+
destructive: { ... },
|
|
57
|
+
success: { ... },
|
|
58
|
+
};
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
**Conclusion:** Each variant has corresponding CSS variables in the format
|
|
62
|
+
`--component-variant-property`.
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
### 3. Props Interface Pattern
|
|
67
|
+
|
|
68
|
+
Standard structure:
|
|
69
|
+
|
|
70
|
+
```tsx
|
|
71
|
+
export interface ComponentProps
|
|
72
|
+
extends React.HTMLAttributes<HTMLDivElement>, VariantProps<typeof componentVariants> {
|
|
73
|
+
// Required props
|
|
74
|
+
readonly label: string;
|
|
75
|
+
readonly value: string | number;
|
|
76
|
+
|
|
77
|
+
// Optional extensions
|
|
78
|
+
readonly icon?: ReactNode;
|
|
79
|
+
readonly variant?: Variant;
|
|
80
|
+
readonly size?: Size;
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
**Conclusion:** Uses `readonly`, extends `HTMLAttributes`, integrates with CVA
|
|
85
|
+
(class-variance-authority).
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## 🔍 Analysis of Current MetricCardGlass API
|
|
90
|
+
|
|
91
|
+
### Problems:
|
|
92
|
+
|
|
93
|
+
1. **❌ No `variant` system**
|
|
94
|
+
- Uses custom `color` instead of standard `variant`
|
|
95
|
+
- Colors: `'emerald' | 'amber' | 'blue' | 'red'` don't match shadcn/ui
|
|
96
|
+
|
|
97
|
+
2. **❌ Complex data model**
|
|
98
|
+
- `value` as percentage 0-100 + `valueFormatter` - unintuitive
|
|
99
|
+
- Requires math for displaying real values
|
|
100
|
+
|
|
101
|
+
3. **❌ Incompatible with shadcn/ui**
|
|
102
|
+
- Uses `label` instead of standard `title` from shadcn/ui Card
|
|
103
|
+
- No `description` support
|
|
104
|
+
|
|
105
|
+
4. **❌ `trend` object too complex**
|
|
106
|
+
- Requires `{ value: number, direction: 'up' | 'down', label?: string }`
|
|
107
|
+
- shadcn/ui typically uses a simple `change` string
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## ✅ Proposed Solution
|
|
112
|
+
|
|
113
|
+
### New API (v2.0)
|
|
114
|
+
|
|
115
|
+
```tsx
|
|
116
|
+
// ========================================
|
|
117
|
+
// TYPES
|
|
118
|
+
// ========================================
|
|
119
|
+
|
|
120
|
+
export type MetricVariant =
|
|
121
|
+
| 'default' // shadcn/ui base
|
|
122
|
+
| 'secondary' // shadcn/ui base
|
|
123
|
+
| 'success' // Glass UI extension
|
|
124
|
+
| 'warning' // Glass UI extension
|
|
125
|
+
| 'destructive'; // shadcn/ui base
|
|
126
|
+
|
|
127
|
+
export type TrendDirection = 'up' | 'down' | 'neutral';
|
|
128
|
+
|
|
129
|
+
export interface MetricChange {
|
|
130
|
+
/** Change value (e.g., 12.5 for +12.5%) */
|
|
131
|
+
readonly value: number;
|
|
132
|
+
/** Trend direction */
|
|
133
|
+
readonly direction?: TrendDirection;
|
|
134
|
+
/** Optional period label (e.g., "vs last month") */
|
|
135
|
+
readonly period?: string;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export interface MetricCardGlassProps
|
|
139
|
+
extends React.HTMLAttributes<HTMLDivElement>, VariantProps<typeof metricCardVariants> {
|
|
140
|
+
// ========================================
|
|
141
|
+
// CORE PROPS (shadcn/ui compatible)
|
|
142
|
+
// ========================================
|
|
143
|
+
|
|
144
|
+
/** Metric title (shadcn/ui Card: title) */
|
|
145
|
+
readonly title: string;
|
|
146
|
+
|
|
147
|
+
/** Display value (shadcn/ui Card: value) */
|
|
148
|
+
readonly value: string | number;
|
|
149
|
+
|
|
150
|
+
/** Optional description (shadcn/ui Card: description) */
|
|
151
|
+
readonly description?: string;
|
|
152
|
+
|
|
153
|
+
/** Change indicator (shadcn/ui: change) */
|
|
154
|
+
readonly change?: string | number | MetricChange;
|
|
155
|
+
|
|
156
|
+
/** Semantic variant (shadcn/ui: variant) */
|
|
157
|
+
readonly variant?: MetricVariant;
|
|
158
|
+
|
|
159
|
+
// ========================================
|
|
160
|
+
// GLASS UI EXTENSIONS
|
|
161
|
+
// ========================================
|
|
162
|
+
|
|
163
|
+
/** Icon to display */
|
|
164
|
+
readonly icon?: ReactNode;
|
|
165
|
+
|
|
166
|
+
/** Data for sparkline visualization */
|
|
167
|
+
readonly sparklineData?: readonly number[];
|
|
168
|
+
|
|
169
|
+
/** Show sparkline chart */
|
|
170
|
+
readonly showSparkline?: boolean;
|
|
171
|
+
|
|
172
|
+
/** Show progress bar (value must be 0-100) */
|
|
173
|
+
readonly showProgress?: boolean;
|
|
174
|
+
|
|
175
|
+
/** Progress percentage (0-100, separate from display value) */
|
|
176
|
+
readonly progress?: number;
|
|
177
|
+
}
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
## 📝 Usage Examples
|
|
183
|
+
|
|
184
|
+
### Simple variant (shadcn/ui style)
|
|
185
|
+
|
|
186
|
+
```tsx
|
|
187
|
+
<MetricCardGlass
|
|
188
|
+
title="Total Revenue"
|
|
189
|
+
value="$45,231"
|
|
190
|
+
change="+12.5%"
|
|
191
|
+
variant="success"
|
|
192
|
+
icon={<DollarSign />}
|
|
193
|
+
/>
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### With detailed change object
|
|
197
|
+
|
|
198
|
+
```tsx
|
|
199
|
+
<MetricCardGlass
|
|
200
|
+
title="Total Revenue"
|
|
201
|
+
value="$45,231"
|
|
202
|
+
change={{
|
|
203
|
+
value: 12.5,
|
|
204
|
+
direction: 'up',
|
|
205
|
+
period: 'vs last month',
|
|
206
|
+
}}
|
|
207
|
+
variant="success"
|
|
208
|
+
icon={<DollarSign />}
|
|
209
|
+
/>
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
### With progress and sparkline (Glass UI extensions)
|
|
213
|
+
|
|
214
|
+
```tsx
|
|
215
|
+
<MetricCardGlass
|
|
216
|
+
title="Completion Rate"
|
|
217
|
+
value="85%"
|
|
218
|
+
description="Project progress"
|
|
219
|
+
change="+5.2%"
|
|
220
|
+
variant="success"
|
|
221
|
+
progress={85}
|
|
222
|
+
sparklineData={[70, 75, 78, 80, 82, 84, 85]}
|
|
223
|
+
showProgress
|
|
224
|
+
showSparkline
|
|
225
|
+
/>
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
### Backward Compatibility (optional)
|
|
229
|
+
|
|
230
|
+
To support the old API, aliases can be added:
|
|
231
|
+
|
|
232
|
+
```tsx
|
|
233
|
+
<MetricCardGlass
|
|
234
|
+
label="Total Revenue" // ⚠️ deprecated, use title
|
|
235
|
+
value={75}
|
|
236
|
+
valueFormatter={(v) => `$${v}`} // ⚠️ deprecated, use value directly
|
|
237
|
+
color="emerald" // ⚠️ deprecated, use variant="success"
|
|
238
|
+
/>
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
---
|
|
242
|
+
|
|
243
|
+
## 🎨 Mapping: old API → new API
|
|
244
|
+
|
|
245
|
+
| Old API | New API | Note |
|
|
246
|
+
| ----------------------------- | -------------------------- | ------------------------------------- |
|
|
247
|
+
| `label` | `title` | shadcn/ui standard |
|
|
248
|
+
| `value: number (0-100)` | `value: string \| number` | Simplification |
|
|
249
|
+
| `valueFormatter` | — | Removed, format before passing |
|
|
250
|
+
| `valueSuffix` | `description` | shadcn/ui standard |
|
|
251
|
+
| `color: 'emerald'` | `variant: 'success'` | Unification |
|
|
252
|
+
| `color: 'amber'` | `variant: 'warning'` | Unification |
|
|
253
|
+
| `color: 'blue'` | `variant: 'default'` | Unification |
|
|
254
|
+
| `color: 'red'` | `variant: 'destructive'` | Unification |
|
|
255
|
+
| `trend: { value, direction }` | `change: string \| object` | Simplification |
|
|
256
|
+
| — | `progress: number` | New: separation of value and progress |
|
|
257
|
+
|
|
258
|
+
---
|
|
259
|
+
|
|
260
|
+
## 🛠 CSS Variables Structure
|
|
261
|
+
|
|
262
|
+
Following the library pattern:
|
|
263
|
+
|
|
264
|
+
```css
|
|
265
|
+
/* glass-theme.css */
|
|
266
|
+
|
|
267
|
+
/* Default variant */
|
|
268
|
+
--metric-default-bg: rgba(255, 255, 255, 0.08);
|
|
269
|
+
--metric-default-border: rgba(255, 255, 255, 0.15);
|
|
270
|
+
--metric-default-text: var(--text-primary);
|
|
271
|
+
--metric-default-glow: 0 0 20px rgba(59, 130, 246, 0.3);
|
|
272
|
+
|
|
273
|
+
/* Success variant (emerald) */
|
|
274
|
+
--metric-success-bg: rgba(16, 185, 129, 0.08);
|
|
275
|
+
--metric-success-border: rgba(16, 185, 129, 0.25);
|
|
276
|
+
--metric-success-text: rgb(52, 211, 153);
|
|
277
|
+
--metric-success-glow: 0 0 20px rgba(16, 185, 129, 0.3);
|
|
278
|
+
|
|
279
|
+
/* Warning variant (amber) */
|
|
280
|
+
--metric-warning-bg: rgba(245, 158, 11, 0.08);
|
|
281
|
+
--metric-warning-border: rgba(245, 158, 11, 0.25);
|
|
282
|
+
--metric-warning-text: rgb(251, 191, 36);
|
|
283
|
+
--metric-warning-glow: 0 0 20px rgba(245, 158, 11, 0.3);
|
|
284
|
+
|
|
285
|
+
/* Destructive variant (red/rose) */
|
|
286
|
+
--metric-destructive-bg: rgba(244, 63, 94, 0.08);
|
|
287
|
+
--metric-destructive-border: rgba(244, 63, 94, 0.25);
|
|
288
|
+
--metric-destructive-text: rgb(251, 113, 133);
|
|
289
|
+
--metric-destructive-glow: 0 0 20px rgba(244, 63, 94, 0.3);
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
---
|
|
293
|
+
|
|
294
|
+
## 🎯 Advantages of New API
|
|
295
|
+
|
|
296
|
+
### 1. **shadcn/ui compatibility** ✅
|
|
297
|
+
|
|
298
|
+
- Uses standard props: `title`, `value`, `description`, `variant`
|
|
299
|
+
- Can easily be replaced with shadcn/ui Card without API changes
|
|
300
|
+
|
|
301
|
+
### 2. **Consistency with the library** ✅
|
|
302
|
+
|
|
303
|
+
- Follows `AlertGlass`, `BadgeGlass`, `ButtonGlass` patterns
|
|
304
|
+
- Uses unified `variant` system
|
|
305
|
+
- CSS variables in unified format
|
|
306
|
+
|
|
307
|
+
### 3. **Ease of use** ✅
|
|
308
|
+
|
|
309
|
+
- No need for `valueFormatter` and math
|
|
310
|
+
- Simple string `change="+12.5%"` instead of object
|
|
311
|
+
- Clear separation of `value` (display) and `progress` (0-100)
|
|
312
|
+
|
|
313
|
+
### 4. **Flexibility** ✅
|
|
314
|
+
|
|
315
|
+
- Supports both simple strings and objects for `change`
|
|
316
|
+
- Optional Glass UI extensions (sparkline, progress)
|
|
317
|
+
- Backward compatibility through aliases (optional)
|
|
318
|
+
|
|
319
|
+
---
|
|
320
|
+
|
|
321
|
+
## 🚀 Migration Plan
|
|
322
|
+
|
|
323
|
+
### Step 1: Create new component
|
|
324
|
+
|
|
325
|
+
- [ ] Create `metric-card-glass-v2.tsx` with new API
|
|
326
|
+
- [ ] Add CVA variants to `metric-card-glass-variants.ts`
|
|
327
|
+
- [ ] Add CSS variables to `glass-theme.css`
|
|
328
|
+
|
|
329
|
+
### Step 2: Testing
|
|
330
|
+
|
|
331
|
+
- [ ] Create stories for new API
|
|
332
|
+
- [ ] Add unit tests
|
|
333
|
+
- [ ] Add visual regression tests
|
|
334
|
+
|
|
335
|
+
### Step 3: Migration
|
|
336
|
+
|
|
337
|
+
- [ ] Update `dashboard.stories.tsx`
|
|
338
|
+
- [ ] Update other usages
|
|
339
|
+
- [ ] Add deprecation warnings for old API
|
|
340
|
+
|
|
341
|
+
### Step 4: Documentation
|
|
342
|
+
|
|
343
|
+
- [ ] Update Storybook docs
|
|
344
|
+
- [ ] Add migration guide
|
|
345
|
+
- [ ] Update README
|
|
346
|
+
|
|
347
|
+
---
|
|
348
|
+
|
|
349
|
+
## 📚 References
|
|
350
|
+
|
|
351
|
+
- [Card - shadcn/ui](https://ui.shadcn.com/docs/components/card)
|
|
352
|
+
- [The Anatomy of shadcn/ui Components | Vercel Academy](https://vercel.com/academy/shadcn-ui/extending-shadcn-ui-with-custom-components)
|
|
353
|
+
- [Shadcn UI Dashboard Widgets](https://shadcnstore.com/blocks/application/widgets)
|
|
354
|
+
- [Stat Cards - Shadcn UI Kit](https://shadcnuikit.com/components/cards/stat)
|