Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

chore(design-system): admonition background fill (#39474)

Danny Whiteac1006fc1a8d
diff --git a/apps/design-system/__registry__/index.tsx b/apps/design-system/__registry__/index.tsx
index e46c387c320..59e7e54043f 100644
--- a/apps/design-system/__registry__/index.tsx
+++ b/apps/design-system/__registry__/index.tsx
@@ -104,6 +104,17 @@ export const Index: Record<string, any> = {
subcategory: "undefined",
chunks: []
},
+ "admonition-button": {
+ name: "admonition-button",
+ type: "components:example",
+ registryDependencies: ["admonition"],
+ component: React.lazy(() => import("@/registry/default/example/admonition-button")),
+ source: "",
+ files: ["registry/default/example/admonition-button.tsx"],
+ category: "undefined",
+ subcategory: "undefined",
+ chunks: []
+ },
"admonition-warning": {
name: "admonition-warning",
type: "components:example",
diff --git a/apps/design-system/content/docs/components/alert.mdx b/apps/design-system/content/docs/components/alert.mdx
index 0f0a031a2a1..5923eaf90d9 100644
--- a/apps/design-system/content/docs/components/alert.mdx
+++ b/apps/design-system/content/docs/components/alert.mdx
@@ -7,6 +7,8 @@ source:
shadcn: true
---
+The primitive component that forms [Admonition](../fragments/admonition). Do not use this component unless you are intentionally deviating from our consistent callout pattern.
+
<ComponentPreview
name="alert-demo"
description="An alert with an icon, title and description. The title says 'Heads up!' and the description is 'You can add components to your app using the cli.'."
diff --git a/apps/design-system/content/docs/fragments/admonition.mdx b/apps/design-system/content/docs/fragments/admonition.mdx
index ac4921783e2..5913866d970 100644
--- a/apps/design-system/content/docs/fragments/admonition.mdx
+++ b/apps/design-system/content/docs/fragments/admonition.mdx
@@ -4,6 +4,8 @@ description: Displays a callout for user attention.
fragment: true
---
+Admonition provides focus for situations that require a callout. Use this instead of [Alert](../components/alert) unless you specifically need the primitives.
+
<ComponentPreview
name="admonition-demo"
className="[&_.preview>[data-orientation=vertical]]:sm:max-w-[70%]"
@@ -25,6 +27,17 @@ import { Admonition } from 'ui-patterns/admonition'
/>
```
+### Buttons
+
+Style the color of the button based upon the _context_ of the Admonition, not its inherited `type`. For example, the below `warning` Admonition has an encouraged action, so its button has `type="default"`. The `destructive` Admonition has a button that is destructive, so the button has `type="danger"`.
+
+<ComponentPreview
+ name="admonition-button"
+ className="[&_.preview>[data-orientation=vertical]]:sm:max-w-[70%]"
+/>
+
+Only ever use the `primary` (green) button `type` on a `default` Admonition. Even then—given that Admonition is an isolated callout—the `primary` button `type` should rarely be used.
+
## Examples
### With actions
diff --git a/apps/design-system/registry/default/example/admonition-button.tsx b/apps/design-system/registry/default/example/admonition-button.tsx
new file mode 100644
index 00000000000..b6251de2bef
--- /dev/null
+++ b/apps/design-system/registry/default/example/admonition-button.tsx
@@ -0,0 +1,24 @@
+import { Button } from 'ui'
+import { Admonition } from 'ui-patterns/admonition'
+
+export default function AdmonitionDemo() {
+ return (
+ <div className="flex flex-col gap-4">
+ <Admonition
+ type="warning"
+ layout="horizontal"
+ title="Set up custom SMTP"
+ description="You’re using the built-in email service. This service has rate limits and is not meant to be
+ used for production apps."
+ actions={<Button type="default">Set up SMTP</Button>}
+ />
+ <Admonition
+ type="destructive"
+ layout="horizontal"
+ title="Deleting this organization will also remove its projects"
+ description="Make sure you have made a backup of your projects if you want to keep your data."
+ actions={<Button type="danger">Delete organization</Button>}
+ />
+ </div>
+ )
+}
diff --git a/apps/design-system/registry/examples.ts b/apps/design-system/registry/examples.ts
index 59495e9004f..f033062e253 100644
--- a/apps/design-system/registry/examples.ts
+++ b/apps/design-system/registry/examples.ts
@@ -13,6 +13,12 @@ export const examples: Registry = [
registryDependencies: ['admonition'],
files: ['example/admonition-demo.tsx'],
},
+ {
+ name: 'admonition-button',
+ type: 'components:example',
+ registryDependencies: ['admonition'],
+ files: ['example/admonition-button.tsx'],
+ },
{
name: 'admonition-warning',
type: 'components:example',
diff --git a/apps/studio/components/interfaces/Auth/EmailRateLimitsAlert.tsx b/apps/studio/components/interfaces/Auth/EmailRateLimitsAlert.tsx
index f2ebefc51a2..f866cbda6d2 100644
--- a/apps/studio/components/interfaces/Auth/EmailRateLimitsAlert.tsx
+++ b/apps/studio/components/interfaces/Auth/EmailRateLimitsAlert.tsx
@@ -10,11 +10,7 @@ export const EmailRateLimitsAlert = () => {
const { ref } = useParams()
return (
- <Admonition
- type="warning"
- title="Set up custom SMTP"
- className="bg-warning-200 border-warning-400"
- >
+ <Admonition type="warning" title="Set up custom SMTP">
<p>
You’re using the built-in email service. This service has rate limits and is not meant to be
used for production apps.{' '}
diff --git a/packages/ui-patterns/src/admonition.tsx b/packages/ui-patterns/src/admonition.tsx
index de15281c1ff..568b2c0dae2 100644
--- a/packages/ui-patterns/src/admonition.tsx
+++ b/packages/ui-patterns/src/admonition.tsx
@@ -79,16 +79,6 @@ const admonitionSVG = cva('', {
},
})
-const admonitionBase = cva('', {
- variants: {
- type: {
- default: `bg-surface-200/25 border border-default`,
- warning: `bg-alternative border border-default`,
- destructive: `bg-alternative border border-default`,
- },
- },
-})
-
export const Admonition = forwardRef<
React.ElementRef<typeof Alert_Shadcn_>,
React.ComponentPropsWithoutRef<typeof Alert_Shadcn_> & AdmonitionProps
@@ -117,12 +107,7 @@ export const Admonition = forwardRef<
ref={ref}
variant={typeMapped}
{...props}
- className={cn(
- 'mb-2',
- admonitionSVG({ type: typeMapped }),
- admonitionBase({ type: typeMapped }),
- props.className
- )}
+ className={cn('mb-2', admonitionSVG({ type: typeMapped }), props.className)}
>
{!!icon ? (
icon
diff --git a/packages/ui/src/components/shadcn/ui/alert.tsx b/packages/ui/src/components/shadcn/ui/alert.tsx
index c0556b84cc0..934c9db155d 100644
--- a/packages/ui/src/components/shadcn/ui/alert.tsx
+++ b/packages/ui/src/components/shadcn/ui/alert.tsx
@@ -13,11 +13,11 @@ export const alertVariants = cva(
variants: {
variant: {
default:
- 'text-foreground bg-alternative border [&>svg]:text-background [&>svg]:bg-foreground',
+ 'bg-surface-200/25 border-default text-foreground [&>svg]:text-background [&>svg]:bg-foreground',
destructive:
- 'text border-destructive-400 bg-destructive-200 [&>svg]:text-destructive-200 [&>svg]:bg-destructive-600',
+ 'bg-destructive-200 border-destructive-400 [&>svg]:text-destructive-200 [&>svg]:bg-destructive-600',
warning:
- 'border-warning-400 bg-warning-200 [&>svg]:text-warning-200 [&>svg]:bg-warning-600',
+ 'bg-warning-200 border-warning-400 [&>svg]:text-warning-200 [&>svg]:bg-warning-600',
},
},
defaultVariants: {