From 5fe0caabf8e650aa221ef0faccf4520b0e1cbee2 Mon Sep 17 00:00:00 2001 From: Dhravya Date: Sun, 2 Jun 2024 12:12:38 -0500 Subject: improvements in dash + chatUI --- apps/web/app/(dash)/chat/actions.ts | 1 + apps/web/app/(dash)/chat/chatWindow.tsx | 60 ++++++++++++++++++++ apps/web/app/(dash)/chat/page.tsx | 14 +++++ apps/web/app/(dash)/header.tsx | 34 ++++++++++++ apps/web/app/(dash)/home/page.tsx | 27 +++++++++ apps/web/app/(dash)/home/queryinput.tsx | 98 +++++++++++++++++++++++++++++++++ apps/web/app/(dash)/layout.tsx | 17 ++++++ apps/web/app/(dash)/menu.tsx | 49 +++++++++++++++++ 8 files changed, 300 insertions(+) create mode 100644 apps/web/app/(dash)/chat/actions.ts create mode 100644 apps/web/app/(dash)/chat/chatWindow.tsx create mode 100644 apps/web/app/(dash)/chat/page.tsx create mode 100644 apps/web/app/(dash)/header.tsx create mode 100644 apps/web/app/(dash)/home/page.tsx create mode 100644 apps/web/app/(dash)/home/queryinput.tsx create mode 100644 apps/web/app/(dash)/layout.tsx create mode 100644 apps/web/app/(dash)/menu.tsx (limited to 'apps/web/app/(dash)') diff --git a/apps/web/app/(dash)/chat/actions.ts b/apps/web/app/(dash)/chat/actions.ts new file mode 100644 index 00000000..908fe79e --- /dev/null +++ b/apps/web/app/(dash)/chat/actions.ts @@ -0,0 +1 @@ +"use server"; diff --git a/apps/web/app/(dash)/chat/chatWindow.tsx b/apps/web/app/(dash)/chat/chatWindow.tsx new file mode 100644 index 00000000..8361bbf8 --- /dev/null +++ b/apps/web/app/(dash)/chat/chatWindow.tsx @@ -0,0 +1,60 @@ +"use client"; + +import { AnimatePresence } from "framer-motion"; +import React, { useEffect, useState } from "react"; +import QueryInput from "../home/queryinput"; +import { cn } from "@repo/ui/lib/utils"; +import { motion } from "framer-motion"; +import { useRouter } from "next/navigation"; + +function ChatWindow({ q, spaces }: { q: string; spaces: number[] }) { + const [layout, setLayout] = useState<"chat" | "initial">("initial"); + + const router = useRouter(); + + useEffect(() => { + if (q !== "") { + setTimeout(() => { + setLayout("chat"); + }, 300); + } else { + router.push("/home"); + } + }, [q]); + return ( +
+ + {layout === "initial" ? ( + +
+ +
+
+ ) : ( +
+

+ {q} +

+
+ )} +
+
+ ); +} + +export default ChatWindow; diff --git a/apps/web/app/(dash)/chat/page.tsx b/apps/web/app/(dash)/chat/page.tsx new file mode 100644 index 00000000..4ad4d468 --- /dev/null +++ b/apps/web/app/(dash)/chat/page.tsx @@ -0,0 +1,14 @@ +import { chatSearchParamsCache } from "../../helpers/lib/searchParams"; +import ChatWindow from "./chatWindow"; + +function Page({ + searchParams, +}: { + searchParams: Record; +}) { + const { firstTime, q, spaces } = chatSearchParamsCache.parse(searchParams); + + return ; +} + +export default Page; diff --git a/apps/web/app/(dash)/header.tsx b/apps/web/app/(dash)/header.tsx new file mode 100644 index 00000000..bcbe9691 --- /dev/null +++ b/apps/web/app/(dash)/header.tsx @@ -0,0 +1,34 @@ +import React from "react"; +import Image from "next/image"; +import Link from "next/link"; +import Logo from "../../public/logo.svg"; +import { AddIcon, ChatIcon } from "@repo/ui/icons"; + +function Header() { + return ( +
+
+ + SuperMemory logo + + +
+ +
+ + +
+
+ ); +} + +export default Header; diff --git a/apps/web/app/(dash)/home/page.tsx b/apps/web/app/(dash)/home/page.tsx new file mode 100644 index 00000000..a6624c1b --- /dev/null +++ b/apps/web/app/(dash)/home/page.tsx @@ -0,0 +1,27 @@ +import React from "react"; +import Menu from "../menu"; +import Header from "../header"; +import QueryInput from "./queryinput"; +import { homeSearchParamsCache } from "@/app/helpers/lib/searchParams"; + +function Page({ + searchParams, +}: { + searchParams: Record; +}) { + // TODO: use this to show a welcome page/modal + const { firstTime } = homeSearchParamsCache.parse(searchParams); + + return ( +
+ {/* all content goes here */} + {/*
hi {firstTime ? 'first time' : ''}
*/} + +
+ +
+
+ ); +} + +export default Page; diff --git a/apps/web/app/(dash)/home/queryinput.tsx b/apps/web/app/(dash)/home/queryinput.tsx new file mode 100644 index 00000000..904fcca6 --- /dev/null +++ b/apps/web/app/(dash)/home/queryinput.tsx @@ -0,0 +1,98 @@ +"use client"; + +import { ArrowRightIcon } from "@repo/ui/icons"; +import Image from "next/image"; +import React, { useState } from "react"; +import Divider from "@repo/ui/shadcn/divider"; +import { MultipleSelector, Option } from "@repo/ui/shadcn/combobox"; +import { useRouter } from "next/navigation"; + +const OPTIONS: Option[] = [ + { label: "nextjs", value: "0" }, + { label: "React", value: "1" }, + { label: "Remix", value: "2" }, + { label: "Vite", value: "3" }, + { label: "Nuxt", value: "4" }, + { label: "Vue", value: "5" }, + { label: "Svelte", value: "6" }, + { label: "Angular", value: "7" }, + { label: "Ember", value: "8" }, + { label: "Gatsby", value: "9" }, +]; + +function QueryInput({ + initialQuery = "", + initialSpaces = [], + disabled = false, +}: { + initialQuery?: string; + initialSpaces?: number[]; + disabled?: boolean; +}) { + const [q, setQ] = useState(initialQuery); + + const [selectedSpaces, setSelectedSpaces] = useState(initialSpaces); + + const { push } = useRouter(); + + const parseQ = () => { + const newQ = + "/chat?q=" + + encodeURI(q) + + (selectedSpaces ? "&spaces=" + selectedSpaces.join(",") : ""); + + return newQ; + }; + + return ( +
+
+ {/* input and action button */} +
push(parseQ())} className="flex gap-4 p-3"> +