diff --git a/apps/design-system/registry/default/example/admonition-responsive.tsx b/apps/design-system/registry/default/example/admonition-responsive.tsx index 2e488553f54..524ea8ec715 100644 --- a/apps/design-system/registry/default/example/admonition-responsive.tsx +++ b/apps/design-system/registry/default/example/admonition-responsive.tsx @@ -8,7 +8,12 @@ export default function AdmonitionDemo() { layout="responsive" title="Disk management has moved" description="Disk management is now handled alongside Project Compute on the Compute and Disk page." - actions={} + actions={ + <> + + + + } /> ) } diff --git a/packages/ui-patterns/src/Admonition/Admonition.tsx b/packages/ui-patterns/src/Admonition/Admonition.tsx index a7f3f6ba2ab..6f6b68646e5 100644 --- a/packages/ui-patterns/src/Admonition/Admonition.tsx +++ b/packages/ui-patterns/src/Admonition/Admonition.tsx @@ -1,5 +1,5 @@ -import { forwardRef } from 'react' -import { Alert, AlertDescription, AlertTitle, cn } from 'ui' +import { Children, forwardRef, Fragment, isValidElement, type ReactNode } from 'react' +import { Alert, AlertDescription, AlertTitle, cn, FloatingPlate } from 'ui' import { TYPE_LABEL, TYPE_TO_VARIANT } from './Admonition.constants' import type { AdmonitionLayout, AdmonitionProps, AdmonitionType } from './Admonition.types' @@ -15,6 +15,25 @@ const admonitionBodyClassName = [ '[&_ul>li]:relative [&_ul>li]:before:absolute [&_ul>li]:before:left-[-1rem] [&_ul>li]:before:top-2.5 [&_ul>li]:before:h-0.5 [&_ul>li]:before:w-2 [&_ul>li]:before:rounded [&_ul>li]:before:bg-border-strong [&_ul>li]:before:content-[""]', ].join(' ') +const ActionPlates = ({ children, layout }: { children: ReactNode; layout: AdmonitionLayout }) => + Children.map(children, (action) => { + if (action === null || action === undefined) return null + if (isValidElement<{ children?: ReactNode }>(action) && action.type === Fragment) { + return {action.props.children} + } + return ( + .w-full]:w-full', + layout === 'responsive' && 'has-[>.w-full]:w-full @lg:has-[>.w-full]:w-auto' + )} + > + {action} + + ) + }) + export const Admonition = forwardRef< React.ComponentRef, Omit< @@ -114,7 +133,7 @@ export const Admonition = forwardRef< layout === 'responsive' && 'mt-3 items-start @md:mt-0 @md:items-center' )} > - {actions} + {actions} )}