Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update styles #192

Merged
merged 8 commits into from
Sep 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added ui/assets/PersonaFlowIcon-512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion ui/src/app/[[...slug]]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default function ConversationPage({
if (!isValidParam(params.slug)) return notFound();

return (
<div className="border-solid border-2 w-full gap-4 flex flex-col">
<div className="border-solid border-2 w-full gap-4 flex flex-col rounded">
<ChatPanel />
</div>
);
Expand Down
Binary file added ui/src/app/icon.ico
Binary file not shown.
3 changes: 3 additions & 0 deletions ui/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ const inter = Inter({ subsets: ["latin"] });
export const metadata: Metadata = {
title: "PersonaFlow",
description: "Where AI meets individuality for unmatched personalization",
icons: {
icon: '/icon.ico'
}
};

export default function RootLayout({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ test("should render", () => {

render(<AssistentBuilder />);

screen.getByRole("button", { name: "Create Assistant" });
expect(screen.getByText("EditAssistant")).toBeInTheDocument();
expect(screen.queryByText("CreateAssistant")).toBeNull();
});
Original file line number Diff line number Diff line change
@@ -1,29 +1,14 @@
"use client";

import { AssistantSelector } from "./assistant-selector";
import { Button } from "@/components/ui/button";
import { SquareIcon } from "@radix-ui/react-icons";
import { EditAssistant } from "./edit-assistant";
import { CreateAssistant } from "./create-assistant";
import { useRouter } from "next/navigation";
import { useSlugRoutes } from "@/hooks/useSlugParams";

export function AssistentBuilder() {
const {assistantId} = useSlugRoutes();
const router = useRouter()

return (
<>
<div className="flex gap-3">
<AssistantSelector />
<Button
className="flex gap-2"
onClick={() => router.push('/')}
>
<SquareIcon />
Create Assistant
</Button>
</div>
{assistantId ? <EditAssistant /> : <CreateAssistant />}
</>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default function BuildPanel() {
};

return (
<div className="flex items-center border-solid border-2">
<div className="flex items-center border-solid border-2 rounded">
<div className=" p-1">
{isOpen ? (
<ChevronRight
Expand Down
6 changes: 5 additions & 1 deletion ui/src/components/features/chat-panel/chat-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { useEffect, useState } from "react";
import { MessageType, TStreamState } from "@/data-provider/types";
import { useSlugRoutes } from "@/hooks/useSlugParams";
import { useRouter } from "next/navigation";
import { ThreadBtn } from "./components/thread-btn";

export default function ChatPanel() {
const [userMessage, setUserMessage] = useState("");
Expand Down Expand Up @@ -51,13 +52,16 @@ export default function ChatPanel() {
return (
<div className="h-full w-full gap-4 flex flex-col">
<div className="h-full flex flex-col">
<ThreadBtn />
{threadId || isNewThread ? (
<MessagesContainer
threadId={threadId as string}
stream={stream as TStreamState}
/>
) : (
<h1>Welcome!</h1>
<div className="self-center h-full items-center flex">
<h1 className="border-2 p-4 rounded">{'<> Send a message to create a thread. </>'}</h1>
</div>
)}

<Composer
Expand Down
11 changes: 11 additions & 0 deletions ui/src/components/features/chat-panel/components/thread-btn.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Button } from "@/components/ui/button"
import { threadAtom } from "@/store"
import { useAtom } from "jotai"

export const ThreadBtn = () => {
const [_, setIsNavbarOpen] = useAtom(threadAtom)

const openNavbar = () => setIsNavbarOpen(isOpen => !isOpen);

return <Button variant="outline" className="w-1/4 m-2" onClick={openNavbar}>Threads</Button>
}
26 changes: 24 additions & 2 deletions ui/src/components/features/header/components/header.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,29 @@
'use client'
import { Button } from "@/components/ui/button";
import { AssistantSelector } from "../../build-panel/components/assistant-selector";
import { useRouter } from "next/navigation";
import { Plus } from "lucide-react";
import PersonaFlowIcon from '../../../../../assets/PersonaFlowIcon-512.png'
import Image from "next/image";

export default function Header() {
const router = useRouter()
return (
<div className="flex gap-2">
<h1>[ personaflow ]</h1>
<div className="flex gap-2 m-2 justify-between">
<div className="flex gap-4 items-center">
<Image className="rounded" src={PersonaFlowIcon} alt="PersonaFlow logo" width={40} height={40}/>
<h1>[ personaflow ]</h1>
</div>
<div className="flex gap-2">
<AssistantSelector />
<Button
className="flex gap-2"
onClick={() => router.push('/')}
>
<Plus />
Create Assistant
</Button>
</div>
</div>
);
}
25 changes: 8 additions & 17 deletions ui/src/components/features/navbar/components/navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@ import { TGroupedThreads } from "@/data-provider/types";
import { useSlugRoutes } from "@/hooks/useSlugParams";
import NewThreadBtn from "./new-thread-btn";
import { useRouter } from "next/navigation";
import { useAtom } from "jotai";
import { threadAtom } from "@/store";

export default function Navbar() {
const { data: threadsData, isLoading: threadsLoading } =
useGetMyThreads(true);

const [filteredThreads, setFilteredThreads] = useState(threadsData || {});
const [open, setOpen] = useState(false);
const [isNavbarOpen] = useAtom(threadAtom);
// const [open, setOpen] = useState(false);

const router = useRouter()

Expand Down Expand Up @@ -48,21 +51,19 @@ export default function Navbar() {
};

return (
<div className="flex h-full border-2">
{/* Container */}
<div
className={cn("flex flex-col m-3", open ? "w-72" : "w-0 collapse m-0")}
className={cn(isNavbarOpen ? "flex h-full border-2 flex-col items-center gap-y-2 p-4" : "w-0 collapse")}
>
{!threadsLoading && <NewThreadBtn handleClick={onNewThreadClick} disabled={!threadId} />}
{!threadsLoading && Object.values(filteredThreads).every((value) => value.length === 0) && (
<div className="border border-2 flex flex-col items-center justify-center">
<div className="flex flex-col items-center justify-center w-64">
<h1>No threads found.</h1>
</div>
)}
<nav className="overflow-y-auto">
{/* Threads loading */}
{threadsLoading ? (
<div className="flex flex-col items-center justify-center h-full">
<div className="flex flex-col items-center justify-center h-full w-64">
<Spinner />
<p className="mt-3">Loading threads... </p>
</div>
Expand All @@ -71,7 +72,7 @@ export default function Navbar() {
// @ts-ignore
if (threads && threads.length > 0) {
return (
<div key={groupName}>
<div key={groupName} className="w-64">
<h2 className="m-3 text-gray-400">{groupName}</h2>
{/* @ts-ignore */}
{threads?.map((thread) => (
Expand All @@ -85,15 +86,5 @@ export default function Navbar() {
)}
</nav>
</div>

{/* Toggle Sidebar */}
<div className="self-center hover:cursor-pointer p-1">
{open ? (
<ChevronLeft onClick={() => setOpen(false)} color="#000" />
) : (
<ChevronRight onClick={() => setOpen(true)} color="#000" />
)}
</div>
</div>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ type TNewThreadBtnProps = {

export default function NewThreadBtn({ handleClick, disabled }: TNewThreadBtnProps) {
return (
<Button onClick={handleClick} className="p-6 w-[calc(100%-20px)] mb-4" disabled={disabled}>
<Button onClick={handleClick} className="p-6 w-[calc(100%-20px)]" disabled={disabled}>
<a className="flex gap-x-2 items-center">
<PlusSquareIcon />
<span>New thread</span>
Expand Down
3 changes: 2 additions & 1 deletion ui/src/store.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { atom } from 'jotai'
import { TMessage } from './data-provider/types'

export const messagesAtom = atom<TMessage[]>([]);
export const messagesAtom = atom<TMessage[]>([]);
export const threadAtom = atom<boolean>(false);
Loading