Files
Danny White 476d4a5851 refactor(ui): drop redundant Button variant="default" props (#50161)
## What kind of change does this PR introduce?

Mechanical cleanup on top of the Button default-variant change (#50160).

## What is the current behavior?

Many callsites still pass `variant="default"` even though that is now
the component default.

## What is the new behavior?

Removes redundant static `variant="default"` from legacy `Button` and
`ButtonTooltip` callsites. Keeps explicit defaults where they document
the API:

- `button-default.tsx` and `button-sizes.tsx` demos
- `DocsButton`, which pins neutral styling at the wrapper boundary

## To test

Studio:

- [Auth → Rate
Limits](https://studio-staging-2s957kwc4-supabase.vercel.app/dashboard/project/_/auth/rate-limits):
dirty the form so Cancel appears; Cancel stays neutral, Save stays green
- [Project Settings → API
Keys](https://studio-staging-2s957kwc4-supabase.vercel.app/dashboard/project/_/settings/api-keys):
`DocsButton` in the header actions stays neutral

Design system:

- [Design system →
Button](https://design-system-git-dnywh-dc924ac1-supabase.vercel.app/design-system/docs/components/button):
`button-default` / `button-sizes` still show explicit default styling;
Primary (green) is restricted to the Primary section (and `asChild`)

WWW:

- [www → Brand
assets](https://zone-www-dot-com-git-dnywh-dc924ac1-supabase.vercel.app/brand-assets):
Download logo kit / Download button kit stay neutral
2026-09-11 17:05:26 +10:00

139 lines
5.0 KiB
TypeScript

import { PermissionAction } from '@supabase/shared-types/out/constants'
import { useParams } from 'common'
import { Copy } from 'lucide-react'
import { useEffect, useState } from 'react'
import { Button, copyToClipboard } from 'ui'
import { Input } from 'ui-patterns/DataInputs/Input'
import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
import ContentSnippet from '../ContentSnippet'
import { DOCS_CONTENT } from '../ProjectAPIDocs.constants'
import type { ContentProps } from './Content.types'
import { useAPIKeys } from '@/data/api-keys/api-keys-query'
import { useProjectSettingsV2Query } from '@/data/config/project-settings-v2-query'
import { useAsyncCheckPermissions } from '@/hooks/misc/useCheckPermissions'
import { useTrack } from '@/lib/telemetry/track'
export const Introduction = ({ showKeys, language, apikey, endpoint }: ContentProps) => {
const { ref } = useParams()
const { can: canReadAPIKeys } = useAsyncCheckPermissions(PermissionAction.SECRETS_READ, '*')
const { data: apiKeysData } = useAPIKeys({ projectRef: ref }, { enabled: canReadAPIKeys })
useProjectSettingsV2Query({ projectRef: ref })
const { anonKey, serviceKey } = apiKeysData ?? {}
const track = useTrack()
const [copied, setCopied] = useState<'anon' | 'service'>()
useEffect(() => {
if (copied !== undefined) setTimeout(() => setCopied(undefined), 2000)
}, [copied])
const anonApiKey = anonKey?.api_key
const serviceApiKey = serviceKey?.api_key ?? 'SUPABASE_CLIENT_SERVICE_KEY'
return (
<>
<ContentSnippet
selectedLanguage={language}
apikey={apikey}
endpoint={endpoint}
snippet={DOCS_CONTENT.init}
>
<div className="px-4 space-y-6">
<div className="flex flex-col space-x-4 mt-8">
<FormItemLayout isReactForm={false} layout="horizontal" label="Project URL">
<Input disabled readOnly copy size="small" value={endpoint} className="w-full" />
</FormItemLayout>
</div>
<div className="flex flex-col space-x-4">
<FormItemLayout
isReactForm={false}
layout="horizontal"
label="Client API key"
description="This key is safe to use in a browser if you have enabled Row Level Security (RLS) for your tables and configured policies."
>
<Input
disabled
readOnly
size="small"
value={showKeys ? apikey : 'Reveal API keys via dropdown in the header'}
actions={[
<Button
key="copy"
icon={<Copy />}
onClick={() => {
setCopied('anon')
copyToClipboard(anonApiKey ?? 'SUPABASE_CLIENT_ANON_KEY')
track('api_docs_code_copy_button_clicked', {
title: 'Client API key',
selectedLanguage: language,
})
}}
>
{copied === 'anon' ? 'Copied' : 'Copy'}
</Button>,
]}
/>
</FormItemLayout>
</div>
<div className="flex flex-col space-x-4">
<FormItemLayout
isReactForm={false}
layout="horizontal"
label="Service key"
description={
<p>
This key has the ability to bypass Row Level Security.{' '}
<span className="text-amber-900">Never share it publicly.</span>
</p>
}
>
<Input
disabled
readOnly
size="small"
value={
showKeys
? (serviceApiKey ?? 'SUPABASE_CLIENT_SERVICE_KEY')
: 'Reveal API keys via dropdown in the header'
}
actions={[
<Button
key="copy"
icon={<Copy />}
onClick={() => {
setCopied('service')
copyToClipboard(serviceApiKey)
track('api_docs_code_copy_button_clicked', {
title: 'Service key',
selectedLanguage: language,
})
}}
>
{copied === 'service' ? 'Copied' : 'Copy'}
</Button>,
]}
/>
</FormItemLayout>
</div>
</div>
</ContentSnippet>
<ContentSnippet
selectedLanguage={language}
apikey={apikey}
endpoint={endpoint}
snippet={DOCS_CONTENT.clientApiKeys}
/>
<ContentSnippet
selectedLanguage={language}
apikey={showKeys ? serviceApiKey : 'SUPABASE_CLIENT_SERVICE_KEY'}
endpoint={endpoint}
snippet={DOCS_CONTENT.serviceApiKeys}
/>
</>
)
}