Skip to content

Commit

Permalink
Merge pull request #4 from ubq-testing/ui-upgrade
Browse files Browse the repository at this point in the history
feat: ui upgrade
  • Loading branch information
Keyrxng authored Oct 14, 2023
2 parents 99dc6b8 + 9c87e85 commit db2cbc2
Show file tree
Hide file tree
Showing 9 changed files with 166 additions and 27 deletions.
10 changes: 10 additions & 0 deletions app/components/dialogue.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from "react";

export default function DialogueBox({ title, content }) {
return (
<div className="dialogue-box">
<h2>{title}</h2>
<p>{content}</p>
</div>
);
}
17 changes: 17 additions & 0 deletions app/components/navbar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import Link from "next/link";

export default function NavBar() {
return (
<div className="flex items-center p-4 justify-center text-center gap-14 ">
<Link className="text-2xl font-bold" href="/">
Chat
</Link>
<Link className="text-2xl font-bold" href="/docs">
Data
</Link>
<Link className="text-2xl font-bold" href="/data">
Docs
</Link>
</div>
);
}
16 changes: 10 additions & 6 deletions app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import './globals.css';
import { Inter } from 'next/font/google';
import NavBar from "./components/navbar";
import "./globals.css";
import { Inter } from "next/font/google";

const inter = Inter({ subsets: ['latin'] });
const inter = Inter({ subsets: ["latin"] });

export const metadata = {
title: 'Create Next App',
description: 'Generated by create next app',
title: "Create Next App",
description: "Generated by create next app",
};

export default function RootLayout({
Expand All @@ -15,7 +16,10 @@ export default function RootLayout({
}) {
return (
<html lang="en">
<body className={inter.className}>{children}</body>
<body className={inter.className}>
<NavBar />
{children}
</body>
</html>
);
}
42 changes: 22 additions & 20 deletions app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
'use client';
"use client";

import { useChat } from 'ai/react';
import { useChat } from "ai/react";

export default function Chat() {
export default function Dual() {
const { messages, input, handleInputChange, handleSubmit, data } = useChat();
return (
<div className="flex flex-col w-full max-w-md py-24 mx-auto stretch">
{messages.length > 0
? messages.map(m => (
<div key={m.id} className="whitespace-pre-wrap">
{m.role === 'user' ? 'User: ' : 'AI: '}
{m.content}
</div>
))
: null}
<div className="flex">
<div className="flex flex-col w-full max-w-md py-24 mx-auto stretch">
{messages.length > 0
? messages.map((m) => (
<div key={m.id} className="whitespace-pre-wrap">
{m.role === "user" ? "User: " : "AI: "}
{m.content}
</div>
))
: null}

<form onSubmit={handleSubmit}>
<input
className="fixed bottom-0 w-full max-w-md p-2 mb-8 border border-gray-300 rounded shadow-xl"
value={input}
placeholder="Say something..."
onChange={handleInputChange}
/>
</form>
<form onSubmit={handleSubmit}>
<input
className="fixed bottom-0 w-full max-w-md p-2 mb-8 border border-gray-300 rounded shadow-xl"
value={input}
placeholder="Say something..."
onChange={handleInputChange}
/>
</form>
</div>
</div>
);
}
19 changes: 19 additions & 0 deletions app/tri-display/@data/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import DialogueBox from "@/app/components/dialogue";
import React from "react";

const content = `
This is just an example dialogue box that wil be used later.
`;

export default function DataPage() {
return (
<div>
<h1>Data Page</h1>
<p>This is the Data page content.</p>

<DialogueBox title="Dialogue Box 1" content={content} />

<DialogueBox title="Dialogue Box 2" content={content} />
</div>
);
}
38 changes: 38 additions & 0 deletions app/tri-display/@docs/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
"use client";
import React, { useEffect, useState } from "react";
import ReactMarkdown from "react-markdown";

const demoDoc = `
# Docs Page
[Google](www.google.com)
- list 1
- list 2
- list 3
\`\` quote \`\`
\`\`\`javascript
function example() {
return 'Hello, Markdown!';
}
\`\`\`
`;

export default function DocsPage() {
const [markdown, setMarkdown] = useState("");

useEffect(() => {
setMarkdown(demoDoc);
}, []);

return (
<div>
<h1>Docs Page</h1>
<div className="markdown-content">
<ReactMarkdown children={markdown} />
</div>
</div>
);
}
18 changes: 18 additions & 0 deletions app/tri-display/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export const metadata = {
title: "Create Next App",
description: "Generated by create next app",
};

export default function DualLayout(props: {
children: React.ReactNode;
data: React.ReactNode;
docs: React.ReactNode;
}) {
return (
<div className="grid grid-cols-3 shrink">
{props.data}
{props.children}
{props.docs}
</div>
);
}
30 changes: 30 additions & 0 deletions app/tri-display/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"use client";

import { useChat } from "ai/react";

export default function Dual() {
const { messages, input, handleInputChange, handleSubmit, data } = useChat();
return (
<div className="flex">
<div className="flex flex-col w-full max-w-md py-24 mx-auto stretch">
{messages.length > 0
? messages.map((m) => (
<div key={m.id} className="whitespace-pre-wrap">
{m.role === "user" ? "User: " : "AI: "}
{m.content}
</div>
))
: null}

<form onSubmit={handleSubmit}>
<input
className="fixed bottom-0 w-full max-w-md p-2 mb-8 border border-gray-300 rounded shadow-xl"
value={input}
placeholder="Say something..."
onChange={handleInputChange}
/>
</form>
</div>
</div>
);
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"next": "13.4.12",
"openai": "4.11.0",
"react": "18.2.0",
"react-dom": "^18.2.0"
"react-dom": "^18.2.0",
"react-markdown": "^9.0.0"
},
"devDependencies": {
"@types/node": "^17.0.12",
Expand Down

0 comments on commit db2cbc2

Please sign in to comment.