shadcn-glass-ui 1.0.11 → 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 +213 -0
- package/README.md +174 -17
- 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/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,418 @@
|
|
|
1
|
+
# API Patterns Comparison - Glass UI Library
|
|
2
|
+
|
|
3
|
+
## Document Purpose
|
|
4
|
+
|
|
5
|
+
Detailed comparison of API patterns across all library components to ensure **consistency** of the
|
|
6
|
+
new `MetricCardGlass` API.
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## 📊 Comparison Table: Core UI Components
|
|
11
|
+
|
|
12
|
+
| Component | Title/Label Prop | Value Prop | Variant System | Children | Icon Support | Notes |
|
|
13
|
+
| --------------------- | -------------------------- | ----------------- | ----------------------------------------------------------------------------------------------------- | -------------- | -------------------------- | ------------------------ |
|
|
14
|
+
| **shadcn/ui Card** | `CardTitle` (subcomponent) | — | — | ✅ Composition | — | Compound component |
|
|
15
|
+
| **AlertGlass** | `title?: string` | — | `variant: 'default' \| 'destructive' \| 'success' \| 'warning'` | ✅ `children` | ✅ Auto (variant-based) | **shadcn/ui compatible** |
|
|
16
|
+
| **BadgeGlass** | — | — | `variant: 'default' \| 'secondary' \| 'destructive' \| 'outline' \| 'success' \| 'warning' \| 'info'` | ✅ `children` | ❌ | **shadcn/ui + extended** |
|
|
17
|
+
| **ButtonGlass** | — | — | `variant: 'primary' \| 'secondary' \| 'ghost' \| 'destructive' \| 'success' \| 'text'` | ✅ `children` | ✅ `iconLeft`, `iconRight` | **shadcn/ui-like** |
|
|
18
|
+
| **GlassCard** | — | — | `intensity: 'low' \| 'medium' \| 'high'` | ✅ `children` | ❌ | Custom Glass prop |
|
|
19
|
+
| **NotificationGlass** | `title: string` (required) | `message: string` | `variant: 'default' \| 'destructive' \| 'success' \| 'warning'` | ❌ | ✅ Auto (variant-based) | **shadcn/ui compatible** |
|
|
20
|
+
|
|
21
|
+
### Insights from Core UI:
|
|
22
|
+
|
|
23
|
+
1. **✅ Variant System** - all use `variant` prop (except GlassCard with `intensity`)
|
|
24
|
+
2. **✅ Title vs Label** - `title` is used in AlertGlass, NotificationGlass
|
|
25
|
+
3. **✅ shadcn/ui variants** - base variants: `default`, `secondary`, `destructive`, `outline`
|
|
26
|
+
4. **✅ Glass UI extensions** - extended variants: `success`, `warning`, `info`
|
|
27
|
+
5. **✅ Icon handling** - automatic icons based on `variant` (AlertGlass, NotificationGlass)
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## 📊 Comparison Table: Composite Components
|
|
32
|
+
|
|
33
|
+
| Component | Title/Label Prop | Value Prop | Color/Variant System | Progress | Trend/Change | Notes |
|
|
34
|
+
| ----------------------------- | ------------------------------ | ------------------------------------------ | ------------------------------------------------ | --------------------- | ------------------ | --------------------- |
|
|
35
|
+
| **CircularMetricGlass** | `label: string` | `value: number (0-100)` | `color: 'emerald' \| 'amber' \| 'blue' \| 'red'` | ✅ Circular progress | ❌ | Simple metric display |
|
|
36
|
+
| **AICardGlass** | — (hardcoded "AI Code Review") | — | ❌ | ❌ | ❌ | Fixed layout card |
|
|
37
|
+
| **YearCardGlass** | `label: string` (badge) | `commits: string` | `gradient?: ProgressGradient` | ✅ `progress: number` | ❌ | Career stats card |
|
|
38
|
+
| **TrustScoreDisplayGlass** | `title?: string` | `score: number (0-100)` | ❌ (color auto) | ✅ Circular | ❌ | Score display |
|
|
39
|
+
| **MetricCardGlass (current)** | `label: string` | `value: number (0-100)` + `valueFormatter` | `color: 'emerald' \| 'amber' \| 'blue' \| 'red'` | ✅ `showProgress` | ✅ `trend: object` | **Inconsistent!** |
|
|
40
|
+
|
|
41
|
+
### Insights from Composite:
|
|
42
|
+
|
|
43
|
+
1. **❌ ISSUE:** `label` is used instead of `title`
|
|
44
|
+
2. **❌ ISSUE:** `color` instead of `variant` (doesn't match Core UI)
|
|
45
|
+
3. **❌ ISSUE:** `value` as percentage 0-100 instead of display value
|
|
46
|
+
4. **✅ Good:** Separate `progress` prop in YearCardGlass
|
|
47
|
+
5. **❌ ISSUE:** Complex `trend` object instead of simple `change`
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## 🎯 Patterns from shadcn/ui Card
|
|
52
|
+
|
|
53
|
+
### Compound Component Pattern
|
|
54
|
+
|
|
55
|
+
```tsx
|
|
56
|
+
// shadcn/ui uses composition
|
|
57
|
+
<Card>
|
|
58
|
+
<CardHeader>
|
|
59
|
+
<CardTitle>Card Title</CardTitle>
|
|
60
|
+
<CardDescription>Card Description</CardDescription>
|
|
61
|
+
</CardHeader>
|
|
62
|
+
<CardContent>
|
|
63
|
+
<p>Card Content</p>
|
|
64
|
+
</CardContent>
|
|
65
|
+
<CardFooter>
|
|
66
|
+
<Button>Action</Button>
|
|
67
|
+
</CardFooter>
|
|
68
|
+
</Card>
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Advantages of Compound Pattern:
|
|
72
|
+
|
|
73
|
+
- ✅ Maximum composition flexibility
|
|
74
|
+
- ✅ No need for complex layout props
|
|
75
|
+
- ✅ Easy to extend
|
|
76
|
+
- ❌ More verbose API
|
|
77
|
+
|
|
78
|
+
### Disadvantages for MetricCard:
|
|
79
|
+
|
|
80
|
+
- ❌ Too complex for simple use case
|
|
81
|
+
- ❌ More boilerplate code
|
|
82
|
+
- ❌ Not suitable for fixed layout metrics
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## 🔍 Analysis: Which Pattern to Choose?
|
|
87
|
+
|
|
88
|
+
### Option 1: Compound Component (like shadcn/ui Card)
|
|
89
|
+
|
|
90
|
+
```tsx
|
|
91
|
+
<MetricCardGlass>
|
|
92
|
+
<MetricCardGlass.Header>
|
|
93
|
+
<MetricCardGlass.Title>Total Revenue</MetricCardGlass.Title>
|
|
94
|
+
<MetricCardGlass.Icon><DollarSign /></MetricCardGlass.Icon>
|
|
95
|
+
</MetricCardGlass.Header>
|
|
96
|
+
<MetricCardGlass.Value>$45,231</MetricCardGlass.Value>
|
|
97
|
+
<MetricCardGlass.Change>+12.5%</MetricCardGlass.Change>
|
|
98
|
+
<MetricCardGlass.Sparkline data={[...]} />
|
|
99
|
+
</MetricCardGlass>
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
**Assessment:**
|
|
103
|
+
|
|
104
|
+
- ✅ Maximum flexibility
|
|
105
|
+
- ❌ Too verbose for fixed layout
|
|
106
|
+
- ❌ Doesn't match other Composite components
|
|
107
|
+
|
|
108
|
+
### Option 2: Flat Props (like CircularMetricGlass, YearCardGlass)
|
|
109
|
+
|
|
110
|
+
```tsx
|
|
111
|
+
<MetricCardGlass
|
|
112
|
+
title="Total Revenue"
|
|
113
|
+
value="$45,231"
|
|
114
|
+
change="+12.5%"
|
|
115
|
+
variant="success"
|
|
116
|
+
icon={<DollarSign />}
|
|
117
|
+
sparklineData={[...]}
|
|
118
|
+
/>
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
**Assessment:**
|
|
122
|
+
|
|
123
|
+
- ✅ Simple and clear API
|
|
124
|
+
- ✅ Matches CircularMetricGlass, YearCardGlass
|
|
125
|
+
- ✅ Less boilerplate
|
|
126
|
+
- ✅ **RECOMMENDED** ✨
|
|
127
|
+
|
|
128
|
+
### Option 3: Hybrid (Props + Composition for complex cases)
|
|
129
|
+
|
|
130
|
+
```tsx
|
|
131
|
+
// Simple case
|
|
132
|
+
<MetricCardGlass title="Revenue" value="$45,231" change="+12.5%" />
|
|
133
|
+
|
|
134
|
+
// Complex case with custom layout
|
|
135
|
+
<MetricCardGlass>
|
|
136
|
+
<MetricCardGlass.Header>...</MetricCardGlass.Header>
|
|
137
|
+
<CustomContent />
|
|
138
|
+
</MetricCardGlass>
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
**Assessment:**
|
|
142
|
+
|
|
143
|
+
- ✅ Flexibility + simplicity
|
|
144
|
+
- ❌ More complex to implement
|
|
145
|
+
- ❌ API becomes less predictable
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
## ✅ RECOMMENDATION: Option 2 - Flat Props API
|
|
150
|
+
|
|
151
|
+
### Why?
|
|
152
|
+
|
|
153
|
+
1. **Consistency with the library** ✅
|
|
154
|
+
- Matches the pattern of CircularMetricGlass, YearCardGlass, TrustScoreDisplayGlass
|
|
155
|
+
- All Composite components use flat props
|
|
156
|
+
|
|
157
|
+
2. **Ease of use** ✅
|
|
158
|
+
- Less code for typical cases
|
|
159
|
+
- Clear API without nesting
|
|
160
|
+
- Easy to migrate from current API
|
|
161
|
+
|
|
162
|
+
3. **shadcn/ui compatibility** ✅
|
|
163
|
+
- Uses `title` (like CardTitle)
|
|
164
|
+
- Uses `description` (like CardDescription)
|
|
165
|
+
- Uses `variant` system (like Alert, Badge, Button)
|
|
166
|
+
|
|
167
|
+
4. **Extensibility** ✅
|
|
168
|
+
- Can add `children` for custom content
|
|
169
|
+
- Can add `asChild` for polymorphism
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
## 📝 Final API for MetricCardGlass
|
|
174
|
+
|
|
175
|
+
### Type Definitions
|
|
176
|
+
|
|
177
|
+
```tsx
|
|
178
|
+
// ========================================
|
|
179
|
+
// VARIANT SYSTEM (following AlertGlass, BadgeGlass)
|
|
180
|
+
// ========================================
|
|
181
|
+
|
|
182
|
+
export type MetricVariant =
|
|
183
|
+
| 'default' // shadcn/ui base (blue)
|
|
184
|
+
| 'secondary' // shadcn/ui base (gray)
|
|
185
|
+
| 'success' // Glass UI extension (green)
|
|
186
|
+
| 'warning' // Glass UI extension (yellow)
|
|
187
|
+
| 'destructive'; // shadcn/ui base (red)
|
|
188
|
+
|
|
189
|
+
// Mapping: old color → new variant
|
|
190
|
+
// emerald → success
|
|
191
|
+
// amber → warning
|
|
192
|
+
// blue → default
|
|
193
|
+
// red → destructive
|
|
194
|
+
|
|
195
|
+
// ========================================
|
|
196
|
+
// CHANGE/TREND TYPES (simplified)
|
|
197
|
+
// ========================================
|
|
198
|
+
|
|
199
|
+
export type TrendDirection = 'up' | 'down' | 'neutral';
|
|
200
|
+
|
|
201
|
+
export interface MetricChange {
|
|
202
|
+
/** Change value (e.g., 12.5 for +12.5%) */
|
|
203
|
+
readonly value: number;
|
|
204
|
+
/** Trend direction (auto-detected if not provided) */
|
|
205
|
+
readonly direction?: TrendDirection;
|
|
206
|
+
/** Optional period label (e.g., "vs last month") */
|
|
207
|
+
readonly period?: string;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// ========================================
|
|
211
|
+
// MAIN PROPS INTERFACE
|
|
212
|
+
// ========================================
|
|
213
|
+
|
|
214
|
+
export interface MetricCardGlassProps
|
|
215
|
+
extends React.HTMLAttributes<HTMLDivElement>, VariantProps<typeof metricCardVariants> {
|
|
216
|
+
// ========================================
|
|
217
|
+
// CORE PROPS (shadcn/ui compatible)
|
|
218
|
+
// ========================================
|
|
219
|
+
|
|
220
|
+
/** Metric title (shadcn/ui Card: title) */
|
|
221
|
+
readonly title: string;
|
|
222
|
+
|
|
223
|
+
/** Display value (shadcn/ui Card: value) */
|
|
224
|
+
readonly value: string | number;
|
|
225
|
+
|
|
226
|
+
/** Optional description/subtitle (shadcn/ui Card: description) */
|
|
227
|
+
readonly description?: string;
|
|
228
|
+
|
|
229
|
+
/** Change indicator (shadcn/ui: change) */
|
|
230
|
+
readonly change?: string | number | MetricChange;
|
|
231
|
+
|
|
232
|
+
/** Semantic variant (follows AlertGlass, BadgeGlass pattern) */
|
|
233
|
+
readonly variant?: MetricVariant;
|
|
234
|
+
|
|
235
|
+
/** Icon to display */
|
|
236
|
+
readonly icon?: ReactNode;
|
|
237
|
+
|
|
238
|
+
// ========================================
|
|
239
|
+
// GLASS UI EXTENSIONS
|
|
240
|
+
// ========================================
|
|
241
|
+
|
|
242
|
+
/** Data for sparkline visualization */
|
|
243
|
+
readonly sparklineData?: readonly number[];
|
|
244
|
+
|
|
245
|
+
/** Show sparkline chart */
|
|
246
|
+
readonly showSparkline?: boolean;
|
|
247
|
+
|
|
248
|
+
/** Show progress bar (requires progress prop) */
|
|
249
|
+
readonly showProgress?: boolean;
|
|
250
|
+
|
|
251
|
+
/** Progress percentage (0-100, separate from display value) */
|
|
252
|
+
readonly progress?: number;
|
|
253
|
+
|
|
254
|
+
// ========================================
|
|
255
|
+
// DEPRECATED (backward compatibility)
|
|
256
|
+
// ========================================
|
|
257
|
+
|
|
258
|
+
/** @deprecated Use `title` instead */
|
|
259
|
+
readonly label?: string;
|
|
260
|
+
|
|
261
|
+
/** @deprecated Use `variant` instead. Mapping: emerald→success, amber→warning, blue→default, red→destructive */
|
|
262
|
+
readonly color?: 'emerald' | 'amber' | 'blue' | 'red';
|
|
263
|
+
|
|
264
|
+
/** @deprecated Format value before passing. Use `value` prop directly */
|
|
265
|
+
readonly valueFormatter?: (value: number) => string;
|
|
266
|
+
|
|
267
|
+
/** @deprecated Use `description` instead */
|
|
268
|
+
readonly valueSuffix?: string;
|
|
269
|
+
|
|
270
|
+
/** @deprecated Use `change` instead */
|
|
271
|
+
readonly trend?: { value: number; direction: TrendDirection; label?: string };
|
|
272
|
+
}
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
### Usage Examples
|
|
276
|
+
|
|
277
|
+
```tsx
|
|
278
|
+
// ========================================
|
|
279
|
+
// SIMPLE VARIANT (shadcn/ui style)
|
|
280
|
+
// ========================================
|
|
281
|
+
|
|
282
|
+
<MetricCardGlass
|
|
283
|
+
title="Total Revenue"
|
|
284
|
+
value="$45,231"
|
|
285
|
+
change="+12.5%"
|
|
286
|
+
variant="success"
|
|
287
|
+
icon={<DollarSign />}
|
|
288
|
+
/>
|
|
289
|
+
|
|
290
|
+
// ========================================
|
|
291
|
+
// WITH DESCRIPTION
|
|
292
|
+
// ========================================
|
|
293
|
+
|
|
294
|
+
<MetricCardGlass
|
|
295
|
+
title="Active Users"
|
|
296
|
+
value="8,459"
|
|
297
|
+
description="Current active sessions"
|
|
298
|
+
change="+5.2%"
|
|
299
|
+
variant="default"
|
|
300
|
+
icon={<Users />}
|
|
301
|
+
/>
|
|
302
|
+
|
|
303
|
+
// ========================================
|
|
304
|
+
// WITH DETAILED CHANGE OBJECT
|
|
305
|
+
// ========================================
|
|
306
|
+
|
|
307
|
+
<MetricCardGlass
|
|
308
|
+
title="Conversion Rate"
|
|
309
|
+
value="3.24%"
|
|
310
|
+
change={{
|
|
311
|
+
value: 2.1,
|
|
312
|
+
direction: 'up',
|
|
313
|
+
period: 'vs last month'
|
|
314
|
+
}}
|
|
315
|
+
variant="success"
|
|
316
|
+
/>
|
|
317
|
+
|
|
318
|
+
// ========================================
|
|
319
|
+
// WITH PROGRESS AND SPARKLINE (Glass UI extensions)
|
|
320
|
+
// ========================================
|
|
321
|
+
|
|
322
|
+
<MetricCardGlass
|
|
323
|
+
title="Completion Rate"
|
|
324
|
+
value="85%"
|
|
325
|
+
description="Project milestones"
|
|
326
|
+
change="+5.2%"
|
|
327
|
+
variant="success"
|
|
328
|
+
progress={85} // 0-100 for progress bar
|
|
329
|
+
sparklineData={[70, 75, 78, 80, 82, 84, 85]}
|
|
330
|
+
showProgress
|
|
331
|
+
showSparkline
|
|
332
|
+
/>
|
|
333
|
+
|
|
334
|
+
// ========================================
|
|
335
|
+
// BACKWARD COMPATIBILITY (deprecated props)
|
|
336
|
+
// ========================================
|
|
337
|
+
|
|
338
|
+
<MetricCardGlass
|
|
339
|
+
label="Total Revenue" // ⚠️ deprecated → title
|
|
340
|
+
value={75}
|
|
341
|
+
valueFormatter={(v) => `$${v}`} // ⚠️ deprecated → format before
|
|
342
|
+
color="emerald" // ⚠️ deprecated → variant="success"
|
|
343
|
+
trend={{ value: 12.5, direction: 'up' }} // ⚠️ deprecated → change
|
|
344
|
+
/>
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
---
|
|
348
|
+
|
|
349
|
+
## 🎨 CSS Variables Structure
|
|
350
|
+
|
|
351
|
+
Following the AlertGlass and BadgeGlass pattern:
|
|
352
|
+
|
|
353
|
+
```css
|
|
354
|
+
/* ========================================
|
|
355
|
+
METRIC CARD VARIANTS
|
|
356
|
+
Following AlertGlass, BadgeGlass pattern
|
|
357
|
+
======================================== */
|
|
358
|
+
|
|
359
|
+
/* Default variant (blue) */
|
|
360
|
+
--metric-default-bg: rgba(59, 130, 246, 0.08);
|
|
361
|
+
--metric-default-border: rgba(59, 130, 246, 0.25);
|
|
362
|
+
--metric-default-text: rgb(96, 165, 250);
|
|
363
|
+
--metric-default-glow: 0 0 20px rgba(59, 130, 246, 0.3);
|
|
364
|
+
|
|
365
|
+
/* Secondary variant (gray) */
|
|
366
|
+
--metric-secondary-bg: rgba(148, 163, 184, 0.08);
|
|
367
|
+
--metric-secondary-border: rgba(148, 163, 184, 0.25);
|
|
368
|
+
--metric-secondary-text: rgb(203, 213, 225);
|
|
369
|
+
--metric-secondary-glow: 0 0 20px rgba(148, 163, 184, 0.2);
|
|
370
|
+
|
|
371
|
+
/* Success variant (green/emerald) */
|
|
372
|
+
--metric-success-bg: rgba(16, 185, 129, 0.08);
|
|
373
|
+
--metric-success-border: rgba(16, 185, 129, 0.25);
|
|
374
|
+
--metric-success-text: rgb(52, 211, 153);
|
|
375
|
+
--metric-success-glow: 0 0 20px rgba(16, 185, 129, 0.3);
|
|
376
|
+
|
|
377
|
+
/* Warning variant (yellow/amber) */
|
|
378
|
+
--metric-warning-bg: rgba(245, 158, 11, 0.08);
|
|
379
|
+
--metric-warning-border: rgba(245, 158, 11, 0.25);
|
|
380
|
+
--metric-warning-text: rgb(251, 191, 36);
|
|
381
|
+
--metric-warning-glow: 0 0 20px rgba(245, 158, 11, 0.3);
|
|
382
|
+
|
|
383
|
+
/* Destructive variant (red/rose) */
|
|
384
|
+
--metric-destructive-bg: rgba(244, 63, 94, 0.08);
|
|
385
|
+
--metric-destructive-border: rgba(244, 63, 94, 0.25);
|
|
386
|
+
--metric-destructive-text: rgb(251, 113, 133);
|
|
387
|
+
--metric-destructive-glow: 0 0 20px rgba(244, 63, 94, 0.3);
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
---
|
|
391
|
+
|
|
392
|
+
## ✅ Final Consistency Verification
|
|
393
|
+
|
|
394
|
+
| Criteria | AlertGlass | BadgeGlass | MetricCardGlass (new) | Compliance |
|
|
395
|
+
| -------------------------- | ---------- | ---------- | --------------------- | ---------- |
|
|
396
|
+
| Uses `variant` prop | ✅ | ✅ | ✅ | ✅ |
|
|
397
|
+
| Base shadcn/ui variants | ✅ | ✅ | ✅ | ✅ |
|
|
398
|
+
| Glass UI extensions | ✅ | ✅ | ✅ | ✅ |
|
|
399
|
+
| CSS variables pattern | ✅ | ✅ | ✅ | ✅ |
|
|
400
|
+
| `title` prop (not `label`) | ✅ | — | ✅ | ✅ |
|
|
401
|
+
| `description` support | — | — | ✅ | ✅ |
|
|
402
|
+
| `extends HTMLAttributes` | ✅ | ✅ | ✅ | ✅ |
|
|
403
|
+
| `readonly` props | ✅ | ✅ | ✅ | ✅ |
|
|
404
|
+
| CVA integration | ✅ | ✅ | ✅ | ✅ |
|
|
405
|
+
| Icon support | ✅ (auto) | ❌ | ✅ (prop) | ✅ |
|
|
406
|
+
|
|
407
|
+
**Result: 10/10 - Complete consistency!** ✅
|
|
408
|
+
|
|
409
|
+
---
|
|
410
|
+
|
|
411
|
+
## 📚 References
|
|
412
|
+
|
|
413
|
+
- [AlertGlass](../src/components/glass/ui/alert-glass.tsx)
|
|
414
|
+
- [BadgeGlass](../src/components/glass/ui/badge-glass.tsx)
|
|
415
|
+
- [ButtonGlass](../src/components/glass/ui/button-glass.tsx)
|
|
416
|
+
- [CircularMetricGlass](../src/components/glass/composite/circular-metric-glass.tsx)
|
|
417
|
+
- [YearCardGlass](../src/components/glass/composite/year-card-glass.tsx)
|
|
418
|
+
- [shadcn/ui Card](https://ui.shadcn.com/docs/components/card)
|