diff --git a/apps/web/components/quick-note-card.tsx b/apps/web/components/quick-note-card.tsx index 19c7b033..51a4aa6f 100644 --- a/apps/web/components/quick-note-card.tsx +++ b/apps/web/components/quick-note-card.tsx @@ -1,6 +1,6 @@ "use client" -import { useRef, useCallback, useState } from "react" +import { useRef, useCallback, useEffect, useState } from "react" import { cn } from "@lib/utils" import { dmSansClassName } from "@/lib/fonts" import { Maximize2, Plus, Loader2 } from "lucide-react" @@ -50,32 +50,77 @@ export function QuickNoteCard({ const handleBlurCapture = useCallback( (e: React.FocusEvent) => { if (e.currentTarget.contains(e.relatedTarget as Node | null)) return - setIsExpanded(draftRef.current.trim().length > 0) + setIsExpanded(false) }, [], ) + const handleBackdropPointerDown = useCallback(() => { + const activeElement = document.activeElement + if (activeElement instanceof HTMLElement) { + activeElement.blur() + } + setIsExpanded(false) + }, []) + + useEffect(() => { + if (!isExpanded) return + + const handleKeyDown = (event: KeyboardEvent) => { + if (event.key !== "Escape") return + const activeElement = document.activeElement + if (activeElement instanceof HTMLElement) { + activeElement.blur() + } + setIsExpanded(false) + } + + window.addEventListener("keydown", handleKeyDown) + return () => window.removeEventListener("keydown", handleKeyDown) + }, [isExpanded]) + const canSave = draft.trim().length > 0 && !isSaving + const hasDraft = draft.trim().length > 0 const editorHeight = - isExpanded || draft.trim() ? "min-h-[188px]" : "min-h-[120px]" + isExpanded || hasDraft + ? "min-h-[min(58dvh,520px)] sm:min-h-[min(54vh,560px)]" + : "min-h-[120px]" return ( -
+ <> + {isExpanded && ( +
+ )}
setIsExpanded(true)} - onBlurCapture={handleBlurCapture} + className={cn( + "relative rounded-[22px] bg-[#1B1F24] p-1 transition-[box-shadow,transform] duration-200", + isExpanded && "z-[70] scale-[1.01]", + )} style={{ - boxShadow: "inset 1.421px 1.421px 4.263px 0 rgba(11, 15, 21, 0.4)", + boxShadow: isExpanded + ? "0 24px 80px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255,255,255,0.08), 0.711px 0.711px 0.711px 0 rgba(255, 255, 255, 0.10) inset" + : "0 2.842px 14.211px 0 rgba(0, 0, 0, 0.25), 0.711px 0.711px 0.711px 0 rgba(255, 255, 255, 0.10) inset", }} > +
setIsExpanded(true)} + onBlurCapture={handleBlurCapture} + style={{ + boxShadow: + "inset 1.421px 1.421px 4.263px 0 rgba(11, 15, 21, 0.4)", + }} + >
+ ) }