@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.
- package/dist/ai-client-I6MDWNYA.js +21 -0
- package/dist/bin.js +292 -367
- package/dist/bin.js.map +1 -1
- package/dist/{chunk-PW7QTQA6.js → chunk-4OC7FTJB.js} +2 -2
- package/dist/{chunk-HRFUSSZI.js → chunk-AM4MRTMN.js} +2 -2
- package/dist/{chunk-5G3VZH43.js → chunk-GVDSFQ4E.js} +281 -351
- package/dist/chunk-GVDSFQ4E.js.map +1 -0
- package/dist/chunk-JJ2VRTBU.js +626 -0
- package/dist/chunk-JJ2VRTBU.js.map +1 -0
- package/dist/{chunk-D5PYOXEI.js → chunk-LVWFOLUZ.js} +148 -13
- package/dist/{chunk-D5PYOXEI.js.map → chunk-LVWFOLUZ.js.map} +1 -1
- package/dist/{chunk-WXSR2II7.js → chunk-OQKMEFOS.js} +58 -6
- package/dist/chunk-OQKMEFOS.js.map +1 -0
- package/dist/chunk-SXTKFDCR.js +104 -0
- package/dist/chunk-SXTKFDCR.js.map +1 -0
- package/dist/chunk-T5OMVL7E.js +443 -0
- package/dist/chunk-T5OMVL7E.js.map +1 -0
- package/dist/{chunk-ZM4ZQZWZ.js → chunk-TPWGL2XS.js} +39 -37
- package/dist/chunk-TPWGL2XS.js.map +1 -0
- package/dist/{chunk-OQO55NKV.js → chunk-WFS63PCW.js} +85 -11
- package/dist/chunk-WFS63PCW.js.map +1 -0
- package/dist/core/index.js +9 -1
- package/dist/{discovery-NEOY4MPN.js → discovery-ZJQSXF56.js} +3 -3
- package/dist/{generate-FBHSXR3D.js → generate-RJFS2JWA.js} +4 -4
- package/dist/index.js +7 -6
- package/dist/index.js.map +1 -1
- package/dist/init-ZSX3NRCZ.js +636 -0
- package/dist/init-ZSX3NRCZ.js.map +1 -0
- package/dist/mcp-bin.js +2 -2
- package/dist/{scan-CJF2DOQW.js → scan-3PMCJ4RB.js} +6 -6
- package/dist/scan-generate-SYU4PYZD.js +1115 -0
- package/dist/scan-generate-SYU4PYZD.js.map +1 -0
- package/dist/{service-TQYWY65E.js → service-VMGNJZ42.js} +3 -3
- package/dist/snapshot-XOISO2IS.js +139 -0
- package/dist/snapshot-XOISO2IS.js.map +1 -0
- package/dist/{static-viewer-NUBFPKWH.js → static-viewer-5GXH2MGE.js} +3 -3
- package/dist/static-viewer-5GXH2MGE.js.map +1 -0
- package/dist/{test-Z5LVO724.js → test-SI4NSHQX.js} +4 -4
- package/dist/{tokens-CE46OTMD.js → tokens-T6SIVUT5.js} +5 -5
- package/dist/{viewer-DNMNC5VS.js → viewer-7ZEAFBVN.js} +80 -58
- package/dist/viewer-7ZEAFBVN.js.map +1 -0
- package/package.json +6 -14
- package/src/ai-client.ts +156 -0
- package/src/bin.ts +74 -2
- package/src/build.ts +95 -33
- package/src/commands/__tests__/drift-sync.test.ts +252 -0
- package/src/commands/__tests__/scan-generate.test.ts +497 -45
- package/src/commands/enhance.ts +11 -35
- package/src/commands/init.ts +296 -193
- package/src/commands/scan-generate.ts +740 -139
- package/src/commands/scan.ts +37 -32
- package/src/commands/setup.ts +143 -52
- package/src/commands/snapshot.ts +197 -0
- package/src/commands/sync.ts +357 -0
- package/src/commands/validate.ts +43 -1
- package/src/core/component-extractor.test.ts +282 -0
- package/src/core/component-extractor.ts +1030 -0
- package/src/core/discovery.ts +93 -7
- package/src/service/enhance/props-extractor.ts +235 -13
- package/src/validators.ts +236 -0
- 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-5G3VZH43.js.map +0 -1
- package/dist/chunk-OQO55NKV.js.map +0 -1
- package/dist/chunk-WXSR2II7.js.map +0 -1
- package/dist/chunk-ZM4ZQZWZ.js.map +0 -1
- package/dist/init-NDQXUWDU.js +0 -796
- package/dist/init-NDQXUWDU.js.map +0 -1
- package/dist/scan-generate-SJAN5MVI.js +0 -691
- package/dist/scan-generate-SJAN5MVI.js.map +0 -1
- package/dist/viewer-DNMNC5VS.js.map +0 -1
- package/src/ai.ts +0 -266
- package/src/commands/init-framework.ts +0 -414
- package/src/mcp/bin.ts +0 -36
- package/src/migrate/bin.ts +0 -114
- package/src/theme/index.ts +0 -77
- 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/assets/fragments_logo.png +0 -0
- package/src/viewer/bin.ts +0 -86
- package/src/viewer/cli/health.ts +0 -256
- package/src/viewer/cli/index.ts +0 -33
- package/src/viewer/cli/scan.ts +0 -124
- package/src/viewer/cli/utils.ts +0 -174
- 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 -137
- 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/{discovery-NEOY4MPN.js.map → ai-client-I6MDWNYA.js.map} +0 -0
- /package/dist/{chunk-PW7QTQA6.js.map → chunk-4OC7FTJB.js.map} +0 -0
- /package/dist/{chunk-HRFUSSZI.js.map → chunk-AM4MRTMN.js.map} +0 -0
- /package/dist/{scan-CJF2DOQW.js.map → discovery-ZJQSXF56.js.map} +0 -0
- /package/dist/{generate-FBHSXR3D.js.map → generate-RJFS2JWA.js.map} +0 -0
- /package/dist/{service-TQYWY65E.js.map → scan-3PMCJ4RB.js.map} +0 -0
- /package/dist/{static-viewer-NUBFPKWH.js.map → service-VMGNJZ42.js.map} +0 -0
- /package/dist/{test-Z5LVO724.js.map → test-SI4NSHQX.js.map} +0 -0
- /package/dist/{tokens-CE46OTMD.js.map → tokens-T6SIVUT5.js.map} +0 -0
|
@@ -1,522 +0,0 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
|
-
/**
|
|
3
|
-
* Multi-Viewport Preview - Show component at multiple sizes simultaneously
|
|
4
|
-
*
|
|
5
|
-
* Displays the component at mobile, tablet, and desktop widths
|
|
6
|
-
* with proper device mockups and horizontal scrolling.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import { useState, type ReactNode } from "react";
|
|
10
|
-
import { Box, Stack, Text, Button, Menu } from "@fragments-sdk/ui";
|
|
11
|
-
import { ErrorBoundary } from "./ErrorBoundary.js";
|
|
12
|
-
import { IsolatedPreviewFrame } from "./IsolatedPreviewFrame.js";
|
|
13
|
-
import { ChevronDownIcon } from "./Icons.js";
|
|
14
|
-
|
|
15
|
-
interface ViewportConfig {
|
|
16
|
-
name: string;
|
|
17
|
-
width: number;
|
|
18
|
-
height: number;
|
|
19
|
-
type: "mobile" | "tablet" | "desktop";
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
interface MobilePreset {
|
|
23
|
-
name: string;
|
|
24
|
-
width: number;
|
|
25
|
-
height: number;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const MOBILE_PRESETS: MobilePreset[] = [
|
|
29
|
-
{ name: "iPhone SE", width: 375, height: 667 },
|
|
30
|
-
{ name: "iPhone 14", width: 390, height: 844 },
|
|
31
|
-
{ name: "iPhone 14 Pro Max", width: 430, height: 932 },
|
|
32
|
-
{ name: "Pixel 7", width: 412, height: 915 },
|
|
33
|
-
{ name: "Galaxy S21", width: 360, height: 800 },
|
|
34
|
-
];
|
|
35
|
-
|
|
36
|
-
const DEFAULT_VIEWPORTS: ViewportConfig[] = [
|
|
37
|
-
{ name: "Mobile", width: 375, height: 667, type: "mobile" },
|
|
38
|
-
{ name: "Tablet", width: 768, height: 1024, type: "tablet" },
|
|
39
|
-
{ name: "Desktop", width: 1280, height: 800, type: "desktop" },
|
|
40
|
-
];
|
|
41
|
-
|
|
42
|
-
interface MultiViewportPreviewProps {
|
|
43
|
-
/** Component name for error boundary */
|
|
44
|
-
componentName: string;
|
|
45
|
-
/** Fragment path for iframe rendering */
|
|
46
|
-
fragmentPath: string;
|
|
47
|
-
/** Variant name for iframe rendering */
|
|
48
|
-
variantName: string;
|
|
49
|
-
/** Render function that returns the component (fallback) */
|
|
50
|
-
renderContent: () => ReactNode;
|
|
51
|
-
/** Preview theme */
|
|
52
|
-
previewTheme: "light" | "dark";
|
|
53
|
-
/** Base zoom level (used for scaling if needed) */
|
|
54
|
-
zoom: number;
|
|
55
|
-
/** Whether to use iframe isolation */
|
|
56
|
-
useIframeIsolation?: boolean;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export function MultiViewportPreview({
|
|
60
|
-
componentName,
|
|
61
|
-
fragmentPath,
|
|
62
|
-
variantName,
|
|
63
|
-
renderContent,
|
|
64
|
-
previewTheme,
|
|
65
|
-
zoom,
|
|
66
|
-
useIframeIsolation = true,
|
|
67
|
-
}: MultiViewportPreviewProps) {
|
|
68
|
-
const [selectedMobile, setSelectedMobile] = useState<MobilePreset>(MOBILE_PRESETS[0]);
|
|
69
|
-
|
|
70
|
-
// Build viewports with selected mobile preset
|
|
71
|
-
const viewports: ViewportConfig[] = [
|
|
72
|
-
{ name: "Mobile", width: selectedMobile.width, height: selectedMobile.height, type: "mobile" },
|
|
73
|
-
{ name: "Tablet", width: 768, height: 1024, type: "tablet" },
|
|
74
|
-
{ name: "Desktop", width: 1280, height: 800, type: "desktop" },
|
|
75
|
-
];
|
|
76
|
-
|
|
77
|
-
return (
|
|
78
|
-
<Box height="100%" display="flex" style={{ flexDirection: 'column' }} background="primary">
|
|
79
|
-
{/* Header */}
|
|
80
|
-
<Box paddingX="md" paddingY="sm" borderBottom background="secondary" style={{ flexShrink: 0 }}>
|
|
81
|
-
<Stack direction="row" align="center" justify="center" gap="lg">
|
|
82
|
-
{/* Mobile with dropdown */}
|
|
83
|
-
<Menu>
|
|
84
|
-
<Menu.Trigger>
|
|
85
|
-
<Button variant="ghost" size="sm">
|
|
86
|
-
<span style={{ fontSize: 18 }}>📱</span>
|
|
87
|
-
<Text size="sm" weight="medium" color="secondary">Mobile</Text>
|
|
88
|
-
<Text size="xs" color="tertiary">({selectedMobile.width}px)</Text>
|
|
89
|
-
<ChevronDownIcon style={{ width: 12, height: 12 }} />
|
|
90
|
-
</Button>
|
|
91
|
-
</Menu.Trigger>
|
|
92
|
-
<Menu.Content>
|
|
93
|
-
{MOBILE_PRESETS.map((preset) => (
|
|
94
|
-
<Menu.Item
|
|
95
|
-
key={preset.name}
|
|
96
|
-
onClick={() => setSelectedMobile(preset)}
|
|
97
|
-
>
|
|
98
|
-
<Stack direction="row" justify="between" style={{ width: '100%' }}>
|
|
99
|
-
<Text size="xs">{preset.name}</Text>
|
|
100
|
-
<Text size="xs" color="tertiary">{preset.width}×{preset.height}</Text>
|
|
101
|
-
</Stack>
|
|
102
|
-
</Menu.Item>
|
|
103
|
-
))}
|
|
104
|
-
</Menu.Content>
|
|
105
|
-
</Menu>
|
|
106
|
-
|
|
107
|
-
{/* Tablet */}
|
|
108
|
-
<Stack direction="row" align="center" gap="sm">
|
|
109
|
-
<span style={{ fontSize: 18 }}>📱</span>
|
|
110
|
-
<Text size="sm" weight="medium" color="secondary">Tablet</Text>
|
|
111
|
-
<Text size="xs" color="tertiary">(768px)</Text>
|
|
112
|
-
</Stack>
|
|
113
|
-
|
|
114
|
-
{/* Desktop */}
|
|
115
|
-
<Stack direction="row" align="center" gap="sm">
|
|
116
|
-
<span style={{ fontSize: 18 }}>🖥️</span>
|
|
117
|
-
<Text size="sm" weight="medium" color="secondary">Desktop</Text>
|
|
118
|
-
<Text size="xs" color="tertiary">(1280px)</Text>
|
|
119
|
-
</Stack>
|
|
120
|
-
</Stack>
|
|
121
|
-
</Box>
|
|
122
|
-
|
|
123
|
-
{/* Viewport panels with horizontal scroll */}
|
|
124
|
-
<Box overflow="auto" style={{ flex: 1 }}>
|
|
125
|
-
<Stack direction="row" gap="lg" style={{ padding: 32, minWidth: 'max-content' }}>
|
|
126
|
-
{viewports.map((vp) => (
|
|
127
|
-
<ViewportPanel
|
|
128
|
-
key={`${vp.name}-${vp.width}`}
|
|
129
|
-
viewport={vp}
|
|
130
|
-
componentName={componentName}
|
|
131
|
-
fragmentPath={fragmentPath}
|
|
132
|
-
variantName={variantName}
|
|
133
|
-
renderContent={renderContent}
|
|
134
|
-
previewTheme={previewTheme}
|
|
135
|
-
useIframeIsolation={useIframeIsolation}
|
|
136
|
-
/>
|
|
137
|
-
))}
|
|
138
|
-
</Stack>
|
|
139
|
-
</Box>
|
|
140
|
-
</Box>
|
|
141
|
-
);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
interface ViewportPanelProps {
|
|
145
|
-
viewport: ViewportConfig;
|
|
146
|
-
componentName: string;
|
|
147
|
-
fragmentPath: string;
|
|
148
|
-
variantName: string;
|
|
149
|
-
renderContent: () => ReactNode;
|
|
150
|
-
previewTheme: "light" | "dark";
|
|
151
|
-
useIframeIsolation: boolean;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
function ViewportPanel({
|
|
155
|
-
viewport,
|
|
156
|
-
componentName,
|
|
157
|
-
fragmentPath,
|
|
158
|
-
variantName,
|
|
159
|
-
renderContent,
|
|
160
|
-
previewTheme,
|
|
161
|
-
useIframeIsolation,
|
|
162
|
-
}: ViewportPanelProps) {
|
|
163
|
-
if (viewport.type === "desktop") {
|
|
164
|
-
return (
|
|
165
|
-
<DesktopMockup
|
|
166
|
-
width={viewport.width}
|
|
167
|
-
height={viewport.height}
|
|
168
|
-
label={viewport.name}
|
|
169
|
-
previewTheme={previewTheme}
|
|
170
|
-
componentName={componentName}
|
|
171
|
-
fragmentPath={fragmentPath}
|
|
172
|
-
variantName={variantName}
|
|
173
|
-
renderContent={renderContent}
|
|
174
|
-
useIframeIsolation={useIframeIsolation}
|
|
175
|
-
/>
|
|
176
|
-
);
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
return (
|
|
180
|
-
<DeviceMockup
|
|
181
|
-
type={viewport.type}
|
|
182
|
-
width={viewport.width}
|
|
183
|
-
height={viewport.height}
|
|
184
|
-
label={viewport.name}
|
|
185
|
-
previewTheme={previewTheme}
|
|
186
|
-
componentName={componentName}
|
|
187
|
-
fragmentPath={fragmentPath}
|
|
188
|
-
variantName={variantName}
|
|
189
|
-
renderContent={renderContent}
|
|
190
|
-
useIframeIsolation={useIframeIsolation}
|
|
191
|
-
/>
|
|
192
|
-
);
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
interface DeviceMockupProps {
|
|
196
|
-
type: "mobile" | "tablet";
|
|
197
|
-
width: number;
|
|
198
|
-
height: number;
|
|
199
|
-
label: string;
|
|
200
|
-
previewTheme: "light" | "dark";
|
|
201
|
-
componentName: string;
|
|
202
|
-
fragmentPath: string;
|
|
203
|
-
variantName: string;
|
|
204
|
-
renderContent: () => ReactNode;
|
|
205
|
-
useIframeIsolation: boolean;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
function DeviceMockup({
|
|
209
|
-
type,
|
|
210
|
-
width,
|
|
211
|
-
height,
|
|
212
|
-
label,
|
|
213
|
-
previewTheme,
|
|
214
|
-
componentName,
|
|
215
|
-
fragmentPath,
|
|
216
|
-
variantName,
|
|
217
|
-
renderContent,
|
|
218
|
-
useIframeIsolation,
|
|
219
|
-
}: DeviceMockupProps) {
|
|
220
|
-
const isMobile = type === "mobile";
|
|
221
|
-
const frameWidth = width + 24; // Add bezel width
|
|
222
|
-
const screenHeight = height;
|
|
223
|
-
|
|
224
|
-
return (
|
|
225
|
-
<Stack align="center">
|
|
226
|
-
{/* Label */}
|
|
227
|
-
<Text size="sm" weight="medium" color="tertiary" style={{ marginBottom: 12 }}>
|
|
228
|
-
{label}
|
|
229
|
-
</Text>
|
|
230
|
-
|
|
231
|
-
{/* Device frame */}
|
|
232
|
-
<div
|
|
233
|
-
style={{
|
|
234
|
-
position: 'relative',
|
|
235
|
-
flexShrink: 0,
|
|
236
|
-
width: `${frameWidth}px`,
|
|
237
|
-
}}
|
|
238
|
-
>
|
|
239
|
-
<div
|
|
240
|
-
style={{
|
|
241
|
-
position: 'relative',
|
|
242
|
-
borderRadius: 40,
|
|
243
|
-
background: '#1a1a1a',
|
|
244
|
-
padding: 12,
|
|
245
|
-
boxShadow: '0 25px 50px -12px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255,255,255,0.1)',
|
|
246
|
-
}}
|
|
247
|
-
>
|
|
248
|
-
{/* Side buttons (mobile only) */}
|
|
249
|
-
{isMobile && (
|
|
250
|
-
<>
|
|
251
|
-
<div style={{
|
|
252
|
-
position: 'absolute',
|
|
253
|
-
left: -3,
|
|
254
|
-
top: 96,
|
|
255
|
-
width: 3,
|
|
256
|
-
height: 32,
|
|
257
|
-
background: '#2a2a2a',
|
|
258
|
-
borderRadius: '4px 0 0 4px',
|
|
259
|
-
}} />
|
|
260
|
-
<div style={{
|
|
261
|
-
position: 'absolute',
|
|
262
|
-
left: -3,
|
|
263
|
-
top: 144,
|
|
264
|
-
width: 3,
|
|
265
|
-
height: 48,
|
|
266
|
-
background: '#2a2a2a',
|
|
267
|
-
borderRadius: '4px 0 0 4px',
|
|
268
|
-
}} />
|
|
269
|
-
<div style={{
|
|
270
|
-
position: 'absolute',
|
|
271
|
-
left: -3,
|
|
272
|
-
top: 208,
|
|
273
|
-
width: 3,
|
|
274
|
-
height: 48,
|
|
275
|
-
background: '#2a2a2a',
|
|
276
|
-
borderRadius: '4px 0 0 4px',
|
|
277
|
-
}} />
|
|
278
|
-
<div style={{
|
|
279
|
-
position: 'absolute',
|
|
280
|
-
right: -3,
|
|
281
|
-
top: 128,
|
|
282
|
-
width: 3,
|
|
283
|
-
height: 64,
|
|
284
|
-
background: '#2a2a2a',
|
|
285
|
-
borderRadius: '0 4px 4px 0',
|
|
286
|
-
}} />
|
|
287
|
-
</>
|
|
288
|
-
)}
|
|
289
|
-
|
|
290
|
-
{/* Screen container */}
|
|
291
|
-
<div
|
|
292
|
-
style={{
|
|
293
|
-
position: 'relative',
|
|
294
|
-
borderRadius: 32,
|
|
295
|
-
overflow: 'hidden',
|
|
296
|
-
background: '#ffffff',
|
|
297
|
-
height: `${screenHeight}px`,
|
|
298
|
-
width: `${width}px`,
|
|
299
|
-
}}
|
|
300
|
-
>
|
|
301
|
-
{/* Notch (mobile) or Camera (tablet) */}
|
|
302
|
-
{isMobile ? (
|
|
303
|
-
<div style={{
|
|
304
|
-
position: 'absolute',
|
|
305
|
-
top: 0,
|
|
306
|
-
left: '50%',
|
|
307
|
-
transform: 'translateX(-50%)',
|
|
308
|
-
width: 120,
|
|
309
|
-
height: 30,
|
|
310
|
-
background: '#1a1a1a',
|
|
311
|
-
borderRadius: '0 0 16px 16px',
|
|
312
|
-
zIndex: 10,
|
|
313
|
-
display: 'flex',
|
|
314
|
-
alignItems: 'center',
|
|
315
|
-
justifyContent: 'center',
|
|
316
|
-
gap: 8,
|
|
317
|
-
}}>
|
|
318
|
-
<div style={{ width: 8, height: 8, borderRadius: '50%', background: '#2a2a2a' }} />
|
|
319
|
-
<div style={{ width: 48, height: 6, borderRadius: 9999, background: '#2a2a2a' }} />
|
|
320
|
-
</div>
|
|
321
|
-
) : (
|
|
322
|
-
<div style={{
|
|
323
|
-
position: 'absolute',
|
|
324
|
-
top: 8,
|
|
325
|
-
left: '50%',
|
|
326
|
-
transform: 'translateX(-50%)',
|
|
327
|
-
width: 12,
|
|
328
|
-
height: 12,
|
|
329
|
-
borderRadius: '50%',
|
|
330
|
-
background: '#2a2a2a',
|
|
331
|
-
zIndex: 10,
|
|
332
|
-
}} />
|
|
333
|
-
)}
|
|
334
|
-
|
|
335
|
-
{/* Screen content */}
|
|
336
|
-
<div
|
|
337
|
-
style={{ width: '100%', height: '100%', overflow: 'hidden' }}
|
|
338
|
-
data-theme={previewTheme}
|
|
339
|
-
>
|
|
340
|
-
{useIframeIsolation ? (
|
|
341
|
-
<IsolatedPreviewFrame
|
|
342
|
-
fragmentPath={fragmentPath}
|
|
343
|
-
variantName={variantName}
|
|
344
|
-
theme={previewTheme}
|
|
345
|
-
width="100%"
|
|
346
|
-
height="100%"
|
|
347
|
-
minHeight={screenHeight}
|
|
348
|
-
/>
|
|
349
|
-
) : (
|
|
350
|
-
<div style={{
|
|
351
|
-
paddingTop: isMobile ? 40 : 24,
|
|
352
|
-
paddingLeft: 16,
|
|
353
|
-
paddingRight: 16,
|
|
354
|
-
paddingBottom: 16,
|
|
355
|
-
}}>
|
|
356
|
-
<ErrorBoundary
|
|
357
|
-
componentName={componentName}
|
|
358
|
-
fallback={
|
|
359
|
-
<Text size="xs" color="tertiary" style={{ padding: 8 }}>
|
|
360
|
-
Error rendering at {width}px
|
|
361
|
-
</Text>
|
|
362
|
-
}
|
|
363
|
-
>
|
|
364
|
-
{renderContent()}
|
|
365
|
-
</ErrorBoundary>
|
|
366
|
-
</div>
|
|
367
|
-
)}
|
|
368
|
-
</div>
|
|
369
|
-
|
|
370
|
-
{/* Home indicator */}
|
|
371
|
-
<div style={{
|
|
372
|
-
position: 'absolute',
|
|
373
|
-
bottom: 8,
|
|
374
|
-
left: '50%',
|
|
375
|
-
transform: 'translateX(-50%)',
|
|
376
|
-
width: 100,
|
|
377
|
-
height: 4,
|
|
378
|
-
background: 'rgba(0,0,0,0.2)',
|
|
379
|
-
borderRadius: 9999,
|
|
380
|
-
zIndex: 10,
|
|
381
|
-
}} />
|
|
382
|
-
</div>
|
|
383
|
-
</div>
|
|
384
|
-
</div>
|
|
385
|
-
</Stack>
|
|
386
|
-
);
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
interface DesktopMockupProps {
|
|
390
|
-
width: number;
|
|
391
|
-
height: number;
|
|
392
|
-
label: string;
|
|
393
|
-
previewTheme: "light" | "dark";
|
|
394
|
-
componentName: string;
|
|
395
|
-
fragmentPath: string;
|
|
396
|
-
variantName: string;
|
|
397
|
-
renderContent: () => ReactNode;
|
|
398
|
-
useIframeIsolation: boolean;
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
function DesktopMockup({
|
|
402
|
-
width,
|
|
403
|
-
height,
|
|
404
|
-
label,
|
|
405
|
-
previewTheme,
|
|
406
|
-
componentName,
|
|
407
|
-
fragmentPath,
|
|
408
|
-
variantName,
|
|
409
|
-
renderContent,
|
|
410
|
-
useIframeIsolation,
|
|
411
|
-
}: DesktopMockupProps) {
|
|
412
|
-
return (
|
|
413
|
-
<Stack align="center">
|
|
414
|
-
{/* Label */}
|
|
415
|
-
<Text size="sm" weight="medium" color="tertiary" style={{ marginBottom: 12 }}>
|
|
416
|
-
{label}
|
|
417
|
-
</Text>
|
|
418
|
-
|
|
419
|
-
{/* Monitor frame */}
|
|
420
|
-
<Stack align="center">
|
|
421
|
-
{/* Screen */}
|
|
422
|
-
<div
|
|
423
|
-
style={{
|
|
424
|
-
position: 'relative',
|
|
425
|
-
background: '#1a1a1a',
|
|
426
|
-
borderRadius: 8,
|
|
427
|
-
padding: 8,
|
|
428
|
-
boxShadow: '0 25px 50px -12px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255,255,255,0.1)',
|
|
429
|
-
}}
|
|
430
|
-
>
|
|
431
|
-
{/* Browser chrome */}
|
|
432
|
-
<div style={{
|
|
433
|
-
display: 'flex',
|
|
434
|
-
alignItems: 'center',
|
|
435
|
-
gap: 8,
|
|
436
|
-
padding: '8px 12px',
|
|
437
|
-
background: '#2a2a2a',
|
|
438
|
-
borderRadius: '6px 6px 0 0',
|
|
439
|
-
}}>
|
|
440
|
-
<div style={{ display: 'flex', alignItems: 'center', gap: 6 }}>
|
|
441
|
-
<div style={{ width: 12, height: 12, borderRadius: '50%', background: '#ff5f57' }} />
|
|
442
|
-
<div style={{ width: 12, height: 12, borderRadius: '50%', background: '#ffbd2e' }} />
|
|
443
|
-
<div style={{ width: 12, height: 12, borderRadius: '50%', background: '#28ca41' }} />
|
|
444
|
-
</div>
|
|
445
|
-
<div style={{ flex: 1, margin: '0 16px' }}>
|
|
446
|
-
<div style={{
|
|
447
|
-
height: 24,
|
|
448
|
-
background: '#3a3a3a',
|
|
449
|
-
borderRadius: 6,
|
|
450
|
-
display: 'flex',
|
|
451
|
-
alignItems: 'center',
|
|
452
|
-
justifyContent: 'center',
|
|
453
|
-
padding: '0 12px',
|
|
454
|
-
}}>
|
|
455
|
-
<span style={{
|
|
456
|
-
fontSize: 12,
|
|
457
|
-
color: '#9ca3af',
|
|
458
|
-
overflow: 'hidden',
|
|
459
|
-
textOverflow: 'ellipsis',
|
|
460
|
-
whiteSpace: 'nowrap',
|
|
461
|
-
}}>
|
|
462
|
-
localhost:6006 — {width}px
|
|
463
|
-
</span>
|
|
464
|
-
</div>
|
|
465
|
-
</div>
|
|
466
|
-
</div>
|
|
467
|
-
|
|
468
|
-
{/* Screen content */}
|
|
469
|
-
<div
|
|
470
|
-
style={{
|
|
471
|
-
overflow: 'hidden',
|
|
472
|
-
width: `${width}px`,
|
|
473
|
-
height: `${height}px`,
|
|
474
|
-
}}
|
|
475
|
-
data-theme={previewTheme}
|
|
476
|
-
>
|
|
477
|
-
{useIframeIsolation ? (
|
|
478
|
-
<IsolatedPreviewFrame
|
|
479
|
-
fragmentPath={fragmentPath}
|
|
480
|
-
variantName={variantName}
|
|
481
|
-
theme={previewTheme}
|
|
482
|
-
width="100%"
|
|
483
|
-
height="100%"
|
|
484
|
-
minHeight={height}
|
|
485
|
-
/>
|
|
486
|
-
) : (
|
|
487
|
-
<div style={{ padding: 24 }}>
|
|
488
|
-
<ErrorBoundary
|
|
489
|
-
componentName={componentName}
|
|
490
|
-
fallback={
|
|
491
|
-
<Text size="xs" color="tertiary" style={{ padding: 8 }}>
|
|
492
|
-
Error rendering at {width}px
|
|
493
|
-
</Text>
|
|
494
|
-
}
|
|
495
|
-
>
|
|
496
|
-
{renderContent()}
|
|
497
|
-
</ErrorBoundary>
|
|
498
|
-
</div>
|
|
499
|
-
)}
|
|
500
|
-
</div>
|
|
501
|
-
</div>
|
|
502
|
-
|
|
503
|
-
{/* Monitor stand */}
|
|
504
|
-
<div style={{
|
|
505
|
-
width: 80,
|
|
506
|
-
height: 16,
|
|
507
|
-
background: 'linear-gradient(to bottom, #2a2a2a, #1a1a1a)',
|
|
508
|
-
borderRadius: '0 0 2px 2px',
|
|
509
|
-
}} />
|
|
510
|
-
<div style={{
|
|
511
|
-
width: 128,
|
|
512
|
-
height: 8,
|
|
513
|
-
background: '#1a1a1a',
|
|
514
|
-
borderRadius: 9999,
|
|
515
|
-
boxShadow: '0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1)',
|
|
516
|
-
}} />
|
|
517
|
-
</Stack>
|
|
518
|
-
</Stack>
|
|
519
|
-
);
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
export { DEFAULT_VIEWPORTS as VIEWPORTS, MOBILE_PRESETS };
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import type { FragmentDefinition } from "../../core/index.js";
|
|
2
|
-
import { Stack, Text, Alert, EmptyState } from "@fragments-sdk/ui";
|
|
3
|
-
import { LoadErrorMessage } from "./LoadErrorMessage.js";
|
|
4
|
-
|
|
5
|
-
interface NoVariantsMessageProps {
|
|
6
|
-
fragment?: FragmentDefinition;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export function NoVariantsMessage({ fragment }: NoVariantsMessageProps) {
|
|
10
|
-
// Check for load error (missing dependencies, schema errors, etc.)
|
|
11
|
-
const loadError = (fragment as any)?._loadError;
|
|
12
|
-
if (loadError) {
|
|
13
|
-
return <LoadErrorMessage error={loadError} componentName={fragment?.meta?.name} />;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const skippedVariants = (fragment?._generated as any)?.skippedVariants;
|
|
17
|
-
|
|
18
|
-
if (!skippedVariants || skippedVariants.length === 0) {
|
|
19
|
-
return (
|
|
20
|
-
<EmptyState style={{ height: "100%" }}>
|
|
21
|
-
<EmptyState.Description>No variants defined</EmptyState.Description>
|
|
22
|
-
</EmptyState>
|
|
23
|
-
);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return (
|
|
27
|
-
<Stack align="center" justify="center" style={{ height: "100%", padding: "24px" }}>
|
|
28
|
-
<Alert variant="info">
|
|
29
|
-
<Alert.Body>
|
|
30
|
-
<Alert.Title>
|
|
31
|
-
{skippedVariants.length} variant{skippedVariants.length === 1 ? "" : "s"} skipped
|
|
32
|
-
</Alert.Title>
|
|
33
|
-
<Alert.Content>
|
|
34
|
-
<Stack direction="column" gap="sm">
|
|
35
|
-
<Text size="xs" color="secondary">
|
|
36
|
-
These variants couldn't be rendered because they use syntax the parser doesn't
|
|
37
|
-
support yet:
|
|
38
|
-
</Text>
|
|
39
|
-
<ul style={{ marginTop: "4px", marginLeft: "16px", listStyleType: "disc" }}>
|
|
40
|
-
{skippedVariants.map((sv: any, i: number) => (
|
|
41
|
-
<li key={i}>
|
|
42
|
-
<Text size="xs" color="secondary">
|
|
43
|
-
<Text as="span" size="xs" weight="semibold">
|
|
44
|
-
{sv.name}:
|
|
45
|
-
</Text>{" "}
|
|
46
|
-
<Text as="span" size="xs" color="tertiary">
|
|
47
|
-
{sv.reason}
|
|
48
|
-
</Text>
|
|
49
|
-
</Text>
|
|
50
|
-
</li>
|
|
51
|
-
))}
|
|
52
|
-
</ul>
|
|
53
|
-
</Stack>
|
|
54
|
-
</Alert.Content>
|
|
55
|
-
</Alert.Body>
|
|
56
|
-
</Alert>
|
|
57
|
-
</Stack>
|
|
58
|
-
);
|
|
59
|
-
}
|