|
1 | | -"use client"; |
2 | 1 | import React, { useState } from "react"; |
3 | 2 | import { FeatureSection } from "./FeatureSection"; |
| 3 | +import { ContentItem, FeatureWindow } from "./ui/FeatureWindow"; |
4 | 4 |
|
5 | | -export const FeatureCollab: React.FC = () => { |
| 5 | +export const FeatureCollab: React.FC<{ |
| 6 | + code: { realtime: string }; |
| 7 | +}> = ({ code }) => { |
6 | 8 | const [activeTab, setActiveTab] = useState< |
7 | 9 | "realtime" | "comments" | "suggestions" |
8 | 10 | >("realtime"); |
9 | 11 |
|
10 | | - const content = { |
| 12 | + const content: Record<string, ContentItem> = { |
11 | 13 | realtime: { |
| 14 | + type: "code", |
12 | 15 | file: "CollaborativeEditor.tsx", |
13 | | - code: `import * as Y from "yjs"; |
14 | | -import { WebsocketProvider } from "y-websocket"; |
15 | | -
|
16 | | -const doc = new Y.Doc(); |
17 | | -const provider = new WebsocketProvider( |
18 | | - "ws://localhost:1234", "room-id", doc); |
19 | | -
|
20 | | -const editor = useCreateBlockNote({ |
21 | | - collaboration: { |
22 | | - fragment: doc.getXmlFragment("document"), |
23 | | - user: { name: "Alice", color: "#ff0000" }, |
24 | | - provider, |
25 | | - } |
26 | | -}); |
27 | | -
|
28 | | -// Cursors and presence included`, |
| 16 | + code: code.realtime, |
29 | 17 | }, |
30 | 18 | comments: { |
31 | | - file: "Comments.tsx", |
32 | | - code: "", // Using image override |
| 19 | + type: "image", |
| 20 | + src: "/img/screenshots/home/comments.png", |
| 21 | + alt: "Comments", |
33 | 22 | }, |
34 | 23 | suggestions: { |
35 | | - file: "History.tsx", |
36 | | - code: "", // Using image override |
| 24 | + type: "image", |
| 25 | + src: "/img/screenshots/home/versioning.png", |
| 26 | + alt: "Versioning", |
37 | 27 | }, |
38 | 28 | }; |
39 | 29 |
|
@@ -68,43 +58,7 @@ const editor = useCreateBlockNote({ |
68 | 58 | onTabChange={(id) => setActiveTab(id as any)} |
69 | 59 | reverse={false} |
70 | 60 | > |
71 | | - {/* Window Chrome */} |
72 | | - {activeTab !== "suggestions" && activeTab !== "comments" && ( |
73 | | - <div className="flex items-center justify-between border-b border-white/5 bg-[#18181B] px-4 py-3"> |
74 | | - <div className="flex gap-1.5"> |
75 | | - <div className="h-2.5 w-2.5 rounded-full bg-[#FF5F56]"></div> |
76 | | - <div className="h-2.5 w-2.5 rounded-full bg-[#FFBD2E]"></div> |
77 | | - <div className="h-2.5 w-2.5 rounded-full bg-[#27C93F]"></div> |
78 | | - </div> |
79 | | - <span className="font-mono text-xs text-stone-500"> |
80 | | - {content[activeTab].file} |
81 | | - </span> |
82 | | - <div className="w-4"></div> |
83 | | - </div> |
84 | | - )} |
85 | | - |
86 | | - {/* Code */} |
87 | | - <div |
88 | | - className={`min-h-[300px] overflow-x-auto bg-[#0F0F11] ${activeTab === "realtime" ? "p-6" : ""}`} |
89 | | - > |
90 | | - {activeTab === "suggestions" ? ( |
91 | | - <img |
92 | | - src="/img/screenshots/home/versioning.png" |
93 | | - alt="Versioning" |
94 | | - className="w-full rounded-md" |
95 | | - /> |
96 | | - ) : activeTab === "comments" ? ( |
97 | | - <img |
98 | | - src="/img/screenshots/home/comments.png" |
99 | | - alt="Comments" |
100 | | - className="w-full rounded-md" |
101 | | - /> |
102 | | - ) : ( |
103 | | - <pre className="whitespace-pre font-mono text-sm leading-relaxed text-stone-300"> |
104 | | - {content[activeTab].code} |
105 | | - </pre> |
106 | | - )} |
107 | | - </div> |
| 61 | + <FeatureWindow content={content[activeTab]} theme="dark" /> |
108 | 62 | </FeatureSection> |
109 | 63 | ); |
110 | 64 | }; |
0 commit comments