From fed4aa58c9de71f5cd02449e482d38373c58277b Mon Sep 17 00:00:00 2001 From: Yash Date: Mon, 1 Apr 2024 02:19:54 +0000 Subject: add new page popover --- apps/web/src/app/globals.css | 6 +- apps/web/src/app/layout.tsx | 6 +- apps/web/src/app/ui/page.tsx | 2 +- apps/web/src/components/Sidebar.tsx | 145 -------------------- apps/web/src/components/Sidebar/ListItem.tsx | 189 +++++++++++++++++++++++++++ apps/web/src/components/Sidebar/index.tsx | 46 +++++++ apps/web/src/components/ui/drawer.tsx | 118 +++++++++++++++++ apps/web/src/components/ui/input.tsx | 18 +-- apps/web/src/components/ui/popover.tsx | 31 +++++ apps/web/src/components/ui/textarea.tsx | 24 ++++ apps/web/src/lib/utils.ts | 19 ++- 11 files changed, 444 insertions(+), 160 deletions(-) delete mode 100644 apps/web/src/components/Sidebar.tsx create mode 100644 apps/web/src/components/Sidebar/ListItem.tsx create mode 100644 apps/web/src/components/Sidebar/index.tsx create mode 100644 apps/web/src/components/ui/drawer.tsx create mode 100644 apps/web/src/components/ui/popover.tsx create mode 100644 apps/web/src/components/ui/textarea.tsx (limited to 'apps/web/src') diff --git a/apps/web/src/app/globals.css b/apps/web/src/app/globals.css index 394bda43..2bb3159a 100644 --- a/apps/web/src/app/globals.css +++ b/apps/web/src/app/globals.css @@ -20,7 +20,7 @@ } body { - @apply bg-rgray-1 text-rgray-11; + @apply bg-rgray-2 text-rgray-11; /* color: rgb(var(--foreground-rgb)); background: linear-gradient( to bottom, @@ -30,6 +30,10 @@ body { rgb(var(--background-start-rgb)); */ } +[vaul-drawer-wrapper] { + @apply bg-rgray-1; +} + @layer utilities { .text-balance { text-wrap: balance; diff --git a/apps/web/src/app/layout.tsx b/apps/web/src/app/layout.tsx index 5464c1d3..5b2ced94 100644 --- a/apps/web/src/app/layout.tsx +++ b/apps/web/src/app/layout.tsx @@ -16,7 +16,11 @@ export default function RootLayout({ }>) { return ( - {children} + +
+ {children} +
+ ); } diff --git a/apps/web/src/app/ui/page.tsx b/apps/web/src/app/ui/page.tsx index 2f7c6a4b..43cff341 100644 --- a/apps/web/src/app/ui/page.tsx +++ b/apps/web/src/app/ui/page.tsx @@ -1,4 +1,4 @@ -import Sidebar from "@/components/Sidebar"; +import Sidebar from "@/components/Sidebar/index"; export default async function Home() { return ( diff --git a/apps/web/src/components/Sidebar.tsx b/apps/web/src/components/Sidebar.tsx deleted file mode 100644 index 0644d779..00000000 --- a/apps/web/src/components/Sidebar.tsx +++ /dev/null @@ -1,145 +0,0 @@ -"use client"; -import { StoredContent } from "@/server/db/schema"; -import { - Plus, - MoreHorizontal, - ArrowUpRight, - Edit3, - Trash2, -} from "lucide-react"; -import { - DropdownMenu, - DropdownMenuContent, - DropdownMenuItem, - DropdownMenuTrigger, -} from "./ui/dropdown-menu"; - -import { useState, useEffect, useRef } from "react"; - -export default function Sidebar() { - const websties: StoredContent[] = [ - { - id: 1, - content: "", - title: "Visual Studio Code", - url: "https://code.visualstudio.com", - description: "", - image: "https://code.visualstudio.com/favicon.ico", - baseUrl: "https://code.visualstudio.com", - savedAt: new Date(), - }, - { - id: 1, - content: "", - title: "yxshv/vscode: An unofficial remake of vscode's landing page", - url: "https://github.com/yxshv/vscode", - description: "", - image: "https://github.com/favicon.ico", - baseUrl: "https://github.com", - savedAt: new Date(), - }, - ]; - - return ( - - ); -} - -export const ListItem: React.FC<{ item: StoredContent }> = ({ item }) => { - const [isEditing, setIsEditing] = useState(false); - const editInputRef = useRef(null); - - useEffect(() => { - if (isEditing) { - setTimeout(() => { - editInputRef.current?.focus(); - }, 500); - } - }, [isEditing]); - - return ( -
- isEditing && e.preventDefault()} - className="flex w-[90%] items-center gap-2 focus:outline-none" - > - {isEditing ? ( - - ) : ( - <> - {item.title - - - )} - {isEditing ? ( - setIsEditing(false)} - onKeyDown={(e) => e.key === "Escape" && setIsEditing(false)} - /> - ) : ( - - {item.title ?? "Untitled website"} - - )} - - - - - - - window.open(item.url)}> - - Open - - { - setIsEditing(true); - }} - > - - Edit - - - - Delete - - - -
- ); -}; diff --git a/apps/web/src/components/Sidebar/ListItem.tsx b/apps/web/src/components/Sidebar/ListItem.tsx new file mode 100644 index 00000000..e2648e4b --- /dev/null +++ b/apps/web/src/components/Sidebar/ListItem.tsx @@ -0,0 +1,189 @@ +"use client"; +import { cleanUrl } from "@/lib/utils"; +import { StoredContent } from "@/server/db/schema"; +import { + DropdownMenu, + DropdownMenuTrigger, + DropdownMenuContent, + DropdownMenuItem, +} from "../ui/dropdown-menu"; +import { Label } from "../ui/label"; +import { + ArrowUpRight, + MoreHorizontal, + Edit3, + Trash2, + Save, + ChevronRight, + Plus, +} from "lucide-react"; +import { useState } from "react"; +import { + Drawer, + DrawerContent, + DrawerHeader, + DrawerTitle, + DrawerDescription, + DrawerFooter, + DrawerClose, +} from "../ui/drawer"; +import { Input } from "../ui/input"; +import { Textarea } from "../ui/textarea"; +import { Popover, PopoverContent, PopoverTrigger } from "../ui/popover"; + +export const ListItem: React.FC<{ item: StoredContent }> = ({ item }) => { + const [isDropdownOpen, setIsDropdownOpen] = useState(false); + const [isEditDrawerOpen, setIsEditDrawerOpen] = useState(false); + + return ( +
+ +
+ {item.title + +
+ + + {item.title ?? "Untitled website"} + +
+ + + + + + window.open(item.url)}> + + Open + + { + setIsDropdownOpen(false); + setIsEditDrawerOpen(true); + }} + > + + Edit + + + + Delete + + + + + + + + Edit Page Details + + Change the page details + + + {cleanUrl(item.url)} + + + +
+ + +
+
+ +