11"use client" ;
22
3- import { useEffect } from "react" ;
3+ import { useEffect , useMemo } from "react" ;
44import { useBookmarkStore } from "@/stores/bookmarks" ;
55
66export function BookmarkDrawer ( ) {
@@ -13,12 +13,17 @@ export function BookmarkDrawer() {
1313 exportBookmarks,
1414 } = useBookmarkStore ( ) ;
1515
16+ const hasBookmarks = bookmarks . length > 0 ;
17+ const canExport = drawerOpen && hasBookmarks ;
18+
1619 useEffect ( ( ) => {
1720 if ( drawerOpen ) {
1821 fetchBookmarks ( ) ;
1922 }
2023 } , [ drawerOpen , fetchBookmarks ] ) ;
2124
25+ const footerText = useMemo ( ( ) => ( hasBookmarks ? `${ bookmarks . length } BOOKMARKS` : "No bookmarks yet" ) , [ bookmarks . length , hasBookmarks ] ) ;
26+
2227 if ( ! drawerOpen ) return null ;
2328
2429 return (
@@ -30,14 +35,22 @@ export function BookmarkDrawer() {
3035 </ h2 >
3136 < div className = "flex items-center gap-2" >
3237 < button
38+ type = "button"
3339 onClick = { exportBookmarks }
34- className = "font-mono text-sm text-accent hover:text-accent/80 uppercase tracking-wider"
40+ disabled = { ! hasBookmarks }
41+ className = { `font-mono text-sm uppercase tracking-wider ${
42+ hasBookmarks ? "text-accent hover:text-accent/80" : "text-hud-label cursor-not-allowed"
43+ } `}
44+ title = { hasBookmarks ? "Download bookmarks JSON" : "No bookmarks to export" }
45+ aria-label = { hasBookmarks ? "Export bookmarks" : "Export unavailable: no bookmarks" }
3546 >
3647 EXPORT
3748 </ button >
3849 < button
50+ type = "button"
3951 onClick = { ( ) => setDrawerOpen ( false ) }
4052 className = "font-mono text-[13px] text-hud-muted hover:text-danger"
53+ aria-label = "Close bookmark drawer"
4154 >
4255 ✕
4356 </ button >
@@ -64,8 +77,10 @@ export function BookmarkDrawer() {
6477 { bm . label || bm . entity_type }
6578 </ a >
6679 < button
80+ type = "button"
6781 onClick = { ( ) => removeBookmark ( bm . id ) }
6882 className = "font-mono text-[11px] text-hud-muted hover:text-danger ml-2 flex-shrink-0"
83+ aria-label = { `Remove bookmark for ${ bm . label || bm . entity_type } ` }
6984 >
7085 DEL
7186 </ button >
@@ -85,9 +100,11 @@ export function BookmarkDrawer() {
85100
86101 { /* Footer */ }
87102 < div className = "px-4 py-2 border-t border-hud-border" >
88- < div className = "font-mono text-[11px] text-hud-label" >
89- { bookmarks . length } BOOKMARKS
90- </ div >
103+ < div className = "font-mono text-[11px] text-hud-label" > { footerText } </ div >
104+ </ div >
105+
106+ < div className = "sr-only" aria-live = "polite" >
107+ { canExport ? `Bookmark drawer open, ${ bookmarks . length } bookmarks` : "Bookmark drawer open, no bookmarks" }
91108 </ div >
92109 </ div >
93110 ) ;
0 commit comments