forked from NguyenHaiNam24082000/react-cursor-chat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
entry.tsx
60 lines (56 loc) · 1.51 KB
/
entry.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import { useState } from "react";
import { createRoot } from "react-dom/client";
import { createPresence } from "@yomo/presence";
import CursorChat from "./index";
import { faker } from "@faker-js/faker";
import "./entry.css";
const domContainer = document.querySelector("#app");
if (!domContainer) throw new Error("no dom container");
const root = createRoot(domContainer);
const id = Math.random().toString();
let url =
(import.meta as any).env.VITE_PRESENCE_URL || "https://lo.yomo.dev:8443/v1";
const presence = createPresence(url, {
publicKey: (import.meta as any).env.VITE_PRESENCE_PUBLIC_KEY,
id,
autoDowngrade: true,
});
const App = () => {
const [darkMode, setDarkMode] = useState(true);
return (
<div
style={{
background: darkMode ? "black" : "white",
display: "flex",
flexDirection: "column",
alignItems: "center",
justifyContent: "center",
gap: "20px",
height: "100vh",
width: "100vw",
}}
>
<button
style={{
color: darkMode ? "black" : "white",
background: "pink",
borderRadius: "4px",
padding: "16px",
cursor: "none",
}}
onClick={() => {
setDarkMode(!darkMode);
}}
>
{darkMode ? "close dark mode" : "open dark mode"}
</button>
<CursorChat
presence={presence}
id={id}
name={faker.name.fullName()}
avatar={faker.image.avatar()}
/>
</div>
);
};
root.render(<App />);