@@ -12,11 +12,13 @@ import {
1212 Settings ,
1313 Sparkles ,
1414} from "lucide-react" ;
15- import { type ReactNode , useEffect , useRef , useState } from "react" ;
15+ import { type ReactNode , useCallback , useRef , useState } from "react" ;
1616import { LOCALES , setLocaleChoice , systemLocale , useLocale , useT } from "../../i18n" ;
1717import type { ClaudeAccount } from "../../lib/protocol.gen" ;
1818import { useApp , useHost } from "../../store/context" ;
19+ import { POPOVER , POPOVER_ITEM } from "../../ui/surface" ;
1920import { attempt } from "../../ui/toast" ;
21+ import { useDismiss } from "../../ui/useDismiss" ;
2022import { SettingsDialog } from "./SettingsDialog" ;
2123import { UsageDialog } from "./UsageDialog" ;
2224
@@ -37,23 +39,11 @@ export function AccountArea() {
3739 const [ dialog , setDialog ] = useState < "usage" | "settings" | null > ( null ) ;
3840 const root = useRef < HTMLDivElement > ( null ) ;
3941
40- useEffect ( ( ) => {
41- if ( ! open ) {
42- return ;
43- }
44- const onPointer = ( event : PointerEvent ) => {
45- if ( ! root . current ?. contains ( event . target as Node ) ) {
46- setOpen ( false ) ;
47- }
48- } ;
49- const onKey = ( event : KeyboardEvent ) => event . key === "Escape" && setOpen ( false ) ;
50- window . addEventListener ( "pointerdown" , onPointer ) ;
51- window . addEventListener ( "keydown" , onKey ) ;
52- return ( ) => {
53- window . removeEventListener ( "pointerdown" , onPointer ) ;
54- window . removeEventListener ( "keydown" , onKey ) ;
55- } ;
56- } , [ open ] ) ;
42+ useDismiss (
43+ open ,
44+ root ,
45+ useCallback ( ( ) => setOpen ( false ) , [ ] ) ,
46+ ) ;
5747
5848 const name = account ?. name . trim ( ) || "Botloft" ;
5949 const detail = describe ( account ?. claude ?? null , signedOut , a ) ;
@@ -78,7 +68,7 @@ export function AccountArea() {
7868 aria-expanded = { open }
7969 aria-label = { a . open ( name ) }
8070 onClick = { ( ) => setOpen ( ! open ) }
81- className = { `flex w-full items-center gap-2.5 px-2 py-1.5 text-left hover:bg-sunken ${ open ? "bg-sunken" : "" } ` }
71+ className = { `flex w-full items-center gap-2.5 rounded-lg px-2 py-1.5 text-left hover:bg-sunken ${ open ? "bg-sunken" : "" } ` }
8272 >
8373 < span
8474 aria-hidden
@@ -135,10 +125,10 @@ function AccountMenu({
135125 < div
136126 role = "menu"
137127 aria-label = { name }
138- className = " absolute right-2 bottom-full left-2 z-30 mb-1 border border-line-strong bg-panel py-1"
128+ className = { ` absolute right-2 bottom-full left-2 mb-1 ${ POPOVER } ` }
139129 >
140130 { email && (
141- < p className = "truncate px-3 pt-1 pb-2 text-muted text-xs" data-selectable >
131+ < p className = "truncate px-2.5 pt-1.5 pb-2 text-muted text-xs" data-selectable >
142132 { email }
143133 </ p >
144134 ) }
@@ -161,7 +151,7 @@ function AccountMenu({
161151 < div
162152 role = "menu"
163153 aria-label = { m . language }
164- className = " absolute bottom-0 left-full z-30 ml-1 min-w-56 border border-line-strong bg-panel py-1"
154+ className = { ` absolute bottom-0 left-full ml-2 min-w-56 ${ POPOVER } ` }
165155 >
166156 { [ { id : "system" as const , name : t . shell . language . system ( systemName ) } , ...LOCALES ] . map (
167157 ( entry ) => (
@@ -171,7 +161,7 @@ function AccountMenu({
171161 role = "menuitemradio"
172162 aria-checked = { choice === entry . id }
173163 onClick = { ( ) => setLocaleChoice ( entry . id ) }
174- className = "flex h-8 w-full items-center gap-2 whitespace-nowrap px-3 text-left text-sm hover:bg-sunken"
164+ className = { ` h-8 whitespace-nowrap ${ POPOVER_ITEM } ` }
175165 >
176166 < Check aria-hidden size = { 14 } className = { choice === entry . id ? "" : "invisible" } />
177167 { entry . name }
@@ -181,7 +171,7 @@ function AccountMenu({
181171 </ div >
182172 ) }
183173 </ div >
184- < div className = "my-1 border-line border-t" />
174+ < div className = "mx-1 my-1 border-line border-t" />
185175 < Item icon = { Sparkles } onClick = { ( ) => open ( RELEASES ) } >
186176 { m . whatsNew }
187177 </ Item >
@@ -212,7 +202,7 @@ function Item({
212202 aria-haspopup = { expanded === undefined ? undefined : "menu" }
213203 aria-expanded = { expanded }
214204 onClick = { onClick }
215- className = "flex h-8 w-full items-center gap-2 px-3 text-left text- ink text-sm hover:bg-sunken"
205+ className = { ` h-8 text-ink ${ POPOVER_ITEM } ` }
216206 >
217207 < Icon aria-hidden size = { 14 } className = "text-ink-soft" />
218208 < span className = "flex-1" > { children } </ span >
0 commit comments