oneie 3.6.7 → 3.6.12
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/.claude/agents/agent-backend.md +83 -0
- package/.claude/agents/agent-designer.md +97 -0
- package/.claude/agents/agent-director.md +118 -7
- package/.claude/agents/agent-documenter.md +93 -0
- package/.claude/agents/agent-frontend.md +96 -0
- package/.claude/agents/agent-ops.md +264 -32
- package/.claude/agents/agent-problem-solver.md +166 -0
- package/.claude/agents/agent-quality.md +127 -0
- package/.claude/commands/build.md +293 -0
- package/.claude/commands/cascade.md +231 -127
- package/.claude/commands/deploy.md +56 -17
- package/.claude/commands/mcp-toggle.md +93 -0
- package/.claude/commands/one.md +78 -127
- package/.claude/commands/plan.md +394 -80
- package/.claude/commands/push.md +75 -14
- package/.claude/commands/release.md +89 -25
- package/.claude/commands/server.md +2 -0
- package/.claude/hooks/__pycache__/todo.cpython-313.pyc +0 -0
- package/.claude/hooks/root-cleanup.py +75 -0
- package/.claude/skills/INDEX.md +523 -0
- package/.claude/skills/REGISTRY.md +529 -0
- package/.claude/skills/agent-backend-create-mutation.md +319 -0
- package/.claude/skills/agent-designer-create-wireframe.md +341 -0
- package/.claude/skills/agent-frontend-create-page.md +413 -0
- package/.claude/skills/agents/README.md +238 -0
- package/dist/clone-web.js +1 -1
- package/dist/clone-web.js.map +1 -1
- package/folders.yaml +1 -1
- package/one/.obsidian/workspace.json +38 -38
- package/one/connections/api/queries-reference.md +842 -0
- package/one/connections/api-reference.md +1011 -0
- package/one/connections/integration-examples.md +875 -0
- package/one/connections/integration-guide.md +869 -0
- package/one/connections/integration-phase2.md +736 -0
- package/one/events/API_ROUTES_FIXES_SUMMARY.md +262 -0
- package/one/events/ASTRO-INTEGRATION-EXAMPLES.md +636 -0
- package/one/events/BEFORE_AFTER_COMPARISON.md +960 -0
- package/one/events/CONNECTIONS_DEMO.md +501 -0
- package/one/events/DELIVERABLES.md +432 -0
- package/one/events/DEMO-GROUPS-PAGE.md +392 -0
- package/one/events/DEMO-TESTING-SUMMARY.md +518 -0
- package/one/events/DEMO_COMPONENTS.md +487 -0
- package/one/events/DEMO_HOOKS_INDEX.md +334 -0
- package/one/events/DEMO_INFRASTRUCTURE.md +905 -0
- package/one/events/DEMO_INFRASTRUCTURE_SUMMARY.md +570 -0
- package/one/events/DEMO_INTEGRATION_CHECKLIST.md +431 -0
- package/one/events/DEMO_QUICK_REFERENCE.md +441 -0
- package/one/events/DEMO_SETUP.md +476 -0
- package/one/events/EFFECT_TS_API_PATTERN.md +478 -0
- package/one/events/GROUPS_DEMO_IMPLEMENTATION.md +414 -0
- package/one/events/HOOKS-DEMO.md +441 -0
- package/one/events/ONTOLOGY-HOOKS-README.md +700 -0
- package/one/events/ONTOLOGY-INTEGRATION-MANIFEST.md +365 -0
- package/one/events/QA-CHECKLIST.md +674 -0
- package/one/events/QUICK-START-ONTOLOGY.md +408 -0
- package/one/events/SEARCH_DEMO_CODE_REFERENCE.md +639 -0
- package/one/events/SEARCH_DEMO_DELIVERY.md +415 -0
- package/one/events/SEARCH_DEMO_SUMMARY.md +303 -0
- package/one/events/SEARCH_DEMO_VISUAL_GUIDE.md +381 -0
- package/one/events/TEST-PLAN-INDEX.md +346 -0
- package/one/events/TEST-PLAN.md +1417 -0
- package/one/events/TESTING-DELIVERY.txt +372 -0
- package/one/events/TRANSITIONS-QUICK-START.md +141 -0
- package/one/events/TYPESCRIPT_FIXES.md +152 -0
- package/one/events/TYPESCRIPT_FIXES_COMPLETE.txt +412 -0
- package/one/events/TYPESCRIPT_FIXES_INDEX.md +341 -0
- package/one/events/VIEW-TRANSITIONS.md +428 -0
- package/one/events/backend-integration-tests.md +606 -0
- package/one/events/backend-structure-diagram.txt +393 -0
- package/one/events/backend-structure-summary.txt +269 -0
- package/one/events/cloudflare-pages-infrastructure-setup.md +264 -0
- package/one/events/convex-analysis-index.md +304 -0
- package/one/events/convex-structure-analysis.md +700 -0
- package/one/events/design-spec-complete.md +208 -0
- package/one/events/ontology-test-examples.md +562 -0
- package/one/events/phase1-backend-implementation-complete.md +518 -0
- package/one/events/test-dashboard.md +345 -0
- package/one/events/test-index.md +361 -0
- package/one/events/test-report-ontology.md +582 -0
- package/one/events/testing-summary.md +344 -0
- package/one/groups/features.md +2878 -0
- package/one/groups/strategy copy.md +869 -0
- package/one/knowledge/backend-api-reference.md +710 -0
- package/one/knowledge/documentation-summary.md +285 -0
- package/one/knowledge/lessons-learned.md +294 -4
- package/one/knowledge/ontology-visual-guide.md +360 -0
- package/one/knowledge/ontology.md +9 -17
- package/one/things/demo-accessibility-animations.md +999 -0
- package/one/things/demo-components.md +1304 -0
- package/one/things/demo-design-summary.md +629 -0
- package/one/things/demo-design-system.md +919 -0
- package/one/things/demo-page-layouts.md +989 -0
- package/one/things/designs/accessibility-audit.md +790 -0
- package/one/things/designs/component-specifications.md +757 -0
- package/one/things/designs/design-overview.md +318 -0
- package/one/things/designs/design-tokens.md +414 -0
- package/one/things/designs/wireframes-dashboard.md +653 -0
- package/one/things/docs/api-requests.md +923 -0
- package/one/things/features/0 All Features.md +2 -0
- package/one/things/implementation/backend-guide.md +412 -0
- package/one/things/plans/2-backend-agnostic-frontend.md +11 -8
- package/one/things/plans/2-sites.md +895 -0
- package/one/things/plans/ai-elements.md +1259 -0
- package/one/things/plans/ai-integration.md +947 -0
- package/one/things/plans/ai-sdk.md +761 -0
- package/one/things/plans/app.md +1 -1
- package/one/things/plans/architecture-summary.md +283 -0
- package/one/things/plans/async-ai-agents.md +215 -0
- package/one/things/plans/backend-agnostic-frontend.md +11 -6
- package/one/things/plans/backend-cleanup-quickstart.md +346 -0
- package/one/things/plans/backend-ontology-conformance.md +416 -0
- package/one/things/plans/backend-status.md +541 -0
- package/one/things/plans/backend-structure.md +799 -0
- package/one/things/plans/backend-target-structure.md +438 -0
- package/one/things/plans/backend.md +1133 -0
- package/one/things/plans/better-auth-any-backend.md +11 -11
- package/one/things/plans/cli-updates-required.md +280 -0
- package/one/things/plans/complete-step-by-step.md +1302 -0
- package/one/things/plans/convex-agents.md +1005 -0
- package/one/things/plans/deployment-architecture.md +426 -0
- package/one/things/plans/development-plan.md +1220 -0
- package/one/things/plans/effect.md +808 -48
- package/one/things/plans/integrate-frontend-and-backend.md +579 -0
- package/one/things/plans/mcp-clear-context-prompt.md +60 -0
- package/one/things/plans/mcp-simple.md +228 -0
- package/one/things/plans/one.md +8 -7
- package/one/things/plans/ontology-6-dimensions.md +20 -14
- package/one/things/plans/quick-wins.md +1273 -0
- package/one/things/plans/readme-backend-cleanup.md +361 -0
- package/one/things/plans/separate-demo.md +830 -0
- package/one/things/plans/separate.md +3 -3
- package/one/things/plans/sequence.md +1897 -0
- package/one/things/plans/sync-checklist.md +321 -0
- package/one/things/plans/unified-implementation-plan.md +3 -3
- package/one/things/plans/update-demos.md +513 -0
- package/package.json +1 -1
- package/.claude/agents/backend-specialist.md +0 -169
- package/.claude/agents/designer.md +0 -216
- package/.claude/agents/frontend-specialist.md +0 -236
- package/.claude/commands/done.md +0 -35
- package/.claude/commands/infer.md +0 -138
- package/.claude/commands/next.md +0 -53
- package/.claude/commands/one copy.md +0 -565
- package/.claude/commands/one-template.md +0 -106
- package/.claude/commands/one-v1.md +0 -609
- package/.claude/hooks/__pycache__/knowledge-post.cpython-313.pyc +0 -0
- package/.claude/hooks/__pycache__/knowledge-pre.cpython-313.pyc +0 -0
- package/one/groups/nine-padel-customers.md +0 -138
- package/one/groups/nine-padel-data-structure.md +0 -167
- package/one/groups/nine-padel-ontology-specification.md +0 -359
- package/one/groups/nine-padel-ontology.md +0 -143
- package/one/groups/nine-padel-strategy.md +0 -234
- package/one/groups/nine-padel.md +0 -211
- package/one/groups/nine-padle-contents.baked.md +0 -1252
- package/one/groups/nine-padle-contents.md +0 -6
- package/one/things/features/1-1-agent-prompts/design.md +0 -470
- package/one/things/features/1-1-agent-prompts/tests.md +0 -264
- package/one/things/features/1-2-yaml-orchestrator/design.md +0 -497
- package/one/things/features/1-2-yaml-orchestrator/tests.md +0 -227
- package/one/things/features/1-3-event-coordination/design.md +0 -544
- package/one/things/features/1-3-event-coordination/tests.md +0 -223
- package/one/things/features/1-4-knowledge-management/design.md +0 -609
- package/one/things/features/1-4-knowledge-management/tests.md +0 -195
- package/one/things/features/1-5-quality-loops/design.md +0 -797
- package/one/things/features/1-5-quality-loops/tests.md +0 -212
- package/one/things/features/1-6-numbering-structure/design.md +0 -610
- package/one/things/features/1-6-numbering-structure/tests.md +0 -213
- package/one/things/features/dataprovider-interface/1-tests.md +0 -1522
|
@@ -0,0 +1,1304 @@
|
|
|
1
|
+
# ONE Platform Demo Components
|
|
2
|
+
|
|
3
|
+
## Version 1.0.0 - Component Definition Specification
|
|
4
|
+
|
|
5
|
+
This document defines all reusable components for ONE Platform demo pages. Components follow shadcn/ui patterns with Tailwind v4 styling.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Component Library Architecture
|
|
10
|
+
|
|
11
|
+
### Hierarchy
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
┌─ Base Components (shadcn/ui)
|
|
15
|
+
│ ├─ Button
|
|
16
|
+
│ ├─ Card
|
|
17
|
+
│ ├─ Input
|
|
18
|
+
│ ├─ Select
|
|
19
|
+
│ ├─ Textarea
|
|
20
|
+
│ ├─ Badge
|
|
21
|
+
│ └─ Dialog
|
|
22
|
+
│
|
|
23
|
+
├─ Demo Components (custom)
|
|
24
|
+
│ ├─ DemoContainer
|
|
25
|
+
│ ├─ DemoHero
|
|
26
|
+
│ ├─ DemoPlayground
|
|
27
|
+
│ ├─ DemoCodeBlock
|
|
28
|
+
│ ├─ DemoForm
|
|
29
|
+
│ ├─ DemoList
|
|
30
|
+
│ ├─ DemoStats
|
|
31
|
+
│ ├─ DemoGraph
|
|
32
|
+
│ └─ DemoCTA
|
|
33
|
+
│
|
|
34
|
+
└─ Feature Components
|
|
35
|
+
├─ RelationshipExplorer
|
|
36
|
+
├─ CodeExample
|
|
37
|
+
├─ EntityCard
|
|
38
|
+
└─ TimelineEvent
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## 1. DemoContainer
|
|
44
|
+
|
|
45
|
+
### Purpose
|
|
46
|
+
|
|
47
|
+
Wrapper component that provides consistent max-width, padding, and spacing for all section content.
|
|
48
|
+
|
|
49
|
+
### Props
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
interface DemoContainerProps {
|
|
53
|
+
children: ReactNode;
|
|
54
|
+
className?: string;
|
|
55
|
+
variant?: 'light' | 'dark' | 'card'; // Background variant
|
|
56
|
+
noPadding?: boolean;
|
|
57
|
+
tight?: boolean; // Reduces padding
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Implementation
|
|
62
|
+
|
|
63
|
+
```tsx
|
|
64
|
+
// src/components/demo/DemoContainer.tsx
|
|
65
|
+
import { cn } from '@/lib/utils';
|
|
66
|
+
|
|
67
|
+
export function DemoContainer({
|
|
68
|
+
children,
|
|
69
|
+
className,
|
|
70
|
+
variant = 'light',
|
|
71
|
+
noPadding = false,
|
|
72
|
+
tight = false,
|
|
73
|
+
}: DemoContainerProps) {
|
|
74
|
+
const variants = {
|
|
75
|
+
light: 'bg-background',
|
|
76
|
+
dark: 'bg-foreground/5',
|
|
77
|
+
card: 'bg-card border border-border',
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
return (
|
|
81
|
+
<div className={cn(
|
|
82
|
+
'relative',
|
|
83
|
+
variants[variant],
|
|
84
|
+
!noPadding && 'px-4 py-8 md:px-6 md:py-12 lg:px-8 lg:py-16',
|
|
85
|
+
tight && 'px-4 py-4 md:px-6 md:py-6',
|
|
86
|
+
className,
|
|
87
|
+
)}>
|
|
88
|
+
<div className="max-w-7xl mx-auto">
|
|
89
|
+
{children}
|
|
90
|
+
</div>
|
|
91
|
+
</div>
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Usage
|
|
97
|
+
|
|
98
|
+
```astro
|
|
99
|
+
<DemoContainer variant="light">
|
|
100
|
+
<h2 class="text-3xl font-bold mb-4">Section Title</h2>
|
|
101
|
+
<p>Content...</p>
|
|
102
|
+
</DemoContainer>
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## 2. DemoHero
|
|
108
|
+
|
|
109
|
+
### Purpose
|
|
110
|
+
|
|
111
|
+
Hero section component with headline, subheading, and CTAs.
|
|
112
|
+
|
|
113
|
+
### Props
|
|
114
|
+
|
|
115
|
+
```typescript
|
|
116
|
+
interface DemoHeroProps {
|
|
117
|
+
icon?: ReactNode;
|
|
118
|
+
badge?: string;
|
|
119
|
+
title: string;
|
|
120
|
+
subtitle: string;
|
|
121
|
+
primaryCta?: {
|
|
122
|
+
label: string;
|
|
123
|
+
onClick?: () => void;
|
|
124
|
+
href?: string;
|
|
125
|
+
};
|
|
126
|
+
secondaryCta?: {
|
|
127
|
+
label: string;
|
|
128
|
+
onClick?: () => void;
|
|
129
|
+
href?: string;
|
|
130
|
+
};
|
|
131
|
+
showScroll?: boolean; // Show scroll indicator
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Implementation
|
|
136
|
+
|
|
137
|
+
```tsx
|
|
138
|
+
// src/components/demo/DemoHero.tsx
|
|
139
|
+
import { Button } from '@/components/ui/button';
|
|
140
|
+
import { cn } from '@/lib/utils';
|
|
141
|
+
|
|
142
|
+
export function DemoHero({
|
|
143
|
+
icon,
|
|
144
|
+
badge,
|
|
145
|
+
title,
|
|
146
|
+
subtitle,
|
|
147
|
+
primaryCta,
|
|
148
|
+
secondaryCta,
|
|
149
|
+
showScroll = true,
|
|
150
|
+
}: DemoHeroProps) {
|
|
151
|
+
return (
|
|
152
|
+
<section className="
|
|
153
|
+
relative overflow-hidden
|
|
154
|
+
px-4 py-20 sm:px-6 sm:py-24 md:px-8 md:py-32
|
|
155
|
+
bg-gradient-to-br from-primary/5 via-background to-background
|
|
156
|
+
">
|
|
157
|
+
{/* Background blur */}
|
|
158
|
+
<div className="absolute inset-0 -z-10">
|
|
159
|
+
<div className="absolute left-1/4 top-0 h-96 w-96 rounded-full
|
|
160
|
+
bg-primary/10 blur-[120px]"></div>
|
|
161
|
+
<div className="absolute right-1/3 bottom-0 h-80 w-80 rounded-full
|
|
162
|
+
bg-accent/10 blur-[120px]"></div>
|
|
163
|
+
</div>
|
|
164
|
+
|
|
165
|
+
{/* Content */}
|
|
166
|
+
<div className="max-w-4xl mx-auto text-center">
|
|
167
|
+
{/* Badge */}
|
|
168
|
+
{badge && (
|
|
169
|
+
<div className="inline-flex items-center gap-2 mb-6
|
|
170
|
+
px-3 py-1.5 rounded-full bg-primary/10 text-primary">
|
|
171
|
+
<span className="w-2 h-2 rounded-full bg-primary"></span>
|
|
172
|
+
<span className="text-sm font-medium">{badge}</span>
|
|
173
|
+
</div>
|
|
174
|
+
)}
|
|
175
|
+
|
|
176
|
+
{/* Icon */}
|
|
177
|
+
{icon && (
|
|
178
|
+
<div className="mb-6 flex justify-center">
|
|
179
|
+
{icon}
|
|
180
|
+
</div>
|
|
181
|
+
)}
|
|
182
|
+
|
|
183
|
+
{/* Title */}
|
|
184
|
+
<h1 className="text-4xl md:text-5xl lg:text-6xl
|
|
185
|
+
font-bold leading-tight tracking-tight
|
|
186
|
+
mb-6 text-foreground">
|
|
187
|
+
{title}
|
|
188
|
+
</h1>
|
|
189
|
+
|
|
190
|
+
{/* Subtitle */}
|
|
191
|
+
<p className="text-xl md:text-2xl text-muted-foreground
|
|
192
|
+
mb-12 max-w-2xl mx-auto leading-relaxed">
|
|
193
|
+
{subtitle}
|
|
194
|
+
</p>
|
|
195
|
+
|
|
196
|
+
{/* CTAs */}
|
|
197
|
+
<div className="flex flex-col sm:flex-row gap-4 justify-center">
|
|
198
|
+
{primaryCta && (
|
|
199
|
+
<Button
|
|
200
|
+
variant="default"
|
|
201
|
+
size="lg"
|
|
202
|
+
asChild={!!primaryCta.href}
|
|
203
|
+
>
|
|
204
|
+
{primaryCta.href ? (
|
|
205
|
+
<a href={primaryCta.href}>
|
|
206
|
+
{primaryCta.label} <span className="ml-2">→</span>
|
|
207
|
+
</a>
|
|
208
|
+
) : (
|
|
209
|
+
<span onClick={primaryCta.onClick}>
|
|
210
|
+
{primaryCta.label} <span className="ml-2">→</span>
|
|
211
|
+
</span>
|
|
212
|
+
)}
|
|
213
|
+
</Button>
|
|
214
|
+
)}
|
|
215
|
+
|
|
216
|
+
{secondaryCta && (
|
|
217
|
+
<Button
|
|
218
|
+
variant="outline"
|
|
219
|
+
size="lg"
|
|
220
|
+
asChild={!!secondaryCta.href}
|
|
221
|
+
>
|
|
222
|
+
{secondaryCta.href ? (
|
|
223
|
+
<a href={secondaryCta.href}>
|
|
224
|
+
{secondaryCta.label}
|
|
225
|
+
</a>
|
|
226
|
+
) : (
|
|
227
|
+
<span onClick={secondaryCta.onClick}>
|
|
228
|
+
{secondaryCta.label}
|
|
229
|
+
</span>
|
|
230
|
+
)}
|
|
231
|
+
</Button>
|
|
232
|
+
)}
|
|
233
|
+
</div>
|
|
234
|
+
</div>
|
|
235
|
+
|
|
236
|
+
{/* Scroll indicator */}
|
|
237
|
+
{showScroll && (
|
|
238
|
+
<div className="flex justify-center mt-12 text-muted-foreground animate-bounce">
|
|
239
|
+
<svg className="w-6 h-6" fill="none" stroke="currentColor">
|
|
240
|
+
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2"
|
|
241
|
+
d="M19 14l-7 7m0 0l-7-7m7 7V3"></path>
|
|
242
|
+
</svg>
|
|
243
|
+
</div>
|
|
244
|
+
)}
|
|
245
|
+
</section>
|
|
246
|
+
);
|
|
247
|
+
}
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
### Usage
|
|
251
|
+
|
|
252
|
+
```astro
|
|
253
|
+
<DemoHero
|
|
254
|
+
badge="The Ontology"
|
|
255
|
+
title="The Groups Dimension"
|
|
256
|
+
subtitle="Hierarchical containers for collaboration"
|
|
257
|
+
primaryCta={{
|
|
258
|
+
label: "Start Playground",
|
|
259
|
+
href: "#playground"
|
|
260
|
+
}}
|
|
261
|
+
secondaryCta={{
|
|
262
|
+
label: "Read Docs",
|
|
263
|
+
href: "/docs/groups"
|
|
264
|
+
}}
|
|
265
|
+
showScroll
|
|
266
|
+
/>
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
---
|
|
270
|
+
|
|
271
|
+
## 3. DemoPlayground
|
|
272
|
+
|
|
273
|
+
### Purpose
|
|
274
|
+
|
|
275
|
+
Interactive form + live data display section for hands-on experimentation.
|
|
276
|
+
|
|
277
|
+
### Props
|
|
278
|
+
|
|
279
|
+
```typescript
|
|
280
|
+
interface DemoPlaygroundProps {
|
|
281
|
+
title: string;
|
|
282
|
+
description?: string;
|
|
283
|
+
fields: FormField[];
|
|
284
|
+
onSubmit: (data: Record<string, any>) => void;
|
|
285
|
+
liveData?: Record<string, any>;
|
|
286
|
+
isLoading?: boolean;
|
|
287
|
+
stats?: Array<{ label: string; value: string | number }>;
|
|
288
|
+
tip?: string;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
interface FormField {
|
|
292
|
+
name: string;
|
|
293
|
+
label: string;
|
|
294
|
+
type: 'text' | 'select' | 'textarea' | 'number' | 'email';
|
|
295
|
+
placeholder?: string;
|
|
296
|
+
options?: Array<{ value: string; label: string }>;
|
|
297
|
+
required?: boolean;
|
|
298
|
+
}
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
### Implementation
|
|
302
|
+
|
|
303
|
+
```tsx
|
|
304
|
+
// src/components/demo/DemoPlayground.tsx
|
|
305
|
+
'use client';
|
|
306
|
+
|
|
307
|
+
import { useState } from 'react';
|
|
308
|
+
import { Button } from '@/components/ui/button';
|
|
309
|
+
import { Input } from '@/components/ui/input';
|
|
310
|
+
import { Label } from '@/components/ui/label';
|
|
311
|
+
import { Textarea } from '@/components/ui/textarea';
|
|
312
|
+
import {
|
|
313
|
+
Select,
|
|
314
|
+
SelectContent,
|
|
315
|
+
SelectItem,
|
|
316
|
+
SelectTrigger,
|
|
317
|
+
SelectValue,
|
|
318
|
+
} from '@/components/ui/select';
|
|
319
|
+
|
|
320
|
+
export function DemoPlayground({
|
|
321
|
+
title,
|
|
322
|
+
description,
|
|
323
|
+
fields,
|
|
324
|
+
onSubmit,
|
|
325
|
+
liveData,
|
|
326
|
+
isLoading,
|
|
327
|
+
stats,
|
|
328
|
+
tip,
|
|
329
|
+
}: DemoPlaygroundProps) {
|
|
330
|
+
const [formData, setFormData] = useState<Record<string, any>>({});
|
|
331
|
+
|
|
332
|
+
const handleSubmit = (e: React.FormEvent) => {
|
|
333
|
+
e.preventDefault();
|
|
334
|
+
onSubmit(formData);
|
|
335
|
+
};
|
|
336
|
+
|
|
337
|
+
return (
|
|
338
|
+
<div className="space-y-6">
|
|
339
|
+
{/* Header */}
|
|
340
|
+
<div>
|
|
341
|
+
<h2 className="text-3xl font-bold mb-2">{title}</h2>
|
|
342
|
+
{description && (
|
|
343
|
+
<p className="text-muted-foreground">{description}</p>
|
|
344
|
+
)}
|
|
345
|
+
</div>
|
|
346
|
+
|
|
347
|
+
{/* Main content */}
|
|
348
|
+
<div className="grid grid-cols-1 lg:grid-cols-2 gap-8">
|
|
349
|
+
{/* Form */}
|
|
350
|
+
<div className="bg-background rounded-lg p-6 border border-border">
|
|
351
|
+
<h3 className="text-lg font-semibold mb-4">Create New Entity</h3>
|
|
352
|
+
|
|
353
|
+
<form onSubmit={handleSubmit} className="space-y-4">
|
|
354
|
+
{fields.map((field) => (
|
|
355
|
+
<div key={field.name} className="flex flex-col">
|
|
356
|
+
<Label htmlFor={field.name} className="mb-2">
|
|
357
|
+
{field.label}
|
|
358
|
+
</Label>
|
|
359
|
+
|
|
360
|
+
{field.type === 'text' || field.type === 'email' || field.type === 'number' ? (
|
|
361
|
+
<Input
|
|
362
|
+
id={field.name}
|
|
363
|
+
type={field.type}
|
|
364
|
+
placeholder={field.placeholder}
|
|
365
|
+
value={formData[field.name] || ''}
|
|
366
|
+
onChange={(e) =>
|
|
367
|
+
setFormData({ ...formData, [field.name]: e.target.value })
|
|
368
|
+
}
|
|
369
|
+
required={field.required}
|
|
370
|
+
/>
|
|
371
|
+
) : field.type === 'select' ? (
|
|
372
|
+
<Select
|
|
373
|
+
value={formData[field.name] || ''}
|
|
374
|
+
onValueChange={(value) =>
|
|
375
|
+
setFormData({ ...formData, [field.name]: value })
|
|
376
|
+
}
|
|
377
|
+
>
|
|
378
|
+
<SelectTrigger id={field.name}>
|
|
379
|
+
<SelectValue placeholder={field.placeholder} />
|
|
380
|
+
</SelectTrigger>
|
|
381
|
+
<SelectContent>
|
|
382
|
+
{field.options?.map((opt) => (
|
|
383
|
+
<SelectItem key={opt.value} value={opt.value}>
|
|
384
|
+
{opt.label}
|
|
385
|
+
</SelectItem>
|
|
386
|
+
))}
|
|
387
|
+
</SelectContent>
|
|
388
|
+
</Select>
|
|
389
|
+
) : field.type === 'textarea' ? (
|
|
390
|
+
<Textarea
|
|
391
|
+
id={field.name}
|
|
392
|
+
placeholder={field.placeholder}
|
|
393
|
+
value={formData[field.name] || ''}
|
|
394
|
+
onChange={(e) =>
|
|
395
|
+
setFormData({ ...formData, [field.name]: e.target.value })
|
|
396
|
+
}
|
|
397
|
+
required={field.required}
|
|
398
|
+
rows={4}
|
|
399
|
+
/>
|
|
400
|
+
) : null}
|
|
401
|
+
</div>
|
|
402
|
+
))}
|
|
403
|
+
|
|
404
|
+
<Button
|
|
405
|
+
type="submit"
|
|
406
|
+
className="w-full"
|
|
407
|
+
disabled={isLoading}
|
|
408
|
+
>
|
|
409
|
+
{isLoading ? 'Creating...' : 'Create Entity'} →
|
|
410
|
+
</Button>
|
|
411
|
+
</form>
|
|
412
|
+
</div>
|
|
413
|
+
|
|
414
|
+
{/* Live data */}
|
|
415
|
+
<div className="space-y-4">
|
|
416
|
+
<div className="bg-background rounded-lg p-6 border border-border">
|
|
417
|
+
<h3 className="text-lg font-semibold mb-4">Live Data (JSON)</h3>
|
|
418
|
+
|
|
419
|
+
<div className="
|
|
420
|
+
bg-foreground/5 rounded-md p-4
|
|
421
|
+
border border-border
|
|
422
|
+
overflow-x-auto
|
|
423
|
+
max-h-80 overflow-y-auto
|
|
424
|
+
font-mono text-sm
|
|
425
|
+
text-foreground/80
|
|
426
|
+
">
|
|
427
|
+
<pre>{JSON.stringify(liveData || {}, null, 2)}</pre>
|
|
428
|
+
</div>
|
|
429
|
+
|
|
430
|
+
<p className="mt-4 text-xs text-muted-foreground flex items-center gap-2">
|
|
431
|
+
<span className="inline-block w-2 h-2 rounded-full bg-green-500"></span>
|
|
432
|
+
Data updates in real-time
|
|
433
|
+
</p>
|
|
434
|
+
</div>
|
|
435
|
+
|
|
436
|
+
{/* Stats */}
|
|
437
|
+
{stats && stats.length > 0 && (
|
|
438
|
+
<div className="grid grid-cols-2 gap-4">
|
|
439
|
+
{stats.map((stat) => (
|
|
440
|
+
<div key={stat.label} className="
|
|
441
|
+
bg-background rounded-lg p-4
|
|
442
|
+
border border-border text-center
|
|
443
|
+
">
|
|
444
|
+
<p className="text-2xl font-bold text-primary">
|
|
445
|
+
{stat.value}
|
|
446
|
+
</p>
|
|
447
|
+
<p className="text-xs text-muted-foreground mt-1">
|
|
448
|
+
{stat.label}
|
|
449
|
+
</p>
|
|
450
|
+
</div>
|
|
451
|
+
))}
|
|
452
|
+
</div>
|
|
453
|
+
)}
|
|
454
|
+
</div>
|
|
455
|
+
</div>
|
|
456
|
+
|
|
457
|
+
{/* Tip */}
|
|
458
|
+
{tip && (
|
|
459
|
+
<div className="p-4 rounded-lg bg-accent/5 border border-accent/20">
|
|
460
|
+
<p className="text-sm text-foreground">
|
|
461
|
+
<strong>Pro Tip:</strong> {tip}
|
|
462
|
+
</p>
|
|
463
|
+
</div>
|
|
464
|
+
)}
|
|
465
|
+
</div>
|
|
466
|
+
);
|
|
467
|
+
}
|
|
468
|
+
```
|
|
469
|
+
|
|
470
|
+
### Usage
|
|
471
|
+
|
|
472
|
+
```astro
|
|
473
|
+
<DemoPlayground
|
|
474
|
+
title="Try It Yourself"
|
|
475
|
+
description="Create and explore Things entities in real time"
|
|
476
|
+
fields={[
|
|
477
|
+
{
|
|
478
|
+
name: 'name',
|
|
479
|
+
label: 'Entity Name',
|
|
480
|
+
type: 'text',
|
|
481
|
+
placeholder: 'Enter entity name',
|
|
482
|
+
required: true,
|
|
483
|
+
},
|
|
484
|
+
{
|
|
485
|
+
name: 'type',
|
|
486
|
+
label: 'Entity Type',
|
|
487
|
+
type: 'select',
|
|
488
|
+
options: [
|
|
489
|
+
{ value: 'course', label: 'Course' },
|
|
490
|
+
{ value: 'product', label: 'Product' },
|
|
491
|
+
{ value: 'agent', label: 'Agent' },
|
|
492
|
+
],
|
|
493
|
+
},
|
|
494
|
+
{
|
|
495
|
+
name: 'description',
|
|
496
|
+
label: 'Description',
|
|
497
|
+
type: 'textarea',
|
|
498
|
+
placeholder: 'Describe this entity...',
|
|
499
|
+
},
|
|
500
|
+
]}
|
|
501
|
+
onSubmit={(data) => console.log(data)}
|
|
502
|
+
liveData={{
|
|
503
|
+
id: 'thing_123',
|
|
504
|
+
name: data.name,
|
|
505
|
+
type: data.type,
|
|
506
|
+
createdAt: new Date().toISOString(),
|
|
507
|
+
}}
|
|
508
|
+
stats={[
|
|
509
|
+
{ label: 'Entities Created', value: 42 },
|
|
510
|
+
{ label: 'Relationships', value: 18 },
|
|
511
|
+
]}
|
|
512
|
+
tip="Click 'Create Entity' to see real-time updates in the JSON viewer"
|
|
513
|
+
client:load
|
|
514
|
+
/>
|
|
515
|
+
```
|
|
516
|
+
|
|
517
|
+
---
|
|
518
|
+
|
|
519
|
+
## 4. DemoCodeBlock
|
|
520
|
+
|
|
521
|
+
### Purpose
|
|
522
|
+
|
|
523
|
+
Syntax-highlighted code example with copy button and metadata.
|
|
524
|
+
|
|
525
|
+
### Props
|
|
526
|
+
|
|
527
|
+
```typescript
|
|
528
|
+
interface DemoCodeBlockProps {
|
|
529
|
+
code: string;
|
|
530
|
+
language?: 'typescript' | 'javascript' | 'sql' | 'json' | 'bash';
|
|
531
|
+
title?: string;
|
|
532
|
+
filename?: string;
|
|
533
|
+
showLineNumbers?: boolean;
|
|
534
|
+
height?: 'sm' | 'md' | 'lg' | 'auto';
|
|
535
|
+
keyPoints?: string[];
|
|
536
|
+
relatedDocs?: Array<{ label: string; href: string }>;
|
|
537
|
+
}
|
|
538
|
+
```
|
|
539
|
+
|
|
540
|
+
### Implementation
|
|
541
|
+
|
|
542
|
+
```tsx
|
|
543
|
+
// src/components/demo/DemoCodeBlock.tsx
|
|
544
|
+
'use client';
|
|
545
|
+
|
|
546
|
+
import { useState } from 'react';
|
|
547
|
+
import { Button } from '@/components/ui/button';
|
|
548
|
+
import { Check, Copy } from 'lucide-react';
|
|
549
|
+
|
|
550
|
+
export function DemoCodeBlock({
|
|
551
|
+
code,
|
|
552
|
+
language = 'typescript',
|
|
553
|
+
title,
|
|
554
|
+
filename,
|
|
555
|
+
showLineNumbers = false,
|
|
556
|
+
height = 'md',
|
|
557
|
+
keyPoints,
|
|
558
|
+
relatedDocs,
|
|
559
|
+
}: DemoCodeBlockProps) {
|
|
560
|
+
const [copied, setCopied] = useState(false);
|
|
561
|
+
|
|
562
|
+
const handleCopy = () => {
|
|
563
|
+
navigator.clipboard.writeText(code);
|
|
564
|
+
setCopied(true);
|
|
565
|
+
setTimeout(() => setCopied(false), 2000);
|
|
566
|
+
};
|
|
567
|
+
|
|
568
|
+
const heightClasses = {
|
|
569
|
+
sm: 'max-h-64',
|
|
570
|
+
md: 'max-h-96',
|
|
571
|
+
lg: 'max-h-screen',
|
|
572
|
+
auto: '',
|
|
573
|
+
};
|
|
574
|
+
|
|
575
|
+
return (
|
|
576
|
+
<div className="rounded-lg border border-border overflow-hidden">
|
|
577
|
+
{/* Header */}
|
|
578
|
+
<div className="bg-muted px-6 py-4 border-b border-border
|
|
579
|
+
flex items-center justify-between">
|
|
580
|
+
<div>
|
|
581
|
+
{title && (
|
|
582
|
+
<h3 className="font-semibold text-foreground">{title}</h3>
|
|
583
|
+
)}
|
|
584
|
+
{filename && (
|
|
585
|
+
<p className="text-xs text-muted-foreground font-mono mt-1">
|
|
586
|
+
{filename}
|
|
587
|
+
</p>
|
|
588
|
+
)}
|
|
589
|
+
</div>
|
|
590
|
+
<span className="text-xs font-mono text-muted-foreground">
|
|
591
|
+
{language.toUpperCase()}
|
|
592
|
+
</span>
|
|
593
|
+
</div>
|
|
594
|
+
|
|
595
|
+
{/* Code */}
|
|
596
|
+
<div className={`
|
|
597
|
+
relative
|
|
598
|
+
overflow-hidden
|
|
599
|
+
${heightClasses[height]}
|
|
600
|
+
overflow-y-auto
|
|
601
|
+
`}>
|
|
602
|
+
<pre className="p-6 bg-foreground/5 border-t border-border
|
|
603
|
+
overflow-x-auto
|
|
604
|
+
text-sm font-mono text-foreground/80
|
|
605
|
+
whitespace-pre-wrap break-words">
|
|
606
|
+
<code>{code}</code>
|
|
607
|
+
</pre>
|
|
608
|
+
|
|
609
|
+
{/* Copy button */}
|
|
610
|
+
<button
|
|
611
|
+
onClick={handleCopy}
|
|
612
|
+
className="absolute top-4 right-4
|
|
613
|
+
px-3 py-1.5 rounded-md
|
|
614
|
+
bg-primary text-primary-foreground
|
|
615
|
+
text-xs font-medium
|
|
616
|
+
hover:bg-primary/90
|
|
617
|
+
transition-colors duration-200
|
|
618
|
+
focus-visible:outline-2 focus-visible:outline-ring
|
|
619
|
+
flex items-center gap-2"
|
|
620
|
+
aria-label="Copy code"
|
|
621
|
+
>
|
|
622
|
+
{copied ? (
|
|
623
|
+
<>
|
|
624
|
+
<Check className="w-4 h-4" />
|
|
625
|
+
Copied
|
|
626
|
+
</>
|
|
627
|
+
) : (
|
|
628
|
+
<>
|
|
629
|
+
<Copy className="w-4 h-4" />
|
|
630
|
+
Copy
|
|
631
|
+
</>
|
|
632
|
+
)}
|
|
633
|
+
</button>
|
|
634
|
+
</div>
|
|
635
|
+
|
|
636
|
+
{/* Footer */}
|
|
637
|
+
<div className="px-6 py-4 bg-background border-t border-border
|
|
638
|
+
space-y-4 text-sm">
|
|
639
|
+
{keyPoints && keyPoints.length > 0 && (
|
|
640
|
+
<div>
|
|
641
|
+
<p className="font-semibold text-foreground mb-2">Key Points:</p>
|
|
642
|
+
<ul className="ml-4 space-y-1 text-muted-foreground list-disc">
|
|
643
|
+
{keyPoints.map((point, i) => (
|
|
644
|
+
<li key={i}>{point}</li>
|
|
645
|
+
))}
|
|
646
|
+
</ul>
|
|
647
|
+
</div>
|
|
648
|
+
)}
|
|
649
|
+
|
|
650
|
+
{relatedDocs && relatedDocs.length > 0 && (
|
|
651
|
+
<div>
|
|
652
|
+
<p className="font-semibold text-foreground mb-2">Related:</p>
|
|
653
|
+
<div className="flex flex-wrap gap-2">
|
|
654
|
+
{relatedDocs.map((doc) => (
|
|
655
|
+
<a
|
|
656
|
+
key={doc.href}
|
|
657
|
+
href={doc.href}
|
|
658
|
+
className="px-2.5 py-1.5 rounded-md
|
|
659
|
+
bg-primary/10 text-primary
|
|
660
|
+
text-xs font-medium
|
|
661
|
+
hover:bg-primary/20
|
|
662
|
+
transition-colors"
|
|
663
|
+
>
|
|
664
|
+
{doc.label}
|
|
665
|
+
</a>
|
|
666
|
+
))}
|
|
667
|
+
</div>
|
|
668
|
+
</div>
|
|
669
|
+
)}
|
|
670
|
+
</div>
|
|
671
|
+
</div>
|
|
672
|
+
);
|
|
673
|
+
}
|
|
674
|
+
```
|
|
675
|
+
|
|
676
|
+
### Usage
|
|
677
|
+
|
|
678
|
+
```astro
|
|
679
|
+
<DemoCodeBlock
|
|
680
|
+
code={`export const create = mutation({
|
|
681
|
+
args: { name: v.string(), type: v.string() },
|
|
682
|
+
handler: async (ctx, args) => {
|
|
683
|
+
return await ctx.db.insert('things', {
|
|
684
|
+
type: args.type,
|
|
685
|
+
name: args.name,
|
|
686
|
+
status: 'draft',
|
|
687
|
+
createdAt: Date.now(),
|
|
688
|
+
});
|
|
689
|
+
},
|
|
690
|
+
});`}
|
|
691
|
+
language="typescript"
|
|
692
|
+
title="Create Thing Example"
|
|
693
|
+
filename="convex/mutations/things.ts"
|
|
694
|
+
height="md"
|
|
695
|
+
keyPoints={[
|
|
696
|
+
'All entities stored in things table',
|
|
697
|
+
'Type system enforces correctness',
|
|
698
|
+
'Mutations return entity ID',
|
|
699
|
+
]}
|
|
700
|
+
relatedDocs={[
|
|
701
|
+
{ label: 'Mutations Guide', href: '/docs/mutations' },
|
|
702
|
+
{ label: 'Things Spec', href: '/docs/things' },
|
|
703
|
+
]}
|
|
704
|
+
/>
|
|
705
|
+
```
|
|
706
|
+
|
|
707
|
+
---
|
|
708
|
+
|
|
709
|
+
## 5. DemoStats
|
|
710
|
+
|
|
711
|
+
### Purpose
|
|
712
|
+
|
|
713
|
+
Display statistics and metrics in card format.
|
|
714
|
+
|
|
715
|
+
### Props
|
|
716
|
+
|
|
717
|
+
```typescript
|
|
718
|
+
interface DemoStatsProps {
|
|
719
|
+
stats: Array<{
|
|
720
|
+
label: string;
|
|
721
|
+
value: string | number;
|
|
722
|
+
description?: string;
|
|
723
|
+
icon?: ReactNode;
|
|
724
|
+
trend?: 'up' | 'down' | 'neutral';
|
|
725
|
+
trendValue?: string;
|
|
726
|
+
}>;
|
|
727
|
+
columns?: 1 | 2 | 3 | 4;
|
|
728
|
+
}
|
|
729
|
+
```
|
|
730
|
+
|
|
731
|
+
### Implementation
|
|
732
|
+
|
|
733
|
+
```tsx
|
|
734
|
+
// src/components/demo/DemoStats.tsx
|
|
735
|
+
import { cn } from '@/lib/utils';
|
|
736
|
+
import { TrendingUp, TrendingDown } from 'lucide-react';
|
|
737
|
+
|
|
738
|
+
export function DemoStats({
|
|
739
|
+
stats,
|
|
740
|
+
columns = 3,
|
|
741
|
+
}: DemoStatsProps) {
|
|
742
|
+
const gridClasses = {
|
|
743
|
+
1: 'grid-cols-1',
|
|
744
|
+
2: 'grid-cols-1 md:grid-cols-2',
|
|
745
|
+
3: 'grid-cols-1 md:grid-cols-2 lg:grid-cols-3',
|
|
746
|
+
4: 'grid-cols-2 lg:grid-cols-4',
|
|
747
|
+
};
|
|
748
|
+
|
|
749
|
+
return (
|
|
750
|
+
<div className={cn('grid gap-4', gridClasses[columns])}>
|
|
751
|
+
{stats.map((stat, i) => (
|
|
752
|
+
<div
|
|
753
|
+
key={i}
|
|
754
|
+
className="
|
|
755
|
+
rounded-lg bg-background border border-border
|
|
756
|
+
p-6 transition-all duration-300
|
|
757
|
+
hover:shadow-md hover:-translate-y-1
|
|
758
|
+
"
|
|
759
|
+
>
|
|
760
|
+
{/* Icon */}
|
|
761
|
+
{stat.icon && (
|
|
762
|
+
<div className="mb-4 text-primary">
|
|
763
|
+
{stat.icon}
|
|
764
|
+
</div>
|
|
765
|
+
)}
|
|
766
|
+
|
|
767
|
+
{/* Value */}
|
|
768
|
+
<p className="text-3xl font-bold text-foreground">
|
|
769
|
+
{stat.value}
|
|
770
|
+
</p>
|
|
771
|
+
|
|
772
|
+
{/* Label */}
|
|
773
|
+
<p className="text-sm text-muted-foreground mt-1">
|
|
774
|
+
{stat.label}
|
|
775
|
+
</p>
|
|
776
|
+
|
|
777
|
+
{/* Trend */}
|
|
778
|
+
{stat.trendValue && (
|
|
779
|
+
<div className="mt-4 flex items-center gap-2">
|
|
780
|
+
{stat.trend === 'up' && (
|
|
781
|
+
<TrendingUp className="w-4 h-4 text-green-500" />
|
|
782
|
+
)}
|
|
783
|
+
{stat.trend === 'down' && (
|
|
784
|
+
<TrendingDown className="w-4 h-4 text-red-500" />
|
|
785
|
+
)}
|
|
786
|
+
<span className={cn(
|
|
787
|
+
'text-xs font-medium',
|
|
788
|
+
stat.trend === 'up' ? 'text-green-600' :
|
|
789
|
+
stat.trend === 'down' ? 'text-red-600' :
|
|
790
|
+
'text-muted-foreground'
|
|
791
|
+
)}>
|
|
792
|
+
{stat.trendValue}
|
|
793
|
+
</span>
|
|
794
|
+
</div>
|
|
795
|
+
)}
|
|
796
|
+
|
|
797
|
+
{/* Description */}
|
|
798
|
+
{stat.description && (
|
|
799
|
+
<p className="text-xs text-muted-foreground mt-3">
|
|
800
|
+
{stat.description}
|
|
801
|
+
</p>
|
|
802
|
+
)}
|
|
803
|
+
</div>
|
|
804
|
+
))}
|
|
805
|
+
</div>
|
|
806
|
+
);
|
|
807
|
+
}
|
|
808
|
+
```
|
|
809
|
+
|
|
810
|
+
### Usage
|
|
811
|
+
|
|
812
|
+
```astro
|
|
813
|
+
<DemoStats
|
|
814
|
+
columns={3}
|
|
815
|
+
stats={[
|
|
816
|
+
{
|
|
817
|
+
label: 'Total Entities',
|
|
818
|
+
value: '1,247',
|
|
819
|
+
trend: 'up',
|
|
820
|
+
trendValue: '+12.5%',
|
|
821
|
+
icon: <Database className="w-5 h-5" />
|
|
822
|
+
},
|
|
823
|
+
{
|
|
824
|
+
label: 'Active Connections',
|
|
825
|
+
value: '843',
|
|
826
|
+
trend: 'up',
|
|
827
|
+
trendValue: '+8.2%',
|
|
828
|
+
icon: <Network className="w-5 h-5" />
|
|
829
|
+
},
|
|
830
|
+
{
|
|
831
|
+
label: 'Events Logged',
|
|
832
|
+
value: '5,340',
|
|
833
|
+
trend: 'up',
|
|
834
|
+
trendValue: '+23.1%',
|
|
835
|
+
icon: <Activity className="w-5 h-5" />
|
|
836
|
+
},
|
|
837
|
+
]}
|
|
838
|
+
/>
|
|
839
|
+
```
|
|
840
|
+
|
|
841
|
+
---
|
|
842
|
+
|
|
843
|
+
## 6. DemoForm
|
|
844
|
+
|
|
845
|
+
### Purpose
|
|
846
|
+
|
|
847
|
+
Reusable form component with validation and error handling.
|
|
848
|
+
|
|
849
|
+
### Props
|
|
850
|
+
|
|
851
|
+
```typescript
|
|
852
|
+
interface DemoFormProps {
|
|
853
|
+
fields: FormField[];
|
|
854
|
+
onSubmit: (data: Record<string, any>) => Promise<void>;
|
|
855
|
+
isLoading?: boolean;
|
|
856
|
+
submitLabel?: string;
|
|
857
|
+
successMessage?: string;
|
|
858
|
+
}
|
|
859
|
+
```
|
|
860
|
+
|
|
861
|
+
### Implementation
|
|
862
|
+
|
|
863
|
+
```tsx
|
|
864
|
+
// src/components/demo/DemoForm.tsx
|
|
865
|
+
'use client';
|
|
866
|
+
|
|
867
|
+
import { useState } from 'react';
|
|
868
|
+
import { Button } from '@/components/ui/button';
|
|
869
|
+
import { Input } from '@/components/ui/input';
|
|
870
|
+
import { Label } from '@/components/ui/label';
|
|
871
|
+
import { AlertCircle, CheckCircle } from 'lucide-react';
|
|
872
|
+
|
|
873
|
+
export function DemoForm({
|
|
874
|
+
fields,
|
|
875
|
+
onSubmit,
|
|
876
|
+
isLoading = false,
|
|
877
|
+
submitLabel = 'Submit',
|
|
878
|
+
successMessage = 'Form submitted successfully!',
|
|
879
|
+
}: DemoFormProps) {
|
|
880
|
+
const [formData, setFormData] = useState<Record<string, any>>({});
|
|
881
|
+
const [errors, setErrors] = useState<Record<string, string>>({});
|
|
882
|
+
const [success, setSuccess] = useState(false);
|
|
883
|
+
|
|
884
|
+
const handleSubmit = async (e: React.FormEvent) => {
|
|
885
|
+
e.preventDefault();
|
|
886
|
+
setErrors({});
|
|
887
|
+
|
|
888
|
+
try {
|
|
889
|
+
await onSubmit(formData);
|
|
890
|
+
setSuccess(true);
|
|
891
|
+
setTimeout(() => setSuccess(false), 3000);
|
|
892
|
+
setFormData({});
|
|
893
|
+
} catch (error: any) {
|
|
894
|
+
setErrors({
|
|
895
|
+
submit: error.message || 'An error occurred',
|
|
896
|
+
});
|
|
897
|
+
}
|
|
898
|
+
};
|
|
899
|
+
|
|
900
|
+
return (
|
|
901
|
+
<form onSubmit={handleSubmit} className="space-y-6">
|
|
902
|
+
{/* Form fields */}
|
|
903
|
+
{fields.map((field) => (
|
|
904
|
+
<div key={field.name} className="flex flex-col">
|
|
905
|
+
<Label htmlFor={field.name} className="mb-2 font-medium">
|
|
906
|
+
{field.label}
|
|
907
|
+
{field.required && <span className="text-destructive ml-1">*</span>}
|
|
908
|
+
</Label>
|
|
909
|
+
|
|
910
|
+
{field.type === 'textarea' ? (
|
|
911
|
+
<textarea
|
|
912
|
+
id={field.name}
|
|
913
|
+
placeholder={field.placeholder}
|
|
914
|
+
value={formData[field.name] || ''}
|
|
915
|
+
onChange={(e) =>
|
|
916
|
+
setFormData({ ...formData, [field.name]: e.target.value })
|
|
917
|
+
}
|
|
918
|
+
required={field.required}
|
|
919
|
+
className="
|
|
920
|
+
px-4 py-2.5 rounded-md
|
|
921
|
+
border border-input
|
|
922
|
+
bg-background text-foreground
|
|
923
|
+
placeholder:text-muted-foreground
|
|
924
|
+
focus-visible:outline-2 focus-visible:outline-offset-2
|
|
925
|
+
focus-visible:outline-ring
|
|
926
|
+
font-sans
|
|
927
|
+
"
|
|
928
|
+
rows={4}
|
|
929
|
+
/>
|
|
930
|
+
) : (
|
|
931
|
+
<Input
|
|
932
|
+
id={field.name}
|
|
933
|
+
type={field.type}
|
|
934
|
+
placeholder={field.placeholder}
|
|
935
|
+
value={formData[field.name] || ''}
|
|
936
|
+
onChange={(e) =>
|
|
937
|
+
setFormData({ ...formData, [field.name]: e.target.value })
|
|
938
|
+
}
|
|
939
|
+
required={field.required}
|
|
940
|
+
/>
|
|
941
|
+
)}
|
|
942
|
+
|
|
943
|
+
{/* Field error */}
|
|
944
|
+
{errors[field.name] && (
|
|
945
|
+
<p className="mt-2 text-sm text-destructive flex items-center gap-1">
|
|
946
|
+
<AlertCircle className="w-4 h-4" />
|
|
947
|
+
{errors[field.name]}
|
|
948
|
+
</p>
|
|
949
|
+
)}
|
|
950
|
+
</div>
|
|
951
|
+
))}
|
|
952
|
+
|
|
953
|
+
{/* Submit error */}
|
|
954
|
+
{errors.submit && (
|
|
955
|
+
<div className="p-4 rounded-lg bg-destructive/10 border border-destructive/20
|
|
956
|
+
text-destructive text-sm flex items-start gap-3">
|
|
957
|
+
<AlertCircle className="w-5 h-5 flex-shrink-0 mt-0.5" />
|
|
958
|
+
<p>{errors.submit}</p>
|
|
959
|
+
</div>
|
|
960
|
+
)}
|
|
961
|
+
|
|
962
|
+
{/* Success message */}
|
|
963
|
+
{success && (
|
|
964
|
+
<div className="p-4 rounded-lg bg-green-500/10 border border-green-500/20
|
|
965
|
+
text-green-700 text-sm flex items-start gap-3">
|
|
966
|
+
<CheckCircle className="w-5 h-5 flex-shrink-0 mt-0.5" />
|
|
967
|
+
<p>{successMessage}</p>
|
|
968
|
+
</div>
|
|
969
|
+
)}
|
|
970
|
+
|
|
971
|
+
{/* Submit button */}
|
|
972
|
+
<Button
|
|
973
|
+
type="submit"
|
|
974
|
+
disabled={isLoading}
|
|
975
|
+
className="w-full"
|
|
976
|
+
>
|
|
977
|
+
{isLoading ? 'Submitting...' : submitLabel}
|
|
978
|
+
</Button>
|
|
979
|
+
</form>
|
|
980
|
+
);
|
|
981
|
+
}
|
|
982
|
+
```
|
|
983
|
+
|
|
984
|
+
---
|
|
985
|
+
|
|
986
|
+
## 7. DemoList
|
|
987
|
+
|
|
988
|
+
### Purpose
|
|
989
|
+
|
|
990
|
+
Display list of items with optional filtering and sorting.
|
|
991
|
+
|
|
992
|
+
### Props
|
|
993
|
+
|
|
994
|
+
```typescript
|
|
995
|
+
interface DemoListProps<T> {
|
|
996
|
+
items: T[];
|
|
997
|
+
renderItem: (item: T, index: number) => ReactNode;
|
|
998
|
+
emptyMessage?: string;
|
|
999
|
+
columns?: 1 | 2 | 3;
|
|
1000
|
+
gap?: 'sm' | 'md' | 'lg';
|
|
1001
|
+
}
|
|
1002
|
+
```
|
|
1003
|
+
|
|
1004
|
+
### Implementation
|
|
1005
|
+
|
|
1006
|
+
```tsx
|
|
1007
|
+
// src/components/demo/DemoList.tsx
|
|
1008
|
+
import { cn } from '@/lib/utils';
|
|
1009
|
+
|
|
1010
|
+
export function DemoList<T>({
|
|
1011
|
+
items,
|
|
1012
|
+
renderItem,
|
|
1013
|
+
emptyMessage = 'No items found',
|
|
1014
|
+
columns = 1,
|
|
1015
|
+
gap = 'md',
|
|
1016
|
+
}: DemoListProps<T>) {
|
|
1017
|
+
const columnClasses = {
|
|
1018
|
+
1: 'grid-cols-1',
|
|
1019
|
+
2: 'grid-cols-1 md:grid-cols-2',
|
|
1020
|
+
3: 'grid-cols-1 md:grid-cols-2 lg:grid-cols-3',
|
|
1021
|
+
};
|
|
1022
|
+
|
|
1023
|
+
const gapClasses = {
|
|
1024
|
+
sm: 'gap-3',
|
|
1025
|
+
md: 'gap-4',
|
|
1026
|
+
lg: 'gap-6',
|
|
1027
|
+
};
|
|
1028
|
+
|
|
1029
|
+
if (items.length === 0) {
|
|
1030
|
+
return (
|
|
1031
|
+
<div className="py-12 text-center">
|
|
1032
|
+
<p className="text-muted-foreground">{emptyMessage}</p>
|
|
1033
|
+
</div>
|
|
1034
|
+
);
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
return (
|
|
1038
|
+
<div className={cn('grid', columnClasses[columns], gapClasses[gap])}>
|
|
1039
|
+
{items.map((item, index) =>
|
|
1040
|
+
renderItem(item, index)
|
|
1041
|
+
)}
|
|
1042
|
+
</div>
|
|
1043
|
+
);
|
|
1044
|
+
}
|
|
1045
|
+
```
|
|
1046
|
+
|
|
1047
|
+
---
|
|
1048
|
+
|
|
1049
|
+
## 8. DemoGraph
|
|
1050
|
+
|
|
1051
|
+
### Purpose
|
|
1052
|
+
|
|
1053
|
+
Interactive relationship graph visualization component.
|
|
1054
|
+
|
|
1055
|
+
### Props
|
|
1056
|
+
|
|
1057
|
+
```typescript
|
|
1058
|
+
interface DemoGraphProps {
|
|
1059
|
+
data: GraphData;
|
|
1060
|
+
onNodeClick?: (nodeId: string) => void;
|
|
1061
|
+
height?: string;
|
|
1062
|
+
enableZoom?: boolean;
|
|
1063
|
+
enablePan?: boolean;
|
|
1064
|
+
theme?: 'light' | 'dark';
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1067
|
+
interface GraphData {
|
|
1068
|
+
nodes: Array<{
|
|
1069
|
+
id: string;
|
|
1070
|
+
label: string;
|
|
1071
|
+
type: string;
|
|
1072
|
+
color?: string;
|
|
1073
|
+
}>;
|
|
1074
|
+
edges: Array<{
|
|
1075
|
+
from: string;
|
|
1076
|
+
to: string;
|
|
1077
|
+
label?: string;
|
|
1078
|
+
}>;
|
|
1079
|
+
}
|
|
1080
|
+
```
|
|
1081
|
+
|
|
1082
|
+
### Implementation
|
|
1083
|
+
|
|
1084
|
+
```tsx
|
|
1085
|
+
// src/components/demo/DemoGraph.tsx
|
|
1086
|
+
'use client';
|
|
1087
|
+
|
|
1088
|
+
import { useEffect, useRef } from 'react';
|
|
1089
|
+
import { cn } from '@/lib/utils';
|
|
1090
|
+
|
|
1091
|
+
export function DemoGraph({
|
|
1092
|
+
data,
|
|
1093
|
+
onNodeClick,
|
|
1094
|
+
height = '500px',
|
|
1095
|
+
enableZoom = true,
|
|
1096
|
+
enablePan = true,
|
|
1097
|
+
theme = 'light',
|
|
1098
|
+
}: DemoGraphProps) {
|
|
1099
|
+
const containerRef = useRef<HTMLDivElement>(null);
|
|
1100
|
+
|
|
1101
|
+
useEffect(() => {
|
|
1102
|
+
if (!containerRef.current) return;
|
|
1103
|
+
|
|
1104
|
+
// Initialize graph visualization library
|
|
1105
|
+
// (Vis.js, D3.js, or Three.js implementation)
|
|
1106
|
+
// This is a placeholder for the actual implementation
|
|
1107
|
+
|
|
1108
|
+
console.log('Graph data:', data);
|
|
1109
|
+
}, [data, onNodeClick, enableZoom, enablePan, theme]);
|
|
1110
|
+
|
|
1111
|
+
return (
|
|
1112
|
+
<div
|
|
1113
|
+
ref={containerRef}
|
|
1114
|
+
className={cn(
|
|
1115
|
+
'rounded-lg border border-border bg-background',
|
|
1116
|
+
'transition-all duration-300',
|
|
1117
|
+
'overflow-hidden'
|
|
1118
|
+
)}
|
|
1119
|
+
style={{ height }}
|
|
1120
|
+
>
|
|
1121
|
+
{/* Graph rendered here via vis-network or similar */}
|
|
1122
|
+
<canvas className="w-full h-full" />
|
|
1123
|
+
</div>
|
|
1124
|
+
);
|
|
1125
|
+
}
|
|
1126
|
+
```
|
|
1127
|
+
|
|
1128
|
+
---
|
|
1129
|
+
|
|
1130
|
+
## 9. DemoCTA
|
|
1131
|
+
|
|
1132
|
+
### Purpose
|
|
1133
|
+
|
|
1134
|
+
Call-to-action section with headline, description, and buttons.
|
|
1135
|
+
|
|
1136
|
+
### Props
|
|
1137
|
+
|
|
1138
|
+
```typescript
|
|
1139
|
+
interface DemoCTAProps {
|
|
1140
|
+
headline: string;
|
|
1141
|
+
description?: string;
|
|
1142
|
+
icon?: ReactNode;
|
|
1143
|
+
primaryCta: {
|
|
1144
|
+
label: string;
|
|
1145
|
+
href?: string;
|
|
1146
|
+
onClick?: () => void;
|
|
1147
|
+
};
|
|
1148
|
+
secondaryCta?: {
|
|
1149
|
+
label: string;
|
|
1150
|
+
href?: string;
|
|
1151
|
+
onClick?: () => void;
|
|
1152
|
+
};
|
|
1153
|
+
stats?: Array<{ label: string; value: string }>;
|
|
1154
|
+
bgGradient?: 'primary' | 'accent' | 'secondary';
|
|
1155
|
+
}
|
|
1156
|
+
```
|
|
1157
|
+
|
|
1158
|
+
### Implementation
|
|
1159
|
+
|
|
1160
|
+
```tsx
|
|
1161
|
+
// src/components/demo/DemoCTA.tsx
|
|
1162
|
+
import { Button } from '@/components/ui/button';
|
|
1163
|
+
import { cn } from '@/lib/utils';
|
|
1164
|
+
|
|
1165
|
+
export function DemoCTA({
|
|
1166
|
+
headline,
|
|
1167
|
+
description,
|
|
1168
|
+
icon,
|
|
1169
|
+
primaryCta,
|
|
1170
|
+
secondaryCta,
|
|
1171
|
+
stats,
|
|
1172
|
+
bgGradient = 'primary',
|
|
1173
|
+
}: DemoCTAProps) {
|
|
1174
|
+
const bgClasses = {
|
|
1175
|
+
primary: 'bg-gradient-to-br from-primary to-primary/80 text-primary-foreground',
|
|
1176
|
+
accent: 'bg-gradient-to-br from-accent to-accent/80 text-accent-foreground',
|
|
1177
|
+
secondary: 'bg-gradient-to-br from-secondary to-secondary/80 text-secondary-foreground',
|
|
1178
|
+
};
|
|
1179
|
+
|
|
1180
|
+
return (
|
|
1181
|
+
<section className={cn(
|
|
1182
|
+
'relative overflow-hidden',
|
|
1183
|
+
'px-4 py-20 md:px-6 md:py-28',
|
|
1184
|
+
bgClasses[bgGradient]
|
|
1185
|
+
)}>
|
|
1186
|
+
{/* Content */}
|
|
1187
|
+
<div className="max-w-4xl mx-auto text-center">
|
|
1188
|
+
{icon && (
|
|
1189
|
+
<div className="mb-6 flex justify-center opacity-75">
|
|
1190
|
+
{icon}
|
|
1191
|
+
</div>
|
|
1192
|
+
)}
|
|
1193
|
+
|
|
1194
|
+
<h2 className="text-4xl md:text-5xl font-bold leading-tight mb-6">
|
|
1195
|
+
{headline}
|
|
1196
|
+
</h2>
|
|
1197
|
+
|
|
1198
|
+
{description && (
|
|
1199
|
+
<p className="text-xl opacity-90 mb-8 max-w-2xl mx-auto">
|
|
1200
|
+
{description}
|
|
1201
|
+
</p>
|
|
1202
|
+
)}
|
|
1203
|
+
|
|
1204
|
+
{/* CTAs */}
|
|
1205
|
+
<div className="flex flex-col sm:flex-row gap-4 justify-center mb-12">
|
|
1206
|
+
<Button
|
|
1207
|
+
variant="secondary"
|
|
1208
|
+
size="lg"
|
|
1209
|
+
asChild={!!primaryCta.href}
|
|
1210
|
+
>
|
|
1211
|
+
{primaryCta.href ? (
|
|
1212
|
+
<a href={primaryCta.href}>{primaryCta.label} →</a>
|
|
1213
|
+
) : (
|
|
1214
|
+
<span onClick={primaryCta.onClick}>
|
|
1215
|
+
{primaryCta.label} →
|
|
1216
|
+
</span>
|
|
1217
|
+
)}
|
|
1218
|
+
</Button>
|
|
1219
|
+
|
|
1220
|
+
{secondaryCta && (
|
|
1221
|
+
<Button
|
|
1222
|
+
variant="outline"
|
|
1223
|
+
size="lg"
|
|
1224
|
+
asChild={!!secondaryCta.href}
|
|
1225
|
+
>
|
|
1226
|
+
{secondaryCta.href ? (
|
|
1227
|
+
<a href={secondaryCta.href}>{secondaryCta.label}</a>
|
|
1228
|
+
) : (
|
|
1229
|
+
<span onClick={secondaryCta.onClick}>
|
|
1230
|
+
{secondaryCta.label}
|
|
1231
|
+
</span>
|
|
1232
|
+
)}
|
|
1233
|
+
</Button>
|
|
1234
|
+
)}
|
|
1235
|
+
</div>
|
|
1236
|
+
|
|
1237
|
+
{/* Stats */}
|
|
1238
|
+
{stats && stats.length > 0 && (
|
|
1239
|
+
<div className="grid grid-cols-2 md:grid-cols-3 gap-6 pt-8 border-t border-opacity-20">
|
|
1240
|
+
{stats.map((stat) => (
|
|
1241
|
+
<div key={stat.label}>
|
|
1242
|
+
<p className="text-3xl font-bold">{stat.value}</p>
|
|
1243
|
+
<p className="text-sm opacity-75 mt-2">{stat.label}</p>
|
|
1244
|
+
</div>
|
|
1245
|
+
))}
|
|
1246
|
+
</div>
|
|
1247
|
+
)}
|
|
1248
|
+
</div>
|
|
1249
|
+
</section>
|
|
1250
|
+
);
|
|
1251
|
+
}
|
|
1252
|
+
```
|
|
1253
|
+
|
|
1254
|
+
---
|
|
1255
|
+
|
|
1256
|
+
## Component Usage Guidelines
|
|
1257
|
+
|
|
1258
|
+
### Import Pattern
|
|
1259
|
+
|
|
1260
|
+
```tsx
|
|
1261
|
+
import { DemoHero } from '@/components/demo/DemoHero';
|
|
1262
|
+
import { DemoPlayground } from '@/components/demo/DemoPlayground';
|
|
1263
|
+
import { DemoCodeBlock } from '@/components/demo/DemoCodeBlock';
|
|
1264
|
+
import { DemoStats } from '@/components/demo/DemoStats';
|
|
1265
|
+
import { DemoCTA } from '@/components/demo/DemoCTA';
|
|
1266
|
+
```
|
|
1267
|
+
|
|
1268
|
+
### Composition Pattern
|
|
1269
|
+
|
|
1270
|
+
```astro
|
|
1271
|
+
<DemoContainer>
|
|
1272
|
+
<DemoHero ... />
|
|
1273
|
+
</DemoContainer>
|
|
1274
|
+
|
|
1275
|
+
<DemoContainer variant="card">
|
|
1276
|
+
<DemoPlayground client:load ... />
|
|
1277
|
+
</DemoContainer>
|
|
1278
|
+
|
|
1279
|
+
<DemoContainer>
|
|
1280
|
+
<DemoCodeBlock ... />
|
|
1281
|
+
<DemoCodeBlock ... />
|
|
1282
|
+
</DemoContainer>
|
|
1283
|
+
|
|
1284
|
+
<DemoCTA ... />
|
|
1285
|
+
```
|
|
1286
|
+
|
|
1287
|
+
### Client vs Server
|
|
1288
|
+
|
|
1289
|
+
- **Server (Astro):** DemoContainer, DemoHero, DemoCodeBlock, DemoCTA, DemoStats
|
|
1290
|
+
- **Client (React):** DemoPlayground, DemoForm, DemoList, DemoGraph (add `client:load`)
|
|
1291
|
+
|
|
1292
|
+
---
|
|
1293
|
+
|
|
1294
|
+
## Version History
|
|
1295
|
+
|
|
1296
|
+
| Version | Date | Changes |
|
|
1297
|
+
|---------|------|---------|
|
|
1298
|
+
| 1.0.0 | Oct 2024 | Initial component specifications |
|
|
1299
|
+
|
|
1300
|
+
---
|
|
1301
|
+
|
|
1302
|
+
**Components Maintained By:** Design Agent
|
|
1303
|
+
**Last Updated:** October 25, 2024
|
|
1304
|
+
**Status:** Production Ready
|