diff --git a/apps/web/src/app/page.tsx b/apps/web/src/app/page.tsx index c25de8c7..221ce2b4 100644 --- a/apps/web/src/app/page.tsx +++ b/apps/web/src/app/page.tsx @@ -61,13 +61,9 @@ export default async function Home() { .where(eq(storedContent.user, userData.id)) .all(); - console.log(contents); - const collectedSpaces = contents.length > 0 ? await transformContent(contents) : []; - console.log('collected', collectedSpaces); - return (
diff --git a/apps/web/src/app/ui/content.tsx b/apps/web/src/app/ui/content.tsx new file mode 100644 index 00000000..8bfebcb9 --- /dev/null +++ b/apps/web/src/app/ui/content.tsx @@ -0,0 +1,15 @@ +"use client"; +import Main from "@/components/Main"; +import Sidebar from "@/components/Sidebar/index"; +import { useState } from "react"; + +export default function Content() { + const [selectedItem, setSelectedItem] = useState(null); + + return ( +
+ +
+
+ ); +} diff --git a/apps/web/src/app/ui/page.tsx b/apps/web/src/app/ui/page.tsx index b19aa4e0..35175334 100644 --- a/apps/web/src/app/ui/page.tsx +++ b/apps/web/src/app/ui/page.tsx @@ -1,18 +1,10 @@ -import Main from '@/components/Main'; -import Sidebar from '@/components/Sidebar/index'; -import { cookies } from 'next/headers'; +import { MemoryProvider } from "@/contexts/MemoryContext"; +import Content from "./content"; export default function Home() { - const selectedItem = cookies().get('selectedItem')?.value; - const setSelectedItem = async (selectedItem: string | null) => { - 'use server'; - cookies().set('selectedItem', selectedItem!); - }; - return ( -
- {/* */} -
-
+ + + ); } diff --git a/apps/web/src/components/Main.tsx b/apps/web/src/components/Main.tsx index dcbd3612..e9a7071d 100644 --- a/apps/web/src/components/Main.tsx +++ b/apps/web/src/components/Main.tsx @@ -1,34 +1,32 @@ -'use client'; -import { useEffect, useRef, useState } from 'react'; -import { FilterCombobox } from './Sidebar/FilterCombobox'; -import { Textarea2 } from './ui/textarea'; -import { ArrowRight } from 'lucide-react'; -import { MemoryDrawer } from './MemoryDrawer'; -import useViewport from '@/hooks/useViewport'; -import { motion } from 'framer-motion'; -import { cn } from '@/lib/utils'; +"use client"; +import { useEffect, useRef, useState } from "react"; +import { FilterCombobox } from "./Sidebar/FilterCombobox"; +import { Textarea2 } from "./ui/textarea"; +import { ArrowRight } from "lucide-react"; +import { MemoryDrawer } from "./MemoryDrawer"; +import useViewport from "@/hooks/useViewport"; +import { motion } from "framer-motion"; +import { cn } from "@/lib/utils"; + +function supportsDVH() { + try { + return CSS.supports("height: 100dvh"); + } catch { + return false; + } +} export default function Main({ sidebarOpen }: { sidebarOpen: boolean }) { const [hide, setHide] = useState(false); - const [value, setValue] = useState(''); + const [value, setValue] = useState(""); const { width } = useViewport(); const textArea = useRef(null); const main = useRef(null); - console.log('main px', sidebarOpen); - useEffect(() => { function onResize() { if (!main.current || !window.visualViewport) return; - // setValue( - // (prev) => - // prev + - // " changed to " + - // window.visualViewport?.height + - // " " + - // window.innerHeight, - // ); if ( window.visualViewport.height < window.innerHeight + 20 && window.visualViewport.height > window.innerHeight - 20 @@ -41,9 +39,9 @@ export default function Main({ sidebarOpen }: { sidebarOpen: boolean }) { } } - window.visualViewport?.addEventListener('resize', onResize); + window.visualViewport?.addEventListener("resize", onResize); return () => { - window.visualViewport?.removeEventListener('resize', onResize); + window.visualViewport?.removeEventListener("resize", onResize); }; }, []); @@ -52,24 +50,20 @@ export default function Main({ sidebarOpen }: { sidebarOpen: boolean }) { data-sidebar-open={sidebarOpen} ref={main} className={cn( - "sidebar flex w-full flex-col items-end justify-center gap-5 px-5 pt-5 transition-[padding-left,padding-top,padding-right] delay-200 duration-200 md:items-center md:px-72 [&[data-sidebar-open='true']]:pr-10 [&[data-sidebar-open='true']]:delay-0 md:[&[data-sidebar-open='true']]:pl-[calc(2.5rem+30vw)]", - hide - ? 'pb-5' - : CSS.supports('height: 100dvh') - ? 'pb-[13vh]' - : 'pb-[20vh]', + "sidebar flex w-full flex-col items-end justify-center gap-5 px-5 pt-5 transition-[padding-left,padding-top,padding-right] delay-200 duration-200 md:items-center md:gap-10 md:px-72 [&[data-sidebar-open='true']]:pr-10 [&[data-sidebar-open='true']]:delay-0 md:[&[data-sidebar-open='true']]:pl-[calc(2.5rem+30vw)]", + hide ? "pb-5" : supportsDVH() ? "pb-[13vh]" : "pb-[20vh]", )} > -

+

Ask your Second brain

setValue(e.target.value), diff --git a/apps/web/src/components/Sidebar/FilterCombobox.tsx b/apps/web/src/components/Sidebar/FilterCombobox.tsx index d22e8d8c..ae433c95 100644 --- a/apps/web/src/components/Sidebar/FilterCombobox.tsx +++ b/apps/web/src/components/Sidebar/FilterCombobox.tsx @@ -20,141 +20,17 @@ import { } from "@/components/ui/popover"; import { SpaceIcon } from "@/assets/Memories"; import { AnimatePresence, LayoutGroup, motion } from "framer-motion"; - -const spaces = [ - { - value: "1", - label: "Cool Tech", - }, - { - value: "2", - label: "Cool Courses", - }, - { - value: "3", - label: "Cool Libraries", - }, - { - value: "4", - label: "Cool People", - }, - { - value: "5", - label: "Cool Projects", - }, - { - value: "6", - label: "Cool Tools", - }, - { - value: "7", - label: "Cool Websites", - }, - { - value: "8", - label: "Cool Books", - }, - { - value: "9", - label: "Cool Videos", - }, - { - value: "10", - label: "Cool Podcasts", - }, - { - value: "11", - label: "Cool Articles", - }, - { - value: "12", - label: "Cool Blogs", - }, - { - value: "13", - label: "Cool News", - }, - { - value: "14", - label: "Cool Forums", - }, - { - value: "15", - label: "Cool Communities", - }, - { - value: "16", - label: "Cool Events", - }, - { - value: "17", - label: "Cool Jobs", - }, - { - value: "18", - label: "Cool Companies", - }, - { - value: "19", - label: "Cool Startups", - }, - { - value: "20", - label: "Cool Investors", - }, - { - value: "21", - label: "Cool Funds", - }, - { - value: "22", - label: "Cool Incubators", - }, - { - value: "23", - label: "Cool Accelerators", - }, - { - value: "24", - label: "Cool Hackathons", - }, - { - value: "25", - label: "Cool Conferences", - }, - { - value: "26", - label: "Cool Workshops", - }, - { - value: "27", - label: "Cool Seminars", - }, - { - value: "28", - label: "Cool Webinars", - }, - { - value: "29", - label: "Cool Courses", - }, - { - value: "30", - label: "Cool Bootcamps", - }, - { - value: "31", - label: "Cool Certifications", - }, -]; +import { useMemory } from "@/contexts/MemoryContext"; export interface Props extends React.ButtonHTMLAttributes {} export function FilterCombobox({ className, ...props }: Props) { - const [open, setOpen] = React.useState(false); - const [values, setValues] = React.useState([]); + const { spaces, addSpace } = useMemory(); - const sortedSpaces = spaces.sort(({ value: a }, { value: b }) => + const [open, setOpen] = React.useState(false); + const [values, setValues] = React.useState([]); + + const sortedSpaces = spaces.sort(({ id: a }, { id: b }) => values.includes(a) && !values.includes(b) ? -1 : values.includes(b) && !values.includes(a) @@ -192,8 +68,8 @@ export function FilterCombobox({ className, ...props }: Props) { spaces - .find((s) => s.value === val) - ?.label.toLowerCase() + .find((s) => s.id.toString() === val) + ?.title.toLowerCase() .includes(search.toLowerCase().trim()) ? 1 : 0 @@ -206,13 +82,13 @@ export function FilterCombobox({ className, ...props }: Props) { {sortedSpaces.map((space) => ( { setValues((prev) => - prev.includes(val) - ? prev.filter((v) => v !== val) - : [...prev, val], + prev.includes(parseInt(val)) + ? prev.filter((v) => v !== parseInt(val)) + : [...prev, parseInt(val)], ); }} asChild @@ -222,14 +98,14 @@ export function FilterCombobox({ className, ...props }: Props) { animate={{ opacity: 1, transition: { delay: 0.05 } }} transition={{ duration: 0.15 }} layout - layoutId={`space-combobox-${space.value}`} + layoutId={`space-combobox-${space.id}`} className="text-rgray-11" > - {space.label} - {values.includes(space.value)} + {space.title} + {values.includes(space.id)}
@@ -67,8 +57,8 @@ export function MemoriesBar({ spaces }: { spaces: CollectedSpaces[] }) { const SpaceExitVariant: Variant = { opacity: 0, scale: 0, - borderRadius: '50%', - background: 'var(--gray-1)', + borderRadius: "50%", + background: "var(--gray-1)", transition: { duration: 0.2, }, @@ -93,22 +83,22 @@ export function SpaceItem({ { if (!itemRef.current) return; - const trash = document.querySelector('#trash')! as HTMLDivElement; - const trashBin = document.querySelector('#trash-button')!; + const trash = document.querySelector("#trash")! as HTMLDivElement; + const trashBin = document.querySelector("#trash-button")!; const trashRect = trashBin.getBoundingClientRect(); const scopeRect = itemRef.current.getBoundingClientRect(); - const el = document.createElement('div'); - el.style.position = 'fixed'; - el.style.top = '0'; - el.style.left = '0'; - el.style.width = '15px'; - el.style.height = '15px'; - el.style.backgroundColor = 'var(--gray-7)'; - el.style.zIndex = '60'; - el.style.borderRadius = '50%'; - el.style.transform = 'scale(5)'; - el.style.opacity = '0'; - trash.dataset['open'] = 'true'; + const el = document.createElement("div"); + el.style.position = "fixed"; + el.style.top = "0"; + el.style.left = "0"; + el.style.width = "15px"; + el.style.height = "15px"; + el.style.backgroundColor = "var(--gray-7)"; + el.style.zIndex = "60"; + el.style.borderRadius = "50%"; + el.style.transform = "scale(5)"; + el.style.opacity = "0"; + trash.dataset["open"] = "true"; const initial = { x: scopeRect.left + scopeRect.width / 2, y: scopeRect.top + scopeRect.height / 2, @@ -133,35 +123,35 @@ export function SpaceItem({ animateItem(itemRef.current, SpaceExitVariant, { duration: 0.2, }).then(() => { - itemRef.current.style.scale = '0'; + itemRef.current.style.scale = "0"; onDelete(); }); document.body.appendChild(el); el.animate( { - transform: ['scale(5)', 'scale(1)'], + transform: ["scale(5)", "scale(1)"], opacity: [0, 0.3, 1], }, { duration: 200, - easing: 'cubic-bezier(0.64, 0.57, 0.67, 1.53)', - fill: 'forwards', + easing: "cubic-bezier(0.64, 0.57, 0.67, 1.53)", + fill: "forwards", }, ); el.animate( { - offsetDistance: ['0%', '100%'], + offsetDistance: ["0%", "100%"], }, { duration: 2000, - easing: 'cubic-bezier(0.64, 0.57, 0.67, 1.53)', - fill: 'forwards', + easing: "cubic-bezier(0.64, 0.57, 0.67, 1.53)", + fill: "forwards", delay: 200, }, ).onfinish = () => { el.animate( - { transform: 'scale(0)', opacity: 0 }, - { duration: 200, fill: 'forwards' }, + { transform: "scale(0)", opacity: 0 }, + { duration: 200, fill: "forwards" }, ).onfinish = () => { el.remove(); }; diff --git a/apps/web/src/components/Sidebar/PagesItem.tsx b/apps/web/src/components/Sidebar/PagesItem.tsx deleted file mode 100644 index fea8bf33..00000000 --- a/apps/web/src/components/Sidebar/PagesItem.tsx +++ /dev/null @@ -1,189 +0,0 @@ -"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 PageItem: 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)} - - - -
- - -
-
- -