mirror of
https://github.com/supabase/supabase.git
synced 2026-06-14 23:25:16 +08:00
## I have read the [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) file. YES ## What kind of change does this PR introduce? Improving accessibility for icon-only buttons ## What is the current behavior? Icon-only buttons do not have explicit accessible names for screen readers. ## What is the new behavior? All icon-only buttons now have explicit accessible names using visually hidden text (sr-only), ensuring proper screen reader support. ## Additional context Tooltip text is preserved for visual users. No visual changes were introduced. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Added/updated aria-labels across refresh buttons, sidebar controls, dropdown triggers, and navigation links for better accessibility. * Added conditional aria-labels for the “Create with Assistant” control to reflect permission states. * Improved screen-reader descriptions for sidebar toggle and other stateful controls to better convey status changes. <!-- review_stack_entry_start --> [](https://app.coderabbit.ai/change-stack/supabase/supabase/pull/45981) <!-- review_stack_entry_end --> <!-- end of auto-generated comment: release notes by coderabbit.ai -->
54 lines
1.6 KiB
TypeScript
54 lines
1.6 KiB
TypeScript
import { useBreakpoint } from 'common'
|
|
import { PanelLeftClose, PanelLeftOpen } from 'lucide-react'
|
|
import { cn, Tooltip, TooltipContent, TooltipTrigger } from 'ui'
|
|
|
|
import { useAppStateSnapshot } from '@/state/app-state'
|
|
|
|
export function CollapseButton({ hideTabs }: { hideTabs: boolean }) {
|
|
const { showSidebar, setShowSidebar, mobileMenuOpen, setMobileMenuOpen } = useAppStateSnapshot()
|
|
const isMobile = useBreakpoint('md')
|
|
|
|
const handleToggle = () => {
|
|
if (isMobile) {
|
|
setMobileMenuOpen(!mobileMenuOpen)
|
|
} else {
|
|
setShowSidebar(!showSidebar)
|
|
}
|
|
}
|
|
|
|
return (
|
|
<Tooltip>
|
|
<TooltipTrigger asChild>
|
|
<button
|
|
className={cn(
|
|
'hidden md:flex items-center justify-center w-10 h-(--header-height) hover:bg-surface-100 shrink-0',
|
|
!hideTabs && 'border-b border-b-default'
|
|
)}
|
|
onClick={handleToggle}
|
|
>
|
|
{showSidebar ? (
|
|
<>
|
|
<PanelLeftClose
|
|
size={16}
|
|
strokeWidth={1.5}
|
|
className="text-foreground-lighter hover:text-foreground-light"
|
|
/>
|
|
<span className="sr-only">Collapse sidebar</span>
|
|
</>
|
|
) : (
|
|
<>
|
|
<PanelLeftOpen
|
|
size={16}
|
|
strokeWidth={1.5}
|
|
className="text-foreground-lighter hover:text-foreground-light"
|
|
/>
|
|
<span className="sr-only">Expand sidebar</span>
|
|
</>
|
|
)}
|
|
</button>
|
|
</TooltipTrigger>
|
|
<TooltipContent side="bottom">{showSidebar ? 'Collapse' : 'Expand'} sidebar</TooltipContent>
|
|
</Tooltip>
|
|
)
|
|
}
|