@fragments-sdk/cli 0.10.0 → 0.11.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.
- package/dist/bin.js +26 -8
- package/dist/bin.js.map +1 -1
- package/dist/{chunk-ZDA3PLQ6.js → chunk-5G3VZH43.js} +2 -2
- package/dist/{chunk-566BNPQZ.js → chunk-HRFUSSZI.js} +25 -6
- package/dist/chunk-HRFUSSZI.js.map +1 -0
- package/dist/{chunk-CAMXG5HJ.js → chunk-ZM4ZQZWZ.js} +2 -2
- package/dist/{generate-BGKTKO6E.js → generate-FBHSXR3D.js} +2 -2
- package/dist/index.js +2 -2
- package/dist/{init-Q53R5Q2T.js → init-UFGK5TCN.js} +77 -6
- package/dist/init-UFGK5TCN.js.map +1 -0
- package/dist/{scan-OQU7M4GH.js → scan-CJF2DOQW.js} +3 -3
- package/dist/{scan-generate-T5QNUG7N.js → scan-generate-SJAN5MVI.js} +2 -2
- package/dist/snapshot-SV2JOFZH.js +139 -0
- package/dist/snapshot-SV2JOFZH.js.map +1 -0
- package/dist/{test-2CSOSS3B.js → test-Z5LVO724.js} +2 -2
- package/dist/{tokens-DXEGYTOJ.js → tokens-CE46OTMD.js} +2 -2
- package/dist/{viewer-DBEPYM3G.js → viewer-DLLJIMCK.js} +69 -47
- package/dist/viewer-DLLJIMCK.js.map +1 -0
- package/package.json +6 -14
- package/src/bin.ts +30 -0
- package/src/commands/init.ts +76 -1
- package/src/commands/snapshot.ts +197 -0
- package/src/core/loader.ts +38 -8
- package/src/viewer/__tests__/viewer-integration.test.ts +85 -74
- package/src/viewer/server.ts +37 -22
- package/src/viewer/vite-plugin.ts +25 -9
- package/dist/chunk-566BNPQZ.js.map +0 -1
- package/dist/init-Q53R5Q2T.js.map +0 -1
- package/dist/viewer-DBEPYM3G.js.map +0 -1
- package/src/viewer/__tests__/a11y-fixes.test.ts +0 -358
- package/src/viewer/__tests__/jsx-parser.test.ts +0 -502
- package/src/viewer/__tests__/render-utils.test.ts +0 -232
- package/src/viewer/__tests__/style-utils.test.ts +0 -404
- package/src/viewer/assets/fragments-logo.ts +0 -4
- package/src/viewer/components/AccessibilityPanel.tsx +0 -1457
- package/src/viewer/components/ActionCapture.tsx +0 -172
- package/src/viewer/components/ActionsPanel.tsx +0 -332
- package/src/viewer/components/AllVariantsPreview.tsx +0 -78
- package/src/viewer/components/App.tsx +0 -582
- package/src/viewer/components/BottomPanel.tsx +0 -288
- package/src/viewer/components/CodePanel.naming.test.tsx +0 -59
- package/src/viewer/components/CodePanel.tsx +0 -118
- package/src/viewer/components/CommandPalette.tsx +0 -392
- package/src/viewer/components/ComponentDocView.tsx +0 -164
- package/src/viewer/components/ComponentGraph.tsx +0 -380
- package/src/viewer/components/ComponentHeader.tsx +0 -88
- package/src/viewer/components/ContractPanel.tsx +0 -241
- package/src/viewer/components/EmptyVariantMessage.tsx +0 -54
- package/src/viewer/components/ErrorBoundary.tsx +0 -97
- package/src/viewer/components/FigmaEmbed.tsx +0 -238
- package/src/viewer/components/FragmentEditor.tsx +0 -525
- package/src/viewer/components/FragmentRenderer.tsx +0 -61
- package/src/viewer/components/HeaderSearch.tsx +0 -24
- package/src/viewer/components/HealthDashboard.tsx +0 -441
- package/src/viewer/components/HmrStatusIndicator.tsx +0 -61
- package/src/viewer/components/Icons.tsx +0 -479
- package/src/viewer/components/InteractionsPanel.tsx +0 -757
- package/src/viewer/components/IsolatedPreviewFrame.tsx +0 -346
- package/src/viewer/components/IsolatedRender.tsx +0 -113
- package/src/viewer/components/KeyboardShortcutsHelp.tsx +0 -53
- package/src/viewer/components/LandingPage.tsx +0 -421
- package/src/viewer/components/Layout.tsx +0 -27
- package/src/viewer/components/LeftSidebar.tsx +0 -472
- package/src/viewer/components/LoadErrorMessage.tsx +0 -102
- package/src/viewer/components/MultiViewportPreview.tsx +0 -522
- package/src/viewer/components/NoVariantsMessage.tsx +0 -59
- package/src/viewer/components/PanelShell.tsx +0 -161
- package/src/viewer/components/PerformancePanel.tsx +0 -304
- package/src/viewer/components/PreviewArea.tsx +0 -472
- package/src/viewer/components/PreviewAside.tsx +0 -168
- package/src/viewer/components/PreviewFrameHost.tsx +0 -303
- package/src/viewer/components/PreviewPane.tsx +0 -149
- package/src/viewer/components/PreviewToolbar.tsx +0 -80
- package/src/viewer/components/PropsEditor.tsx +0 -506
- package/src/viewer/components/PropsTable.tsx +0 -111
- package/src/viewer/components/RelationsSection.tsx +0 -88
- package/src/viewer/components/ResizablePanel.tsx +0 -271
- package/src/viewer/components/RightSidebar.tsx +0 -102
- package/src/viewer/components/RuntimeToolsRegistrar.tsx +0 -17
- package/src/viewer/components/ScreenshotButton.tsx +0 -90
- package/src/viewer/components/Sidebar.tsx +0 -169
- package/src/viewer/components/SkeletonLoader.tsx +0 -161
- package/src/viewer/components/ThemeProvider.tsx +0 -42
- package/src/viewer/components/Toast.tsx +0 -3
- package/src/viewer/components/TokenStylePanel.tsx +0 -699
- package/src/viewer/components/TopToolbar.tsx +0 -159
- package/src/viewer/components/UsageSection.tsx +0 -95
- package/src/viewer/components/VariantMatrix.tsx +0 -388
- package/src/viewer/components/VariantRenderer.tsx +0 -131
- package/src/viewer/components/VariantTabs.tsx +0 -40
- package/src/viewer/components/ViewerHeader.tsx +0 -69
- package/src/viewer/components/ViewerStateSync.tsx +0 -52
- package/src/viewer/components/ViewportSelector.tsx +0 -172
- package/src/viewer/components/WebMCPDevTools.tsx +0 -503
- package/src/viewer/components/WebMCPIntegration.tsx +0 -47
- package/src/viewer/components/WebMCPStatusIndicator.tsx +0 -60
- package/src/viewer/components/_future/CreatePage.tsx +0 -836
- package/src/viewer/components/viewer-utils.ts +0 -16
- package/src/viewer/composition-renderer.ts +0 -381
- package/src/viewer/constants/index.ts +0 -1
- package/src/viewer/constants/ui.ts +0 -166
- package/src/viewer/entry.tsx +0 -335
- package/src/viewer/hooks/index.ts +0 -2
- package/src/viewer/hooks/useA11yCache.ts +0 -383
- package/src/viewer/hooks/useA11yService.ts +0 -364
- package/src/viewer/hooks/useActions.ts +0 -138
- package/src/viewer/hooks/useAppState.ts +0 -147
- package/src/viewer/hooks/useCompiledFragments.ts +0 -42
- package/src/viewer/hooks/useFigmaIntegration.ts +0 -132
- package/src/viewer/hooks/useHmrStatus.ts +0 -109
- package/src/viewer/hooks/useKeyboardShortcuts.ts +0 -270
- package/src/viewer/hooks/usePreviewBridge.ts +0 -347
- package/src/viewer/hooks/useScrollSpy.ts +0 -78
- package/src/viewer/hooks/useUrlState.ts +0 -318
- package/src/viewer/hooks/useViewSettings.ts +0 -111
- package/src/viewer/index.html +0 -28
- package/src/viewer/intelligence/healthReport.ts +0 -505
- package/src/viewer/intelligence/styleDrift.ts +0 -340
- package/src/viewer/intelligence/usageScanner.ts +0 -309
- package/src/viewer/jsx-parser.ts +0 -486
- package/src/viewer/preview-frame-entry.tsx +0 -25
- package/src/viewer/preview-frame.html +0 -125
- package/src/viewer/public/favicon.ico +0 -0
- package/src/viewer/render-template.html +0 -68
- package/src/viewer/styles/globals.css +0 -278
- package/src/viewer/types/a11y.ts +0 -197
- package/src/viewer/utils/a11y-fixes.ts +0 -509
- package/src/viewer/utils/actionExport.ts +0 -372
- package/src/viewer/utils/colorSchemes.ts +0 -201
- package/src/viewer/utils/detectRelationships.ts +0 -256
- package/src/viewer/vendor/shared/src/ComponentDocContent.module.scss +0 -10
- package/src/viewer/vendor/shared/src/ComponentDocContent.module.scss.d.ts +0 -2
- package/src/viewer/vendor/shared/src/ComponentDocContent.tsx +0 -274
- package/src/viewer/vendor/shared/src/DocsHeaderBar.tsx +0 -129
- package/src/viewer/vendor/shared/src/DocsPageAsideHost.tsx +0 -89
- package/src/viewer/vendor/shared/src/DocsPageShell.tsx +0 -124
- package/src/viewer/vendor/shared/src/DocsSearchCommand.tsx +0 -99
- package/src/viewer/vendor/shared/src/DocsSidebarNav.tsx +0 -66
- package/src/viewer/vendor/shared/src/PropsTable.module.scss +0 -68
- package/src/viewer/vendor/shared/src/PropsTable.module.scss.d.ts +0 -2
- package/src/viewer/vendor/shared/src/PropsTable.tsx +0 -76
- package/src/viewer/vendor/shared/src/VariantPreviewCard.module.scss +0 -114
- package/src/viewer/vendor/shared/src/VariantPreviewCard.module.scss.d.ts +0 -2
- package/src/viewer/vendor/shared/src/VariantPreviewCard.tsx +0 -134
- package/src/viewer/vendor/shared/src/docs-data/index.ts +0 -32
- package/src/viewer/vendor/shared/src/docs-data/mcp-configs.ts +0 -72
- package/src/viewer/vendor/shared/src/docs-data/palettes.ts +0 -75
- package/src/viewer/vendor/shared/src/docs-data/setup-examples.ts +0 -55
- package/src/viewer/vendor/shared/src/docs-layout.scss +0 -28
- package/src/viewer/vendor/shared/src/docs-layout.scss.d.ts +0 -2
- package/src/viewer/vendor/shared/src/index.ts +0 -34
- package/src/viewer/vendor/shared/src/types.ts +0 -53
- package/src/viewer/webmcp/__tests__/analytics.test.ts +0 -108
- package/src/viewer/webmcp/analytics.ts +0 -165
- package/src/viewer/webmcp/index.ts +0 -3
- package/src/viewer/webmcp/posthog-bridge.ts +0 -39
- package/src/viewer/webmcp/runtime-tools.ts +0 -152
- package/src/viewer/webmcp/scan-utils.ts +0 -135
- package/src/viewer/webmcp/use-tool-analytics.ts +0 -69
- package/src/viewer/webmcp/viewer-state.ts +0 -45
- /package/dist/{chunk-ZDA3PLQ6.js.map → chunk-5G3VZH43.js.map} +0 -0
- /package/dist/{chunk-CAMXG5HJ.js.map → chunk-ZM4ZQZWZ.js.map} +0 -0
- /package/dist/{generate-BGKTKO6E.js.map → generate-FBHSXR3D.js.map} +0 -0
- /package/dist/{scan-OQU7M4GH.js.map → scan-CJF2DOQW.js.map} +0 -0
- /package/dist/{scan-generate-T5QNUG7N.js.map → scan-generate-SJAN5MVI.js.map} +0 -0
- /package/dist/{test-2CSOSS3B.js.map → test-Z5LVO724.js.map} +0 -0
- /package/dist/{tokens-DXEGYTOJ.js.map → tokens-CE46OTMD.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
|
-
}
|