Files
supabase/apps/docs/features/directives/CodeSample.client.tsx
T
Ivan Vasilov 56de26fe22 chore: Migrate the monorepo to use Tailwind v4 (#45318)
This PR migrates the whole monorepo to use Tailwind v4:
- Removed `@tailwindcss/container-queries` plugin since it's included by
default in v4,
- Bump all instances of Tailwind to v4. Made minimal changes to the
shared config to remove non-supported features (`alpha` mentions),
- Migrate all apps to be compatible with v4 configs,
- Fix the `typography.css` import in 3 apps,
- Add missing rules which were included by default in v3,
- Run `pnpm dlx @tailwindcss/upgrade` on all apps, which renames a lot
of classes
- Rename all misnamed classes according to
https://tailwindcss.com/docs/upgrade-guide#renamed-utilities in all
apps.

---------

Co-authored-by: Jordi Enric <jordi.err@gmail.com>
2026-04-30 10:53:24 +00:00

79 lines
2.3 KiB
TypeScript

'use client'
import Link from 'next/link'
import { useState, type PropsWithChildren } from 'react'
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from 'ui'
import { Admonition } from 'ui-patterns/admonition'
export function CodeSampleDummy() {
return (
<Admonition type="caution" title="Local development warning">
The <code>$CodeSample</code> directive with external repos is not supported in local
development because it relies on a GitHub API key. Please check the preview site to see the
final UI.
</Admonition>
)
}
export function CodeSampleWrapper({
children,
/**
* A GitHub URL to the source code file.
*/
source: _source,
}: PropsWithChildren<{ source: string | URL | (string | URL)[] }>) {
const source = Array.isArray(_source) ? _source : [_source]
if (source.length === 1) {
return <SingleSource source={source[0]}>{children}</SingleSource>
}
if (source.length > 1) {
return <MultipleSources sources={source}>{children}</MultipleSources>
}
return <>{children}</>
}
function MultipleSources({ children, sources }: PropsWithChildren<{ sources: (string | URL)[] }>) {
return (
<>
{children}
<DropdownMenu>
<DropdownMenuTrigger asChild>
<button className="block -mt-4 mb-4 ml-auto text-foreground-lighter text-sm focus-visible:outline-hidden focus-visible:underline">
View sources
</button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
{sources.map((source) => (
<DropdownMenuItem
key={source.toString()}
onSelect={() => window.open(source.toString(), '_blank', 'noopener noreferrer')}
>
...{source.toString().split('/').slice(-2).join('/')}
</DropdownMenuItem>
))}
</DropdownMenuContent>
</DropdownMenu>
</>
)
}
function SingleSource({ children, source }: PropsWithChildren<{ source: string | URL }>) {
return (
<>
{children}
<Link
href={source.toString()}
target="_blank"
rel="noopener noreferrer"
className="block -mt-5 mb-4 text-right no-underline text-foreground-lighter text-sm"
>
View source
</Link>
</>
)
}