mirror of
https://github.com/supabase/supabase.git
synced 2026-10-05 01:15:03 +03:00
* migrate some www components to tokens * consolidate InteractiveShimmerCard to Panel component * update tokens in blog * update tokens in careers page * update tokens in customers section * update tokens in open-source section * update tokens in Realtime page * update tokens in Storage and Vector * update tokens in SplitCodeBlockCarousel * update tokens in PGCharts * remove unused css files * update tokens in Card * update tokens in Pricing page * clean up priving page imports * remove hardcoded theme vars * migrate first half of defaultTheme.ts to tokens * migrate second half of defaultTheme.ts to tokens * improve inputs * add foreground to text-light and text-lighter * add foreground to text-light and text-lighter * migrate docs components with styling tokens * migrate docs components with styling tokens * fix broken Repos component * fix broken classes in blog * update tokens on Button and other components * update tokens on IconPanel * update studio main layout base styling tokens * update tokens across studio, docs and www * update tokens across studio, docs and www * update ui/Panel to styling tokens * update ExampleProject and TableEditorMenu tokens * www vector page tokens * update studio UI tokens * update other studio UI tokens * update more studio UI tokens * change tokens here, change tokens there * finish updating colors with tokens variables * add gui sandbox for theme experimentation * use common package for www, docs and studio and fix Command K tokens * provide light mode default tokens options * fix conflict leftover * update loading line * fix className typo * fix prettier * update themeSandbox preset default values * fix text-background0 * prettier * update warningBanner with warning color * switch all border-border with border-default * improve border-secondary and foreground-muted in light mode * force ring color on toggle * fix button bg color and border-muted light token * fix input bg color * fix dark button hover * fix homepage product card * fix code-hike table header colors * button dark border * remove tabIndex leftover from homepage main ctas --------- Co-authored-by: Kevin Grüneberg <k.grueneberg1994@gmail.com> Co-authored-by: Jonathan Summers-Muir <MildTomato@users.noreply.github.com>
215 lines
7.0 KiB
TypeScript
215 lines
7.0 KiB
TypeScript
import ReactMarkdown from 'react-markdown'
|
|
import { CodeBlock, IconChevronRight, Tabs } from 'ui'
|
|
import spec from '~/../../spec/cli_v1_commands.yaml' assert { type: 'yml' }
|
|
import Options from '~/components/Options'
|
|
import Param from '~/components/Params'
|
|
import RefSubLayout from '~/layouts/ref/RefSubLayout'
|
|
import RefDetailCollapse from './RefDetailCollapse'
|
|
|
|
export type Flag = {
|
|
id: string
|
|
name: string
|
|
description: string
|
|
default_value: string
|
|
accepted_values: AcceptedValue[]
|
|
required?: boolean
|
|
/** Whether subcommands inherit this flag. */
|
|
inherit?: boolean
|
|
}
|
|
|
|
export type AcceptedValue = {
|
|
id: string
|
|
name: string
|
|
type: 'string' | 'boolean' | 'object'
|
|
description?: string
|
|
}
|
|
|
|
export type Example = {
|
|
id: string
|
|
name: string
|
|
code: string
|
|
response: string
|
|
description?: string
|
|
}
|
|
|
|
export type Command = {
|
|
id: string
|
|
title: string
|
|
description: string
|
|
flags?: Flag[]
|
|
summary: string
|
|
tags?: string[]
|
|
links?: string[]
|
|
subcommands?: string[]
|
|
usage?: string
|
|
examples?: Example[]
|
|
}
|
|
|
|
const CliCommandSection = (props) => {
|
|
const command = spec.commands.find((x: any) => x.id === props.funcData.id)
|
|
const parentCommand = spec.commands.find(
|
|
(x: any) => x.subcommands && x.subcommands.find((y: any) => y === props.funcData.id)
|
|
)
|
|
|
|
const commandFlags = [
|
|
...(parentCommand?.flags?.filter((x: any) => x.inherit) || []),
|
|
...command.flags,
|
|
]
|
|
|
|
return (
|
|
<RefSubLayout.Section
|
|
key={command.id}
|
|
slug={command.id}
|
|
title={'$ ' + command.title}
|
|
id={command.id}
|
|
monoFont={true}
|
|
scrollSpyHeader={true}
|
|
>
|
|
<RefSubLayout.Details>
|
|
<div className="grid ref-container" id={command.id}>
|
|
<div className="border-b pb-8" key={command.id}>
|
|
<header
|
|
className={[
|
|
// 'border-b sticky top-16 z-10',
|
|
' mb-16',
|
|
].join(' ')}
|
|
>
|
|
{command.description ? (
|
|
<div className="prose">
|
|
<ReactMarkdown>{command.description}</ReactMarkdown>
|
|
</div>
|
|
) : (
|
|
<p className="capitalize mb-4 scroll-mt-16 mt-0 text-foreground-light text-base">
|
|
{command.summary}
|
|
</p>
|
|
)}
|
|
</header>
|
|
|
|
{command.subcommands?.length > 0 && (
|
|
<div className="mb-3">
|
|
<h3 className="text-lg text-foreground mb-3">Available Commands</h3>
|
|
<ul>
|
|
{command.subcommands.map((subcommand) => (
|
|
<li key={subcommand} className="flex items-center gap-3">
|
|
<div className="text-foreground-muted">
|
|
<IconChevronRight size={14} strokeWidth={2} />
|
|
</div>
|
|
<a
|
|
href={`#${subcommand}`}
|
|
className="transition text-foreground-light hover:text-brand"
|
|
>
|
|
$ {subcommand.replace(/-/g, ' ')}
|
|
</a>
|
|
</li>
|
|
))}
|
|
</ul>
|
|
</div>
|
|
)}
|
|
{commandFlags.length > 0 && (
|
|
<>
|
|
<h3 className="text-lg text-foreground mb-3">Flags</h3>
|
|
<ul className="">
|
|
{commandFlags.map((flag: Flag) => (
|
|
<>
|
|
<li className="mt-0">
|
|
<Param {...flag} isOptional={!flag.required}>
|
|
{flag?.accepted_values && (
|
|
<Options>
|
|
{flag?.accepted_values.map((value) => {
|
|
return <Options.Option {...value} />
|
|
})}
|
|
</Options>
|
|
)}
|
|
</Param>
|
|
</li>
|
|
</>
|
|
))}
|
|
</ul>
|
|
</>
|
|
)}
|
|
</div>
|
|
</div>
|
|
</RefSubLayout.Details>
|
|
{(command.examples || command.usage) && (
|
|
<RefSubLayout.Examples>
|
|
<div className="overflow-hidden w-full">
|
|
<Tabs
|
|
defaultActiveId={`${command.id}-basic-usage`}
|
|
size="tiny"
|
|
type="rounded-pills"
|
|
scrollable
|
|
queryGroup="example"
|
|
>
|
|
{command.examples ? (
|
|
command.examples.map((example) => {
|
|
const exampleId = `${command.id}-${example.id}`
|
|
return (
|
|
<Tabs.Panel
|
|
id={exampleId}
|
|
key={exampleId}
|
|
label={example.name}
|
|
className="flex flex-col gap-3"
|
|
>
|
|
<CodeBlock
|
|
className="useless-code-block-class"
|
|
language="bash"
|
|
hideLineNumbers={true}
|
|
>
|
|
{example.code}
|
|
</CodeBlock>
|
|
|
|
<RefDetailCollapse
|
|
id={`${exampleId}-response`}
|
|
label="Response"
|
|
defaultOpen={false}
|
|
>
|
|
<CodeBlock
|
|
className="useless-code-block-class rounded !rounded-tl-none !rounded-tr-none border border-DEFAULT"
|
|
language="bash"
|
|
hideLineNumbers={true}
|
|
>
|
|
{example.response}
|
|
</CodeBlock>
|
|
</RefDetailCollapse>
|
|
|
|
{example.description && (
|
|
<RefDetailCollapse
|
|
id={`${exampleId}-notes`}
|
|
label="Notes"
|
|
defaultOpen={false}
|
|
>
|
|
<div className="bg-overlay border border-overlay rounded !rounded-tl-none !rounded-tr-none prose max-w-none px-5 py-2">
|
|
<ReactMarkdown className="text-sm">{example.description}</ReactMarkdown>
|
|
</div>
|
|
</RefDetailCollapse>
|
|
)}
|
|
</Tabs.Panel>
|
|
)
|
|
})
|
|
) : (
|
|
// TODO: remove this block once all commands have examples
|
|
<Tabs.Panel
|
|
id={`${command.id}-basic-usage`}
|
|
key={`${command.id}-basic-usage`}
|
|
label="Basic usage"
|
|
className="flex flex-col gap-3"
|
|
>
|
|
<CodeBlock
|
|
className="useless-code-block-class"
|
|
language="bash"
|
|
hideLineNumbers={true}
|
|
>
|
|
{command.usage}
|
|
</CodeBlock>
|
|
</Tabs.Panel>
|
|
)}
|
|
</Tabs>
|
|
</div>
|
|
</RefSubLayout.Examples>
|
|
)}
|
|
</RefSubLayout.Section>
|
|
)
|
|
}
|
|
|
|
export default CliCommandSection
|