Files
TREK/client/src/mobile/components/MIconBtn.tsx
T
Maurice 508e17bc11 fix(assistant): the phone chat holds the focus as a dialog, and its lists close on Escape
The full screen chat is a modal dialog but left the focus on the trip behind
it. It now takes the focus when shown, keeps Tab inside and hands the focus
back when set aside or closed, through the helper MSheet now shares. The
dropdown panels take the focus onto their first entry, close on Escape and
give the focus back to their button; the history and menu buttons say
whether their panel is open, and the open chat is announced as current.
2026-10-24 02:06:24 +00:00

51 lines
1.5 KiB
TypeScript

import { type AriaAttributes, ReactNode } from 'react'
interface MIconBtnProps {
onClick?: () => void
ariaLabel: string
/** glass = topbar-style glass circle, neutral = flat --m-ic circle (sheet close) */
variant?: 'glass' | 'neutral'
/** Diameter in px (topbar 38, sheet close 34) */
size?: number
className?: string
/** Dimmed and inert. For a button whose position should stay put even when it cannot act. */
disabled?: boolean
/** For a button that opens a panel: whether it is open now, said to a screen reader. */
ariaExpanded?: boolean
/** For a button that opens a panel: what kind it is (`menu` for a menu). */
ariaHaspopup?: AriaAttributes['aria-haspopup']
children: ReactNode
}
/** Round icon button used in the top bar (glass) and sheet headers (neutral). */
export default function MIconBtn({
onClick,
ariaLabel,
variant = 'glass',
size = 38,
className = '',
disabled = false,
ariaExpanded,
ariaHaspopup,
children,
}: MIconBtnProps) {
return (
<button
type="button"
onClick={onClick}
aria-label={ariaLabel}
aria-expanded={ariaExpanded}
aria-haspopup={ariaHaspopup}
disabled={disabled}
className={`relative flex flex-none items-center justify-center rounded-full text-m-ink disabled:opacity-35 ${
variant === 'glass'
? 'border border-[color:var(--m-gbr)] bg-[color:var(--m-glass)]'
: 'bg-[color:var(--m-ic)]'
} ${className}`}
style={{ width: size, height: size }}
>
{children}
</button>
)
}