Files
supabase/apps/studio/components/interfaces/ProjectAPIDocs/ContentSnippet.tsx
Ivan VasilovandJordi Enric 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

84 lines
2.3 KiB
TypeScript

import { useParams } from 'common'
import { PropsWithChildren } from 'react'
import { SimpleCodeBlock } from 'ui-patterns/SimpleCodeBlock'
import { Markdown } from '../Markdown'
import { useSendEventMutation } from '@/data/telemetry/send-event-mutation'
import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganization'
interface ContentSnippetProps {
apikey?: string
endpoint?: string
selectedLanguage: 'js' | 'bash'
snippet: {
key: string
category: string
title: string
description?: string
js?: (apikey?: string, endpoint?: string) => string
bash?: (apikey?: string, endpoint?: string) => string
}
}
const ContentSnippet = ({
apikey,
endpoint,
selectedLanguage,
snippet,
children,
}: PropsWithChildren<ContentSnippetProps>) => {
const { ref: projectRef } = useParams()
const { data: org } = useSelectedOrganizationQuery()
const { mutate: sendEvent } = useSendEventMutation()
const codeSnippet = snippet[selectedLanguage]?.(apikey, endpoint).replaceAll(
'[ref]',
projectRef ?? ''
)
const handleCopy = () => {
sendEvent({
action: 'api_docs_code_copy_button_clicked',
properties: {
title: snippet.title,
selectedLanguage,
},
groups: {
project: projectRef ?? 'Unknown',
organization: org?.slug ?? 'Unknown',
},
})
}
return (
<div className="space-y-4 py-6 pb-2 last:pb-6">
<div className="px-4 space-y-4">
<h2 id={snippet.key} tabIndex={-1} className="doc-heading">
{snippet.title}
</h2>
{snippet.description !== undefined && (
<div className="doc-section">
<article className="text text-sm text-foreground-light">
<Markdown
className="max-w-none"
content={snippet.description.replaceAll('[ref]', projectRef ?? '_')}
/>
</article>
</div>
)}
</div>
{children}
{codeSnippet !== undefined && (
<div className="px-4 codeblock-container">
<div className="bg rounded-sm p-2">
<SimpleCodeBlock className={selectedLanguage} onCopy={handleCopy}>
{codeSnippet}
</SimpleCodeBlock>
</div>
</div>
)}
</div>
)
}
export default ContentSnippet