@fragments-sdk/cli 0.10.1 → 0.12.1

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.
Files changed (223) hide show
  1. package/dist/ai-client-I6MDWNYA.js +21 -0
  2. package/dist/bin.js +292 -367
  3. package/dist/bin.js.map +1 -1
  4. package/dist/{chunk-PW7QTQA6.js → chunk-4OC7FTJB.js} +2 -2
  5. package/dist/{chunk-HRFUSSZI.js → chunk-AM4MRTMN.js} +2 -2
  6. package/dist/{chunk-5G3VZH43.js → chunk-GVDSFQ4E.js} +281 -351
  7. package/dist/chunk-GVDSFQ4E.js.map +1 -0
  8. package/dist/chunk-JJ2VRTBU.js +626 -0
  9. package/dist/chunk-JJ2VRTBU.js.map +1 -0
  10. package/dist/{chunk-D5PYOXEI.js → chunk-LVWFOLUZ.js} +148 -13
  11. package/dist/{chunk-D5PYOXEI.js.map → chunk-LVWFOLUZ.js.map} +1 -1
  12. package/dist/{chunk-WXSR2II7.js → chunk-OQKMEFOS.js} +58 -6
  13. package/dist/chunk-OQKMEFOS.js.map +1 -0
  14. package/dist/chunk-SXTKFDCR.js +104 -0
  15. package/dist/chunk-SXTKFDCR.js.map +1 -0
  16. package/dist/chunk-T5OMVL7E.js +443 -0
  17. package/dist/chunk-T5OMVL7E.js.map +1 -0
  18. package/dist/{chunk-ZM4ZQZWZ.js → chunk-TPWGL2XS.js} +39 -37
  19. package/dist/chunk-TPWGL2XS.js.map +1 -0
  20. package/dist/{chunk-OQO55NKV.js → chunk-WFS63PCW.js} +85 -11
  21. package/dist/chunk-WFS63PCW.js.map +1 -0
  22. package/dist/core/index.js +9 -1
  23. package/dist/{discovery-NEOY4MPN.js → discovery-ZJQSXF56.js} +3 -3
  24. package/dist/{generate-FBHSXR3D.js → generate-RJFS2JWA.js} +4 -4
  25. package/dist/index.js +7 -6
  26. package/dist/index.js.map +1 -1
  27. package/dist/init-ZSX3NRCZ.js +636 -0
  28. package/dist/init-ZSX3NRCZ.js.map +1 -0
  29. package/dist/mcp-bin.js +2 -2
  30. package/dist/{scan-CJF2DOQW.js → scan-3PMCJ4RB.js} +6 -6
  31. package/dist/scan-generate-SYU4PYZD.js +1115 -0
  32. package/dist/scan-generate-SYU4PYZD.js.map +1 -0
  33. package/dist/{service-TQYWY65E.js → service-VMGNJZ42.js} +3 -3
  34. package/dist/snapshot-XOISO2IS.js +139 -0
  35. package/dist/snapshot-XOISO2IS.js.map +1 -0
  36. package/dist/{static-viewer-NUBFPKWH.js → static-viewer-5GXH2MGE.js} +3 -3
  37. package/dist/static-viewer-5GXH2MGE.js.map +1 -0
  38. package/dist/{test-Z5LVO724.js → test-SI4NSHQX.js} +4 -4
  39. package/dist/{tokens-CE46OTMD.js → tokens-T6SIVUT5.js} +5 -5
  40. package/dist/{viewer-DNMNC5VS.js → viewer-7ZEAFBVN.js} +80 -58
  41. package/dist/viewer-7ZEAFBVN.js.map +1 -0
  42. package/package.json +6 -14
  43. package/src/ai-client.ts +156 -0
  44. package/src/bin.ts +74 -2
  45. package/src/build.ts +95 -33
  46. package/src/commands/__tests__/drift-sync.test.ts +252 -0
  47. package/src/commands/__tests__/scan-generate.test.ts +497 -45
  48. package/src/commands/enhance.ts +11 -35
  49. package/src/commands/init.ts +296 -193
  50. package/src/commands/scan-generate.ts +740 -139
  51. package/src/commands/scan.ts +37 -32
  52. package/src/commands/setup.ts +143 -52
  53. package/src/commands/snapshot.ts +197 -0
  54. package/src/commands/sync.ts +357 -0
  55. package/src/commands/validate.ts +43 -1
  56. package/src/core/component-extractor.test.ts +282 -0
  57. package/src/core/component-extractor.ts +1030 -0
  58. package/src/core/discovery.ts +93 -7
  59. package/src/service/enhance/props-extractor.ts +235 -13
  60. package/src/validators.ts +236 -0
  61. package/src/viewer/__tests__/viewer-integration.test.ts +85 -74
  62. package/src/viewer/server.ts +37 -22
  63. package/src/viewer/vite-plugin.ts +25 -9
  64. package/dist/chunk-5G3VZH43.js.map +0 -1
  65. package/dist/chunk-OQO55NKV.js.map +0 -1
  66. package/dist/chunk-WXSR2II7.js.map +0 -1
  67. package/dist/chunk-ZM4ZQZWZ.js.map +0 -1
  68. package/dist/init-NDQXUWDU.js +0 -796
  69. package/dist/init-NDQXUWDU.js.map +0 -1
  70. package/dist/scan-generate-SJAN5MVI.js +0 -691
  71. package/dist/scan-generate-SJAN5MVI.js.map +0 -1
  72. package/dist/viewer-DNMNC5VS.js.map +0 -1
  73. package/src/ai.ts +0 -266
  74. package/src/commands/init-framework.ts +0 -414
  75. package/src/mcp/bin.ts +0 -36
  76. package/src/migrate/bin.ts +0 -114
  77. package/src/theme/index.ts +0 -77
  78. package/src/viewer/__tests__/a11y-fixes.test.ts +0 -358
  79. package/src/viewer/__tests__/jsx-parser.test.ts +0 -502
  80. package/src/viewer/__tests__/render-utils.test.ts +0 -232
  81. package/src/viewer/__tests__/style-utils.test.ts +0 -404
  82. package/src/viewer/assets/fragments-logo.ts +0 -4
  83. package/src/viewer/assets/fragments_logo.png +0 -0
  84. package/src/viewer/bin.ts +0 -86
  85. package/src/viewer/cli/health.ts +0 -256
  86. package/src/viewer/cli/index.ts +0 -33
  87. package/src/viewer/cli/scan.ts +0 -124
  88. package/src/viewer/cli/utils.ts +0 -174
  89. package/src/viewer/components/AccessibilityPanel.tsx +0 -1457
  90. package/src/viewer/components/ActionCapture.tsx +0 -172
  91. package/src/viewer/components/ActionsPanel.tsx +0 -332
  92. package/src/viewer/components/AllVariantsPreview.tsx +0 -78
  93. package/src/viewer/components/App.tsx +0 -582
  94. package/src/viewer/components/BottomPanel.tsx +0 -288
  95. package/src/viewer/components/CodePanel.naming.test.tsx +0 -59
  96. package/src/viewer/components/CodePanel.tsx +0 -118
  97. package/src/viewer/components/CommandPalette.tsx +0 -392
  98. package/src/viewer/components/ComponentDocView.tsx +0 -164
  99. package/src/viewer/components/ComponentGraph.tsx +0 -380
  100. package/src/viewer/components/ComponentHeader.tsx +0 -88
  101. package/src/viewer/components/ContractPanel.tsx +0 -241
  102. package/src/viewer/components/EmptyVariantMessage.tsx +0 -54
  103. package/src/viewer/components/ErrorBoundary.tsx +0 -97
  104. package/src/viewer/components/FigmaEmbed.tsx +0 -238
  105. package/src/viewer/components/FragmentEditor.tsx +0 -525
  106. package/src/viewer/components/FragmentRenderer.tsx +0 -61
  107. package/src/viewer/components/HeaderSearch.tsx +0 -24
  108. package/src/viewer/components/HealthDashboard.tsx +0 -441
  109. package/src/viewer/components/HmrStatusIndicator.tsx +0 -61
  110. package/src/viewer/components/Icons.tsx +0 -479
  111. package/src/viewer/components/InteractionsPanel.tsx +0 -757
  112. package/src/viewer/components/IsolatedPreviewFrame.tsx +0 -346
  113. package/src/viewer/components/IsolatedRender.tsx +0 -113
  114. package/src/viewer/components/KeyboardShortcutsHelp.tsx +0 -53
  115. package/src/viewer/components/LandingPage.tsx +0 -421
  116. package/src/viewer/components/Layout.tsx +0 -27
  117. package/src/viewer/components/LeftSidebar.tsx +0 -472
  118. package/src/viewer/components/LoadErrorMessage.tsx +0 -102
  119. package/src/viewer/components/MultiViewportPreview.tsx +0 -522
  120. package/src/viewer/components/NoVariantsMessage.tsx +0 -59
  121. package/src/viewer/components/PanelShell.tsx +0 -161
  122. package/src/viewer/components/PerformancePanel.tsx +0 -304
  123. package/src/viewer/components/PreviewArea.tsx +0 -472
  124. package/src/viewer/components/PreviewAside.tsx +0 -168
  125. package/src/viewer/components/PreviewFrameHost.tsx +0 -303
  126. package/src/viewer/components/PreviewPane.tsx +0 -149
  127. package/src/viewer/components/PreviewToolbar.tsx +0 -80
  128. package/src/viewer/components/PropsEditor.tsx +0 -506
  129. package/src/viewer/components/PropsTable.tsx +0 -111
  130. package/src/viewer/components/RelationsSection.tsx +0 -88
  131. package/src/viewer/components/ResizablePanel.tsx +0 -271
  132. package/src/viewer/components/RightSidebar.tsx +0 -102
  133. package/src/viewer/components/RuntimeToolsRegistrar.tsx +0 -17
  134. package/src/viewer/components/ScreenshotButton.tsx +0 -90
  135. package/src/viewer/components/Sidebar.tsx +0 -169
  136. package/src/viewer/components/SkeletonLoader.tsx +0 -161
  137. package/src/viewer/components/ThemeProvider.tsx +0 -42
  138. package/src/viewer/components/Toast.tsx +0 -3
  139. package/src/viewer/components/TokenStylePanel.tsx +0 -699
  140. package/src/viewer/components/TopToolbar.tsx +0 -159
  141. package/src/viewer/components/UsageSection.tsx +0 -95
  142. package/src/viewer/components/VariantMatrix.tsx +0 -388
  143. package/src/viewer/components/VariantRenderer.tsx +0 -131
  144. package/src/viewer/components/VariantTabs.tsx +0 -40
  145. package/src/viewer/components/ViewerHeader.tsx +0 -69
  146. package/src/viewer/components/ViewerStateSync.tsx +0 -52
  147. package/src/viewer/components/ViewportSelector.tsx +0 -172
  148. package/src/viewer/components/WebMCPDevTools.tsx +0 -503
  149. package/src/viewer/components/WebMCPIntegration.tsx +0 -47
  150. package/src/viewer/components/WebMCPStatusIndicator.tsx +0 -60
  151. package/src/viewer/components/_future/CreatePage.tsx +0 -836
  152. package/src/viewer/components/viewer-utils.ts +0 -16
  153. package/src/viewer/composition-renderer.ts +0 -381
  154. package/src/viewer/constants/index.ts +0 -1
  155. package/src/viewer/constants/ui.ts +0 -166
  156. package/src/viewer/entry.tsx +0 -335
  157. package/src/viewer/hooks/index.ts +0 -2
  158. package/src/viewer/hooks/useA11yCache.ts +0 -383
  159. package/src/viewer/hooks/useA11yService.ts +0 -364
  160. package/src/viewer/hooks/useActions.ts +0 -138
  161. package/src/viewer/hooks/useAppState.ts +0 -147
  162. package/src/viewer/hooks/useCompiledFragments.ts +0 -42
  163. package/src/viewer/hooks/useFigmaIntegration.ts +0 -132
  164. package/src/viewer/hooks/useHmrStatus.ts +0 -109
  165. package/src/viewer/hooks/useKeyboardShortcuts.ts +0 -270
  166. package/src/viewer/hooks/usePreviewBridge.ts +0 -347
  167. package/src/viewer/hooks/useScrollSpy.ts +0 -78
  168. package/src/viewer/hooks/useUrlState.ts +0 -318
  169. package/src/viewer/hooks/useViewSettings.ts +0 -111
  170. package/src/viewer/index.html +0 -28
  171. package/src/viewer/intelligence/healthReport.ts +0 -505
  172. package/src/viewer/intelligence/styleDrift.ts +0 -340
  173. package/src/viewer/intelligence/usageScanner.ts +0 -309
  174. package/src/viewer/jsx-parser.ts +0 -486
  175. package/src/viewer/preview-frame-entry.tsx +0 -25
  176. package/src/viewer/preview-frame.html +0 -125
  177. package/src/viewer/public/favicon.ico +0 -0
  178. package/src/viewer/render-template.html +0 -68
  179. package/src/viewer/styles/globals.css +0 -278
  180. package/src/viewer/types/a11y.ts +0 -197
  181. package/src/viewer/utils/a11y-fixes.ts +0 -509
  182. package/src/viewer/utils/actionExport.ts +0 -372
  183. package/src/viewer/utils/colorSchemes.ts +0 -201
  184. package/src/viewer/utils/detectRelationships.ts +0 -256
  185. package/src/viewer/vendor/shared/src/ComponentDocContent.module.scss +0 -10
  186. package/src/viewer/vendor/shared/src/ComponentDocContent.module.scss.d.ts +0 -2
  187. package/src/viewer/vendor/shared/src/ComponentDocContent.tsx +0 -274
  188. package/src/viewer/vendor/shared/src/DocsHeaderBar.tsx +0 -129
  189. package/src/viewer/vendor/shared/src/DocsPageAsideHost.tsx +0 -89
  190. package/src/viewer/vendor/shared/src/DocsPageShell.tsx +0 -124
  191. package/src/viewer/vendor/shared/src/DocsSearchCommand.tsx +0 -99
  192. package/src/viewer/vendor/shared/src/DocsSidebarNav.tsx +0 -66
  193. package/src/viewer/vendor/shared/src/PropsTable.module.scss +0 -68
  194. package/src/viewer/vendor/shared/src/PropsTable.module.scss.d.ts +0 -2
  195. package/src/viewer/vendor/shared/src/PropsTable.tsx +0 -76
  196. package/src/viewer/vendor/shared/src/VariantPreviewCard.module.scss +0 -114
  197. package/src/viewer/vendor/shared/src/VariantPreviewCard.module.scss.d.ts +0 -2
  198. package/src/viewer/vendor/shared/src/VariantPreviewCard.tsx +0 -137
  199. package/src/viewer/vendor/shared/src/docs-data/index.ts +0 -32
  200. package/src/viewer/vendor/shared/src/docs-data/mcp-configs.ts +0 -72
  201. package/src/viewer/vendor/shared/src/docs-data/palettes.ts +0 -75
  202. package/src/viewer/vendor/shared/src/docs-data/setup-examples.ts +0 -55
  203. package/src/viewer/vendor/shared/src/docs-layout.scss +0 -28
  204. package/src/viewer/vendor/shared/src/docs-layout.scss.d.ts +0 -2
  205. package/src/viewer/vendor/shared/src/index.ts +0 -34
  206. package/src/viewer/vendor/shared/src/types.ts +0 -53
  207. package/src/viewer/webmcp/__tests__/analytics.test.ts +0 -108
  208. package/src/viewer/webmcp/analytics.ts +0 -165
  209. package/src/viewer/webmcp/index.ts +0 -3
  210. package/src/viewer/webmcp/posthog-bridge.ts +0 -39
  211. package/src/viewer/webmcp/runtime-tools.ts +0 -152
  212. package/src/viewer/webmcp/scan-utils.ts +0 -135
  213. package/src/viewer/webmcp/use-tool-analytics.ts +0 -69
  214. package/src/viewer/webmcp/viewer-state.ts +0 -45
  215. /package/dist/{discovery-NEOY4MPN.js.map → ai-client-I6MDWNYA.js.map} +0 -0
  216. /package/dist/{chunk-PW7QTQA6.js.map → chunk-4OC7FTJB.js.map} +0 -0
  217. /package/dist/{chunk-HRFUSSZI.js.map → chunk-AM4MRTMN.js.map} +0 -0
  218. /package/dist/{scan-CJF2DOQW.js.map → discovery-ZJQSXF56.js.map} +0 -0
  219. /package/dist/{generate-FBHSXR3D.js.map → generate-RJFS2JWA.js.map} +0 -0
  220. /package/dist/{service-TQYWY65E.js.map → scan-3PMCJ4RB.js.map} +0 -0
  221. /package/dist/{static-viewer-NUBFPKWH.js.map → service-VMGNJZ42.js.map} +0 -0
  222. /package/dist/{test-Z5LVO724.js.map → test-SI4NSHQX.js.map} +0 -0
  223. /package/dist/{tokens-CE46OTMD.js.map → tokens-T6SIVUT5.js.map} +0 -0
@@ -1,441 +0,0 @@
1
- /**
2
- * Dashboard Component
3
- * Minimalist overview of design system coverage and components
4
- * with enhanced accessibility insights and top issues aggregation
5
- */
6
-
7
- import { useMemo, useState, useCallback, useEffect } from 'react';
8
- import type { FragmentDefinition } from '../../core/index.js';
9
- import type { ImpactValue } from 'axe-core';
10
- import { Badge, Progress, Stack, Text, Card, EmptyState } from '@fragments-sdk/ui';
11
- import {
12
- getAllA11yData,
13
- getA11ySummary,
14
- getAllA11yResults,
15
- type ComponentA11yData,
16
- } from '../hooks/useA11yCache.js';
17
- import type { A11ySummary, CachedA11yResult } from '../types/a11y.js';
18
-
19
- /** Normalize category to Title Case for display */
20
- function titleCase(str: string): string {
21
- return str.replace(/\b\w/g, (c) => c.toUpperCase());
22
- }
23
-
24
- /** Normalize category to a canonical key so "Form" and "Forms" merge into one group */
25
- function categoryKey(raw: string): string {
26
- const tc = titleCase(raw.trim());
27
- if (tc.length > 4 && tc.endsWith('s') && !tc.endsWith('ss')) {
28
- return tc.slice(0, -1);
29
- }
30
- return tc;
31
- }
32
-
33
- interface HealthDashboardProps {
34
- fragments: Array<{ path: string; fragment: FragmentDefinition }>;
35
- onNavigate?: (componentName: string) => void;
36
- }
37
-
38
- interface CoverageMetric {
39
- label: string;
40
- count: number;
41
- total: number;
42
- }
43
-
44
- interface A11yResults {
45
- accessibleComponents: number;
46
- totalComponents: number;
47
- totalViolations: number;
48
- totalCritical: number;
49
- totalSerious: number;
50
- }
51
-
52
- interface ComponentA11yResult {
53
- violations: number;
54
- critical: number;
55
- serious: number;
56
- status: 'pending' | 'scanning' | 'pass' | 'warn' | 'fail';
57
- }
58
-
59
- interface ComponentRow {
60
- name: string;
61
- category: string;
62
- variantCount: number;
63
- status: string;
64
- }
65
-
66
- function calculateCoverage(
67
- fragments: Array<{ path: string; fragment: FragmentDefinition }>
68
- ): { metrics: CoverageMetric[]; components: ComponentRow[]; categoryCount: number } {
69
- const total = fragments.length;
70
-
71
- if (total === 0) {
72
- return { metrics: [], components: [], categoryCount: 0 };
73
- }
74
-
75
- const categories = new Set<string>();
76
- const components: ComponentRow[] = [];
77
-
78
- let documented = 0;
79
- let withVariants = 0;
80
- let withUsage = 0;
81
- let figmaLinked = 0;
82
-
83
- for (const { fragment } of fragments) {
84
- const cat = fragment.meta.category || 'uncategorized';
85
- categories.add(categoryKey(cat));
86
-
87
- if (fragment.meta.description && fragment.meta.description.trim().length > 10) {
88
- documented++;
89
- }
90
-
91
- const variantCount = fragment.variants?.length || 0;
92
- if (variantCount > 0) {
93
- withVariants++;
94
- }
95
-
96
- if (fragment.usage && (fragment.usage.when.length > 0 || fragment.usage.whenNot.length > 0)) {
97
- withUsage++;
98
- }
99
-
100
- if (fragment.meta.figma || fragment.variants?.some((v) => v.figma)) {
101
- figmaLinked++;
102
- }
103
-
104
- components.push({
105
- name: fragment.meta.name,
106
- category: titleCase(cat),
107
- variantCount,
108
- status: fragment.meta.status || 'stable',
109
- });
110
- }
111
-
112
- components.sort((a, b) => {
113
- if (a.category !== b.category) return a.category.localeCompare(b.category);
114
- return a.name.localeCompare(b.name);
115
- });
116
-
117
- const metrics: CoverageMetric[] = [
118
- { label: 'Documented', count: documented, total },
119
- { label: 'Variants', count: withVariants, total },
120
- { label: 'Usage', count: withUsage, total },
121
- { label: 'Figma', count: figmaLinked, total },
122
- ];
123
-
124
- return { metrics, components, categoryCount: categories.size };
125
- }
126
-
127
- function impactToBadgeVariant(impact: ImpactValue | undefined): 'error' | 'warning' | 'info' | 'default' {
128
- switch (impact) {
129
- case 'critical': return 'error';
130
- case 'serious': return 'error';
131
- case 'moderate': return 'warning';
132
- case 'minor': return 'info';
133
- default: return 'default';
134
- }
135
- }
136
-
137
- export function HealthDashboard({ fragments, onNavigate }: HealthDashboardProps) {
138
- const { metrics, components, categoryCount } = useMemo(
139
- () => calculateCoverage(fragments),
140
- [fragments]
141
- );
142
-
143
- const [componentA11y, setComponentA11y] = useState<Record<string, ComponentA11yResult>>({});
144
- const [scanningComponents, setScanningComponents] = useState<Set<string>>(new Set());
145
- const [a11ySummary, setA11ySummary] = useState<A11ySummary | null>(null);
146
-
147
- const convertCacheToA11y = useCallback((cached: Record<string, ComponentA11yData>): Record<string, ComponentA11yResult> => {
148
- const result: Record<string, ComponentA11yResult> = {};
149
- for (const [name, data] of Object.entries(cached)) {
150
- let status: ComponentA11yResult['status'] = 'pass';
151
- if (data.critical > 0 || data.serious > 0) {
152
- status = 'fail';
153
- } else if (data.violations > 0) {
154
- status = 'warn';
155
- }
156
- result[name] = {
157
- violations: data.violations,
158
- critical: data.critical,
159
- serious: data.serious,
160
- status,
161
- };
162
- }
163
- return result;
164
- }, []);
165
-
166
- useEffect(() => {
167
- const cached = getAllA11yData();
168
- if (Object.keys(cached).length > 0) {
169
- setComponentA11y(convertCacheToA11y(cached));
170
- setA11ySummary(getA11ySummary());
171
- }
172
-
173
- const handleCacheUpdate = () => {
174
- const updatedCache = getAllA11yData();
175
- setComponentA11y(convertCacheToA11y(updatedCache));
176
- setA11ySummary(getA11ySummary());
177
- };
178
-
179
- const handleCacheCleared = () => {
180
- setComponentA11y({});
181
- setA11ySummary(null);
182
- };
183
-
184
- const handleScanStarted = (event: CustomEvent<{ componentName: string }>) => {
185
- setScanningComponents(prev => new Set(prev).add(event.detail.componentName));
186
- };
187
-
188
- const handleScanCompleted = (event: CustomEvent<{ componentName: string }>) => {
189
- setScanningComponents(prev => {
190
- const next = new Set(prev);
191
- next.delete(event.detail.componentName);
192
- return next;
193
- });
194
- };
195
-
196
- window.addEventListener('a11y-cache-updated', handleCacheUpdate);
197
- window.addEventListener('a11y-cache-cleared', handleCacheCleared);
198
- window.addEventListener('a11y-scan-started', handleScanStarted as EventListener);
199
- window.addEventListener('a11y-scan-completed', handleScanCompleted as EventListener);
200
-
201
- return () => {
202
- window.removeEventListener('a11y-cache-updated', handleCacheUpdate);
203
- window.removeEventListener('a11y-cache-cleared', handleCacheCleared);
204
- window.removeEventListener('a11y-scan-started', handleScanStarted as EventListener);
205
- window.removeEventListener('a11y-scan-completed', handleScanCompleted as EventListener);
206
- };
207
- }, [convertCacheToA11y]);
208
-
209
- const a11yResults = useMemo((): A11yResults | null => {
210
- const scannedComponents = Object.keys(componentA11y).length;
211
- if (scannedComponents === 0) {
212
- return null;
213
- }
214
-
215
- const summary = a11ySummary || getA11ySummary();
216
- return {
217
- accessibleComponents: summary.accessibleComponents,
218
- totalComponents: summary.totalComponents,
219
- totalViolations:
220
- summary.violationsByImpact.critical +
221
- summary.violationsByImpact.serious +
222
- summary.violationsByImpact.moderate +
223
- summary.violationsByImpact.minor,
224
- totalCritical: summary.violationsByImpact.critical,
225
- totalSerious: summary.violationsByImpact.serious,
226
- };
227
- }, [componentA11y, a11ySummary]);
228
-
229
- if (fragments.length === 0) {
230
- return (
231
- <EmptyState>
232
- <EmptyState.Description>No components loaded</EmptyState.Description>
233
- </EmptyState>
234
- );
235
- }
236
-
237
- const a11yMetric: CoverageMetric | null = a11yResults
238
- ? {
239
- label: 'Accessible',
240
- count: a11yResults.accessibleComponents,
241
- total: a11yResults.totalComponents,
242
- }
243
- : null;
244
-
245
- return (
246
- <Stack direction="column" gap="lg" style={{ maxWidth: '672px' }}>
247
- {/* Header */}
248
- <div>
249
- <Text as="h1" size="lg" weight="semibold">Fragments</Text>
250
- <Text size="sm" color="tertiary" style={{ marginTop: '2px' }}>
251
- {fragments.length} component{fragments.length !== 1 ? 's' : ''} · {categoryCount} categor{categoryCount !== 1 ? 'ies' : 'y'}
252
- </Text>
253
- </div>
254
-
255
- {/* Coverage */}
256
- <Card>
257
- <Card.Body>
258
- <Stack direction="column" gap="sm">
259
- <Text as="h2" size="sm" weight="medium">Coverage</Text>
260
- <Stack direction="column" gap="sm">
261
- {metrics.map((metric) => (
262
- <CoverageRow key={metric.label} metric={metric} />
263
- ))}
264
- {a11yMetric ? (
265
- <CoverageRow metric={a11yMetric} />
266
- ) : (
267
- <Stack direction="row" align="center" gap="sm">
268
- <Text size="sm" color="secondary" style={{ width: '96px', flexShrink: 0 }}>Accessible</Text>
269
- <div style={{ flex: 1 }}>
270
- <Progress value={0} />
271
- </div>
272
- <Text size="xs" color="tertiary" style={{ width: '40px', textAlign: 'right', flexShrink: 0 }}>-</Text>
273
- </Stack>
274
- )}
275
- </Stack>
276
- <div style={{ paddingTop: '8px', borderTop: '1px solid var(--border-subtle)' }}>
277
- {a11yResults ? (
278
- a11yResults.totalViolations > 0 ? (
279
- <Text size="xs" color="tertiary">
280
- {a11yResults.totalViolations} violation{a11yResults.totalViolations !== 1 ? 's' : ''} found
281
- ({a11yResults.totalCritical} critical, {a11yResults.totalSerious} serious)
282
- </Text>
283
- ) : (
284
- <Text size="xs" style={{ color: 'var(--color-success)' }}>
285
- All scanned components pass accessibility checks
286
- </Text>
287
- )
288
- ) : (
289
- <Text size="xs" color="tertiary">
290
- Visit components to scan for accessibility issues
291
- </Text>
292
- )}
293
- </div>
294
- </Stack>
295
- </Card.Body>
296
- </Card>
297
-
298
- {/* Top Issues Section */}
299
- {a11ySummary && a11ySummary.topViolations.length > 0 && (
300
- <Card>
301
- <Card.Body>
302
- <Stack direction="column" gap="sm">
303
- <Text as="h2" size="sm" weight="medium">Top Issues</Text>
304
- <Text size="xs" color="tertiary">
305
- Common accessibility violations across your components
306
- </Text>
307
- <Stack direction="column" gap="sm">
308
- {a11ySummary.topViolations.map((violation) => (
309
- <Stack
310
- key={violation.ruleId}
311
- direction="row"
312
- align="start"
313
- gap="sm"
314
- style={{
315
- padding: '8px',
316
- borderRadius: '4px',
317
- backgroundColor: 'var(--bg-secondary)',
318
- border: '1px solid var(--border-subtle)',
319
- }}
320
- >
321
- {violation.impact && (
322
- <Badge variant={impactToBadgeVariant(violation.impact)} size="sm">
323
- {violation.impact}
324
- </Badge>
325
- )}
326
- <div style={{ flex: 1, minWidth: 0 }}>
327
- <Text size="xs" style={{ overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
328
- {violation.description}
329
- </Text>
330
- <Text size="xs" color="tertiary" style={{ marginTop: '2px' }}>
331
- <Text as="span" size="xs" font="mono">{violation.ruleId}</Text>
332
- {' · '}
333
- {violation.affectedComponents.length} component{violation.affectedComponents.length !== 1 ? 's' : ''}
334
- </Text>
335
- </div>
336
- <Text size="xs" color="tertiary" style={{ flexShrink: 0 }}>
337
- {violation.affectedComponents.length}
338
- </Text>
339
- </Stack>
340
- ))}
341
- </Stack>
342
- {a11ySummary.topViolations.length >= 5 && (
343
- <Text size="xs" color="tertiary" style={{ textAlign: 'center' }}>
344
- Showing top 5 issues
345
- </Text>
346
- )}
347
- </Stack>
348
- </Card.Body>
349
- </Card>
350
- )}
351
-
352
- {/* Components Table */}
353
- <div>
354
- <Text as="h2" size="sm" weight="medium" style={{ marginBottom: '8px' }}>Components</Text>
355
- <div style={{ borderRadius: '8px', border: '1px solid var(--border-subtle)', overflow: 'hidden' }}>
356
- <table style={{ width: '100%', fontSize: '14px', borderCollapse: 'collapse' }}>
357
- <thead>
358
- <tr style={{ borderBottom: '1px solid var(--border-subtle)', backgroundColor: 'var(--bg-secondary)' }}>
359
- <th style={{ textAlign: 'left', padding: '8px 12px', fontSize: '12px', fontWeight: 500, color: 'var(--text-tertiary)' }}>Name</th>
360
- <th style={{ textAlign: 'left', padding: '8px 12px', fontSize: '12px', fontWeight: 500, color: 'var(--text-tertiary)' }}>Category</th>
361
- <th style={{ textAlign: 'left', padding: '8px 12px', fontSize: '12px', fontWeight: 500, color: 'var(--text-tertiary)' }}>Variants</th>
362
- <th style={{ textAlign: 'left', padding: '8px 12px', fontSize: '12px', fontWeight: 500, color: 'var(--text-tertiary)' }}>A11y</th>
363
- <th style={{ textAlign: 'left', padding: '8px 12px', fontSize: '12px', fontWeight: 500, color: 'var(--text-tertiary)' }}>Status</th>
364
- </tr>
365
- </thead>
366
- <tbody>
367
- {components.map((component, index) => {
368
- const a11yStatus = componentA11y[component.name];
369
- const isScanning = scanningComponents.has(component.name);
370
- return (
371
- <tr
372
- key={component.name}
373
- onClick={() => onNavigate?.(component.name)}
374
- style={{
375
- borderBottom: index < components.length - 1 ? '1px solid var(--border-subtle)' : 'none',
376
- cursor: 'pointer',
377
- transition: 'background-color 150ms',
378
- }}
379
- onMouseEnter={(e) => { (e.currentTarget as HTMLElement).style.backgroundColor = 'var(--bg-hover)'; }}
380
- onMouseLeave={(e) => { (e.currentTarget as HTMLElement).style.backgroundColor = ''; }}
381
- >
382
- <td style={{ padding: '8px 12px' }}><Text weight="medium" size="sm">{component.name}</Text></td>
383
- <td style={{ padding: '8px 12px' }}><Text size="sm" color="tertiary">{component.category}</Text></td>
384
- <td style={{ padding: '8px 12px' }}><Text size="sm" color="tertiary">{component.variantCount}</Text></td>
385
- <td style={{ padding: '8px 12px' }}>
386
- <A11yBadge result={a11yStatus} isScanning={isScanning} />
387
- </td>
388
- <td style={{ padding: '8px 12px' }}><Text size="sm" color="tertiary">{component.status}</Text></td>
389
- </tr>
390
- );
391
- })}
392
- </tbody>
393
- </table>
394
- </div>
395
- </div>
396
- </Stack>
397
- );
398
- }
399
-
400
- function CoverageRow({ metric }: { metric: CoverageMetric }) {
401
- const percentage = metric.total > 0 ? Math.round((metric.count / metric.total) * 100) : 0;
402
-
403
- return (
404
- <Stack direction="row" align="center" gap="sm">
405
- <Text size="sm" color="secondary" style={{ width: '96px', flexShrink: 0 }}>{metric.label}</Text>
406
- <div style={{ flex: 1 }}>
407
- <Progress value={percentage} />
408
- </div>
409
- <Text size="xs" color="tertiary" style={{ width: '40px', textAlign: 'right', flexShrink: 0 }}>
410
- {metric.count}/{metric.total}
411
- </Text>
412
- </Stack>
413
- );
414
- }
415
-
416
- function A11yBadge({ result, isScanning }: { result?: ComponentA11yResult; isScanning?: boolean }) {
417
- if (isScanning) {
418
- return <Badge variant="warning" size="sm">Scanning</Badge>;
419
- }
420
-
421
- if (!result || result.status === 'pending') {
422
- return <Text size="xs" color="tertiary">-</Text>;
423
- }
424
-
425
- if (result.status === 'scanning') {
426
- return <Badge variant="default" size="sm">...</Badge>;
427
- }
428
-
429
- if (result.status === 'pass') {
430
- return <Badge variant="success" size="sm">Pass</Badge>;
431
- }
432
-
433
- if (result.status === 'fail') {
434
- return <Badge variant="error" size="sm">{result.violations}</Badge>;
435
- }
436
-
437
- // warn status
438
- return <Badge variant="warning" size="sm">{result.violations}</Badge>;
439
- }
440
-
441
- export default HealthDashboard;
@@ -1,61 +0,0 @@
1
- import { Badge, Stack, Text } from '@fragments-sdk/ui';
2
- import { HMR_STATUS } from '../constants/ui.js';
3
- import { useHmrStatus } from '../hooks/useHmrStatus.js';
4
- import { WifiIcon, WifiOffIcon } from './Icons.js';
5
-
6
- interface HmrStatusIndicatorProps {
7
- className?: string;
8
- }
9
-
10
- export function HmrStatusIndicator({ className }: HmrStatusIndicatorProps) {
11
- const { status, lastUpdate } = useHmrStatus();
12
- const config = HMR_STATUS[status];
13
-
14
- const variant = status === 'connected' ? 'success' as const
15
- : status === 'disconnected' ? 'error' as const
16
- : 'warning' as const;
17
-
18
- return (
19
- <Stack direction="row" gap="xs" align="center" className={className}>
20
- <Badge variant={variant} size="sm" dot>
21
- <span style={{ display: 'flex', alignItems: 'center', gap: '4px' }}>
22
- {status === 'disconnected' ? (
23
- <WifiOffIcon style={{ width: '12px', height: '12px' }} />
24
- ) : (
25
- <WifiIcon style={{ width: '12px', height: '12px' }} />
26
- )}
27
- </span>
28
- </Badge>
29
-
30
- {lastUpdate && (
31
- <Text
32
- size="2xs"
33
- color="tertiary"
34
- truncate
35
- style={{ maxWidth: '100px' }}
36
- title={lastUpdate}
37
- >
38
- Updated: {lastUpdate.split('/').pop()}
39
- </Text>
40
- )}
41
- </Stack>
42
- );
43
- }
44
-
45
- /**
46
- * Compact version that just shows the status dot.
47
- */
48
- export function HmrStatusDot() {
49
- const { status } = useHmrStatus();
50
- const config = HMR_STATUS[status];
51
-
52
- const variant = status === 'connected' ? 'success' as const
53
- : status === 'disconnected' ? 'error' as const
54
- : 'warning' as const;
55
-
56
- return (
57
- <Badge variant={variant} size="sm" dot title={config.label}>
58
- <span />
59
- </Badge>
60
- );
61
- }