From 3d334829a4f9c30b201b72a518239bab09c0bac2 Mon Sep 17 00:00:00 2001 From: Yash Date: Thu, 4 Apr 2024 16:45:12 +0000 Subject: [PATCH] improve phone ux --- apps/web/src/app/globals.css | 7 ++++ apps/web/src/components/Main.tsx | 45 +++++++++++++++++++----- apps/web/src/components/MemoryDrawer.tsx | 16 ++++++--- apps/web/src/lib/utils.ts | 1 + apps/web/tailwind.config.ts | 2 +- 5 files changed, 57 insertions(+), 14 deletions(-) diff --git a/apps/web/src/app/globals.css b/apps/web/src/app/globals.css index 7d8b7c4e..ea526495 100644 --- a/apps/web/src/app/globals.css +++ b/apps/web/src/app/globals.css @@ -39,3 +39,10 @@ body { text-wrap: balance; } } + +.sidebar { + height: 100vh; + height: 100dvh; + max-height: 100vh; + max-height: 100dvh; +} \ No newline at end of file diff --git a/apps/web/src/components/Main.tsx b/apps/web/src/components/Main.tsx index 8796c52e..aa72a48e 100644 --- a/apps/web/src/components/Main.tsx +++ b/apps/web/src/components/Main.tsx @@ -6,37 +6,66 @@ import { ArrowRight } from "lucide-react"; import { MemoryDrawer } from "./MemoryDrawer"; import useViewport from "@/hooks/useViewport"; import { motion } from "framer-motion"; +import { cn } from "@/lib/utils"; export default function Main({ sidebarOpen }: { sidebarOpen: boolean }) { + const [hide, setHide] = useState(false); const [value, setValue] = useState(""); const { width } = useViewport(); const textArea = useRef(null); + const main = useRef(null); console.log("main px", sidebarOpen); useEffect(() => { function onResize() { - if (!textArea.current || !window.visualViewport) return; - - const visualViewportHeight = window.visualViewport.height; + 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 + ) { + setHide(false); + window.scrollTo(0, 0); + } else { + setHide(true); + window.scrollTo(0, document.body.scrollHeight); + } } window.visualViewport?.addEventListener("resize", onResize); - return () => window.visualViewport?.removeEventListener("resize", onResize); + return () => { + window.visualViewport?.removeEventListener("resize", onResize); + }; }, []); return ( -

+

Ask your Second brain

- {width <= 768 && } + {width <= 768 && }
); } diff --git a/apps/web/src/components/MemoryDrawer.tsx b/apps/web/src/components/MemoryDrawer.tsx index f9d7d6c4..e4d2e5db 100644 --- a/apps/web/src/components/MemoryDrawer.tsx +++ b/apps/web/src/components/MemoryDrawer.tsx @@ -1,10 +1,13 @@ -import { useState } from "react"; +import { useRef, useState } from "react"; import { Drawer, DrawerContent, DrawerOverlay } from "./ui/drawer"; import { MemoryIcon } from "@/assets/Memories"; +import { cn } from "@/lib/utils"; -export interface Props extends React.ButtonHTMLAttributes {} +export interface Props extends React.ButtonHTMLAttributes { + hide?: boolean; +} -export function MemoryDrawer({ className, ...props }: Props) { +export function MemoryDrawer({ className, hide = false, ...props }: Props) { const [activeSnapPoint, setActiveSnapPoint] = useState< number | null | string >(0.1); @@ -21,10 +24,13 @@ export function MemoryDrawer({ className, ...props }: Props) { > -
+
Memories
diff --git a/apps/web/src/lib/utils.ts b/apps/web/src/lib/utils.ts index c6678e4b..665f0973 100644 --- a/apps/web/src/lib/utils.ts +++ b/apps/web/src/lib/utils.ts @@ -1,3 +1,4 @@ +"use client"; import { type ClassValue, clsx } from "clsx"; import { twMerge } from "tailwind-merge"; diff --git a/apps/web/tailwind.config.ts b/apps/web/tailwind.config.ts index a246df25..39457a34 100644 --- a/apps/web/tailwind.config.ts +++ b/apps/web/tailwind.config.ts @@ -63,7 +63,7 @@ const config: Config = { }, }, }, - safelist: ["text-rgray-11/70"], + safelist: ["pb-[20vh]", "pb-5"], darkMode: "class", plugins: [ require("tailwindcss-animate"),