-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRootLayout.tsx
More file actions
137 lines (123 loc) · 3.88 KB
/
RootLayout.tsx
File metadata and controls
137 lines (123 loc) · 3.88 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
"use client";
import * as React from "react";
import { motion } from "framer-motion";
import { useAccount } from "wagmi";
import RootChatInput from "@/components/chat/chat-input-root";
import { ExampleQueries } from "@/components/chat/example-queries";
import { ChatDisconnectedMessage } from "@/components/shared/DIsconnectedMessage";
import { useChat } from "@/contexts/chat-context";
export function RootLayout() {
const { isConnected } = useAccount();
const { input, handleInputChange, activeMode, setActiveMode } = useChat();
// Handler for example query selection
const handleExampleSelect = (query: string) => {
// Check if this is a special query with mode information (format: "query|||mode")
const parts = query.split("|||");
const actualQuery = parts[0];
const modeOverride =
parts.length > 1 ? (parts[1] as "morpheus" | "sentinel") : undefined;
// Update the mode if provided in the query
if (modeOverride) {
setActiveMode(modeOverride);
}
// RootChatInput handles double-click detection and redirect
handleInputChange(actualQuery);
};
const modeTitle =
activeMode === "morpheus"
? "What intelligence do you need?"
: "What do you want to do on chain?";
const modeTitleStyles =
activeMode === "morpheus"
? "text-emerald-800 dark:text-emerald-50 font-light"
: "text-indigo-800 dark:text-indigo-50 font-light";
if (!isConnected) {
return (
<div className="h-screen flex w-full absolute inset-0 bg-transparent">
<div className="flex-1 flex items-center justify-center p-4">
<div className="w-full max-w-md">
<ChatDisconnectedMessage />
</div>
</div>
</div>
);
}
// Main connected layout
return (
<div className="h-screen flex w-full absolute inset-0 bg-transparent">
<div className="flex-1 z-0 relative w-full">
<motion.div
initial={{
opacity: 0,
y: 20,
}}
animate={{ opacity: 1, y: 0 }}
transition={{
duration: 0.6,
ease: "easeOut",
}}
className="mx-auto mt-4 w-full flex-1 px-4 md:pl-8 lg:mt-6 max-w-7xl !mt-0 flex flex-col items-center gap-4 pt-12 md:pr-14 2xl:pr-20 pt-[10vh] md:pt-[30vh] max-sm:!px-1"
>
{/* Dynamic title */}
<motion.h1
key={activeMode}
initial={{ opacity: 0.6 }}
animate={{ opacity: 1 }}
transition={{
duration: 0.35,
ease: "easeOut",
}}
className={`text-2xl lg:text-5xl ${modeTitleStyles} drop-shadow-[0_2px_3px_rgba(0,0,0,0.3)] mb-7 text-center`}
>
{modeTitle}
</motion.h1>
{/* Chat input */}
<motion.div
initial={{
opacity: 0,
scale: 0.95,
}}
animate={{
opacity: 1,
scale: 1,
}}
transition={{
delay: 0.4,
duration: 0.6,
ease: "easeOut",
}}
className="w-full max-w-2xl"
>
<RootChatInput
input={input}
onChange={handleInputChange}
initialMode={activeMode}
/>
</motion.div>
<motion.div
initial={{
opacity: 0,
y: 20,
}}
animate={{
opacity: 1,
y: 0,
}}
transition={{
delay: 0.6,
duration: 0.6,
ease: "easeOut",
}}
className="w-full"
>
<ExampleQueries
onSelect={handleExampleSelect}
activeMode={activeMode}
onModeSelect={setActiveMode}
/>
</motion.div>
</motion.div>
</div>
</div>
);
}