11import { Download , PanelRight , Share , User } from "lucide-react" ;
2+ import { useRef , useState } from "react" ;
23import { HARDCODED_USERS } from "./utils" ;
34
45interface EditorMenuProps {
@@ -23,21 +24,31 @@ export function EditorMenu({
2324 onToggleSidebar,
2425 disabled,
2526} : EditorMenuProps ) {
27+ const [ exportOpen , setExportOpen ] = useState ( false ) ;
28+ const exportRef = useRef < HTMLDivElement > ( null ) ;
29+
30+ // Close on outside click via onBlur with a relatedTarget check
31+ const handleBlur = ( e : React . FocusEvent ) => {
32+ if ( ! exportRef . current ?. contains ( e . relatedTarget as Node ) ) {
33+ setExportOpen ( false ) ;
34+ }
35+ } ;
36+
2637 return (
27- < div className = "flex items-center justify-between border-b border-stone-200 bg-stone-50 px-4 py-2" >
28- < div className = "flex gap-1.5" >
38+ < div className = "flex items-center justify-between border-b border-stone-200 bg-stone-50 px-2 py-2 sm:px-4 " >
39+ < div className = "hidden gap-1.5 sm:flex " >
2940 < div className = "h-3 w-3 rounded-full bg-red-400" />
3041 < div className = "h-3 w-3 rounded-full bg-amber-400" />
3142 < div className = "h-3 w-3 rounded-full bg-green-400" />
3243 </ div >
3344
34- < div className = "flex items-center gap-2" >
45+ < div className = "flex items-center gap-1 sm:gap- 2" >
3546 < div
36- className = { `flex items-center gap-2 rounded-md border border-stone-200 bg-white px-2 py-1 ${ disabled ? "opacity-50" : "" } ` }
47+ className = { `flex items-center gap-1 rounded-md border border-stone-200 bg-white px-2 py-1 sm:gap-2 ${ disabled ? "opacity-50" : "" } ` }
3748 >
3849 < User className = "h-3 w-3 text-stone-500" />
3950 < select
40- className = "w-[100px ] bg-transparent text-xs outline-none"
51+ className = "w-[80px ] bg-transparent text-xs outline-none sm:w-[100px] "
4152 value = { user . id }
4253 onChange = { ( e ) => {
4354 const u = HARDCODED_USERS . find ( ( u ) => u . id === e . target . value ) ;
@@ -53,7 +64,7 @@ export function EditorMenu({
5364 </ select >
5465 </ div >
5566
56- < div className = "mx-2 h-4 w-px bg-stone-300" />
67+ < div className = "mx-1 h-4 w-px bg-stone-300 sm:mx-2 " />
5768
5869 < div
5970 className = { `flex gap-1 ${ disabled ? "pointer-events-none opacity-50" : "" } ` }
@@ -62,46 +73,59 @@ export function EditorMenu({
6273 className = "flex items-center gap-1 rounded-md border border-stone-200 bg-white px-2 py-1 text-xs hover:bg-stone-50"
6374 onClick = { ( ) => {
6475 navigator . clipboard . writeText ( window . location . href ) ;
65- alert ( "URL copied to clipboard!" ) ;
6676 } }
6777 disabled = { disabled }
6878 >
69- < Share className = "h-3 w-3" /> Share
79+ < Share className = "h-3 w-3" />
80+ < span className = "hidden sm:inline" > Share</ span >
7081 </ button >
71- < div className = "group relative" >
82+ < div className = "relative" ref = { exportRef } onBlur = { handleBlur } >
7283 < button
7384 className = "flex items-center gap-1 rounded-md border border-stone-200 bg-white px-2 py-1 text-xs hover:bg-stone-50"
7485 disabled = { disabled }
86+ onClick = { ( ) => setExportOpen ( ! exportOpen ) }
7587 >
76- < Download className = "h-3 w-3" /> Export
88+ < Download className = "h-3 w-3" />
89+ < span className = "hidden sm:inline" > Export</ span >
7790 </ button >
78- < div className = "absolute right-0 top-full z-10 hidden w-20 flex-col rounded-md border border-stone-200 bg-white py-1 shadow-md group-hover:flex" >
79- < button
80- className = "px-3 py-1 text-left text-xs hover:bg-stone-50"
81- onClick = { ( ) => onExport ( "pdf" ) }
82- >
83- PDF
84- </ button >
85- < button
86- className = "px-3 py-1 text-left text-xs hover:bg-stone-50"
87- onClick = { ( ) => onExport ( "docx" ) }
88- >
89- DOCX
90- </ button >
91- < button
92- className = "px-3 py-1 text-left text-xs hover:bg-stone-50"
93- onClick = { ( ) => onExport ( "odt" ) }
94- >
95- ODT
96- </ button >
97- </ div >
91+ { exportOpen && (
92+ < div className = "absolute right-0 top-full z-10 flex w-20 flex-col rounded-md border border-stone-200 bg-white py-1 shadow-md" >
93+ < button
94+ className = "px-3 py-1 text-left text-xs hover:bg-stone-50"
95+ onClick = { ( ) => {
96+ onExport ( "pdf" ) ;
97+ setExportOpen ( false ) ;
98+ } }
99+ >
100+ PDF
101+ </ button >
102+ < button
103+ className = "px-3 py-1 text-left text-xs hover:bg-stone-50"
104+ onClick = { ( ) => {
105+ onExport ( "docx" ) ;
106+ setExportOpen ( false ) ;
107+ } }
108+ >
109+ DOCX
110+ </ button >
111+ < button
112+ className = "px-3 py-1 text-left text-xs hover:bg-stone-50"
113+ onClick = { ( ) => {
114+ onExport ( "odt" ) ;
115+ setExportOpen ( false ) ;
116+ } }
117+ >
118+ ODT
119+ </ button >
120+ </ div >
121+ ) }
98122 </ div >
99123 </ div >
100124
101- < div className = "mx-2 h-4 w-px bg-stone-300" />
125+ < div className = "mx-1 hidden h-4 w-px bg-stone-300 sm:block sm:mx-2 " />
102126
103127 < button
104- className = { `flex items-center gap-1 rounded-md border border-stone-200 px-2 py-1 text-xs hover:bg-stone-50 ${
128+ className = { `hidden items-center gap-1 rounded-md border border-stone-200 px-2 py-1 text-xs hover:bg-stone-50 sm:flex ${
105129 sidebarOpen
106130 ? "bg-stone-100 text-stone-900"
107131 : "bg-white text-stone-500"
0 commit comments