mirror of
https://github.com/supabase/supabase.git
synced 2026-10-05 17:35:10 +03:00
## 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
97 lines
2.7 KiB
TypeScript
97 lines
2.7 KiB
TypeScript
import { ExternalLink, Maximize2, Minimize2 } from 'lucide-react'
|
|
import Link from 'next/link'
|
|
import { forwardRef, ReactNode, useState } from 'react'
|
|
import { Button } from 'ui'
|
|
|
|
interface InformationBoxProps {
|
|
icon?: ReactNode
|
|
title: ReactNode | string
|
|
description?: ReactNode | string
|
|
url?: string
|
|
urlLabel?: string
|
|
defaultVisibility?: boolean
|
|
hideCollapse?: boolean
|
|
button?: React.ReactNode
|
|
className?: string
|
|
block?: boolean
|
|
}
|
|
|
|
/** @deprecated Use `Admonition` from 'ui-patterns' instead. */
|
|
|
|
const InformationBox = forwardRef<HTMLDivElement, InformationBoxProps>(
|
|
(
|
|
{
|
|
icon,
|
|
title,
|
|
description,
|
|
url,
|
|
urlLabel = 'Read more',
|
|
defaultVisibility = false,
|
|
hideCollapse = false,
|
|
button,
|
|
className = '',
|
|
block = false,
|
|
},
|
|
ref
|
|
) => {
|
|
const [isExpanded, setIsExpanded] = useState<boolean>(defaultVisibility)
|
|
|
|
return (
|
|
<div
|
|
ref={ref}
|
|
role="alert"
|
|
className={`${block ? 'block w-full' : ''}
|
|
block w-full rounded-md border bg-surface-300/25 py-3 ${className}`}
|
|
>
|
|
<div className="flex flex-col px-4">
|
|
<div className="flex items-center justify-between">
|
|
<div className="flex w-full space-x-3 items-center">
|
|
{icon && <span className="text-foreground-lighter">{icon}</span>}
|
|
<div className="grow">
|
|
<h5 className="text-foreground">{title}</h5>
|
|
</div>
|
|
</div>
|
|
{description && !hideCollapse ? (
|
|
<div
|
|
className="cursor-pointer text-foreground-lighter"
|
|
onClick={() => setIsExpanded(!isExpanded)}
|
|
>
|
|
{isExpanded ? (
|
|
<Minimize2 size={14} strokeWidth={1.5} />
|
|
) : (
|
|
<Maximize2 size={14} strokeWidth={1.5} />
|
|
)}
|
|
</div>
|
|
) : null}
|
|
</div>
|
|
{(description || url || button) && (
|
|
<div
|
|
className={`flex flex-col space-y-3 overflow-hidden transition-all ${
|
|
isExpanded ? 'mt-3' : ''
|
|
}`}
|
|
style={{ maxHeight: isExpanded ? 500 : 0 }}
|
|
>
|
|
<div className="text-foreground-light text-sm">{description}</div>
|
|
|
|
{url && (
|
|
<div>
|
|
<Button asChild icon={<ExternalLink />}>
|
|
<Link href={url} target="_blank" rel="noreferrer">
|
|
{urlLabel}
|
|
</Link>
|
|
</Button>
|
|
</div>
|
|
)}
|
|
|
|
{button && <div>{button}</div>}
|
|
</div>
|
|
)}
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|
|
)
|
|
|
|
InformationBox.displayName = 'InformationBox'
|
|
export default InformationBox
|