|
1 | 1 | "use client"; |
2 | 2 |
|
3 | | -import { useEffect } from "react"; |
| 3 | +import { useEffect, useState } from "react"; |
4 | 4 | import { ExampleLayout } from "@/components/example-layout"; |
5 | 5 | import { useGenerativeUIExamples, useExampleSuggestions } from "@/hooks"; |
6 | 6 | import { ExplainerCardsPortal } from "@/components/explainer-cards"; |
| 7 | +import { DemoGallery, type DemoItem } from "@/components/demo-gallery"; |
7 | 8 | import { CopilotChat } from "@copilotkit/react-core/v2"; |
| 9 | +import { useCopilotChatInternal } from "@copilotkit/react-core"; |
8 | 10 |
|
9 | 11 | export default function HomePage() { |
10 | 12 | useGenerativeUIExamples(); |
11 | 13 | useExampleSuggestions(); |
12 | 14 |
|
| 15 | + const [demoDrawerOpen, setDemoDrawerOpen] = useState(false); |
| 16 | + const { sendMessage } = useCopilotChatInternal(); |
| 17 | + |
| 18 | + const handleTryDemo = (demo: DemoItem) => { |
| 19 | + setDemoDrawerOpen(false); |
| 20 | + sendMessage({ id: crypto.randomUUID(), content: demo.prompt, role: "user" }); |
| 21 | + }; |
| 22 | + |
13 | 23 | // Widget bridge: handle messages from widget iframes |
14 | 24 | useEffect(() => { |
15 | 25 | const handler = (e: MessageEvent) => { |
@@ -55,6 +65,25 @@ export default function HomePage() { |
55 | 65 | </p> |
56 | 66 | </div> |
57 | 67 | <div className="flex items-center gap-2"> |
| 68 | + <button |
| 69 | + onClick={() => setDemoDrawerOpen(true)} |
| 70 | + className="inline-flex items-center gap-1.5 px-3 py-2 rounded-full text-sm font-medium no-underline whitespace-nowrap transition-all duration-150 hover:-translate-y-px cursor-pointer" |
| 71 | + style={{ |
| 72 | + color: "var(--text-secondary)", |
| 73 | + border: "1px solid var(--color-border-glass, rgba(0,0,0,0.1))", |
| 74 | + background: "var(--surface-primary, rgba(255,255,255,0.6))", |
| 75 | + fontFamily: "var(--font-family)", |
| 76 | + }} |
| 77 | + title="Open Demo Gallery" |
| 78 | + > |
| 79 | + <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"> |
| 80 | + <rect width="7" height="7" x="3" y="3" rx="1" /> |
| 81 | + <rect width="7" height="7" x="14" y="3" rx="1" /> |
| 82 | + <rect width="7" height="7" x="14" y="14" rx="1" /> |
| 83 | + <rect width="7" height="7" x="3" y="14" rx="1" /> |
| 84 | + </svg> |
| 85 | + Demos |
| 86 | + </button> |
58 | 87 | <a |
59 | 88 | href="https://github.com/CopilotKit/OpenGenerativeUI" |
60 | 89 | target="_blank" |
@@ -84,6 +113,11 @@ export default function HomePage() { |
84 | 113 | </div> |
85 | 114 | </div> |
86 | 115 |
|
| 116 | + <DemoGallery |
| 117 | + open={demoDrawerOpen} |
| 118 | + onClose={() => setDemoDrawerOpen(false)} |
| 119 | + onTryDemo={handleTryDemo} |
| 120 | + /> |
87 | 121 | </> |
88 | 122 | ); |
89 | 123 | } |
0 commit comments