diff --git a/apps/design-system/__registry__/index.tsx b/apps/design-system/__registry__/index.tsx index b442e4c0ecc..9a7bdddcb15 100644 --- a/apps/design-system/__registry__/index.tsx +++ b/apps/design-system/__registry__/index.tsx @@ -192,13 +192,13 @@ export const Index: Record = { subcategory: "undefined", chunks: [] }, - "alert-collapsible-demo": { - name: "alert-collapsible-demo", + "collapsible-alert-demo": { + name: "collapsible-alert-demo", type: "components:example", - registryDependencies: ["alert","collapsible","button"], - component: React.lazy(() => import("@/registry/default/example/alert-collapsible-demo")), + registryDependencies: ["collapsible-alert"], + component: React.lazy(() => import("@/registry/default/example/collapsible-alert-demo")), source: "", - files: ["registry/default/example/alert-collapsible-demo.tsx"], + files: ["registry/default/example/collapsible-alert-demo.tsx"], category: "undefined", subcategory: "undefined", chunks: [] diff --git a/apps/design-system/config/docs.ts b/apps/design-system/config/docs.ts index ced6685f7aa..6cc07a6d0cb 100644 --- a/apps/design-system/config/docs.ts +++ b/apps/design-system/config/docs.ts @@ -117,6 +117,11 @@ export const docsConfig: DocsConfig = { href: '/docs/fragments/admonition', items: [], }, + { + title: 'Collapsible Alert', + href: '/docs/fragments/collapsible-alert', + items: [], + }, { title: 'Assistant Chat', href: '/docs/fragments/assistant-chat', diff --git a/apps/design-system/content/docs/components/alert.mdx b/apps/design-system/content/docs/components/alert.mdx index 3204cf452e8..f5c277e7c21 100644 --- a/apps/design-system/content/docs/components/alert.mdx +++ b/apps/design-system/content/docs/components/alert.mdx @@ -1,29 +1,24 @@ --- title: Alert -description: Displays a callout for user attention. +description: Displays a low-level callout primitive for user attention. component: true source: radix: true shadcn: true --- -Alert forms the core primitives for [Admonition](../fragments/admonition). Use the Admonition component unless you must deviate from our consistent patterns. Examples where Alert might make sense include: +Alert is the low-level shadcn primitive that forms the foundation for [Admonition](../fragments/admonition). Use Admonition for product callouts unless you need custom composition that the Admonition API does not support. -- Bespoke icon requirement -- Highly custom internal contents +Examples where Alert may be appropriate include bespoke icons, custom internal layouts, or wrapper components that need direct access to `alertVariants`. + +Use [Collapsible Alert](../fragments/collapsible-alert) when a callout also needs expandable detail. Use [Collapsible](./collapsible) only for generic disclosure behaviour that is not itself an alert. -## Installation - -```bash -npx shadcn-ui@latest add alert -``` - ## Usage ```tsx -import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert' +import { Alert, AlertDescription, AlertTitle } from 'ui/src/components/shadcn/ui/alert' ``` ```tsx @@ -35,3 +30,11 @@ import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert' ``` + +### Variants + +Use `alertVariants` when building shared wrappers around the primitive. + +```tsx +import { alertVariants } from 'ui/src/components/shadcn/ui/alert' +``` diff --git a/apps/design-system/content/docs/components/collapsible.mdx b/apps/design-system/content/docs/components/collapsible.mdx index d581612ebac..7eb271478ed 100644 --- a/apps/design-system/content/docs/components/collapsible.mdx +++ b/apps/design-system/content/docs/components/collapsible.mdx @@ -1,37 +1,51 @@ --- -title: Alert Collapsible -description: An alert-styled block with a collapsible content section, toggled by an icon button. +title: Collapsible +description: An expandable content region using the shadcn Collapsible primitive. component: true --- - +Collapsible is a low-level primitive for revealing and hiding related content. Use it when a component needs custom trigger or content composition. + +Use Collapsible for generic disclosure behaviour: rows, sections, menus, tool details, and custom layouts. Use [Collapsible Alert](../fragments/collapsible-alert) instead when the disclosure is an alert-styled callout that should keep standard alert padding, variants, trigger styling, and toggle treatment. + + ## Usage ```tsx -import { AlertCollapsible } from 'ui' +import { + Collapsible, + CollapsibleContent, + CollapsibleTrigger, +} from 'ui/src/components/shadcn/ui/collapsible' ``` ```tsx - -

Content revealed when expanded.

-
+ + Toggle + +

Content revealed when expanded.

+
+
``` ### Default open ```tsx - -

This section is expanded by default.

-
+ + Details + +

This section is expanded by default.

+
+
``` -### Variants +### Animation -Supports the same `variant` prop as `Alert`: `default`, `destructive`, and `warning`. +Add animation classes to `CollapsibleContent` when animated open and close transitions are needed. ```tsx - -

Something needs attention.

-
+ +

Content revealed when expanded.

+
``` diff --git a/apps/design-system/content/docs/fragments/admonition.mdx b/apps/design-system/content/docs/fragments/admonition.mdx index c0adf6a7803..afbb2230391 100644 --- a/apps/design-system/content/docs/fragments/admonition.mdx +++ b/apps/design-system/content/docs/fragments/admonition.mdx @@ -4,7 +4,7 @@ description: Displays a callout for user attention. fragment: true --- -Admonition provides focus for situations that require a callout. +Admonition provides the standard product callout pattern for situations that require user attention. -Use Admonition instead of [Alert](../components/alert) unless you specifically need the primitives. If in doubt, stick with Admonition. +Use Admonition instead of the low-level [Alert](../components/alert) primitive unless you specifically need custom composition. If in doubt, stick with Admonition. + +Use [Collapsible Alert](./collapsible-alert) when the callout needs to remain visible while optional detail can be expanded. Use [Collapsible](../components/collapsible) for generic disclosure behaviour that is not itself a callout. Use `title` for the heading slot when the callout needs its own heading. `title` is optional: short callouts may use `description` without a title when nearby content already provides enough context. diff --git a/apps/design-system/content/docs/fragments/collapsible-alert.mdx b/apps/design-system/content/docs/fragments/collapsible-alert.mdx new file mode 100644 index 00000000000..5cae9a4934f --- /dev/null +++ b/apps/design-system/content/docs/fragments/collapsible-alert.mdx @@ -0,0 +1,43 @@ +--- +title: Collapsible Alert +description: An alert-styled block with a collapsible content section, toggled by an icon button. +fragment: true +--- + +Collapsible Alert combines an Alert-style container with a collapsible content section. Use it when the callout itself needs to stay visible while optional detail can be expanded. + +Use Collapsible Alert when the disclosure is itself a callout. It owns the alert styling, padding, trigger treatment, and toggle button. Use [Collapsible](../components/collapsible) instead when you only need generic reveal and hide behaviour and the surrounding layout is not an alert. + +For non-expandable product callouts, use [Admonition](./admonition). Use the low-level [Alert](../components/alert) primitive only when a wrapper or bespoke composition needs direct control over the alert structure. + + + +## Usage + +```tsx +import { CollapsibleAlert } from 'ui-patterns/collapsible-alert' +``` + +```tsx + +

Content revealed when expanded.

+
+``` + +### Default open + +```tsx + +

This section is expanded by default.

+
+``` + +### Variants + +Supports the same `variant` prop as Alert: `default`, `destructive`, and `warning`. + +```tsx + +

Something needs attention.

+
+``` diff --git a/apps/design-system/registry/default/example/alert-collapsible-demo.tsx b/apps/design-system/registry/default/example/alert-collapsible-demo.tsx deleted file mode 100644 index 0aa7671fedd..00000000000 --- a/apps/design-system/registry/default/example/alert-collapsible-demo.tsx +++ /dev/null @@ -1,11 +0,0 @@ -import { AlertCollapsible } from 'ui' - -export default function AlertCollapsibleDemo() { - return ( - -

- Try a different browser or disable extensions that block network requests. -

-
- ) -} diff --git a/apps/design-system/registry/default/example/alert-demo.tsx b/apps/design-system/registry/default/example/alert-demo.tsx index cbb9ce1b70e..5618d1c845f 100644 --- a/apps/design-system/registry/default/example/alert-demo.tsx +++ b/apps/design-system/registry/default/example/alert-demo.tsx @@ -1,14 +1,12 @@ import { Terminal } from 'lucide-react' -import { Alert_Shadcn_, AlertDescription_Shadcn_, AlertTitle_Shadcn_ } from 'ui' +import { Alert, AlertDescription, AlertTitle } from 'ui/src/components/shadcn/ui/alert' export default function AlertDemo() { return ( - + - Heads up! - - You can also add components to your app using the CLI. - - + Heads up! + You can also add components to your app using the CLI. + ) } diff --git a/apps/design-system/registry/default/example/collapsible-alert-demo.tsx b/apps/design-system/registry/default/example/collapsible-alert-demo.tsx new file mode 100644 index 00000000000..96cb3e30324 --- /dev/null +++ b/apps/design-system/registry/default/example/collapsible-alert-demo.tsx @@ -0,0 +1,11 @@ +import { CollapsibleAlert } from 'ui-patterns/collapsible-alert' + +export default function CollapsibleAlertDemo() { + return ( + +

+ Try a different browser or disable extensions that block network requests. +

+
+ ) +} diff --git a/apps/design-system/registry/default/example/collapsible-demo.tsx b/apps/design-system/registry/default/example/collapsible-demo.tsx index 5e569b1a35f..a5a5b556bbb 100644 --- a/apps/design-system/registry/default/example/collapsible-demo.tsx +++ b/apps/design-system/registry/default/example/collapsible-demo.tsx @@ -1,33 +1,33 @@ 'use client' -import { ChevronsUpDown, Plus, X } from 'lucide-react' +import { ChevronsUpDown } from 'lucide-react' import * as React from 'react' +import { Button } from 'ui' import { - Button, - Collapsible_Shadcn_, - CollapsibleContent_Shadcn_, - CollapsibleTrigger_Shadcn_, -} from 'ui' + Collapsible, + CollapsibleContent, + CollapsibleTrigger, +} from 'ui/src/components/shadcn/ui/collapsible' export default function CollapsibleDemo() { const [isOpen, setIsOpen] = React.useState(false) return ( - +

@peduarte starred 3 repositories

- + - +
@radix-ui/primitives
- +
@radix-ui/colors
@stitches/react
-
-
+ + ) } diff --git a/apps/design-system/registry/examples.ts b/apps/design-system/registry/examples.ts index d5f9a19ae22..4c363b3ece2 100644 --- a/apps/design-system/registry/examples.ts +++ b/apps/design-system/registry/examples.ts @@ -62,10 +62,10 @@ export const examples: Registry = [ files: ['example/alert-demo.tsx'], }, { - name: 'alert-collapsible-demo', + name: 'collapsible-alert-demo', type: 'components:example', - registryDependencies: ['alert', 'collapsible', 'button'], - files: ['example/alert-collapsible-demo.tsx'], + registryDependencies: ['collapsible-alert'], + files: ['example/collapsible-alert-demo.tsx'], }, { name: 'alert-dialog-demo', diff --git a/apps/studio/components/interfaces/SignIn/SessionTimeoutModal.tsx b/apps/studio/components/interfaces/SignIn/SessionTimeoutModal.tsx index 5261078adb4..47ed100e959 100644 --- a/apps/studio/components/interfaces/SignIn/SessionTimeoutModal.tsx +++ b/apps/studio/components/interfaces/SignIn/SessionTimeoutModal.tsx @@ -3,7 +3,6 @@ import { SupportCategories } from '@supabase/shared-types/out/constants' import { useEffect } from 'react' import { toast } from 'sonner' import { - AlertCollapsible, AlertDialog, AlertDialogAction, AlertDialogCancel, @@ -14,6 +13,7 @@ import { AlertDialogTitle, Button, } from 'ui' +import { CollapsibleAlert } from 'ui-patterns/collapsible-alert' import { SupportLink } from '../Support/SupportLink' import { InlineLink, InlineLinkClassName } from '@/components/ui/InlineLink' @@ -61,7 +61,7 @@ export const SessionTimeoutModal = ({

Please sign in again to continue.

- +

Try a different browser or disable extensions that block network requests. If @@ -93,7 +93,7 @@ export const SessionTimeoutModal = ({ from your session to help us investigate.

-
+
diff --git a/packages/ui-patterns/package.json b/packages/ui-patterns/package.json index ec08d6fc7ae..b1a9707d003 100644 --- a/packages/ui-patterns/package.json +++ b/packages/ui-patterns/package.json @@ -714,6 +714,10 @@ "import": "./src/consent.tsx", "types": "./src/consent.tsx" }, + "./collapsible-alert": { + "import": "./src/collapsible-alert.tsx", + "types": "./src/collapsible-alert.tsx" + }, "./form/FormItemLayout/FormItemLayout": { "import": "./src/form/FormItemLayout/FormItemLayout.tsx", "types": "./src/form/FormItemLayout/FormItemLayout.tsx" diff --git a/packages/ui/src/components/AlertCollapsible/AlertCollapsible.tsx b/packages/ui-patterns/src/collapsible-alert.tsx similarity index 74% rename from packages/ui/src/components/AlertCollapsible/AlertCollapsible.tsx rename to packages/ui-patterns/src/collapsible-alert.tsx index e5e6121b105..08cd030f659 100644 --- a/packages/ui/src/components/AlertCollapsible/AlertCollapsible.tsx +++ b/packages/ui-patterns/src/collapsible-alert.tsx @@ -3,19 +3,21 @@ import { type VariantProps } from 'class-variance-authority' import { ChevronDown } from 'lucide-react' import * as React from 'react' +import { Button, cn } from 'ui' +import { alertVariants } from 'ui/src/components/shadcn/ui/alert' +import { + Collapsible, + CollapsibleContent, + CollapsibleTrigger, +} from 'ui/src/components/shadcn/ui/collapsible' -import { cn } from '../../lib/utils/cn' -import { Button } from '../Button' -import { alertVariants } from '../shadcn/ui/alert' -import { Collapsible, CollapsibleContent, CollapsibleTrigger } from '../shadcn/ui/collapsible' - -export interface AlertCollapsibleProps +export interface CollapsibleAlertProps extends Omit, 'title'>, VariantProps { trigger: React.ReactNode defaultOpen?: boolean } -const AlertCollapsible = React.forwardRef( +const CollapsibleAlert = React.forwardRef( ({ className, variant = 'default', trigger, defaultOpen, children, ...props }, ref) => (
) ) -AlertCollapsible.displayName = 'AlertCollapsible' +CollapsibleAlert.displayName = 'CollapsibleAlert' -export { AlertCollapsible } +export { CollapsibleAlert } diff --git a/packages/ui/index.tsx b/packages/ui/index.tsx index 64c2f69be09..75363347fc0 100644 --- a/packages/ui/index.tsx +++ b/packages/ui/index.tsx @@ -107,8 +107,6 @@ export { AlertDescription as AlertDescription_Shadcn_, } from './src/components/shadcn/ui/alert' -export * from './src/components/AlertCollapsible' - export { Field as Field_Shadcn_, FieldContent as FieldContent_Shadcn_, diff --git a/packages/ui/src/components/AlertCollapsible/index.tsx b/packages/ui/src/components/AlertCollapsible/index.tsx deleted file mode 100644 index a86ab1afc90..00000000000 --- a/packages/ui/src/components/AlertCollapsible/index.tsx +++ /dev/null @@ -1,2 +0,0 @@ -export { AlertCollapsible } from './AlertCollapsible' -export type { AlertCollapsibleProps } from './AlertCollapsible'