mirror of
https://github.com/supabase/supabase.git
synced 2026-07-01 04:47:16 -04:00
96d43099bb
## Problem Our `<Button>` component breaks the default `button` contract by redefining the `type` prop to set its variant (`primary`, `default`, etc) instead of the button type (`submit`, `button`, etc). This is confusing and forces to write more code when using it with shadcn components that expect/inject the standard button props. ## Solution - rename the `type` prop to `variant` - rename the `htmlType` prop to `type` - propagate the changes where necessary - format code ## How to test As this is just prop renaming, if it builds it's ok --------- Co-authored-by: Ivan Vasilov <vasilov.ivan@gmail.com>
41 lines
1.3 KiB
TypeScript
41 lines
1.3 KiB
TypeScript
import { HelpCircle } from 'lucide-react'
|
|
import { cn } from 'ui'
|
|
|
|
import { SIDEBAR_KEYS } from '@/components/layouts/ProjectLayout/LayoutSidebar/LayoutSidebarProvider'
|
|
import { ButtonTooltip } from '@/components/ui/ButtonTooltip'
|
|
import { useTrack } from '@/lib/telemetry/track'
|
|
import { useSidebarManagerSnapshot } from '@/state/sidebar-manager-state'
|
|
|
|
export const HelpButton = () => {
|
|
const { toggleSidebar, activeSidebar } = useSidebarManagerSnapshot()
|
|
const track = useTrack()
|
|
|
|
const isOpen = activeSidebar?.id === SIDEBAR_KEYS.HELP_PANEL
|
|
|
|
return (
|
|
<ButtonTooltip
|
|
id="help-dropdown-button"
|
|
variant={isOpen ? 'secondary' : 'outline'}
|
|
size="tiny"
|
|
className={cn('rounded-full w-[32px] h-[32px] flex items-center justify-center p-0 group')}
|
|
onClick={() => {
|
|
toggleSidebar(SIDEBAR_KEYS.HELP_PANEL)
|
|
if (!isOpen) {
|
|
track('help_button_clicked')
|
|
}
|
|
}}
|
|
tooltip={{ content: { text: 'Help' } }}
|
|
>
|
|
<HelpCircle
|
|
size={16}
|
|
strokeWidth={1.5}
|
|
className={cn(
|
|
'text-foreground-light group-hover:text-foreground',
|
|
isOpen && 'text-background group-hover:text-background'
|
|
)}
|
|
/>
|
|
<span className="sr-only">Help</span>
|
|
</ButtonTooltip>
|
|
)
|
|
}
|