feat: implement chat interface and registration modal
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
<!doctype html>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
@@ -6,7 +6,7 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Vite + React + TS</title>
|
||||
</head>
|
||||
<body>
|
||||
<body class="dark bg-neutral-950 text-neutral-100 antialiased">
|
||||
<div id="root"></div>
|
||||
<script type="module" src="/src/main.tsx"></script>
|
||||
</body>
|
||||
|
@@ -1,10 +1,11 @@
|
||||
import "./App.css";
|
||||
import Layout from "./layout/Layout";
|
||||
import MainChat from "./components/MainChat";
|
||||
|
||||
function App() {
|
||||
return (
|
||||
<Layout>
|
||||
<h1>Hello World</h1>
|
||||
<MainChat />
|
||||
</Layout>
|
||||
);
|
||||
}
|
||||
|
@@ -1,12 +1,39 @@
|
||||
import React from "react";
|
||||
import { LifeBuoy, RectangleEllipsis } from "lucide-react";
|
||||
import Register from "./Register";
|
||||
import { useState } from "react";
|
||||
|
||||
const Header: React.FC = () => {
|
||||
const [isRegisterOpen, setIsRegisterOpen] = useState(false);
|
||||
|
||||
return (
|
||||
<>
|
||||
<header>
|
||||
<h1>Header</h1>
|
||||
<header className="sticky top-0 z-50 flex w-full items-center justify-between gap-4 border-b border-neutral-800 bg-neutral-900/70 px-4 py-3 backdrop-blur supports-[backdrop-filter]:bg-neutral-900/50 md:px-6">
|
||||
<div className="flex items-center gap-2">
|
||||
<div className="h-8 w-8 rounded-md bg-gradient-to-br from-indigo-500 via-violet-500 to-fuchsia-500 shadow ring-1 ring-white/10" />
|
||||
<h1 className="text-lg font-semibold tracking-tight md:text-xl">
|
||||
Versario
|
||||
</h1>
|
||||
</div>
|
||||
<nav className="flex items-center gap-2">
|
||||
<button
|
||||
onClick={() => setIsRegisterOpen(true)}
|
||||
className="inline-flex items-center gap-2 rounded-md border border-neutral-700/80 bg-neutral-800/60 px-3 py-2 text-xs font-medium text-neutral-200 shadow-sm transition hover:border-neutral-600 hover:bg-neutral-700/70 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500 focus-visible:ring-offset-2 focus-visible:ring-offset-neutral-900 md:text-sm"
|
||||
aria-label="Register"
|
||||
>
|
||||
<RectangleEllipsis className="h-4 w-4" />
|
||||
<span className="hidden sm:inline">Register</span>
|
||||
</button>
|
||||
<button
|
||||
className="inline-flex items-center gap-2 rounded-md bg-gradient-to-tr from-indigo-600 to-fuchsia-600 px-3 py-2 text-xs font-semibold text-white shadow-sm ring-1 ring-inset ring-white/10 transition hover:from-indigo-500 hover:to-fuchsia-500 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400 focus-visible:ring-offset-2 focus-visible:ring-offset-neutral-900 md:text-sm"
|
||||
aria-label="Help"
|
||||
>
|
||||
<LifeBuoy className="h-4 w-4" />
|
||||
<span className="hidden sm:inline">Help</span>
|
||||
</button>
|
||||
</nav>
|
||||
|
||||
{isRegisterOpen && <Register />}
|
||||
</header>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
|
79
frontend/src/components/MainChat.tsx
Normal file
79
frontend/src/components/MainChat.tsx
Normal file
@@ -0,0 +1,79 @@
|
||||
import React from "react";
|
||||
|
||||
const sampleMessages = [
|
||||
{ id: 1, role: "assistant", text: "Hello! How can I help you today?" },
|
||||
{
|
||||
id: 2,
|
||||
role: "user",
|
||||
text: "Give me a summary of Tailwind's new features.",
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
role: "assistant",
|
||||
text: "Tailwind 4 introduces a revamped config, faster engine, and cleaner layer imports.",
|
||||
},
|
||||
{ id: 4, role: "user", text: "Great, thanks!" },
|
||||
];
|
||||
|
||||
const MainChat: React.FC = () => {
|
||||
return (
|
||||
<section className="flex h-full flex-1 flex-col">
|
||||
<div className="flex items-center gap-2 border-b border-neutral-800/80 bg-neutral-900/40 px-4 py-3 backdrop-blur supports-[backdrop-filter]:bg-neutral-900/30 md:px-6">
|
||||
<h2 className="text-base font-semibold tracking-tight md:text-lg">
|
||||
<form>
|
||||
<input type="text" placeholder="Search personality..." />
|
||||
<button type="submit">Search</button>
|
||||
</form>
|
||||
</h2>
|
||||
</div>
|
||||
<div className="flex flex-1 flex-col overflow-hidden">
|
||||
<div className="flex-1 space-y-4 overflow-y-auto px-4 py-6 md:px-8 lg:px-10 scrollbar-thin scrollbar-track-transparent scrollbar-thumb-neutral-800/80 hover:scrollbar-thumb-neutral-700">
|
||||
{sampleMessages.map((msg) => {
|
||||
const isUser = msg.role === "user";
|
||||
return (
|
||||
<div
|
||||
key={msg.id}
|
||||
className={`flex ${isUser ? "justify-end" : "justify-start"}`}
|
||||
>
|
||||
<div
|
||||
className={
|
||||
"max-w-[78%] rounded-2xl px-4 py-2 text-sm leading-relaxed shadow-md ring-1 ring-inset " +
|
||||
(isUser
|
||||
? "bg-gradient-to-tr from-indigo-600 to-fuchsia-600 text-white ring-white/10"
|
||||
: "bg-neutral-800/70 text-neutral-100 ring-neutral-700/70")
|
||||
}
|
||||
>
|
||||
{msg.text}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
<div className="border-t border-neutral-800/80 bg-neutral-900/40 p-4 backdrop-blur supports-[backdrop-filter]:bg-neutral-900/30 md:p-6">
|
||||
<form
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
}}
|
||||
className="group relative mx-auto flex max-w-3xl items-end gap-2"
|
||||
>
|
||||
<textarea
|
||||
rows={1}
|
||||
placeholder="Type your message..."
|
||||
className="peer max-h-48 w-full resize-none rounded-xl border border-neutral-700/70 bg-neutral-800/60 p-3 pr-24 text-sm text-neutral-100 placeholder:text-neutral-500 shadow-inner shadow-black/10 outline-none transition focus:border-neutral-500 focus:bg-neutral-800 focus:ring-2 focus:ring-indigo-500/40"
|
||||
/>
|
||||
<div className="absolute bottom-3 right-3 flex items-center gap-2">
|
||||
<button
|
||||
type="submit"
|
||||
className="inline-flex items-center rounded-md bg-gradient-to-tr from-indigo-600 to-fuchsia-600 px-4 py-2 text-xs font-semibold text-white shadow-sm ring-1 ring-inset ring-white/10 transition hover:from-indigo-500 hover:to-fuchsia-500 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400 focus-visible:ring-offset-2 focus-visible:ring-offset-neutral-900 md:text-sm"
|
||||
>
|
||||
Send
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
};
|
||||
|
||||
export default MainChat;
|
50
frontend/src/components/Register.tsx
Normal file
50
frontend/src/components/Register.tsx
Normal file
@@ -0,0 +1,50 @@
|
||||
import React from "react";
|
||||
|
||||
const Register: React.FC = () => {
|
||||
return (
|
||||
<div
|
||||
className="fixed inset-0 z-[80] grid min-h-dvh place-items-center overflow-y-auto bg-neutral-950/70 p-4 backdrop-blur-sm sm:p-6"
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
aria-labelledby="register-title"
|
||||
>
|
||||
<div className="relative w-full max-w-md overflow-hidden rounded-2xl border border-neutral-800/70 bg-neutral-900/70 p-6 shadow-2xl backdrop-blur supports-[backdrop-filter]:bg-neutral-900/60">
|
||||
<div className="pointer-events-none absolute inset-0 rounded-2xl ring-1 ring-inset ring-neutral-700/60" />
|
||||
<header className="mb-5 flex flex-col gap-1">
|
||||
<h1
|
||||
id="register-title"
|
||||
className="text-lg font-semibold tracking-tight text-white md:text-xl"
|
||||
>
|
||||
Register
|
||||
</h1>
|
||||
</header>
|
||||
<form className="space-y-4">
|
||||
<div className="space-y-2">
|
||||
<label
|
||||
htmlFor="email"
|
||||
className="block text-xs font-medium uppercase tracking-wider text-neutral-400"
|
||||
>
|
||||
Email
|
||||
</label>
|
||||
<input
|
||||
type="email"
|
||||
id="email"
|
||||
name="email"
|
||||
placeholder="you@example.com"
|
||||
className="w-full rounded-lg border border-neutral-700/70 bg-neutral-800/60 px-3 py-2 text-sm text-neutral-100 placeholder:text-neutral-500 shadow-inner shadow-black/20 outline-none transition focus:border-neutral-500 focus:bg-neutral-800 focus:ring-2 focus:ring-indigo-500/40"
|
||||
/>
|
||||
</div>
|
||||
<button
|
||||
type="submit"
|
||||
className="inline-flex w-full items-center justify-center gap-2 rounded-lg bg-gradient-to-tr from-indigo-600 to-fuchsia-600 px-4 py-2 text-sm font-semibold text-white shadow-sm ring-1 ring-inset ring-white/10 transition hover:from-indigo-500 hover:to-fuchsia-500 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400 focus-visible:ring-offset-2 focus-visible:ring-offset-neutral-900"
|
||||
>
|
||||
Register
|
||||
</button>
|
||||
</form>
|
||||
<div className="pointer-events-none absolute -bottom-24 right-0 h-48 w-48 translate-x-12 rounded-full bg-gradient-to-tr from-indigo-600/30 via-violet-600/20 to-fuchsia-600/30 blur-3xl" />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default Register;
|
@@ -1,12 +1,43 @@
|
||||
import React from "react";
|
||||
import { Search } from "lucide-react";
|
||||
|
||||
const Sidebar: React.FC = () => {
|
||||
return (
|
||||
<>
|
||||
<aside>
|
||||
<h2>Sidebar</h2>
|
||||
<aside className="hidden h-full w-64 shrink-0 flex-col border-r border-neutral-800 bg-neutral-900/40 px-3 py-4 backdrop-blur md:flex">
|
||||
<form
|
||||
onSubmit={(e) => e.preventDefault()}
|
||||
className="relative mb-4 flex items-center"
|
||||
role="search"
|
||||
>
|
||||
<Search className="pointer-events-none absolute left-3 h-4 w-4 text-neutral-500" />
|
||||
<input
|
||||
type="text"
|
||||
name="searchbar"
|
||||
id="searchbar"
|
||||
placeholder="Search recent chats..."
|
||||
className="w-full rounded-md border border-neutral-700/70 bg-neutral-800/60 py-2 pl-9 pr-3 text-sm text-neutral-200 placeholder:text-neutral-500 shadow-inner shadow-black/10 outline-none ring-0 transition focus:border-neutral-500 focus:bg-neutral-800 focus:ring-2 focus:ring-indigo-500/40"
|
||||
/>
|
||||
</form>
|
||||
<div className="flex-1 space-y-2 overflow-y-auto pr-1 text-sm scrollbar-thin scrollbar-track-transparent scrollbar-thumb-neutral-700/70 hover:scrollbar-thumb-neutral-600">
|
||||
<p className="text-xs uppercase tracking-wider text-neutral-500">
|
||||
Recent
|
||||
</p>
|
||||
<ul className="space-y-1">
|
||||
{Array.from({ length: 6 }).map((_, i) => (
|
||||
<li key={i}>
|
||||
<button className="group flex w-full items-center justify-between rounded-md border border-transparent bg-neutral-800/30 px-3 py-2 text-left font-medium text-neutral-300 transition hover:border-neutral-700/60 hover:bg-neutral-800/70 hover:text-white">
|
||||
<span className="line-clamp-1 text-xs md:text-sm">
|
||||
Conversation {i + 1}
|
||||
</span>
|
||||
<span className="ml-2 hidden text-[10px] font-semibold text-indigo-400 group-hover:inline md:text-xs">
|
||||
Open
|
||||
</span>
|
||||
</button>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
</aside>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
|
@@ -9,22 +9,25 @@ type LayoutProps = {
|
||||
|
||||
const Layout: React.FC<LayoutProps> = ({ children }) => {
|
||||
return (
|
||||
<div>
|
||||
<div className="flex min-h-screen flex-col bg-neutral-950 font-sans text-neutral-100 selection:bg-indigo-600/60 selection:text-white">
|
||||
<Header />
|
||||
<div className="flex flex-1 overflow-hidden">
|
||||
<Sidebar />
|
||||
<main className="flex flex-1 flex-col overflow-hidden">{children}</main>
|
||||
</div>
|
||||
<ToastContainer
|
||||
position="top-right"
|
||||
autoClose={5000}
|
||||
hideProgressBar={false}
|
||||
position="bottom-right"
|
||||
autoClose={4000}
|
||||
newestOnTop
|
||||
closeOnClick
|
||||
rtl={false}
|
||||
pauseOnFocusLoss={false}
|
||||
draggable
|
||||
pauseOnHover
|
||||
theme="dark"
|
||||
className="!w-auto"
|
||||
toastClassName={() =>
|
||||
"relative flex w-full items-start gap-3 rounded-md bg-neutral-800/90 px-4 py-3 text-sm font-medium text-neutral-100 shadow-lg backdrop-blur ring-1 ring-inset ring-neutral-700/70"
|
||||
}
|
||||
/>
|
||||
<main>{children}</main>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
Reference in New Issue
Block a user