mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 15:39:13 +00:00
fix(ui-patterns): keep admonition action surfaces opaque (#52348)
## Problem Default buttons inside Admonition actions are translucent in the following circumstances: - Light mode: button hover - Dark mode: static button This means they show the alert surface (yellow, red, grey, etc) unintentionally. ## Solution Give each independent action its own FloatingPlate, with transparent gaps between buttons. Explicit groups share one plate; fragments are flattened. Full-width groups retain responsive sizing, while single buttons stay snug. | Before | After | | --- | --- | | <img width="1510" height="256" alt="CleanShot 2026-10-27 at 15 32 14@2x" src="https://github.com/user-attachments/assets/2c1c285e-ffb3-4b26-a186-ce39a9b597b3" /> | <img width="1508" height="248" alt="CleanShot 2026-10-27 at 15 32 30@2x" src="https://github.com/user-attachments/assets/1cb86562-2227-4792-a60d-69dc1a06234d" /> | ## Review instructions 1. Open [Admonition examples](https://design-system-git-dnywh-fix-admonition-floating-plate-supabase.vercel.app/design-system/docs/fragments/admonition) and find the examples with action buttons. 2. Light mode: hover the default action buttons. 3. Dark mode: just compare against the [production design system](https://supabase.com/design-system/docs/fragments/admonition), statically. Notice the buttons retain their standard fill.
This commit is contained in:
1 parent
27602135da
commit
c5e45baff7
2 files changed
+28
-4
No files matched your search
@@ -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={<Button>Go to Compute and Disk</Button>}
|
||||
actions={
|
||||
<>
|
||||
<Button>Go to Compute and Disk</Button>
|
||||
<Button>Learn more</Button>
|
||||
</>
|
||||
}
|
||||
/>
|
||||
)
|
||||
}
|
||||
@@ -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 <ActionPlates layout={layout}>{action.props.children}</ActionPlates>
|
||||
}
|
||||
return (
|
||||
<FloatingPlate
|
||||
className={cn(
|
||||
'flex',
|
||||
layout === 'vertical' && 'has-[>.w-full]:w-full',
|
||||
layout === 'responsive' && 'has-[>.w-full]:w-full @lg:has-[>.w-full]:w-auto'
|
||||
)}
|
||||
>
|
||||
{action}
|
||||
</FloatingPlate>
|
||||
)
|
||||
})
|
||||
|
||||
export const Admonition = forwardRef<
|
||||
React.ComponentRef<typeof Alert>,
|
||||
Omit<
|
||||
@@ -114,7 +133,7 @@ export const Admonition = forwardRef<
|
||||
layout === 'responsive' && 'mt-3 items-start @md:mt-0 @md:items-center'
|
||||
)}
|
||||
>
|
||||
{actions}
|
||||
<ActionPlates layout={layout}>{actions}</ActionPlates>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user