Files
supabase/apps/studio/components/interfaces/ConnectButton/ConnectButton.tsx
Ivan Vasilov ea0523ce02 Fix the Connect button to show the text. (#45646)
The connect button was missing its text
Before:
<img width="833" height="244" alt="Screenshot 2026-05-06 at 17 46 23"
src="https://github.com/user-attachments/assets/c03e972f-bef6-4bd7-8819-dd51509c58eb"
/>

After:
<img width="678" height="208" alt="Screenshot 2026-05-06 at 17 46 58"
src="https://github.com/user-attachments/assets/5b020017-133e-47c3-8138-925c27299665"
/>


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Bug Fixes**
* Improved screen reader accessibility in the Connect button by refining
how text visibility is handled based on button display mode.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-05-06 16:04:54 +00:00

54 lines
1.6 KiB
TypeScript

import { Plug } from 'lucide-react'
import { parseAsBoolean, useQueryState } from 'nuqs'
import { ComponentProps } from 'react'
import { Button, cn } from 'ui'
import { ButtonTooltip } from '@/components/ui/ButtonTooltip'
import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
import { PROJECT_STATUS } from '@/lib/constants'
import { useTrack } from '@/lib/telemetry/track'
import { useAppStateSnapshot } from '@/state/app-state'
interface ConnectButtonProps {
buttonType?: ComponentProps<typeof Button>['type']
className?: string
iconOnly?: boolean
}
export const ConnectButton = ({
buttonType = 'default',
className,
iconOnly = false,
}: ConnectButtonProps) => {
const { data: selectedProject } = useSelectedProjectQuery()
const { setConnectSheetSource } = useAppStateSnapshot()
const isActiveHealthy = selectedProject?.status === PROJECT_STATUS.ACTIVE_HEALTHY
const track = useTrack()
const [, setShowConnect] = useQueryState('showConnect', parseAsBoolean.withDefault(false))
return (
<ButtonTooltip
type={buttonType}
disabled={!isActiveHealthy}
className={cn('rounded-full', className)}
icon={<Plug className="rotate-90" />}
onClick={() => {
track('header_connect_button_clicked')
setConnectSheetSource('header_button')
setShowConnect(true)
}}
tooltip={{
content: {
side: 'bottom',
text: !isActiveHealthy
? 'Project is currently not active and cannot be connected'
: undefined,
},
}}
>
<span className={cn({ 'sr-only': iconOnly })}>Connect</span>
</ButtonTooltip>
)
}