mirror of
https://github.com/supabase/supabase.git
synced 2026-06-17 05:08:49 +08:00
This PR preps the monorepo for a migration to Tailwind v4: - Bump all Tailwind dependencies and libraries to the latest possible version, while still compatible with Tailwind 3. - Cleans up obsolete Tailwind 3 specific options and configs. - Cleans up unused CSS files and fixes the CSS imports. - Migrates all `important` uses in `@apply` lines to using the `!` prefix. - Move `typography.css` to the `config` package and import it from the apps. - Migrated all occurrences of `flex-grow`, `flex-shrink`, `overflow-clip` and `overflow-ellipsis` since they're deprecated and will be removed in Tailwind 4. - Make the default theme object typesafe in the `ui` package. - Migrate all `bg-opacity`, `border-opacity`, `ring-opacity` and `divider-opacity` to the new format where they're declared as part of the property color. - Bump and unify all imports of `postcss` dependency.
97 lines
2.8 KiB
TypeScript
97 lines
2.8 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 type="default" 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
|