bipinkrish commited on
Commit ·
bc666cc
0
Parent(s):
init
Browse files- .eslintrc.json +3 -0
- .gitignore +40 -0
- README.md +1 -0
- components.json +21 -0
- next.config.ts +7 -0
- package-lock.json +0 -0
- package.json +36 -0
- postcss.config.mjs +9 -0
- src/app/globals.css +72 -0
- src/app/layout.tsx +25 -0
- src/app/page.tsx +7 -0
- src/components/api.ts +49 -0
- src/components/chat-page.tsx +263 -0
- src/components/dummy-data.ts +78 -0
- src/components/types.ts +27 -0
- src/components/ui/button.tsx +56 -0
- src/components/ui/scroll-area.tsx +48 -0
- src/components/ui/tabs.tsx +55 -0
- src/components/ui/textarea.tsx +22 -0
- src/lib/utils.ts +6 -0
- tailwind.config.ts +67 -0
- tsconfig.json +27 -0
.eslintrc.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"extends": ["next/core-web-vitals", "next/typescript"]
|
| 3 |
+
}
|
.gitignore
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
| 2 |
+
|
| 3 |
+
# dependencies
|
| 4 |
+
/node_modules
|
| 5 |
+
/.pnp
|
| 6 |
+
.pnp.*
|
| 7 |
+
.yarn/*
|
| 8 |
+
!.yarn/patches
|
| 9 |
+
!.yarn/plugins
|
| 10 |
+
!.yarn/releases
|
| 11 |
+
!.yarn/versions
|
| 12 |
+
|
| 13 |
+
# testing
|
| 14 |
+
/coverage
|
| 15 |
+
|
| 16 |
+
# next.js
|
| 17 |
+
/.next/
|
| 18 |
+
/out/
|
| 19 |
+
|
| 20 |
+
# production
|
| 21 |
+
/build
|
| 22 |
+
|
| 23 |
+
# misc
|
| 24 |
+
.DS_Store
|
| 25 |
+
*.pem
|
| 26 |
+
|
| 27 |
+
# debug
|
| 28 |
+
npm-debug.log*
|
| 29 |
+
yarn-debug.log*
|
| 30 |
+
yarn-error.log*
|
| 31 |
+
|
| 32 |
+
# env files (can opt-in for committing if needed)
|
| 33 |
+
.env*
|
| 34 |
+
|
| 35 |
+
# vercel
|
| 36 |
+
.vercel
|
| 37 |
+
|
| 38 |
+
# typescript
|
| 39 |
+
*.tsbuildinfo
|
| 40 |
+
next-env.d.ts
|
README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
# WebZero
|
components.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"$schema": "https://ui.shadcn.com/schema.json",
|
| 3 |
+
"style": "default",
|
| 4 |
+
"rsc": true,
|
| 5 |
+
"tsx": true,
|
| 6 |
+
"tailwind": {
|
| 7 |
+
"config": "tailwind.config.ts",
|
| 8 |
+
"css": "src/app/globals.css",
|
| 9 |
+
"baseColor": "zinc",
|
| 10 |
+
"cssVariables": true,
|
| 11 |
+
"prefix": ""
|
| 12 |
+
},
|
| 13 |
+
"aliases": {
|
| 14 |
+
"components": "@/components",
|
| 15 |
+
"utils": "@/lib/utils",
|
| 16 |
+
"ui": "@/components/ui",
|
| 17 |
+
"lib": "@/lib",
|
| 18 |
+
"hooks": "@/hooks"
|
| 19 |
+
},
|
| 20 |
+
"iconLibrary": "lucide"
|
| 21 |
+
}
|
next.config.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type { NextConfig } from "next";
|
| 2 |
+
|
| 3 |
+
const nextConfig: NextConfig = {
|
| 4 |
+
/* config options here */
|
| 5 |
+
};
|
| 6 |
+
|
| 7 |
+
export default nextConfig;
|
package-lock.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "webzero",
|
| 3 |
+
"version": "0.1.0",
|
| 4 |
+
"private": true,
|
| 5 |
+
"scripts": {
|
| 6 |
+
"dev": "next dev --turbopack",
|
| 7 |
+
"build": "next build",
|
| 8 |
+
"start": "next start",
|
| 9 |
+
"lint": "next lint"
|
| 10 |
+
},
|
| 11 |
+
"dependencies": {
|
| 12 |
+
"@radix-ui/react-scroll-area": "^1.2.1",
|
| 13 |
+
"@radix-ui/react-slot": "^1.1.0",
|
| 14 |
+
"@radix-ui/react-tabs": "^1.1.1",
|
| 15 |
+
"class-variance-authority": "^0.7.0",
|
| 16 |
+
"clsx": "^2.1.1",
|
| 17 |
+
"lucide-react": "^0.460.0",
|
| 18 |
+
"next": "15.0.3",
|
| 19 |
+
"react": "19.0.0-rc-66855b96-20241106",
|
| 20 |
+
"react-dom": "19.0.0-rc-66855b96-20241106",
|
| 21 |
+
"react-syntax-highlighter": "^15.6.1",
|
| 22 |
+
"tailwind-merge": "^2.5.4",
|
| 23 |
+
"tailwindcss-animate": "^1.0.7"
|
| 24 |
+
},
|
| 25 |
+
"devDependencies": {
|
| 26 |
+
"@types/node": "^20",
|
| 27 |
+
"@types/react": "^18",
|
| 28 |
+
"@types/react-dom": "^18",
|
| 29 |
+
"autoprefixer": "^10.4.20",
|
| 30 |
+
"eslint": "^8",
|
| 31 |
+
"eslint-config-next": "15.0.3",
|
| 32 |
+
"postcss": "^8.4.49",
|
| 33 |
+
"tailwindcss": "^3.4.15",
|
| 34 |
+
"typescript": "^5"
|
| 35 |
+
}
|
| 36 |
+
}
|
postcss.config.mjs
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/** @type {import('postcss-load-config').Config} */
|
| 2 |
+
const config = {
|
| 3 |
+
plugins: {
|
| 4 |
+
tailwindcss: {},
|
| 5 |
+
autoprefixer: {},
|
| 6 |
+
},
|
| 7 |
+
};
|
| 8 |
+
|
| 9 |
+
export default config;
|
src/app/globals.css
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
@tailwind base;
|
| 2 |
+
@tailwind components;
|
| 3 |
+
@tailwind utilities;
|
| 4 |
+
|
| 5 |
+
body {
|
| 6 |
+
font-family: Arial, Helvetica, sans-serif;
|
| 7 |
+
}
|
| 8 |
+
|
| 9 |
+
@layer base {
|
| 10 |
+
:root {
|
| 11 |
+
--background: 0 0% 100%;
|
| 12 |
+
--foreground: 240 10% 3.9%;
|
| 13 |
+
--card: 0 0% 100%;
|
| 14 |
+
--card-foreground: 240 10% 3.9%;
|
| 15 |
+
--popover: 0 0% 100%;
|
| 16 |
+
--popover-foreground: 240 10% 3.9%;
|
| 17 |
+
--primary: 240 5.9% 10%;
|
| 18 |
+
--primary-foreground: 0 0% 98%;
|
| 19 |
+
--secondary: 240 4.8% 95.9%;
|
| 20 |
+
--secondary-foreground: 240 5.9% 10%;
|
| 21 |
+
--muted: 240 4.8% 95.9%;
|
| 22 |
+
--muted-foreground: 240 3.8% 46.1%;
|
| 23 |
+
--accent: 240 4.8% 95.9%;
|
| 24 |
+
--accent-foreground: 240 5.9% 10%;
|
| 25 |
+
--destructive: 0 84.2% 60.2%;
|
| 26 |
+
--destructive-foreground: 0 0% 98%;
|
| 27 |
+
--border: 240 5.9% 90%;
|
| 28 |
+
--input: 240 5.9% 90%;
|
| 29 |
+
--ring: 240 10% 3.9%;
|
| 30 |
+
--chart-1: 12 76% 61%;
|
| 31 |
+
--chart-2: 173 58% 39%;
|
| 32 |
+
--chart-3: 197 37% 24%;
|
| 33 |
+
--chart-4: 43 74% 66%;
|
| 34 |
+
--chart-5: 27 87% 67%;
|
| 35 |
+
--radius: 0.5rem;
|
| 36 |
+
}
|
| 37 |
+
.dark {
|
| 38 |
+
--background: 240 10% 3.9%;
|
| 39 |
+
--foreground: 0 0% 98%;
|
| 40 |
+
--card: 240 10% 3.9%;
|
| 41 |
+
--card-foreground: 0 0% 98%;
|
| 42 |
+
--popover: 240 10% 3.9%;
|
| 43 |
+
--popover-foreground: 0 0% 98%;
|
| 44 |
+
--primary: 0 0% 98%;
|
| 45 |
+
--primary-foreground: 240 5.9% 10%;
|
| 46 |
+
--secondary: 240 3.7% 15.9%;
|
| 47 |
+
--secondary-foreground: 0 0% 98%;
|
| 48 |
+
--muted: 240 3.7% 15.9%;
|
| 49 |
+
--muted-foreground: 240 5% 64.9%;
|
| 50 |
+
--accent: 240 3.7% 15.9%;
|
| 51 |
+
--accent-foreground: 0 0% 98%;
|
| 52 |
+
--destructive: 0 62.8% 30.6%;
|
| 53 |
+
--destructive-foreground: 0 0% 98%;
|
| 54 |
+
--border: 240 3.7% 15.9%;
|
| 55 |
+
--input: 240 3.7% 15.9%;
|
| 56 |
+
--ring: 240 4.9% 83.9%;
|
| 57 |
+
--chart-1: 220 70% 50%;
|
| 58 |
+
--chart-2: 160 60% 45%;
|
| 59 |
+
--chart-3: 30 80% 55%;
|
| 60 |
+
--chart-4: 280 65% 60%;
|
| 61 |
+
--chart-5: 340 75% 55%;
|
| 62 |
+
}
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
@layer base {
|
| 66 |
+
* {
|
| 67 |
+
@apply border-border;
|
| 68 |
+
}
|
| 69 |
+
body {
|
| 70 |
+
@apply bg-background text-foreground;
|
| 71 |
+
}
|
| 72 |
+
}
|
src/app/layout.tsx
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type { Metadata } from "next";
|
| 2 |
+
import "./globals.css";
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
export const metadata: Metadata = {
|
| 6 |
+
title: "webzero",
|
| 7 |
+
description: "Generate webpages",
|
| 8 |
+
};
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
export default function RootLayout({
|
| 12 |
+
children,
|
| 13 |
+
}: Readonly<{
|
| 14 |
+
children: React.ReactNode;
|
| 15 |
+
}>) {
|
| 16 |
+
return (
|
| 17 |
+
<html lang="en">
|
| 18 |
+
<body
|
| 19 |
+
className="antialiased"
|
| 20 |
+
>
|
| 21 |
+
{children}
|
| 22 |
+
</body>
|
| 23 |
+
</html>
|
| 24 |
+
);
|
| 25 |
+
}
|
src/app/page.tsx
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { ChatPage } from "@/components/chat-page";
|
| 2 |
+
|
| 3 |
+
export default function Home() {
|
| 4 |
+
return (
|
| 5 |
+
<ChatPage />
|
| 6 |
+
);
|
| 7 |
+
}
|
src/components/api.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { ChatMessage, FileAttachment } from './types'
|
| 2 |
+
import { mockFetchChatHistory, mockSendMessage } from './dummy-data'
|
| 3 |
+
|
| 4 |
+
const API_BASE_URL = 'https://api.webzero.com'
|
| 5 |
+
|
| 6 |
+
export const fetchChatHistory = mockFetchChatHistory;
|
| 7 |
+
export const sendMessage = mockSendMessage;
|
| 8 |
+
|
| 9 |
+
// export async function fetchChatHistory(): Promise<ChatMessage[]> {
|
| 10 |
+
// const response = await fetch(`${API_BASE_URL}/chat-history`)
|
| 11 |
+
// if (!response.ok) {
|
| 12 |
+
// throw new Error('Failed to fetch chat history')
|
| 13 |
+
// }
|
| 14 |
+
// return response.json()
|
| 15 |
+
// }
|
| 16 |
+
|
| 17 |
+
// export async function sendMessage(content: string, files?: File[]): Promise<ChatMessage> {
|
| 18 |
+
// const formData = new FormData()
|
| 19 |
+
// formData.append('content', content)
|
| 20 |
+
|
| 21 |
+
// if (files?.length) {
|
| 22 |
+
// files.forEach(file => formData.append('files', file))
|
| 23 |
+
// }
|
| 24 |
+
|
| 25 |
+
// const response = await fetch(`${API_BASE_URL}/send-message`, {
|
| 26 |
+
// method: 'POST',
|
| 27 |
+
// body: formData,
|
| 28 |
+
// })
|
| 29 |
+
|
| 30 |
+
// if (!response.ok) {
|
| 31 |
+
// throw new Error('Failed to send message')
|
| 32 |
+
// }
|
| 33 |
+
// return response.json()
|
| 34 |
+
// }
|
| 35 |
+
|
| 36 |
+
export async function uploadFile(file: File): Promise<FileAttachment> {
|
| 37 |
+
const formData = new FormData()
|
| 38 |
+
formData.append('file', file)
|
| 39 |
+
|
| 40 |
+
const response = await fetch(`${API_BASE_URL}/upload`, {
|
| 41 |
+
method: 'POST',
|
| 42 |
+
body: formData,
|
| 43 |
+
})
|
| 44 |
+
|
| 45 |
+
if (!response.ok) {
|
| 46 |
+
throw new Error('Failed to upload file')
|
| 47 |
+
}
|
| 48 |
+
return response.json()
|
| 49 |
+
}
|
src/components/chat-page.tsx
ADDED
|
@@ -0,0 +1,263 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use client'
|
| 2 |
+
|
| 3 |
+
import { useState, useEffect, useRef } from 'react'
|
| 4 |
+
import { Code, Eye, Menu, Paperclip, Sun, Moon, Send, Download, Copy, Maximize2, Minimize2 } from 'lucide-react'
|
| 5 |
+
import { Button } from '@/components/ui/button'
|
| 6 |
+
import { Textarea } from '@/components/ui/textarea'
|
| 7 |
+
import { Tabs, TabsList, TabsTrigger, TabsContent } from '@/components/ui/tabs'
|
| 8 |
+
import { ScrollArea } from '@/components/ui/scroll-area'
|
| 9 |
+
import { fetchChatHistory, sendMessage } from './api'
|
| 10 |
+
import { ChatMessage, PreviewState } from './types'
|
| 11 |
+
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter'
|
| 12 |
+
import { oneDark } from 'react-syntax-highlighter/dist/esm/styles/prism'
|
| 13 |
+
|
| 14 |
+
export function ChatPage() {
|
| 15 |
+
const [message, setMessage] = useState('')
|
| 16 |
+
const [isDark, setIsDark] = useState(() => {
|
| 17 |
+
if (typeof window !== 'undefined') {
|
| 18 |
+
return localStorage.getItem('theme') === 'dark'
|
| 19 |
+
}
|
| 20 |
+
return false
|
| 21 |
+
})
|
| 22 |
+
const [isMenuOpen, setIsMenuOpen] = useState(true)
|
| 23 |
+
const [chatHistory, setChatHistory] = useState<ChatMessage[]>([])
|
| 24 |
+
const [selectedMessage, setSelectedMessage] = useState<ChatMessage | null>(null)
|
| 25 |
+
const [previewState, setPreviewState] = useState<PreviewState>({
|
| 26 |
+
isFullscreen: false,
|
| 27 |
+
isOpen: false
|
| 28 |
+
})
|
| 29 |
+
const fileInputRef = useRef<HTMLInputElement>(null)
|
| 30 |
+
|
| 31 |
+
useEffect(() => {
|
| 32 |
+
fetchChatHistory().then(setChatHistory)
|
| 33 |
+
}, [])
|
| 34 |
+
|
| 35 |
+
useEffect(() => {
|
| 36 |
+
localStorage.setItem('theme', isDark ? 'dark' : 'light')
|
| 37 |
+
document.documentElement.classList.toggle('dark', isDark)
|
| 38 |
+
}, [isDark])
|
| 39 |
+
|
| 40 |
+
const toggleTheme = () => setIsDark(!isDark)
|
| 41 |
+
|
| 42 |
+
const handleSubmit = async (e: React.FormEvent) => {
|
| 43 |
+
e.preventDefault()
|
| 44 |
+
if (!message.trim()) return
|
| 45 |
+
|
| 46 |
+
const files = fileInputRef.current?.files
|
| 47 |
+
const newMessage: ChatMessage = {
|
| 48 |
+
id: Date.now().toString(),
|
| 49 |
+
content: message,
|
| 50 |
+
sender: 'user',
|
| 51 |
+
timestamp: new Date().toISOString(),
|
| 52 |
+
files: files ? Array.from(files).map(file => ({
|
| 53 |
+
id: file.name,
|
| 54 |
+
name: file.name,
|
| 55 |
+
type: file.type,
|
| 56 |
+
url: URL.createObjectURL(file),
|
| 57 |
+
size: file.size
|
| 58 |
+
})) : undefined
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
setChatHistory(prev => [...prev, newMessage])
|
| 62 |
+
setMessage('')
|
| 63 |
+
if (fileInputRef.current) fileInputRef.current.value = ''
|
| 64 |
+
|
| 65 |
+
const response = await sendMessage(message, files ? Array.from(files) : undefined)
|
| 66 |
+
setChatHistory(prev => [...prev, response])
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
const handleFileUpload = () => {
|
| 70 |
+
fileInputRef.current?.click()
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
const handlePaste = (e: React.ClipboardEvent) => {
|
| 74 |
+
const items = e.clipboardData.items
|
| 75 |
+
const files = []
|
| 76 |
+
for (let i = 0; i < items.length; i++) {
|
| 77 |
+
if (items[i].type.indexOf('image') !== -1) {
|
| 78 |
+
const file = items[i].getAsFile()
|
| 79 |
+
if (file) files.push(file)
|
| 80 |
+
}
|
| 81 |
+
}
|
| 82 |
+
if (files.length && fileInputRef.current) {
|
| 83 |
+
const dataTransfer = new DataTransfer()
|
| 84 |
+
files.forEach(file => dataTransfer.items.add(file))
|
| 85 |
+
fileInputRef.current.files = dataTransfer.files
|
| 86 |
+
}
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
const handleCopyCode = async (code: string) => {
|
| 90 |
+
await navigator.clipboard.writeText(code)
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
const handleDownloadCode = (code: string, filename: string) => {
|
| 94 |
+
const blob = new Blob([code], { type: 'text/plain' })
|
| 95 |
+
const url = URL.createObjectURL(blob)
|
| 96 |
+
const a = document.createElement('a')
|
| 97 |
+
a.href = url
|
| 98 |
+
a.download = filename
|
| 99 |
+
a.click()
|
| 100 |
+
URL.revokeObjectURL(url)
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
const toggleFullscreen = () => {
|
| 104 |
+
setPreviewState(prev => ({
|
| 105 |
+
...prev,
|
| 106 |
+
isFullscreen: !prev.isFullscreen
|
| 107 |
+
}))
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
return (
|
| 111 |
+
<div className={`min-h-screen flex ${isDark ? 'dark' : ''}`}>
|
| 112 |
+
{/* Sidebar */}
|
| 113 |
+
<div className={`w-64 border-r bg-background ${isMenuOpen ? '' : 'hidden'} md:block`}>
|
| 114 |
+
<div className="p-4 border-b">
|
| 115 |
+
<div className="font-bold text-xl">webzero</div>
|
| 116 |
+
</div>
|
| 117 |
+
<nav className="p-4">
|
| 118 |
+
<Button variant="ghost" className="w-full justify-start">
|
| 119 |
+
New Chat
|
| 120 |
+
</Button>
|
| 121 |
+
</nav>
|
| 122 |
+
</div>
|
| 123 |
+
|
| 124 |
+
{/* Main Content */}
|
| 125 |
+
<div className="flex-1 flex flex-col">
|
| 126 |
+
<header className="h-16 border-b flex items-center justify-between px-4">
|
| 127 |
+
<Button variant="ghost" size="icon" onClick={() => setIsMenuOpen(!isMenuOpen)} className="md:hidden">
|
| 128 |
+
<Menu className="h-5 w-5" />
|
| 129 |
+
</Button>
|
| 130 |
+
<Button variant="ghost" size="icon" onClick={toggleTheme}>
|
| 131 |
+
{isDark ? <Sun className="h-5 w-5" /> : <Moon className="h-5 w-5" />}
|
| 132 |
+
</Button>
|
| 133 |
+
</header>
|
| 134 |
+
|
| 135 |
+
<div className="flex-1 flex">
|
| 136 |
+
{/* Chat/Input Area */}
|
| 137 |
+
<div className="flex-1 flex flex-col">
|
| 138 |
+
<ScrollArea className="flex-1 p-4">
|
| 139 |
+
{chatHistory.map((msg) => (
|
| 140 |
+
<div
|
| 141 |
+
key={msg.id}
|
| 142 |
+
className={`mb-4 p-4 rounded-lg ${
|
| 143 |
+
msg.sender === 'user' ? 'bg-primary/10 ml-auto max-w-[80%]' : 'bg-muted max-w-[80%]'
|
| 144 |
+
} cursor-pointer hover:bg-muted/80 transition-colors`}
|
| 145 |
+
onClick={() => {
|
| 146 |
+
setSelectedMessage(msg)
|
| 147 |
+
setPreviewState(prev => ({ ...prev, isOpen: true }))
|
| 148 |
+
}}
|
| 149 |
+
>
|
| 150 |
+
<div className="mb-2">{msg.content}</div>
|
| 151 |
+
{msg.files?.map(file => (
|
| 152 |
+
<div key={file.id} className="text-sm text-muted-foreground">
|
| 153 |
+
📎 {file.name} ({Math.round(file.size / 1024)}KB)
|
| 154 |
+
</div>
|
| 155 |
+
))}
|
| 156 |
+
</div>
|
| 157 |
+
))}
|
| 158 |
+
</ScrollArea>
|
| 159 |
+
|
| 160 |
+
<div className="border-t p-4">
|
| 161 |
+
<form onSubmit={handleSubmit} className="relative">
|
| 162 |
+
<Textarea
|
| 163 |
+
value={message}
|
| 164 |
+
onChange={(e) => setMessage(e.target.value)}
|
| 165 |
+
onPaste={handlePaste}
|
| 166 |
+
placeholder="Ask webzero a question..."
|
| 167 |
+
className="min-h-[100px] pr-24 resize-none"
|
| 168 |
+
/>
|
| 169 |
+
<input
|
| 170 |
+
type="file"
|
| 171 |
+
ref={fileInputRef}
|
| 172 |
+
className="hidden"
|
| 173 |
+
multiple
|
| 174 |
+
accept="image/*,.pdf,.doc,.docx"
|
| 175 |
+
/>
|
| 176 |
+
<div className="absolute bottom-3 right-3 flex items-center gap-2">
|
| 177 |
+
<Button variant="ghost" size="icon" type="button" onClick={handleFileUpload}>
|
| 178 |
+
<Paperclip className="h-4 w-4" />
|
| 179 |
+
</Button>
|
| 180 |
+
<Button type="submit" size="icon">
|
| 181 |
+
<Send className="h-4 w-4" />
|
| 182 |
+
</Button>
|
| 183 |
+
</div>
|
| 184 |
+
</form>
|
| 185 |
+
</div>
|
| 186 |
+
</div>
|
| 187 |
+
|
| 188 |
+
{/* Preview/Code Panel */}
|
| 189 |
+
{(selectedMessage?.preview || selectedMessage?.code) && previewState.isOpen && (
|
| 190 |
+
<div className={`border-l ${previewState.isFullscreen ? 'fixed inset-0 z-50 bg-background' : 'w-1/2'} hidden lg:block`}>
|
| 191 |
+
<Tabs defaultValue="preview" className="h-full flex flex-col">
|
| 192 |
+
<div className="border-b px-4 flex justify-between items-center">
|
| 193 |
+
<TabsList>
|
| 194 |
+
{selectedMessage.preview && (
|
| 195 |
+
<TabsTrigger value="preview" className="flex items-center gap-2">
|
| 196 |
+
<Eye className="h-4 w-4" />
|
| 197 |
+
Preview
|
| 198 |
+
</TabsTrigger>
|
| 199 |
+
)}
|
| 200 |
+
{selectedMessage.code && (
|
| 201 |
+
<TabsTrigger value="code" className="flex items-center gap-2">
|
| 202 |
+
<Code className="h-4 w-4" />
|
| 203 |
+
Code
|
| 204 |
+
</TabsTrigger>
|
| 205 |
+
)}
|
| 206 |
+
</TabsList>
|
| 207 |
+
<Button variant="ghost" size="icon" onClick={toggleFullscreen}>
|
| 208 |
+
{previewState.isFullscreen ? (
|
| 209 |
+
<Minimize2 className="h-4 w-4" />
|
| 210 |
+
) : (
|
| 211 |
+
<Maximize2 className="h-4 w-4" />
|
| 212 |
+
)}
|
| 213 |
+
</Button>
|
| 214 |
+
</div>
|
| 215 |
+
{selectedMessage.preview && (
|
| 216 |
+
<TabsContent value="preview" className="flex-1 p-4">
|
| 217 |
+
<ScrollArea className="h-full">
|
| 218 |
+
<div dangerouslySetInnerHTML={{ __html: selectedMessage.preview }} />
|
| 219 |
+
</ScrollArea>
|
| 220 |
+
</TabsContent>
|
| 221 |
+
)}
|
| 222 |
+
{selectedMessage.code && (
|
| 223 |
+
<TabsContent value="code" className="flex-1">
|
| 224 |
+
<div className="p-4 border-b flex justify-end gap-2">
|
| 225 |
+
<Button
|
| 226 |
+
variant="outline"
|
| 227 |
+
size="sm"
|
| 228 |
+
onClick={() => handleCopyCode(selectedMessage.code!.content)}
|
| 229 |
+
>
|
| 230 |
+
<Copy className="h-4 w-4 mr-2" />
|
| 231 |
+
Copy
|
| 232 |
+
</Button>
|
| 233 |
+
<Button
|
| 234 |
+
variant="outline"
|
| 235 |
+
size="sm"
|
| 236 |
+
onClick={() => handleDownloadCode(
|
| 237 |
+
selectedMessage.code!.content,
|
| 238 |
+
`code-${selectedMessage.id}.${selectedMessage.code!.language}`
|
| 239 |
+
)}
|
| 240 |
+
>
|
| 241 |
+
<Download className="h-4 w-4 mr-2" />
|
| 242 |
+
Download
|
| 243 |
+
</Button>
|
| 244 |
+
</div>
|
| 245 |
+
<ScrollArea className="h-[calc(100%-4rem)]">
|
| 246 |
+
<SyntaxHighlighter
|
| 247 |
+
language={selectedMessage.code.language}
|
| 248 |
+
style={oneDark}
|
| 249 |
+
className="!m-0 !bg-transparent"
|
| 250 |
+
>
|
| 251 |
+
{selectedMessage.code.content}
|
| 252 |
+
</SyntaxHighlighter>
|
| 253 |
+
</ScrollArea>
|
| 254 |
+
</TabsContent>
|
| 255 |
+
)}
|
| 256 |
+
</Tabs>
|
| 257 |
+
</div>
|
| 258 |
+
)}
|
| 259 |
+
</div>
|
| 260 |
+
</div>
|
| 261 |
+
</div>
|
| 262 |
+
)
|
| 263 |
+
}
|
src/components/dummy-data.ts
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { ChatMessage } from './types'
|
| 2 |
+
|
| 3 |
+
export const dummyChatHistory: ChatMessage[] = [
|
| 4 |
+
{
|
| 5 |
+
id: '1',
|
| 6 |
+
content: 'Create a button component',
|
| 7 |
+
sender: 'user',
|
| 8 |
+
timestamp: '2024-11-16T13:00:00Z',
|
| 9 |
+
},
|
| 10 |
+
{
|
| 11 |
+
id: '2',
|
| 12 |
+
content: 'Here\'s a button component with hover effects:',
|
| 13 |
+
sender: 'assistant',
|
| 14 |
+
timestamp: '2024-11-16T13:01:00Z',
|
| 15 |
+
hasPreview: true,
|
| 16 |
+
preview: `
|
| 17 |
+
<button class="px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600 transition-colors">
|
| 18 |
+
Click me
|
| 19 |
+
</button>
|
| 20 |
+
`,
|
| 21 |
+
code: {
|
| 22 |
+
content: `
|
| 23 |
+
import React from 'react'
|
| 24 |
+
import { Button } from '@/components/ui/button'
|
| 25 |
+
|
| 26 |
+
export default function CustomButton() {
|
| 27 |
+
return (
|
| 28 |
+
<Button className="hover:bg-blue-600 transition-colors">
|
| 29 |
+
Click me
|
| 30 |
+
</Button>
|
| 31 |
+
)
|
| 32 |
+
}`,
|
| 33 |
+
language: 'typescript',
|
| 34 |
+
version: 'v1'
|
| 35 |
+
}
|
| 36 |
+
},
|
| 37 |
+
{
|
| 38 |
+
id: '3',
|
| 39 |
+
content: 'Here\'s my design file',
|
| 40 |
+
sender: 'user',
|
| 41 |
+
timestamp: '2024-11-16T13:02:00Z',
|
| 42 |
+
files: [
|
| 43 |
+
{
|
| 44 |
+
id: 'file1',
|
| 45 |
+
name: 'design.fig',
|
| 46 |
+
type: 'application/figma',
|
| 47 |
+
url: '/files/design.fig',
|
| 48 |
+
size: 1024000
|
| 49 |
+
}
|
| 50 |
+
]
|
| 51 |
+
}
|
| 52 |
+
]
|
| 53 |
+
|
| 54 |
+
export function mockFetchChatHistory(): Promise<ChatMessage[]> {
|
| 55 |
+
return new Promise((resolve) => {
|
| 56 |
+
setTimeout(() => resolve(dummyChatHistory), 500)
|
| 57 |
+
})
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
export function mockSendMessage(content: string, files?: File[]): Promise<ChatMessage> {
|
| 61 |
+
return new Promise((resolve) => {
|
| 62 |
+
setTimeout(() => {
|
| 63 |
+
resolve({
|
| 64 |
+
id: Date.now().toString(),
|
| 65 |
+
content: `Response to: "${content}"${files ? ` with ${files.length} files` : ''}`,
|
| 66 |
+
sender: 'assistant',
|
| 67 |
+
timestamp: new Date().toISOString(),
|
| 68 |
+
hasPreview: true,
|
| 69 |
+
preview: '<div>Preview content</div>',
|
| 70 |
+
code: {
|
| 71 |
+
content: '// Code content',
|
| 72 |
+
language: 'typescript',
|
| 73 |
+
version: 'v1'
|
| 74 |
+
}
|
| 75 |
+
})
|
| 76 |
+
}, 1000)
|
| 77 |
+
})
|
| 78 |
+
}
|
src/components/types.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export interface ChatMessage {
|
| 2 |
+
id: string
|
| 3 |
+
content: string
|
| 4 |
+
sender: 'user' | 'assistant'
|
| 5 |
+
timestamp: string
|
| 6 |
+
files?: FileAttachment[]
|
| 7 |
+
preview?: string
|
| 8 |
+
code?: {
|
| 9 |
+
content: string
|
| 10 |
+
language: string
|
| 11 |
+
version?: string
|
| 12 |
+
}
|
| 13 |
+
hasPreview?: boolean
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
export interface FileAttachment {
|
| 17 |
+
id: string
|
| 18 |
+
name: string
|
| 19 |
+
type: string
|
| 20 |
+
url: string
|
| 21 |
+
size: number
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
export interface PreviewState {
|
| 25 |
+
isFullscreen: boolean
|
| 26 |
+
isOpen: boolean
|
| 27 |
+
}
|
src/components/ui/button.tsx
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as React from "react"
|
| 2 |
+
import { Slot } from "@radix-ui/react-slot"
|
| 3 |
+
import { cva, type VariantProps } from "class-variance-authority"
|
| 4 |
+
|
| 5 |
+
import { cn } from "@/lib/utils"
|
| 6 |
+
|
| 7 |
+
const buttonVariants = cva(
|
| 8 |
+
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
|
| 9 |
+
{
|
| 10 |
+
variants: {
|
| 11 |
+
variant: {
|
| 12 |
+
default: "bg-primary text-primary-foreground hover:bg-primary/90",
|
| 13 |
+
destructive:
|
| 14 |
+
"bg-destructive text-destructive-foreground hover:bg-destructive/90",
|
| 15 |
+
outline:
|
| 16 |
+
"border border-input bg-background hover:bg-accent hover:text-accent-foreground",
|
| 17 |
+
secondary:
|
| 18 |
+
"bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
| 19 |
+
ghost: "hover:bg-accent hover:text-accent-foreground",
|
| 20 |
+
link: "text-primary underline-offset-4 hover:underline",
|
| 21 |
+
},
|
| 22 |
+
size: {
|
| 23 |
+
default: "h-10 px-4 py-2",
|
| 24 |
+
sm: "h-9 rounded-md px-3",
|
| 25 |
+
lg: "h-11 rounded-md px-8",
|
| 26 |
+
icon: "h-10 w-10",
|
| 27 |
+
},
|
| 28 |
+
},
|
| 29 |
+
defaultVariants: {
|
| 30 |
+
variant: "default",
|
| 31 |
+
size: "default",
|
| 32 |
+
},
|
| 33 |
+
}
|
| 34 |
+
)
|
| 35 |
+
|
| 36 |
+
export interface ButtonProps
|
| 37 |
+
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
|
| 38 |
+
VariantProps<typeof buttonVariants> {
|
| 39 |
+
asChild?: boolean
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
| 43 |
+
({ className, variant, size, asChild = false, ...props }, ref) => {
|
| 44 |
+
const Comp = asChild ? Slot : "button"
|
| 45 |
+
return (
|
| 46 |
+
<Comp
|
| 47 |
+
className={cn(buttonVariants({ variant, size, className }))}
|
| 48 |
+
ref={ref}
|
| 49 |
+
{...props}
|
| 50 |
+
/>
|
| 51 |
+
)
|
| 52 |
+
}
|
| 53 |
+
)
|
| 54 |
+
Button.displayName = "Button"
|
| 55 |
+
|
| 56 |
+
export { Button, buttonVariants }
|
src/components/ui/scroll-area.tsx
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use client"
|
| 2 |
+
|
| 3 |
+
import * as React from "react"
|
| 4 |
+
import * as ScrollAreaPrimitive from "@radix-ui/react-scroll-area"
|
| 5 |
+
|
| 6 |
+
import { cn } from "@/lib/utils"
|
| 7 |
+
|
| 8 |
+
const ScrollArea = React.forwardRef<
|
| 9 |
+
React.ElementRef<typeof ScrollAreaPrimitive.Root>,
|
| 10 |
+
React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.Root>
|
| 11 |
+
>(({ className, children, ...props }, ref) => (
|
| 12 |
+
<ScrollAreaPrimitive.Root
|
| 13 |
+
ref={ref}
|
| 14 |
+
className={cn("relative overflow-hidden", className)}
|
| 15 |
+
{...props}
|
| 16 |
+
>
|
| 17 |
+
<ScrollAreaPrimitive.Viewport className="h-full w-full rounded-[inherit]">
|
| 18 |
+
{children}
|
| 19 |
+
</ScrollAreaPrimitive.Viewport>
|
| 20 |
+
<ScrollBar />
|
| 21 |
+
<ScrollAreaPrimitive.Corner />
|
| 22 |
+
</ScrollAreaPrimitive.Root>
|
| 23 |
+
))
|
| 24 |
+
ScrollArea.displayName = ScrollAreaPrimitive.Root.displayName
|
| 25 |
+
|
| 26 |
+
const ScrollBar = React.forwardRef<
|
| 27 |
+
React.ElementRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>,
|
| 28 |
+
React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>
|
| 29 |
+
>(({ className, orientation = "vertical", ...props }, ref) => (
|
| 30 |
+
<ScrollAreaPrimitive.ScrollAreaScrollbar
|
| 31 |
+
ref={ref}
|
| 32 |
+
orientation={orientation}
|
| 33 |
+
className={cn(
|
| 34 |
+
"flex touch-none select-none transition-colors",
|
| 35 |
+
orientation === "vertical" &&
|
| 36 |
+
"h-full w-2.5 border-l border-l-transparent p-[1px]",
|
| 37 |
+
orientation === "horizontal" &&
|
| 38 |
+
"h-2.5 flex-col border-t border-t-transparent p-[1px]",
|
| 39 |
+
className
|
| 40 |
+
)}
|
| 41 |
+
{...props}
|
| 42 |
+
>
|
| 43 |
+
<ScrollAreaPrimitive.ScrollAreaThumb className="relative flex-1 rounded-full bg-border" />
|
| 44 |
+
</ScrollAreaPrimitive.ScrollAreaScrollbar>
|
| 45 |
+
))
|
| 46 |
+
ScrollBar.displayName = ScrollAreaPrimitive.ScrollAreaScrollbar.displayName
|
| 47 |
+
|
| 48 |
+
export { ScrollArea, ScrollBar }
|
src/components/ui/tabs.tsx
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use client"
|
| 2 |
+
|
| 3 |
+
import * as React from "react"
|
| 4 |
+
import * as TabsPrimitive from "@radix-ui/react-tabs"
|
| 5 |
+
|
| 6 |
+
import { cn } from "@/lib/utils"
|
| 7 |
+
|
| 8 |
+
const Tabs = TabsPrimitive.Root
|
| 9 |
+
|
| 10 |
+
const TabsList = React.forwardRef<
|
| 11 |
+
React.ElementRef<typeof TabsPrimitive.List>,
|
| 12 |
+
React.ComponentPropsWithoutRef<typeof TabsPrimitive.List>
|
| 13 |
+
>(({ className, ...props }, ref) => (
|
| 14 |
+
<TabsPrimitive.List
|
| 15 |
+
ref={ref}
|
| 16 |
+
className={cn(
|
| 17 |
+
"inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",
|
| 18 |
+
className
|
| 19 |
+
)}
|
| 20 |
+
{...props}
|
| 21 |
+
/>
|
| 22 |
+
))
|
| 23 |
+
TabsList.displayName = TabsPrimitive.List.displayName
|
| 24 |
+
|
| 25 |
+
const TabsTrigger = React.forwardRef<
|
| 26 |
+
React.ElementRef<typeof TabsPrimitive.Trigger>,
|
| 27 |
+
React.ComponentPropsWithoutRef<typeof TabsPrimitive.Trigger>
|
| 28 |
+
>(({ className, ...props }, ref) => (
|
| 29 |
+
<TabsPrimitive.Trigger
|
| 30 |
+
ref={ref}
|
| 31 |
+
className={cn(
|
| 32 |
+
"inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",
|
| 33 |
+
className
|
| 34 |
+
)}
|
| 35 |
+
{...props}
|
| 36 |
+
/>
|
| 37 |
+
))
|
| 38 |
+
TabsTrigger.displayName = TabsPrimitive.Trigger.displayName
|
| 39 |
+
|
| 40 |
+
const TabsContent = React.forwardRef<
|
| 41 |
+
React.ElementRef<typeof TabsPrimitive.Content>,
|
| 42 |
+
React.ComponentPropsWithoutRef<typeof TabsPrimitive.Content>
|
| 43 |
+
>(({ className, ...props }, ref) => (
|
| 44 |
+
<TabsPrimitive.Content
|
| 45 |
+
ref={ref}
|
| 46 |
+
className={cn(
|
| 47 |
+
"mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
|
| 48 |
+
className
|
| 49 |
+
)}
|
| 50 |
+
{...props}
|
| 51 |
+
/>
|
| 52 |
+
))
|
| 53 |
+
TabsContent.displayName = TabsPrimitive.Content.displayName
|
| 54 |
+
|
| 55 |
+
export { Tabs, TabsList, TabsTrigger, TabsContent }
|
src/components/ui/textarea.tsx
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as React from "react"
|
| 2 |
+
|
| 3 |
+
import { cn } from "@/lib/utils"
|
| 4 |
+
|
| 5 |
+
const Textarea = React.forwardRef<
|
| 6 |
+
HTMLTextAreaElement,
|
| 7 |
+
React.ComponentProps<"textarea">
|
| 8 |
+
>(({ className, ...props }, ref) => {
|
| 9 |
+
return (
|
| 10 |
+
<textarea
|
| 11 |
+
className={cn(
|
| 12 |
+
"flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
|
| 13 |
+
className
|
| 14 |
+
)}
|
| 15 |
+
ref={ref}
|
| 16 |
+
{...props}
|
| 17 |
+
/>
|
| 18 |
+
)
|
| 19 |
+
})
|
| 20 |
+
Textarea.displayName = "Textarea"
|
| 21 |
+
|
| 22 |
+
export { Textarea }
|
src/lib/utils.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { clsx, type ClassValue } from "clsx"
|
| 2 |
+
import { twMerge } from "tailwind-merge"
|
| 3 |
+
|
| 4 |
+
export function cn(...inputs: ClassValue[]) {
|
| 5 |
+
return twMerge(clsx(inputs))
|
| 6 |
+
}
|
tailwind.config.ts
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type { Config } from "tailwindcss";
|
| 2 |
+
|
| 3 |
+
export default {
|
| 4 |
+
darkMode: ["class"],
|
| 5 |
+
content: [
|
| 6 |
+
"./src/pages/**/*.{js,ts,jsx,tsx,mdx}",
|
| 7 |
+
"./src/components/**/*.{js,ts,jsx,tsx,mdx}",
|
| 8 |
+
"./src/app/**/*.{js,ts,jsx,tsx,mdx}",
|
| 9 |
+
],
|
| 10 |
+
theme: {
|
| 11 |
+
extend: {
|
| 12 |
+
colors: {
|
| 13 |
+
background: 'hsl(var(--background))',
|
| 14 |
+
foreground: 'hsl(var(--foreground))',
|
| 15 |
+
card: {
|
| 16 |
+
DEFAULT: 'hsl(var(--card))',
|
| 17 |
+
foreground: 'hsl(var(--card-foreground))'
|
| 18 |
+
},
|
| 19 |
+
popover: {
|
| 20 |
+
DEFAULT: 'hsl(var(--popover))',
|
| 21 |
+
foreground: 'hsl(var(--popover-foreground))'
|
| 22 |
+
},
|
| 23 |
+
primary: {
|
| 24 |
+
DEFAULT: 'hsl(var(--primary))',
|
| 25 |
+
foreground: 'hsl(var(--primary-foreground))'
|
| 26 |
+
},
|
| 27 |
+
secondary: {
|
| 28 |
+
DEFAULT: 'hsl(var(--secondary))',
|
| 29 |
+
foreground: 'hsl(var(--secondary-foreground))'
|
| 30 |
+
},
|
| 31 |
+
muted: {
|
| 32 |
+
DEFAULT: 'hsl(var(--muted))',
|
| 33 |
+
foreground: 'hsl(var(--muted-foreground))'
|
| 34 |
+
},
|
| 35 |
+
accent: {
|
| 36 |
+
DEFAULT: 'hsl(var(--accent))',
|
| 37 |
+
foreground: 'hsl(var(--accent-foreground))'
|
| 38 |
+
},
|
| 39 |
+
destructive: {
|
| 40 |
+
DEFAULT: 'hsl(var(--destructive))',
|
| 41 |
+
foreground: 'hsl(var(--destructive-foreground))'
|
| 42 |
+
},
|
| 43 |
+
border: 'hsl(var(--border))',
|
| 44 |
+
input: 'hsl(var(--input))',
|
| 45 |
+
ring: 'hsl(var(--ring))',
|
| 46 |
+
chart: {
|
| 47 |
+
'1': 'hsl(var(--chart-1))',
|
| 48 |
+
'2': 'hsl(var(--chart-2))',
|
| 49 |
+
'3': 'hsl(var(--chart-3))',
|
| 50 |
+
'4': 'hsl(var(--chart-4))',
|
| 51 |
+
'5': 'hsl(var(--chart-5))'
|
| 52 |
+
}
|
| 53 |
+
},
|
| 54 |
+
borderRadius: {
|
| 55 |
+
lg: 'var(--radius)',
|
| 56 |
+
md: 'calc(var(--radius) - 2px)',
|
| 57 |
+
sm: 'calc(var(--radius) - 4px)'
|
| 58 |
+
}
|
| 59 |
+
}
|
| 60 |
+
},
|
| 61 |
+
plugins: [
|
| 62 |
+
require("tailwindcss-animate"),
|
| 63 |
+
require('postcss-import'),
|
| 64 |
+
require('tailwindcss'),
|
| 65 |
+
require('autoprefixer'),
|
| 66 |
+
],
|
| 67 |
+
} satisfies Config;
|
tsconfig.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"compilerOptions": {
|
| 3 |
+
"target": "ES2017",
|
| 4 |
+
"lib": ["dom", "dom.iterable", "esnext"],
|
| 5 |
+
"allowJs": true,
|
| 6 |
+
"skipLibCheck": true,
|
| 7 |
+
"strict": true,
|
| 8 |
+
"noEmit": true,
|
| 9 |
+
"esModuleInterop": true,
|
| 10 |
+
"module": "esnext",
|
| 11 |
+
"moduleResolution": "bundler",
|
| 12 |
+
"resolveJsonModule": true,
|
| 13 |
+
"isolatedModules": true,
|
| 14 |
+
"jsx": "preserve",
|
| 15 |
+
"incremental": true,
|
| 16 |
+
"plugins": [
|
| 17 |
+
{
|
| 18 |
+
"name": "next"
|
| 19 |
+
}
|
| 20 |
+
],
|
| 21 |
+
"paths": {
|
| 22 |
+
"@/*": ["./src/*"]
|
| 23 |
+
}
|
| 24 |
+
},
|
| 25 |
+
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
|
| 26 |
+
"exclude": ["node_modules"]
|
| 27 |
+
}
|