Files
supabase/apps/docs/features/docs/MdxBase.shared.tsx
T
Anthony Lio 3d326d7644 feat(ui): prose table component (#51794)
## Problem

- docs and kb render markdown tables in different ways
- docs uses its own `Table` component with its own scroll listener
- kb has no scroll container which can lead on phones to overflow
- design system `Table` already scrolls with `ShadowScrollArea` which
was not used within guides

## Solution

- docs and kb article tables use the `ui` `Table`
- (proposal) `Table` gets a `prose` variant
- kb guides map `table` to `<Table prose />`
- `ShadowScrollArea` shows and hides the edge shadows without a fade (no
strong opinion but felt snappier)
- refactor table components to use `ref` vs deprecated `forwardRef`
- fixes #52065 cc @jbergstroem 

<!--
## Preview links

If relevant, include links to changed pages for easy review access.

Copy the preview base URL from the Vercel bot comment on this PR. Use
the following table as an example template.

| Site | Live | Preview | Search for |
| -------------- |
-------------------------------------------------------------------------
|
------------------------------------------------------------------------------------------------------------
| ----------------------------- |
| WWW | [/blog/your-post](https://supabase.com/blog/your-post) |
[/blog/your-post](https://zone-www-dot-com-git-branch-name-supabase.vercel.app/blog/your-post)
| unique phrase from the change |
| Docs |
[/docs/guides/your-page](https://supabase.com/docs/guides/your-page) |
[/docs/guides/your-page](https://docs-git-branch-name-supabase.vercel.app/docs/guides/your-page)
| unique phrase from the change |
| Studio | [/dashboard](https://supabase.com/dashboard) |
[/dashboard](https://studio-git-branch-name-supabase.vercel.app/dashboard)
| unique phrase from the change |
| Design system | [/design-system](https://supabase.com/design-system) |
[/design-system](https://design-system-git-branch-name-supabase.vercel.app/design-system)
| unique phrase from the change |
| UI library | [/library](https://supabase.com/library) |
[/library](https://ui-library-git-branch-name-supabase.vercel.app/library)
| unique phrase from the change |
| Knowledge base |
[/kb/guides/your-page](https://supabase.com/kb/guides/your-page) |
[/kb/guides/your-page](https://kb-git-branch-name-supabase.vercel.app/kb/guides/your-page)
| unique phrase from the change |
-->

<!-- ## Additional context

Optionally add any other context or screenshots.

-->

## Review instructions

1. open `/docs/guides/ai/choosing-compute-addon` on
[prod](https://supabase.com/docs/guides/ai/choosing-compute-addon#hnsw)
and on
[preview](https://docs-3t4ed5odv-supabase.vercel.app/docs/guides/ai/choosing-compute-addon#hnsw)
2. open `/kb/guides/migrate-from-postgres` on
[prod](https://supabase.com/kb/guides/migrate-from-postgres) and on
[preview](https://docs-3t4ed5odv-supabase.vercel.app/kb/guides/migrate-from-postgres).
on live, the table goes out of the article. on preview, the table
scrolls in the article.


## Checklist

Check all before review:

- [x] I have read
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
- [x] If I wrote a new docs topic or edited an existing topic, I used
the `/write-the-docs` or `/edit-the-docs` skill, which applies the docs
[style
guide](https://github.com/supabase/supabase/tree/master/apps/docs/style-guide)
2026-10-22 13:01:54 +03:00

151 lines
5.5 KiB
TypeScript

import { AiPromptsIndex } from '~/app/guides/getting-started/ai-prompts/[slug]/AiPromptsIndex'
import { AiSkillsIndex } from '~/app/guides/getting-started/ai-skills/AiSkillsIndex'
import { AppleSecretGenerator } from '~/components/AppleSecretGenerator'
import AuthProviders from '~/components/AuthProviders'
import { AuthSmsProviderConfig } from '~/components/AuthSmsProviderConfig'
import ButtonCard from '~/components/ButtonCard'
import { ComputeDiskLimitsTable } from '~/components/ComputeDiskLimitsTable'
import { ContentListings } from '~/components/ContentListings'
import { CustomContent } from '~/components/CustomContent'
import { DatabaseAdvisorsIndex } from '~/components/DatabaseAdvisorsIndex'
import { Extensions } from '~/components/Extensions'
import Image, { type ImageProps } from '~/components/Image'
import { McpCiConfigBlock } from '~/components/McpCiConfigBlock'
import { Mermaid } from '~/components/Mermaid'
import { MetricsStackCards } from '~/components/MetricsStackCards'
import { NavData } from '~/components/NavData'
import { Price } from '~/components/Price'
import { ProjectConfigVariables } from '~/components/ProjectConfigVariables'
import { RealtimeLimitsEstimator } from '~/components/RealtimeLimitsEstimator'
import { RegionsList, SmartRegionsList } from '~/components/RegionsList'
import { SharedData } from '~/components/SharedData'
import { StepHikeCompact } from '~/components/StepHikeCompact'
import { TerraformProviderSchema } from '~/components/TerraformProviderSchema'
import { WrapperDashboardIntegration } from '~/components/WrapperDashboardIntegration'
import { CodeSampleDummy, CodeSampleWrapper } from '~/features/directives/CodeSample.client'
import { CodeTabs, NamedCodeBlock } from '~/features/directives/CodeTabs.components'
import { MdxAnchor } from '~/features/docs/MdxAnchor'
import { Accordion, AccordionItem } from '~/features/ui/Accordion'
import { CodeBlock } from '~/features/ui/CodeBlock/CodeBlock'
import { ShowUntil } from '~/features/ui/ShowUntil'
import { TabPanel, Tabs } from '~/features/ui/Tabs'
import { YouTube } from '~/features/ui/YouTube'
import { ArrowDown, Check, X } from 'lucide-react'
import Link from 'next/link'
import { type ComponentPropsWithoutRef } from 'react'
import { Badge, Button, Heading, Table } from 'ui'
import { Admonition, type AdmonitionProps } from 'ui-patterns/Admonition'
import { GlassPanel } from 'ui-patterns/GlassPanel'
import SqlToRest from 'ui-patterns/SqlToRest'
import { AgentPluginsPanel } from '../ui/AgentPluginsPanel'
import { AgentSetup } from '../ui/AgentSetup'
import { AgentWatchSchedule } from '../ui/AgentWatchSchedule'
import { AiPrompt, type AiPromptProps } from '../ui/AiPrompt'
import { ErrorCodes } from '../ui/ErrorCodes'
import { McpConfigPanel } from '../ui/McpConfigPanel'
// Admonition as it appears in docs pages: sits in MDX prose, so it needs a margin-bottom.
const DocsAdmonition = (props: AdmonitionProps) => {
return <Admonition {...props} className="mb-8" />
}
/**
* Route fenced ```mermaid blocks through the Mermaid component; everything else
* continues through `CodeBlock` for syntax highlighting.
*/
const Pre = (props: any) => {
const child = Array.isArray(props.children) ? props.children[0] : props.children
const className: unknown = child?.props?.className
if (typeof className === 'string' && className.split(' ').includes('language-mermaid')) {
const code = child.props.children
if (typeof code === 'string') {
return <Mermaid chart={code.trim()} />
}
}
return <CodeBlock {...props} />
}
const components = {
Accordion,
AccordionItem,
Admonition: DocsAdmonition,
AgentPluginsPanel,
AgentSetup,
AgentWatchSchedule,
AiPrompt: (props: Omit<AiPromptProps, 'telemetry'>) => (
<AiPrompt {...props} telemetry={{ source: 'guide' }} />
),
AiPromptsIndex,
AiSkillsIndex,
AuthSmsProviderConfig,
AppleSecretGenerator,
AuthProviders,
Badge,
Button,
ButtonCard,
CodeSampleDummy,
CodeSampleWrapper,
CodeTabs,
ComputeDiskLimitsTable,
CustomContent,
ContentListings,
DatabaseAdvisorsIndex,
ErrorCodes,
Extensions,
GlassPanel,
IconArrowDown: ArrowDown,
IconCheck: Check,
IconX: X,
Image: (props: ImageProps) => <Image className="rounded-md w-full" {...props} />,
Link,
McpCiConfigBlock,
McpConfigPanel,
Mermaid,
MetricsStackCards,
NamedCodeBlock,
NavData,
ProjectConfigVariables,
RealtimeLimitsEstimator,
RegionsList,
SmartRegionsList,
SharedData,
ShowUntil,
SqlToRest,
StepHikeCompact,
Table,
Tabs,
TabPanel,
TerraformProviderSchema,
WrapperDashboardIntegration,
YouTube,
a: MdxAnchor,
h2: (props: ComponentPropsWithoutRef<'h2'>) => (
<Heading tag="h2" {...props}>
{props.children}
</Heading>
),
h3: (props: ComponentPropsWithoutRef<'h3'>) => (
<Heading tag="h3" {...props}>
{props.children}
</Heading>
),
h4: (props: ComponentPropsWithoutRef<'h4'>) => (
<Heading tag="h4" {...props}>
{props.children}
</Heading>
),
pre: Pre,
table: (props: ComponentPropsWithoutRef<'table'>) => <Table prose {...props} />,
/**
* Force inline code tags to go sync, this prevents Heading anchor resolution fail due to
* our CodeBlock component being async. We need to find a better solution for more future
* proof MDX rendering. Definitely improving the anchors utility in the ui/Heading component
* plus having a more resilient highlighting strategy.
*/
code: (props: any) => <code {...props}>{props.children}</code>,
Price,
}
export { components }