Files
supabase/apps/docs/features/directives/Show.test.ts
T
Saxon FletcherandDanny White cd77bebafd chore(ui): refresh shared button styles (#50197)
## What kind of change does this PR introduce?

UI polish / design system: refreshed button styles, related token
tweaks, and a shared floating-button plate.

Resolves DEPR-652.

## What is the current behavior?

Default, primary, and secondary buttons use older fills, borders, and
hover treatments. Primary still leans on brand scale utilities. Default
fills don’t always read as raised chrome across surfaces, and floating
copy / expand / scroll controls can let busy content show through
translucent fills. Call sites hand-roll `rounded-* bg-background`
wrappers for that.

## What is the new behavior?

Refreshes primary, default, and secondary buttons with medium-weight
labels, subtle shadows and inset edges, and smoother transitions.
Light-mode default buttons use a raised fill with an accent hover state,
primary text is brighter, and inline keyboard shortcuts inherit the
button’s colour.

Adds `FloatingPlate`: an opaque `bg-popover` shell for floating default
buttons (and small clusters). Migrates Studio, Docs-related patterns,
www, and `ui-patterns` floaters onto it so busy content no longer shows
through translucent fills. Positioning, z-index, and hover/focus reveal
stay on the plate’s `className`. Use `rounded="full"` for pills.

Also:

- Moves primary onto semantic `--primary` / `--primary-hover` (with a
light-theme override) instead of brand utility fills
- Tokenises button shadows as `--button-shadow-drop` /
`--button-shadow-raised` / `--button-shadow-default` on the Button base
- Aligns hover direction: darken on light mode, lighten on dark mode for
both default and primary
- Default fill stays opaque `bg-card` in light (occlusion) and
translucent `bg-muted` in dark (adapts to the local surface)
- Documents fills and `FloatingPlate` on the design-system Button page
(with a live example)
- Scales shared radius tokens in Studio and www; medium+ Button sizes
use a proportionally softer radius
- Fixes www nav CTA centering (`lg:inline-flex` instead of `lg:block`)
- Query detail Expand/Collapse wires `aria-expanded` / `aria-controls`

| Before | After |
| --- | --- |
| <img width="1074" height="438" alt="CleanShot 2026-09-18 at 15 52
51@2x"
src="https://github.com/user-attachments/assets/ef43da21-b053-4b7e-9ac4-ab8b428228ab"
/> | <img width="1090" height="464" alt="CleanShot 2026-09-18 at 15 50
59@2x"
src="https://github.com/user-attachments/assets/2ddc55fc-4c8d-499c-a280-f3db3d99023c"
/> |
| <img width="1082" height="446" alt="CleanShot 2026-09-18 at 15 52
35@2x"
src="https://github.com/user-attachments/assets/3dd5452d-325a-4e4a-a79d-26c6c6950a31"
/> | <img width="1078" height="446" alt="CleanShot 2026-09-18 at 15 51
13@2x"
src="https://github.com/user-attachments/assets/93666385-3e6e-42e0-9891-9cd6bb935b67"
/> |

## To test

### Design system

- [Button
page](https://design-system-git-chore-button-styles-supabase.vercel.app/design-system/docs/components/button):
default / primary in light and dark; hover should darken on light,
lighten on dark
- Same page: [Floating over
content](https://design-system-git-chore-button-styles-supabase.vercel.app/design-system/docs/components/button#floating-over-content)
/ [Floating
plate](https://design-system-git-chore-button-styles-supabase.vercel.app/design-system/docs/components/button#floating-plate)
example; Copy over SQL should stay opaque
- Spot-check hover on a code preview Copy control

### Docs

[Docs deploy
preview](https://docs-git-chore-button-styles-supabase.vercel.app/docs):

- [Docs
homepage](https://docs-git-chore-button-styles-supabase.vercel.app/docs):
top-right **Sign up** / **Dashboard** primary; menu icon beside it
(default icon button)
- Shrink below `lg` and open the hamburger drawer: bottom **Sign in**
(default) + **Start your project** (primary) medium block buttons
- Tab once for **Skip to content** (FloatingPlate)
- [MCP
guide](https://docs-git-chore-button-styles-supabase.vercel.app/docs/guides/ai-tools/mcp):
project picker
- [Apple
login](https://docs-git-chore-button-styles-supabase.vercel.app/docs/guides/auth/social-login/auth-apple):
**Generate Secret Key** button in the Apple Secret Generator
- Optional opacity check: any guide code block Copy control (e.g. at the
bottom of [Import data into
Supabase](https://docs-git-chore-button-styles-supabase.vercel.app/docs/guides/database/import-data))

### Studio

[Studio deploy
preview](https://studio-staging-git-chore-button-styles-supabase.vercel.app/):

- **Observability → Query Performance**: open a query detail →
Expand/Collapse pill + SQL Copy chip (dark: no bleed-through)
- **Observability → Query Insights**: select a query → Clear query pill
- **Table Editor → any table → Definition** → floating **Open in SQL
Editor**
- **Connect → Framework → Add files**: Copy on the code tabs
(FloatingPlate; light hover follow-up is DEPR-694)
- Tab once for **Skip to content**

### WWW

- [www deploy
preview](https://zone-www-dot-com-git-chore-button-styles-supabase.vercel.app/):
nav Sign in / Start your project vertical centering; hero medium CTAs
radius

---------

Co-authored-by: Danny White <3104761+dnywh@users.noreply.github.com>
2026-09-23 03:43:00 +00:00

229 lines
5.4 KiB
TypeScript

import { type Feature } from 'common'
import { mdxToMarkdown } from 'mdast-util-mdx'
import { toMarkdown } from 'mdast-util-to-markdown'
import { afterEach, describe, expect, it, vi } from 'vitest'
import { showRemark } from './Show'
import { fromDocsMarkdown } from './utils.server'
// Mock the isFeatureEnabled function from common package
vi.mock('common/enabled-features', () => ({
isFeatureEnabled: vi.fn(),
}))
const { isFeatureEnabled } = await import('common/enabled-features')
describe('$Show', () => {
afterEach(() => {
vi.restoreAllMocks()
})
it('should keep children and remove $Show wrapper when feature is enabled', async () => {
vi.mocked(isFeatureEnabled).mockReturnValue(true)
const markdown = `
# Test content
<$Show if="test-feature">
This content should be visible when feature is enabled.
## A nested heading
Some more content.
</$Show>
Content after the show block.
`.trim()
const mdast = fromDocsMarkdown(markdown)
const transformed = showRemark()(mdast)
const output = toMarkdown(transformed, { extensions: [mdxToMarkdown()] })
const expected = `
# Test content
This content should be visible when feature is enabled.
## A nested heading
Some more content.
Content after the show block.
`.trimStart()
expect(output).toEqual(expected)
expect(isFeatureEnabled).toHaveBeenCalledWith('test-feature')
})
it('should keep children when negated feature is disabled', async () => {
vi.mocked(isFeatureEnabled).mockReturnValue(false)
const markdown = `
# Test content
<$Show if="!negated-feature">
This content should be visible when the feature is disabled.
## Additional content
More text that should remain.
</$Show>
Content after the show block.
`.trim()
const mdast = fromDocsMarkdown(markdown)
const transformed = showRemark()(mdast)
const output = toMarkdown(transformed, { extensions: [mdxToMarkdown()] })
const expected = `
# Test content
This content should be visible when the feature is disabled.
## Additional content
More text that should remain.
Content after the show block.
`.trimStart()
expect(output).toEqual(expected)
expect(isFeatureEnabled).toHaveBeenCalledWith('negated-feature')
})
it('should remove $Show block when negated feature is enabled', async () => {
vi.mocked(isFeatureEnabled).mockReturnValue(true)
const markdown = `
# Test content
<$Show if="!enabled-negated-feature">
This content should NOT be visible because the feature is enabled.
</$Show>
Content after the show block should remain.
`.trim()
const mdast = fromDocsMarkdown(markdown)
const transformed = showRemark()(mdast)
const output = toMarkdown(transformed, { extensions: [mdxToMarkdown()] })
const expected = `
# Test content
Content after the show block should remain.
`.trimStart()
expect(output).toEqual(expected)
expect(isFeatureEnabled).toHaveBeenCalledWith('enabled-negated-feature')
})
it('should handle multiple $Show blocks with different feature flags', async () => {
vi.mocked(isFeatureEnabled).mockImplementation((feature) => {
if (feature === ('enabled-feature' as Feature)) return true
return false
})
const markdown = `
# Test content
<$Show if="enabled-feature">
This should be visible.
</$Show>
<$Show if="disabled-feature">
This should be hidden.
</$Show>
<$Show if="another-disabled-feature">
This should also be hidden.
</$Show>
Final content.
`.trim()
const mdast = fromDocsMarkdown(markdown)
const transformed = showRemark()(mdast)
const output = toMarkdown(transformed, { extensions: [mdxToMarkdown()] })
const expected = `
# Test content
This should be visible.
Final content.
`.trimStart()
expect(output).toEqual(expected)
expect(isFeatureEnabled).toHaveBeenCalledWith('enabled-feature')
expect(isFeatureEnabled).toHaveBeenCalledWith('disabled-feature')
expect(isFeatureEnabled).toHaveBeenCalledWith('another-disabled-feature')
})
it('should handle nested $Show blocks correctly', async () => {
vi.mocked(isFeatureEnabled).mockImplementation((feature) => {
if (feature === ('outer-feature' as Feature)) return true
return false
})
const markdown = `
# Test content
<$Show if="outer-feature">
Outer content visible.
<$Show if="inner-feature">
Inner content should be hidden.
</$Show>
More outer content.
</$Show>
`.trim()
const mdast = fromDocsMarkdown(markdown)
const transformed = showRemark()(mdast)
const output = toMarkdown(transformed, { extensions: [mdxToMarkdown()] })
const expected = `
# Test content
Outer content visible.
More outer content.
`.trimStart()
expect(output).toEqual(expected)
expect(isFeatureEnabled).toHaveBeenCalledWith('outer-feature')
expect(isFeatureEnabled).toHaveBeenCalledWith('inner-feature')
})
it('should throw error when "if" attribute is missing', () => {
const markdown = `
<$Show>
Content without if attribute.
</$Show>
`.trim()
const mdast = fromDocsMarkdown(markdown)
expect(() => {
showRemark()(mdast)
}).toThrow('$Show directive requires a string value for the "if" attribute')
})
it('should throw error when "if" attribute is not a string', () => {
const markdown = `
<$Show if={true}>
Content with non-string if attribute.
</$Show>
`.trim()
const mdast = fromDocsMarkdown(markdown)
expect(() => {
showRemark()(mdast)
}).toThrow('$Show directive requires a string value for the "if" attribute')
})
})