@fragments-sdk/viewer 0.2.1 → 0.2.4
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/package.json +10 -3
- package/src/components/App.tsx +67 -4
- package/src/components/BottomPanel.tsx +31 -1
- package/src/components/ComponentGraph.tsx +1 -1
- package/src/components/EmptyVariantMessage.tsx +1 -1
- package/src/components/ErrorBoundary.tsx +2 -4
- package/src/components/FragmentRenderer.tsx +27 -4
- package/src/components/HeaderSearch.tsx +1 -1
- package/src/components/InteractionsPanel.tsx +5 -5
- package/src/components/LoadErrorMessage.tsx +26 -30
- package/src/components/NoVariantsMessage.tsx +1 -1
- package/src/components/PanelShell.tsx +1 -1
- package/src/components/PerformancePanel.tsx +4 -4
- package/src/components/PreviewArea.tsx +6 -0
- package/src/components/PropsEditor.tsx +33 -17
- package/src/components/SkeletonLoader.tsx +0 -1
- package/src/components/TokenStylePanel.tsx +3 -3
- package/src/components/TopToolbar.tsx +1 -1
- package/src/components/VariantMatrix.tsx +11 -1
- package/src/components/ViewerHeader.tsx +1 -1
- package/src/components/WebMCPDevTools.tsx +2 -2
- package/src/entry.tsx +4 -6
- package/src/hooks/useAppState.ts +1 -1
- package/src/preview-frame-entry.tsx +0 -2
- package/src/shared/DocsHeaderBar.module.scss +174 -0
- package/src/shared/DocsHeaderBar.tsx +149 -14
- package/src/shared/DocsSidebarNav.tsx +3 -3
- package/src/shared/index.ts +4 -1
- package/src/shared/types.ts +29 -3
- package/src/style-utils.ts +1 -1
- package/src/webmcp/runtime-tools.ts +1 -1
- package/tsconfig.json +2 -2
- package/src/assets/fragments-logo.ts +0 -4
- package/src/components/ActionsPanel.tsx +0 -332
- package/src/components/ComponentHeader.tsx +0 -88
- package/src/components/ContractPanel.tsx +0 -241
- package/src/components/FragmentEditor.tsx +0 -525
- package/src/components/HmrStatusIndicator.tsx +0 -61
- package/src/components/LandingPage.tsx +0 -420
- package/src/components/PropsTable.tsx +0 -111
- package/src/components/RelationsSection.tsx +0 -88
- package/src/components/ResizablePanel.tsx +0 -271
- package/src/components/RightSidebar.tsx +0 -102
- package/src/components/ScreenshotButton.tsx +0 -90
- package/src/components/Sidebar.tsx +0 -169
- package/src/components/UsageSection.tsx +0 -95
- package/src/components/VariantTabs.tsx +0 -40
- package/src/components/ViewportSelector.tsx +0 -172
- package/src/components/_future/CreatePage.tsx +0 -835
- package/src/composition-renderer.ts +0 -381
- package/src/constants/index.ts +0 -1
- package/src/hooks/index.ts +0 -2
- package/src/hooks/useHmrStatus.ts +0 -109
- package/src/hooks/useScrollSpy.ts +0 -78
- package/src/intelligence/healthReport.ts +0 -505
- package/src/intelligence/styleDrift.ts +0 -340
- package/src/intelligence/usageScanner.ts +0 -309
- package/src/utils/actionExport.ts +0 -372
- package/src/utils/colorSchemes.ts +0 -201
- package/src/webmcp/index.ts +0 -3
|
@@ -1,420 +0,0 @@
|
|
|
1
|
-
import { useForm, Controller } from 'react-hook-form';
|
|
2
|
-
import { zodResolver } from '@hookform/resolvers/zod';
|
|
3
|
-
import { z } from 'zod';
|
|
4
|
-
import { useState, useRef, useEffect } from 'react';
|
|
5
|
-
import { HexColorPicker } from 'react-colorful';
|
|
6
|
-
import { Box, Button, Input, Toggle, Stack, Text, Card, Field, Separator, Select } from '@fragments-sdk/ui';
|
|
7
|
-
import { generateColorScheme, type ColorSchemeType } from '../utils/colorSchemes.js';
|
|
8
|
-
import { ChevronDownIcon } from './Icons.js';
|
|
9
|
-
|
|
10
|
-
const formSchema = z.object({
|
|
11
|
-
projectName: z.string().min(2, 'Project name must be at least 2 characters'),
|
|
12
|
-
componentName: z.string().min(2, 'Component name must be at least 2 characters'),
|
|
13
|
-
description: z.string().optional(),
|
|
14
|
-
headlessLibrary: z.enum(['radix', 'base-ui']),
|
|
15
|
-
colorSchemeType: z.enum(['monochromatic', 'complementary', 'analogous', 'triadic', 'split-complementary', 'tetradic']),
|
|
16
|
-
primaryColor: z.string().regex(/^#[0-9A-Fa-f]{6}$/, 'Must be a valid hex color'),
|
|
17
|
-
darkMode: z.boolean(),
|
|
18
|
-
borderRadius: z.enum(['none', 'sm', 'md', 'lg', 'full']),
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
export type LandingFormData = z.infer<typeof formSchema>;
|
|
22
|
-
|
|
23
|
-
interface LandingPageProps {
|
|
24
|
-
onSubmit?: (data: LandingFormData) => void;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const SCHEME_OPTIONS: Array<{
|
|
28
|
-
value: ColorSchemeType;
|
|
29
|
-
label: string;
|
|
30
|
-
description: string;
|
|
31
|
-
colorCount: number;
|
|
32
|
-
}> = [
|
|
33
|
-
{ value: 'monochromatic', label: 'Monochromatic', description: 'Variations of a single hue', colorCount: 5 },
|
|
34
|
-
{ value: 'complementary', label: 'Complementary', description: 'Two opposite colors', colorCount: 2 },
|
|
35
|
-
{ value: 'analogous', label: 'Analogous', description: 'Three adjacent colors', colorCount: 3 },
|
|
36
|
-
{ value: 'triadic', label: 'Triadic', description: 'Three evenly spaced colors', colorCount: 3 },
|
|
37
|
-
{ value: 'split-complementary', label: 'Split Complementary', description: 'Base + two adjacent to complement', colorCount: 3 },
|
|
38
|
-
{ value: 'tetradic', label: 'Tetradic (Square)', description: 'Four evenly spaced colors', colorCount: 4 },
|
|
39
|
-
];
|
|
40
|
-
|
|
41
|
-
function getSchemeKeyColors(baseColor: string, type: ColorSchemeType): string[] {
|
|
42
|
-
const fullPalette = generateColorScheme(baseColor, type);
|
|
43
|
-
|
|
44
|
-
switch (type) {
|
|
45
|
-
case 'monochromatic':
|
|
46
|
-
return fullPalette;
|
|
47
|
-
case 'complementary':
|
|
48
|
-
return [fullPalette[1], fullPalette[3]];
|
|
49
|
-
case 'analogous':
|
|
50
|
-
return [fullPalette[0], fullPalette[2], fullPalette[4]];
|
|
51
|
-
case 'triadic':
|
|
52
|
-
return [fullPalette[0], fullPalette[2], fullPalette[4]];
|
|
53
|
-
case 'split-complementary':
|
|
54
|
-
return [fullPalette[0], fullPalette[2], fullPalette[4]];
|
|
55
|
-
case 'tetradic':
|
|
56
|
-
return [fullPalette[0], fullPalette[1], fullPalette[2], fullPalette[3]];
|
|
57
|
-
default:
|
|
58
|
-
return fullPalette;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export function LandingPage({ onSubmit }: LandingPageProps) {
|
|
63
|
-
const [showColorPicker, setShowColorPicker] = useState(false);
|
|
64
|
-
const colorPickerRef = useRef<HTMLDivElement>(null);
|
|
65
|
-
|
|
66
|
-
const {
|
|
67
|
-
register,
|
|
68
|
-
handleSubmit,
|
|
69
|
-
watch,
|
|
70
|
-
control,
|
|
71
|
-
setValue,
|
|
72
|
-
formState: { errors, isSubmitting },
|
|
73
|
-
} = useForm<LandingFormData>({
|
|
74
|
-
resolver: zodResolver(formSchema),
|
|
75
|
-
defaultValues: {
|
|
76
|
-
projectName: '',
|
|
77
|
-
componentName: '',
|
|
78
|
-
description: '',
|
|
79
|
-
headlessLibrary: 'radix',
|
|
80
|
-
colorSchemeType: 'monochromatic',
|
|
81
|
-
primaryColor: '#10a37f',
|
|
82
|
-
darkMode: true,
|
|
83
|
-
borderRadius: 'md',
|
|
84
|
-
},
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
const primaryColor = watch('primaryColor');
|
|
88
|
-
const colorSchemeType = watch('colorSchemeType');
|
|
89
|
-
|
|
90
|
-
const currentPalette = getSchemeKeyColors(primaryColor, colorSchemeType);
|
|
91
|
-
const currentScheme = SCHEME_OPTIONS.find(s => s.value === colorSchemeType);
|
|
92
|
-
|
|
93
|
-
useEffect(() => {
|
|
94
|
-
const handleClickOutside = (event: MouseEvent) => {
|
|
95
|
-
if (colorPickerRef.current && !colorPickerRef.current.contains(event.target as Node)) {
|
|
96
|
-
setShowColorPicker(false);
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
document.addEventListener('mousedown', handleClickOutside);
|
|
100
|
-
return () => document.removeEventListener('mousedown', handleClickOutside);
|
|
101
|
-
}, []);
|
|
102
|
-
|
|
103
|
-
const handleFormSubmit = (data: LandingFormData) => {
|
|
104
|
-
onSubmit?.(data);
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
return (
|
|
108
|
-
<Box background="primary" style={{ minHeight: '100vh' }}>
|
|
109
|
-
<div style={{ maxWidth: '672px', margin: '0 auto', padding: '64px 24px' }}>
|
|
110
|
-
{/* Header */}
|
|
111
|
-
<Stack direction="column" gap="sm" style={{ marginBottom: '48px' }}>
|
|
112
|
-
<Text as="h1" size="xl" weight="semibold">Create Component</Text>
|
|
113
|
-
<Text color="secondary">Configure your component settings below.</Text>
|
|
114
|
-
</Stack>
|
|
115
|
-
|
|
116
|
-
<form onSubmit={handleSubmit(handleFormSubmit)}>
|
|
117
|
-
<Stack direction="column" gap="lg">
|
|
118
|
-
{/* Project Name */}
|
|
119
|
-
<Field>
|
|
120
|
-
<Field.Label>Project Name</Field.Label>
|
|
121
|
-
<Field.Control>
|
|
122
|
-
<Input
|
|
123
|
-
{...register('projectName')}
|
|
124
|
-
placeholder="my-design-system"
|
|
125
|
-
style={errors.projectName ? { boxShadow: '0 0 0 1px #ef4444' } : {}}
|
|
126
|
-
/>
|
|
127
|
-
</Field.Control>
|
|
128
|
-
{errors.projectName && (
|
|
129
|
-
<Field.Error>{errors.projectName.message}</Field.Error>
|
|
130
|
-
)}
|
|
131
|
-
</Field>
|
|
132
|
-
|
|
133
|
-
{/* Component Name */}
|
|
134
|
-
<Field>
|
|
135
|
-
<Field.Label>Component Name</Field.Label>
|
|
136
|
-
<Field.Control>
|
|
137
|
-
<Input
|
|
138
|
-
{...register('componentName')}
|
|
139
|
-
placeholder="Button"
|
|
140
|
-
style={errors.componentName ? { boxShadow: '0 0 0 1px #ef4444' } : {}}
|
|
141
|
-
/>
|
|
142
|
-
</Field.Control>
|
|
143
|
-
{errors.componentName && (
|
|
144
|
-
<Field.Error>{errors.componentName.message}</Field.Error>
|
|
145
|
-
)}
|
|
146
|
-
</Field>
|
|
147
|
-
|
|
148
|
-
{/* Description */}
|
|
149
|
-
<Field>
|
|
150
|
-
<Field.Label>Description</Field.Label>
|
|
151
|
-
<Field.Control>
|
|
152
|
-
<textarea
|
|
153
|
-
{...register('description')}
|
|
154
|
-
rows={2}
|
|
155
|
-
placeholder="A brief description of the component"
|
|
156
|
-
style={{
|
|
157
|
-
width: '100%',
|
|
158
|
-
padding: '12px 16px',
|
|
159
|
-
borderRadius: '12px',
|
|
160
|
-
fontSize: '14px',
|
|
161
|
-
backgroundColor: 'var(--bg-tertiary)',
|
|
162
|
-
color: 'var(--text-primary)',
|
|
163
|
-
border: '1px solid transparent',
|
|
164
|
-
outline: 'none',
|
|
165
|
-
transition: 'all 150ms',
|
|
166
|
-
resize: 'none',
|
|
167
|
-
}}
|
|
168
|
-
onFocus={(e) => { e.currentTarget.style.boxShadow = '0 0 0 1px var(--border-strong)'; }}
|
|
169
|
-
onBlur={(e) => { e.currentTarget.style.boxShadow = 'none'; }}
|
|
170
|
-
/>
|
|
171
|
-
</Field.Control>
|
|
172
|
-
</Field>
|
|
173
|
-
|
|
174
|
-
<Separator />
|
|
175
|
-
|
|
176
|
-
{/* Headless Library */}
|
|
177
|
-
<Field>
|
|
178
|
-
<Field.Label>Headless Library</Field.Label>
|
|
179
|
-
<Field.Control>
|
|
180
|
-
<div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: '12px' }}>
|
|
181
|
-
{[
|
|
182
|
-
{ value: 'radix', label: 'Radix UI', desc: 'Accessible primitives' },
|
|
183
|
-
{ value: 'base-ui', label: 'Base UI', desc: 'Hooks-first approach' },
|
|
184
|
-
].map((lib) => (
|
|
185
|
-
<label
|
|
186
|
-
key={lib.value}
|
|
187
|
-
style={{
|
|
188
|
-
display: 'flex',
|
|
189
|
-
flexDirection: 'column',
|
|
190
|
-
padding: '16px',
|
|
191
|
-
borderRadius: '12px',
|
|
192
|
-
cursor: 'pointer',
|
|
193
|
-
transition: 'all 150ms',
|
|
194
|
-
border: watch('headlessLibrary') === lib.value
|
|
195
|
-
? '1px solid var(--color-accent)'
|
|
196
|
-
: '1px solid var(--border)',
|
|
197
|
-
backgroundColor: watch('headlessLibrary') === lib.value
|
|
198
|
-
? 'rgba(16, 163, 127, 0.05)'
|
|
199
|
-
: 'transparent',
|
|
200
|
-
}}
|
|
201
|
-
>
|
|
202
|
-
<input
|
|
203
|
-
type="radio"
|
|
204
|
-
{...register('headlessLibrary')}
|
|
205
|
-
value={lib.value}
|
|
206
|
-
style={{ position: 'absolute', width: '1px', height: '1px', overflow: 'hidden', clip: 'rect(0,0,0,0)' }}
|
|
207
|
-
/>
|
|
208
|
-
<Text size="sm" weight="medium">{lib.label}</Text>
|
|
209
|
-
<Text size="xs" color="tertiary" style={{ marginTop: '2px' }}>{lib.desc}</Text>
|
|
210
|
-
</label>
|
|
211
|
-
))}
|
|
212
|
-
</div>
|
|
213
|
-
</Field.Control>
|
|
214
|
-
</Field>
|
|
215
|
-
|
|
216
|
-
<Separator />
|
|
217
|
-
|
|
218
|
-
{/* Color Scheme */}
|
|
219
|
-
<Field>
|
|
220
|
-
<Field.Label>Color Scheme</Field.Label>
|
|
221
|
-
<Field.Control>
|
|
222
|
-
<Stack direction="column" gap="md">
|
|
223
|
-
{/* Primary Color */}
|
|
224
|
-
<Stack direction="row" align="center" gap="md">
|
|
225
|
-
<div style={{ position: 'relative' }} ref={colorPickerRef}>
|
|
226
|
-
<button
|
|
227
|
-
type="button"
|
|
228
|
-
onClick={() => setShowColorPicker(!showColorPicker)}
|
|
229
|
-
style={{
|
|
230
|
-
width: '48px',
|
|
231
|
-
height: '48px',
|
|
232
|
-
borderRadius: '8px',
|
|
233
|
-
border: '1px solid var(--border)',
|
|
234
|
-
cursor: 'pointer',
|
|
235
|
-
backgroundColor: primaryColor,
|
|
236
|
-
}}
|
|
237
|
-
/>
|
|
238
|
-
{showColorPicker && (
|
|
239
|
-
<div style={{
|
|
240
|
-
position: 'absolute',
|
|
241
|
-
top: '56px',
|
|
242
|
-
left: 0,
|
|
243
|
-
zIndex: 50,
|
|
244
|
-
padding: '12px',
|
|
245
|
-
borderRadius: '12px',
|
|
246
|
-
backgroundColor: 'var(--bg-elevated)',
|
|
247
|
-
border: '1px solid var(--border)',
|
|
248
|
-
boxShadow: 'var(--shadow-lg)',
|
|
249
|
-
}}>
|
|
250
|
-
<Controller
|
|
251
|
-
name="primaryColor"
|
|
252
|
-
control={control}
|
|
253
|
-
render={({ field }) => (
|
|
254
|
-
<HexColorPicker color={field.value} onChange={field.onChange} />
|
|
255
|
-
)}
|
|
256
|
-
/>
|
|
257
|
-
<Input
|
|
258
|
-
value={primaryColor}
|
|
259
|
-
onChange={(e: React.ChangeEvent<HTMLInputElement>) => setValue('primaryColor', e.target.value)}
|
|
260
|
-
size="sm"
|
|
261
|
-
style={{ width: '100%', marginTop: '12px', fontFamily: 'monospace' }}
|
|
262
|
-
/>
|
|
263
|
-
</div>
|
|
264
|
-
)}
|
|
265
|
-
</div>
|
|
266
|
-
<div style={{ flex: 1 }}>
|
|
267
|
-
<Input
|
|
268
|
-
value={primaryColor}
|
|
269
|
-
onChange={(e: React.ChangeEvent<HTMLInputElement>) => setValue('primaryColor', e.target.value)}
|
|
270
|
-
style={{ fontFamily: 'monospace' }}
|
|
271
|
-
/>
|
|
272
|
-
</div>
|
|
273
|
-
</Stack>
|
|
274
|
-
|
|
275
|
-
{/* Scheme Type Dropdown */}
|
|
276
|
-
<Select
|
|
277
|
-
value={colorSchemeType}
|
|
278
|
-
onValueChange={(value: string) => setValue('colorSchemeType', value as ColorSchemeType)}
|
|
279
|
-
>
|
|
280
|
-
<Select.Trigger>
|
|
281
|
-
<Stack direction="row" align="center" gap="sm">
|
|
282
|
-
<div style={{ display: 'flex', gap: '2px' }}>
|
|
283
|
-
{getSchemeKeyColors(primaryColor, colorSchemeType).map((color, i) => (
|
|
284
|
-
<div
|
|
285
|
-
key={i}
|
|
286
|
-
style={{ width: '16px', height: '16px', borderRadius: '2px', backgroundColor: color }}
|
|
287
|
-
/>
|
|
288
|
-
))}
|
|
289
|
-
</div>
|
|
290
|
-
<span>{currentScheme?.label}</span>
|
|
291
|
-
<Text as="span" color="tertiary">-- {currentScheme?.description}</Text>
|
|
292
|
-
</Stack>
|
|
293
|
-
</Select.Trigger>
|
|
294
|
-
<Select.Content>
|
|
295
|
-
{SCHEME_OPTIONS.map((scheme) => (
|
|
296
|
-
<Select.Item key={scheme.value} value={scheme.value}>
|
|
297
|
-
<Stack direction="row" align="center" gap="sm">
|
|
298
|
-
<div style={{ display: 'flex', gap: '2px', flexShrink: 0 }}>
|
|
299
|
-
{getSchemeKeyColors(primaryColor, scheme.value).map((color, i) => (
|
|
300
|
-
<div
|
|
301
|
-
key={i}
|
|
302
|
-
style={{ width: '20px', height: '20px', borderRadius: '2px', backgroundColor: color }}
|
|
303
|
-
/>
|
|
304
|
-
))}
|
|
305
|
-
</div>
|
|
306
|
-
<div>
|
|
307
|
-
<Text size="sm">{scheme.label}</Text>
|
|
308
|
-
<Text size="xs" color="tertiary">{scheme.description}</Text>
|
|
309
|
-
</div>
|
|
310
|
-
</Stack>
|
|
311
|
-
</Select.Item>
|
|
312
|
-
))}
|
|
313
|
-
</Select.Content>
|
|
314
|
-
</Select>
|
|
315
|
-
|
|
316
|
-
{/* Current Palette Preview */}
|
|
317
|
-
<div>
|
|
318
|
-
<div style={{ display: 'flex', gap: '6px' }}>
|
|
319
|
-
{currentPalette.map((color, i) => (
|
|
320
|
-
<div
|
|
321
|
-
key={i}
|
|
322
|
-
style={{
|
|
323
|
-
flex: 1,
|
|
324
|
-
height: '48px',
|
|
325
|
-
borderRadius: '8px',
|
|
326
|
-
transition: 'background-color 150ms',
|
|
327
|
-
backgroundColor: color,
|
|
328
|
-
}}
|
|
329
|
-
/>
|
|
330
|
-
))}
|
|
331
|
-
</div>
|
|
332
|
-
<Text size="xs" color="tertiary" style={{ marginTop: '8px' }}>
|
|
333
|
-
{currentScheme?.colorCount} color {currentScheme?.label.toLowerCase()} palette
|
|
334
|
-
</Text>
|
|
335
|
-
</div>
|
|
336
|
-
</Stack>
|
|
337
|
-
</Field.Control>
|
|
338
|
-
</Field>
|
|
339
|
-
|
|
340
|
-
<Separator />
|
|
341
|
-
|
|
342
|
-
{/* Style Options */}
|
|
343
|
-
<Stack direction="column" gap="lg">
|
|
344
|
-
{/* Border Radius */}
|
|
345
|
-
<Stack direction="row" align="center" justify="between">
|
|
346
|
-
<div>
|
|
347
|
-
<Text size="sm">Border Radius</Text>
|
|
348
|
-
<Text size="xs" color="tertiary" style={{ marginTop: '2px' }}>Component corner style</Text>
|
|
349
|
-
</div>
|
|
350
|
-
<div style={{
|
|
351
|
-
display: 'flex',
|
|
352
|
-
gap: '4px',
|
|
353
|
-
backgroundColor: 'var(--bg-tertiary)',
|
|
354
|
-
padding: '4px',
|
|
355
|
-
borderRadius: '8px',
|
|
356
|
-
}}>
|
|
357
|
-
{(['none', 'sm', 'md', 'lg', 'full'] as const).map((radius) => (
|
|
358
|
-
<label
|
|
359
|
-
key={radius}
|
|
360
|
-
style={{
|
|
361
|
-
padding: '6px 12px',
|
|
362
|
-
fontSize: '12px',
|
|
363
|
-
fontWeight: 500,
|
|
364
|
-
borderRadius: '6px',
|
|
365
|
-
cursor: 'pointer',
|
|
366
|
-
transition: 'all 150ms',
|
|
367
|
-
color: watch('borderRadius') === radius ? 'var(--text-primary)' : 'var(--text-tertiary)',
|
|
368
|
-
backgroundColor: watch('borderRadius') === radius ? 'var(--bg-primary)' : 'transparent',
|
|
369
|
-
boxShadow: watch('borderRadius') === radius ? 'var(--shadow-sm)' : 'none',
|
|
370
|
-
}}
|
|
371
|
-
>
|
|
372
|
-
<input
|
|
373
|
-
type="radio"
|
|
374
|
-
{...register('borderRadius')}
|
|
375
|
-
value={radius}
|
|
376
|
-
style={{ position: 'absolute', width: '1px', height: '1px', overflow: 'hidden', clip: 'rect(0,0,0,0)' }}
|
|
377
|
-
/>
|
|
378
|
-
{radius}
|
|
379
|
-
</label>
|
|
380
|
-
))}
|
|
381
|
-
</div>
|
|
382
|
-
</Stack>
|
|
383
|
-
|
|
384
|
-
{/* Dark Mode */}
|
|
385
|
-
<Stack direction="row" align="center" justify="between">
|
|
386
|
-
<div>
|
|
387
|
-
<Text size="sm">Dark Mode</Text>
|
|
388
|
-
<Text size="xs" color="tertiary" style={{ marginTop: '2px' }}>Include dark theme styles</Text>
|
|
389
|
-
</div>
|
|
390
|
-
<Controller
|
|
391
|
-
name="darkMode"
|
|
392
|
-
control={control}
|
|
393
|
-
render={({ field }) => (
|
|
394
|
-
<Toggle
|
|
395
|
-
checked={field.value}
|
|
396
|
-
onCheckedChange={field.onChange}
|
|
397
|
-
/>
|
|
398
|
-
)}
|
|
399
|
-
/>
|
|
400
|
-
</Stack>
|
|
401
|
-
</Stack>
|
|
402
|
-
|
|
403
|
-
<Separator />
|
|
404
|
-
|
|
405
|
-
{/* Submit */}
|
|
406
|
-
<Button
|
|
407
|
-
type="submit"
|
|
408
|
-
variant="primary"
|
|
409
|
-
size="lg"
|
|
410
|
-
fullWidth
|
|
411
|
-
disabled={isSubmitting}
|
|
412
|
-
>
|
|
413
|
-
{isSubmitting ? 'Creating...' : 'Create Component'}
|
|
414
|
-
</Button>
|
|
415
|
-
</Stack>
|
|
416
|
-
</form>
|
|
417
|
-
</div>
|
|
418
|
-
</Box>
|
|
419
|
-
);
|
|
420
|
-
}
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import { useMemo } from 'react';
|
|
2
|
-
import type { PropDefinition } from '@fragments-sdk/core';
|
|
3
|
-
import { DataTable, createColumns, Badge, Text, Stack } from '@fragments-sdk/ui';
|
|
4
|
-
import { WarningIcon } from './Icons.js';
|
|
5
|
-
|
|
6
|
-
interface PropsTableProps {
|
|
7
|
-
props: Record<string, PropDefinition>;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
interface PropRow {
|
|
11
|
-
name: string;
|
|
12
|
-
required: boolean;
|
|
13
|
-
type: string;
|
|
14
|
-
values?: string[];
|
|
15
|
-
default: unknown;
|
|
16
|
-
description: string;
|
|
17
|
-
constraints?: string[];
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export function PropsTable({ props }: PropsTableProps) {
|
|
21
|
-
const propEntries = Object.entries(props);
|
|
22
|
-
|
|
23
|
-
const data = useMemo<PropRow[]>(() =>
|
|
24
|
-
propEntries.map(([name, prop]) => ({
|
|
25
|
-
name,
|
|
26
|
-
required: !!prop.required,
|
|
27
|
-
type: prop.type,
|
|
28
|
-
values: prop.values,
|
|
29
|
-
default: prop.default,
|
|
30
|
-
description: prop.description,
|
|
31
|
-
constraints: prop.constraints,
|
|
32
|
-
})),
|
|
33
|
-
[propEntries]
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
const columns = useMemo(() => createColumns<PropRow>([
|
|
37
|
-
{
|
|
38
|
-
key: 'name',
|
|
39
|
-
header: 'Prop',
|
|
40
|
-
cell: (row) => (
|
|
41
|
-
<Text font="mono" size="sm" weight="medium">
|
|
42
|
-
{row.name}
|
|
43
|
-
{row.required && <span style={{ color: 'var(--color-danger, #ef4444)', marginLeft: '2px' }}>*</span>}
|
|
44
|
-
</Text>
|
|
45
|
-
),
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
key: 'type',
|
|
49
|
-
header: 'Type',
|
|
50
|
-
cell: (row) => {
|
|
51
|
-
if (row.type === 'enum' && row.values && row.values.length > 0) {
|
|
52
|
-
return (
|
|
53
|
-
<Stack direction="row" gap="xs" style={{ flexWrap: 'wrap' }}>
|
|
54
|
-
{row.values.map((value, index) => (
|
|
55
|
-
<span key={value} style={{ display: 'inline-flex', alignItems: 'center' }}>
|
|
56
|
-
<Badge size="sm">{value}</Badge>
|
|
57
|
-
{index < row.values!.length - 1 && <Text size="xs" color="tertiary" style={{ margin: '0 4px' }}>|</Text>}
|
|
58
|
-
</span>
|
|
59
|
-
))}
|
|
60
|
-
</Stack>
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
return <Text font="mono" size="xs" color="secondary">{row.type}</Text>;
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
key: 'default',
|
|
68
|
-
header: 'Default',
|
|
69
|
-
cell: (row) => {
|
|
70
|
-
if (row.default !== undefined) {
|
|
71
|
-
return <Text font="mono" size="xs" color="secondary">{String(row.default)}</Text>;
|
|
72
|
-
}
|
|
73
|
-
return <Text color="tertiary">—</Text>;
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
key: 'description',
|
|
78
|
-
header: 'Description',
|
|
79
|
-
cell: (row) => (
|
|
80
|
-
<Stack gap="xs">
|
|
81
|
-
<Text size="sm" color="secondary">{row.description}</Text>
|
|
82
|
-
{row.constraints && row.constraints.length > 0 && (
|
|
83
|
-
<Stack gap="xs">
|
|
84
|
-
{row.constraints.map((constraint, index) => (
|
|
85
|
-
<Stack key={index} direction="row" gap="xs" align="start" style={{ fontSize: '12px', color: 'var(--color-warning, #f59e0b)' }}>
|
|
86
|
-
<WarningIcon style={{ width: 12, height: 12, marginTop: '2px', flexShrink: 0 }} />
|
|
87
|
-
<span>{constraint}</span>
|
|
88
|
-
</Stack>
|
|
89
|
-
))}
|
|
90
|
-
</Stack>
|
|
91
|
-
)}
|
|
92
|
-
</Stack>
|
|
93
|
-
),
|
|
94
|
-
},
|
|
95
|
-
]), []);
|
|
96
|
-
|
|
97
|
-
if (propEntries.length === 0) return null;
|
|
98
|
-
|
|
99
|
-
return (
|
|
100
|
-
<section id="props" style={{ scrollMarginTop: '96px' }}>
|
|
101
|
-
<Text as="h2" size="md" weight="semibold" style={{ marginBottom: '16px' }}>Props</Text>
|
|
102
|
-
<DataTable
|
|
103
|
-
columns={columns}
|
|
104
|
-
data={data}
|
|
105
|
-
size="sm"
|
|
106
|
-
bordered
|
|
107
|
-
getRowId={(row) => row.name}
|
|
108
|
-
/>
|
|
109
|
-
</section>
|
|
110
|
-
);
|
|
111
|
-
}
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { useState } from 'react';
|
|
2
|
-
import type { ComponentRelation } from '@fragments-sdk/core';
|
|
3
|
-
import { getRelationshipConfig } from '../constants/ui.js';
|
|
4
|
-
import { ChevronRightIcon } from './Icons.js';
|
|
5
|
-
|
|
6
|
-
interface RelationsSectionProps {
|
|
7
|
-
relations: ComponentRelation[];
|
|
8
|
-
onNavigate?: (componentName: string) => void;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export function RelationsSection({ relations, onNavigate }: RelationsSectionProps) {
|
|
12
|
-
if (relations.length === 0) return null;
|
|
13
|
-
|
|
14
|
-
return (
|
|
15
|
-
<section id="relations" style={{ scrollMarginTop: '96px' }}>
|
|
16
|
-
<h2 style={{ fontSize: '16px', fontWeight: 600, color: 'var(--text-primary)', marginBottom: '16px' }}>Related Components</h2>
|
|
17
|
-
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fill, minmax(280px, 1fr))', gap: '12px' }}>
|
|
18
|
-
{relations.map((relation, index) => (
|
|
19
|
-
<RelationButton key={index} relation={relation} onNavigate={onNavigate} />
|
|
20
|
-
))}
|
|
21
|
-
</div>
|
|
22
|
-
</section>
|
|
23
|
-
);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function RelationButton({ relation, onNavigate }: { relation: ComponentRelation; onNavigate?: (componentName: string) => void }) {
|
|
27
|
-
const config = getRelationshipConfig(relation.relationship);
|
|
28
|
-
const [hovered, setHovered] = useState(false);
|
|
29
|
-
|
|
30
|
-
return (
|
|
31
|
-
<button
|
|
32
|
-
onClick={() => onNavigate?.(relation.component)}
|
|
33
|
-
onMouseEnter={() => setHovered(true)}
|
|
34
|
-
onMouseLeave={() => setHovered(false)}
|
|
35
|
-
style={{
|
|
36
|
-
textAlign: 'left',
|
|
37
|
-
padding: '16px',
|
|
38
|
-
borderRadius: '12px',
|
|
39
|
-
border: `1px solid ${hovered ? 'var(--border-strong)' : 'var(--border)'}`,
|
|
40
|
-
background: 'var(--bg-elevated)',
|
|
41
|
-
transition: 'all 150ms',
|
|
42
|
-
cursor: 'pointer',
|
|
43
|
-
outline: 'none',
|
|
44
|
-
}}
|
|
45
|
-
>
|
|
46
|
-
<div style={{ display: 'flex', alignItems: 'center', gap: '8px', marginBottom: '6px' }}>
|
|
47
|
-
<span style={{
|
|
48
|
-
fontSize: '13px',
|
|
49
|
-
fontWeight: 500,
|
|
50
|
-
color: hovered ? 'var(--color-accent)' : 'var(--text-primary)',
|
|
51
|
-
transition: 'color 150ms',
|
|
52
|
-
}}>
|
|
53
|
-
{relation.component}
|
|
54
|
-
</span>
|
|
55
|
-
<span style={{
|
|
56
|
-
fontSize: '10px',
|
|
57
|
-
fontWeight: 500,
|
|
58
|
-
padding: '2px 6px',
|
|
59
|
-
borderRadius: '4px',
|
|
60
|
-
background: config.bgColor ?? 'var(--bg-tertiary)',
|
|
61
|
-
color: config.textColor ?? 'var(--text-secondary)',
|
|
62
|
-
}}>
|
|
63
|
-
{config.label}
|
|
64
|
-
</span>
|
|
65
|
-
</div>
|
|
66
|
-
{relation.note && (
|
|
67
|
-
<p style={{ fontSize: '13px', color: 'var(--text-secondary)', lineHeight: 1.6, margin: 0 }}>{relation.note}</p>
|
|
68
|
-
)}
|
|
69
|
-
<div style={{
|
|
70
|
-
marginTop: '8px',
|
|
71
|
-
display: 'flex',
|
|
72
|
-
alignItems: 'center',
|
|
73
|
-
fontSize: '12px',
|
|
74
|
-
color: hovered ? 'var(--text-secondary)' : 'var(--text-tertiary)',
|
|
75
|
-
transition: 'color 150ms',
|
|
76
|
-
}}>
|
|
77
|
-
<span>View component</span>
|
|
78
|
-
<ChevronRightIcon style={{
|
|
79
|
-
width: '12px',
|
|
80
|
-
height: '12px',
|
|
81
|
-
marginLeft: '4px',
|
|
82
|
-
transform: hovered ? 'translateX(2px)' : 'translateX(0)',
|
|
83
|
-
transition: 'transform 150ms',
|
|
84
|
-
}} />
|
|
85
|
-
</div>
|
|
86
|
-
</button>
|
|
87
|
-
);
|
|
88
|
-
}
|