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

129 lines
3.7 KiB
TypeScript

import { Upload } from 'lucide-react'
import { useEffect, useRef, useState } from 'react'
import { useForm } from 'react-hook-form'
import {
Button,
FormControl,
FormField,
FormItem,
FormMessage,
Input,
Tabs,
TabsContent,
TabsList,
TabsTrigger,
} from 'ui'
import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
import { SSOConfigFormSchema } from './SSOConfig'
export const SSOMetadata = ({
form,
}: {
form: ReturnType<typeof useForm<SSOConfigFormSchema>>
}) => {
const fileInputRef = useRef<HTMLInputElement>(null)
const [fileName, setFileName] = useState<string | null>(null)
const [tab, setTab] = useState<'url' | 'file'>('url')
useEffect(() => {
if (form.getValues('metadataXmlFile')) {
setTab('file')
} else if (form.getValues('metadataXmlUrl')) {
setTab('url')
}
}, [form])
const handleFileChange = async (e: React.ChangeEvent<HTMLInputElement>) => {
form.clearErrors('metadataXmlFile')
const file = e.target.files?.[0]
if (!file) return
if (!file.name.endsWith('.xml')) {
form.setError('metadataXmlFile', {
type: 'manual',
message: 'Please upload a valid .xml file',
})
return
}
try {
const text = await file.text()
form.setValue('metadataXmlFile', text, { shouldDirty: true })
setFileName(file.name)
} catch (err) {
form.setError('metadataXmlFile', {
type: 'manual',
message: 'Failed to read file',
})
}
}
return (
<FormItemLayout
label="Metadata"
layout="flex-row-reverse"
description="Provide a link to your metadata .xml file or upload one."
className="gap-1"
>
<div className=" w-96">
<Tabs
value={tab}
onValueChange={(value: string) => setTab(value as 'url' | 'file')}
className="max-w-2xl"
>
<TabsList className="mx-auto gap-5 w-auto">
<TabsTrigger className=" " value="url">
URL
</TabsTrigger>
<TabsTrigger className=" " value="file">
Upload file
</TabsTrigger>
</TabsList>
<TabsContent value="url">
<FormField
name="metadataXmlUrl"
render={({ field }) => (
<FormItem>
<FormControl>
<Input
{...field}
placeholder="https://example.com/metadata.xml"
autoComplete="off"
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
</TabsContent>
<TabsContent value="file">
<FormField
name="metadataXmlUrl"
render={() => (
<div className="flex flex-col gap-2 max-w-md">
<div className="flex items-center gap-2">
<input
ref={fileInputRef}
type="file"
accept=".xml"
className="hidden"
onChange={handleFileChange}
/>
<Button
icon={<Upload className="w-4 h-4" />}
onClick={() => fileInputRef.current?.click()}
>
Upload XML
</Button>
{fileName && <span className="text-xs text-foreground-light">{fileName}</span>}
</div>
<FormMessage />
</div>
)}
/>
</TabsContent>
</Tabs>
</div>
</FormItemLayout>
)
}