The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
add Admonition to Design System (#26710)
Jonathan Summers-Muirec760d4e9741
diff --git a/apps/design-system/__registry__/index.tsx b/apps/design-system/__registry__/index.tsxindex 21fa4b21161..c28056bc40b 100644--- a/apps/design-system/__registry__/index.tsx+++ b/apps/design-system/__registry__/index.tsx@@ -49,6 +49,39 @@ export const Index: Record<string, any> = {subcategory: "undefined",chunks: []},+ "admonition-demo": {+ name: "admonition-demo",+ type: "components:example",+ registryDependencies: ["admonition"],+ component: React.lazy(() => import("@/registry/default/example/admonition-demo")),+ source: "",+ files: ["registry/default/example/admonition-demo.tsx"],+ category: "undefined",+ subcategory: "undefined",+ chunks: []+ },+ "admonition-warning": {+ name: "admonition-warning",+ type: "components:example",+ registryDependencies: ["admonition"],+ component: React.lazy(() => import("@/registry/default/example/admonition-warning")),+ source: "",+ files: ["registry/default/example/admonition-warning.tsx"],+ category: "undefined",+ subcategory: "undefined",+ chunks: []+ },+ "admonition-destructive": {+ name: "admonition-destructive",+ type: "components:example",+ registryDependencies: ["admonition"],+ component: React.lazy(() => import("@/registry/default/example/admonition-destructive")),+ source: "",+ files: ["registry/default/example/admonition-destructive.tsx"],+ category: "undefined",+ subcategory: "undefined",+ chunks: []+ },"alert-demo": {name: "alert-demo",type: "components:example",diff --git a/apps/design-system/components/mdx-components.tsx b/apps/design-system/components/mdx-components.tsxindex 691e2edbda2..52e02bb9bc5 100644--- a/apps/design-system/components/mdx-components.tsx+++ b/apps/design-system/components/mdx-components.tsx@@ -43,6 +43,7 @@ import { Colors } from '@/components/colors'import { Icons } from '@/components/icons'import { ThemeSettings } from '@/components/theme-settings'import { CodeFragment } from '@/components/code-fragment'+import { Admonition } from 'ui-patterns/admonition'const components = {Accordion,@@ -271,6 +272,7 @@ const components = {Icons,ThemeSettings,CodeFragment,+ Admonition,}interface MdxProps {diff --git a/apps/design-system/config/docs.ts b/apps/design-system/config/docs.tsindex 3d13330a4cf..7bddbad0c66 100644--- a/apps/design-system/config/docs.ts+++ b/apps/design-system/config/docs.ts@@ -77,6 +77,11 @@ export const docsConfig: DocsConfig = {href: '/docs/components/fragment-components',items: [],},+ {+ title: 'Admonition',+ href: '/docs/fragments/admonition',+ items: [],+ },{title: 'Text Confirm Dialog',href: '/docs/fragments/text-confirm-dialog',diff --git a/apps/design-system/content/docs/components/form.mdx b/apps/design-system/content/docs/components/form.mdxindex f69cff23052..a70a79c0974 100644--- a/apps/design-system/content/docs/components/form.mdx+++ b/apps/design-system/content/docs/components/form.mdx@@ -54,6 +54,11 @@ The `<Form />` component is a wrapper around the `react-hook-form` library. It p</Form>```+<Admonition title="Please use FormLabel component.">+ **Do not** use the standard [Label](/design-system/docs/components/label) component inside Form+ components.+</Admonition>+## Example```tsxdiff --git a/apps/design-system/content/docs/components/label.mdx b/apps/design-system/content/docs/components/label.mdxindex c2d59c1a998..8b13a43f94b 100644--- a/apps/design-system/content/docs/components/label.mdx+++ b/apps/design-system/content/docs/components/label.mdx@@ -12,50 +12,21 @@ source:<ComponentPreview name="label-demo" peekCode wide />-## Installation+<Admonition+ variant="warning"+ title="Do not use this Label component in a Form"+>-<Tabs defaultValue="cli">+Please use [FormLabel](/design-system/docs/components/form#anatomy) if you are using [Form](/design-system/docs/components/form) based components.-<TabsList>- <TabsTrigger value="cli">CLI</TabsTrigger>- <TabsTrigger value="manual">Manual</TabsTrigger>-</TabsList>-<TabsContent value="cli">--```bash-npx shadcn-ui@latest add label-```--</TabsContent>--<TabsContent value="manual">--<Steps>--<Step>Install the following dependencies:</Step>--```bash-npm install @radix-ui/react-label-```--<Step>Copy and paste the following code into your project.</Step>--<ComponentSource name="label" />--<Step>Update the import paths to match your project setup.</Step>--</Steps>--</TabsContent>--</Tabs>+</Admonition>## Usage```tsx-import { Label } from '@/components/ui/label'+import { Label_Shadcn_ } from '@/components/ui/label'``````tsx-<Label htmlFor="email">Your email address</Label>+<Label_Shadcn_ htmlFor="email">Your email address</Label_Shadcn_>```diff --git a/apps/design-system/content/docs/fragments/admonition.mdx b/apps/design-system/content/docs/fragments/admonition.mdxnew file mode 100644index 00000000000..5df52e91ceb--- /dev/null+++ b/apps/design-system/content/docs/fragments/admonition.mdx@@ -0,0 +1,45 @@+---+title: Admonition+description: Displays a callout for user attention.+fragment: true+links:+ doc: https://www.radix-ui.com/docs/primitives/components/alert+ api: https://www.radix-ui.com/docs/primitives/components/alert#api-reference+---++<ComponentPreview+ name="admonition-demo"+ className="[&_.preview>[data-orientation=vertical]]:sm:max-w-[70%]"+ peekCode+ wide+/>++## Usage++```tsx+import { Admonition } from 'ui-patterns/admonition'+```++```tsx+<Admonition+ type="default"+ title="Is it accessible?"+ description="Yes. It adheres to the WAI-ARIA design pattern."+/>+```++## Examples++### Warning++<ComponentPreview+ name="admonition-warning"+ className="[&_.preview>[data-orientation=vertical]]:sm:max-w-[70%]"+/>++### Destructive++<ComponentPreview+ name="admonition-destructive"+ className="[&_.preview>[data-orientation=vertical]]:sm:max-w-[70%]"+/>diff --git a/apps/design-system/registry/default/example/admonition-demo.tsx b/apps/design-system/registry/default/example/admonition-demo.tsxnew file mode 100644index 00000000000..77c15eea02c--- /dev/null+++ b/apps/design-system/registry/default/example/admonition-demo.tsx@@ -0,0 +1,11 @@+import { Admonition } from 'ui-patterns/admonition'++export default function AdmonitionDemo() {+ return (+ <Admonition+ type="default"+ title="Is it accessible?"+ description="Yes. It adheres to the WAI-ARIA design pattern."+ />+ )+}diff --git a/apps/design-system/registry/default/example/admonition-destructive.tsx b/apps/design-system/registry/default/example/admonition-destructive.tsxnew file mode 100644index 00000000000..261ac5e9b32--- /dev/null+++ b/apps/design-system/registry/default/example/admonition-destructive.tsx@@ -0,0 +1,11 @@+import { Admonition } from 'ui-patterns/admonition'++export default function AdmonitionDestructive() {+ return (+ <Admonition+ type="destructive"+ title="This is a destructive admonition"+ description="This is a destructive admonition description."+ />+ )+}diff --git a/apps/design-system/registry/default/example/admonition-warning.tsx b/apps/design-system/registry/default/example/admonition-warning.tsxnew file mode 100644index 00000000000..0c50b1c174c--- /dev/null+++ b/apps/design-system/registry/default/example/admonition-warning.tsx@@ -0,0 +1,11 @@+import { Admonition } from 'ui-patterns/admonition'++export default function AdmonitionWarning() {+ return (+ <Admonition+ type="warning"+ title="This is a warning"+ description="This is a warning description."+ />+ )+}diff --git a/apps/design-system/registry/examples.ts b/apps/design-system/registry/examples.tsindex a55270130a5..2987c0a1034 100644--- a/apps/design-system/registry/examples.ts+++ b/apps/design-system/registry/examples.ts@@ -7,6 +7,24 @@ export const examples: Registry = [registryDependencies: ['accordion'],files: ['example/accordion-demo.tsx'],},+ {+ name: 'admonition-demo',+ type: 'components:example',+ registryDependencies: ['admonition'],+ files: ['example/admonition-demo.tsx'],+ },+ {+ name: 'admonition-warning',+ type: 'components:example',+ registryDependencies: ['admonition'],+ files: ['example/admonition-warning.tsx'],+ },+ {+ name: 'admonition-destructive',+ type: 'components:example',+ registryDependencies: ['admonition'],+ files: ['example/admonition-destructive.tsx'],+ },{name: 'alert-demo',type: 'components:example',diff --git a/apps/docs/components/AppleSecretGenerator/AppleSecretGenerator.tsx b/apps/docs/components/AppleSecretGenerator/AppleSecretGenerator.tsxindex 4029b1d8770..97941f86b6b 100644--- a/apps/docs/components/AppleSecretGenerator/AppleSecretGenerator.tsx+++ b/apps/docs/components/AppleSecretGenerator/AppleSecretGenerator.tsx@@ -1,5 +1,6 @@import { useState } from 'react'-import { Admonition, Button, Input } from 'ui'+import { Button, Input } from 'ui'+import { Admonition } from 'ui-patterns/admonition'function base64URL(value: string) {return globalThis.btoa(value).replace(/[=]/g, '').replace(/[+]/g, '-').replace(/[\/]/g, '_')diff --git a/apps/docs/components/AuthSmsProviderConfig/AuthSmsProviderConfig.Warnings.tsx b/apps/docs/components/AuthSmsProviderConfig/AuthSmsProviderConfig.Warnings.tsxindex 23801c33a0c..4043d3432e6 100644--- a/apps/docs/components/AuthSmsProviderConfig/AuthSmsProviderConfig.Warnings.tsx+++ b/apps/docs/components/AuthSmsProviderConfig/AuthSmsProviderConfig.Warnings.tsx@@ -1,5 +1,5 @@import Link from 'next/link'-import { Admonition } from 'ui'+import { Admonition } from 'ui-patterns/admonition'const CostWarning = () => (<Admonition type="warning">diff --git a/apps/docs/components/reference/OldVersionAlert.tsx b/apps/docs/components/reference/OldVersionAlert.tsxindex 6e20ebf1009..993dbd0fb4d 100644--- a/apps/docs/components/reference/OldVersionAlert.tsx+++ b/apps/docs/components/reference/OldVersionAlert.tsx@@ -1,6 +1,6 @@import Link from 'next/link'import { useRouter } from 'next/router'-import { Admonition } from 'ui'+import { Admonition } from 'ui-patterns/admonition'import { useMenuActiveRefId } from '~/hooks/useMenuState'import { ICommonSection } from './Reference.types'diff --git a/apps/studio/components/interfaces/Organization/NewProject/FreeProjectLimitWarning.tsx b/apps/studio/components/interfaces/Organization/NewProject/FreeProjectLimitWarning.tsxindex 3ce18b3a6ef..4e27eb868a0 100644--- a/apps/studio/components/interfaces/Organization/NewProject/FreeProjectLimitWarning.tsx+++ b/apps/studio/components/interfaces/Organization/NewProject/FreeProjectLimitWarning.tsx@@ -1,5 +1,6 @@import Link from 'next/link'-import { Admonition, Button, IconAlertCircle } from 'ui'+import { Button, IconAlertCircle } from 'ui'+import { Admonition } from 'ui-patterns/admonition'import InformationBox from 'components/ui/InformationBox'import type { MemberWithFreeProjectLimit } from 'data/organizations/free-project-limit-check-query'diff --git a/packages/ui-patterns/Dialogs/ConfirmationModal.tsx b/packages/ui-patterns/Dialogs/ConfirmationModal.tsxindex c575c4c9d84..4ed5633bf51 100644--- a/packages/ui-patterns/Dialogs/ConfirmationModal.tsx+++ b/packages/ui-patterns/Dialogs/ConfirmationModal.tsx@@ -2,7 +2,6 @@import { MouseEventHandler, forwardRef, useEffect, useState } from 'react'import {- Admonition,Alert_Shadcn_,Button,Dialog,@@ -12,6 +11,7 @@ import {DialogTitle,cn,} from 'ui'+import { Admonition } from './../admonition'import { DialogHeader } from 'ui/src/components/shadcn/ui/dialog'export interface ConfirmationModalProps {diff --git a/packages/ui-patterns/Dialogs/TextConfirmModal.tsx b/packages/ui-patterns/Dialogs/TextConfirmModal.tsxindex 65c59663b89..bfbb61eeda0 100644--- a/packages/ui-patterns/Dialogs/TextConfirmModal.tsx+++ b/packages/ui-patterns/Dialogs/TextConfirmModal.tsx@@ -4,7 +4,6 @@ import { zodResolver } from '@hookform/resolvers/zod'import { ReactNode, forwardRef, useEffect } from 'react'import { useForm } from 'react-hook-form'import {- Admonition,Alert_Shadcn_,Button,Dialog,@@ -22,6 +21,7 @@ import {Input_Shadcn_,cn,} from 'ui'+import { Admonition } from './../admonition'import { DialogHeader } from 'ui/src/components/shadcn/ui/dialog'import { z } from 'zod'diff --git a/packages/ui/src/components/Admonition/index.tsx b/packages/ui-patterns/admonition.tsxsimilarity index 70%rename from packages/ui/src/components/Admonition/index.tsxrename to packages/ui-patterns/admonition.tsxindex 158f272de21..225e414a45b 100644--- a/packages/ui/src/components/Admonition/index.tsx+++ b/packages/ui-patterns/admonition.tsx@@ -1,7 +1,7 @@import { cva } from 'class-variance-authority'import React, { forwardRef } from 'react'-import { cn } from '../../lib/utils/cn'-import { Alert, AlertDescription, AlertTitle } from './../shadcn/ui/alert'+import { cn } from 'ui/src/lib/utils/cn'+import { Alert, AlertDescription, AlertTitle } from 'ui/src/components/shadcn/ui/alert'export interface AdmonitionProps {type:@@ -16,6 +16,7 @@ export interface AdmonitionProps {label?: stringtitle?: stringdescription?: string | React.ReactNode+ showIcon?: boolean}const admonitionToAlertMapping: Record<@@ -75,7 +76,7 @@ const admonitionSVG = cva('', {const admonitionBase = cva('', {variants: {type: {- default: `bg-surface-200/25 border`,+ default: `bg-surface-200/25 border border-default`,warning: `bg-alternative border border-default ![&_p]:text-background-muted`,destructive: `bg-alternative border border-default`,},@@ -85,43 +86,54 @@ const admonitionBase = cva('', {export const Admonition = forwardRef<React.ElementRef<typeof Alert>,React.ComponentPropsWithoutRef<typeof Alert> & AdmonitionProps->(({ type = 'note', label, title, description, children, ...props }, ref) => {- const typeMapped = admonitionToAlertMapping[type]+>(+ (+ { type = 'note', variant, showIcon = true, label, title, description, children, ...props },+ ref+ ) => {+ const typeMapped = variant ? admonitionToAlertMapping[variant] : admonitionToAlertMapping[type]- return (- <Alert- ref={ref}- variant={typeMapped}- {...props}- className={cn(- 'mb-2',- admonitionSVG({ type: typeMapped }),- admonitionBase({ type: typeMapped }),- props.className- )}- >- {typeMapped === 'warning' || typeMapped === 'destructive' ? <WarningIcon /> : <InfoIcon />}- {label || title ? (- <>- <AlertTitle- className={cn(- 'text mt-0.5 flex gap-3 text-sm [&_p]:mb-1.5 [&_p]:mt-0',- !label && 'flex-col'+ return (+ <Alert+ ref={ref}+ variant={typeMapped}+ {...props}+ className={cn(+ 'mb-2',+ admonitionSVG({ type: typeMapped }),+ admonitionBase({ type: typeMapped }),+ props.className+ )}+ >+ {(showIcon && typeMapped === 'warning') || typeMapped === 'destructive' ? (+ <WarningIcon />+ ) : (+ <InfoIcon />+ )}+ {label || title ? (+ <>+ <AlertTitle+ className={cn(+ 'text mt-0.5 flex gap-3 text-sm [&_p]:mb-1.5 [&_p]:mt-0',+ !label && 'flex-col'+ )}+ >+ {label || title}+ </AlertTitle>+ {description && <AlertDescription>{description}</AlertDescription>}+ {/* // children is to handle Docs and MDX issues with children and <p> elements */}+ {children && (+ <AlertDescription className="mt-3 [&_p]:mb-1.5 [&_p]:mt-0">+ {children}+ </AlertDescription>)}- >- {label || title}- </AlertTitle>- {description && <AlertDescription>{description}</AlertDescription>}- {/* // children is to handle Docs and MDX issues with children and <p> elements */}- {children && (- <AlertDescription className="mt-3 [&_p]:mb-1.5 [&_p]:mt-0">{children}</AlertDescription>- )}- </>- ) : (- <div className="text mt [&_p]:mb-1.5 [&_p]:mt-0 mt-0.5 [&_p:last-child]:mb-0">- {children}- </div>- )}- </Alert>- )-})+ </>+ ) : (+ <div className="text mt [&_p]:mb-1.5 [&_p]:mt-0 mt-0.5 [&_p:last-child]:mb-0">+ {children}+ </div>+ )}+ </Alert>+ )+ }+)diff --git a/packages/ui-patterns/index.tsx b/packages/ui-patterns/index.tsxindex 4de370e84c1..f051cc56bbd 100644--- a/packages/ui-patterns/index.tsx+++ b/packages/ui-patterns/index.tsx@@ -19,3 +19,4 @@ export * from './Dialogs/ConfirmationModal'export * from './AssistantChat/AssistantChatForm'export * from './AssistantChat/AssistantCommandsPopover'export * from './SqlToRest'+export * from './admonition'diff --git a/packages/ui/index.tsx b/packages/ui/index.tsxindex fe135421128..13c571b5d67 100644--- a/packages/ui/index.tsx+++ b/packages/ui/index.tsx@@ -4,7 +4,7 @@ export * from './src/lib/Markdown'// GENERAL-export * from './src/components/Admonition'+export * from 'ui-patterns/admonition'export * from './src/components/Button'export * from './src/components/Icon'export * from './src/components/Icon/IconContext'