mirror of
https://github.com/supabase/supabase.git
synced 2026-10-05 17:35:10 +03:00
## I have read the [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) file. YES/NO ## What kind of change does this PR introduce? Bug fix, feature, docs update, ... ## What is the current behavior? Please link any relevant issues here. ## What is the new behavior? Feel free to include screenshots if it includes visual changes. ## Additional context Add any other context or screenshots. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Refreshed theming across the UI to use modern color expressions and shared theme variables (including OKLCH-based gradients), improving consistency for charts, code blocks, overlays, icons, and decorative backgrounds. * **Bug Fixes** * Improved light/dark color and gradient consistency across axis/grid styling, reference lines, buttons/badges, sidebar accents, loaders, and other visual components. * **Documentation** * Updated styling/theming guidance to align with the revised semantic token system and the updated theme variable usage patterns. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
107 lines
3.1 KiB
TypeScript
107 lines
3.1 KiB
TypeScript
'use client'
|
|
|
|
import * as React from 'react'
|
|
import { cn } from 'ui'
|
|
|
|
import { Index } from '@/__registry__'
|
|
import { useConfig } from '@/hooks/use-config'
|
|
import { styles } from '@/registry/styles'
|
|
|
|
interface ComponentPreviewProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
name: string
|
|
extractClassname?: boolean
|
|
extractedClassNames?: string
|
|
align?: 'center' | 'start' | 'end'
|
|
peekCode?: boolean
|
|
showGrid?: boolean
|
|
showDottedGrid?: boolean
|
|
wide?: boolean
|
|
}
|
|
|
|
export function CodeFragment({
|
|
name,
|
|
children,
|
|
className,
|
|
extractClassname,
|
|
extractedClassNames,
|
|
align = 'center',
|
|
peekCode = false,
|
|
showGrid = false,
|
|
showDottedGrid = true,
|
|
wide = false,
|
|
...props
|
|
}: ComponentPreviewProps) {
|
|
const [config] = useConfig()
|
|
const index = styles.findIndex((style) => style.name === config.style)
|
|
|
|
const Codes = React.Children.toArray(children) as React.ReactElement[]
|
|
const Code = Codes[index]
|
|
|
|
const [expand, setExpandState] = React.useState(false)
|
|
|
|
const Preview = React.useMemo(() => {
|
|
// console.log('Index', Index)
|
|
// console.log('name', name)
|
|
// console.log('config.style', config.style)
|
|
|
|
const Component = Index[config.style][name]?.component
|
|
// const Component = Index[name]?.component
|
|
|
|
if (!Component) {
|
|
return (
|
|
<p className="text-sm text-muted-foreground">
|
|
Code fragment{' '}
|
|
<code className="relative rounded-sm bg-muted px-[0.3rem] py-[0.2rem] font-mono text-sm">
|
|
{name}
|
|
</code>{' '}
|
|
not found in registry.
|
|
</p>
|
|
)
|
|
}
|
|
|
|
return <Component />
|
|
}, [name, config.style])
|
|
|
|
const ComponentPreview = React.useMemo(() => {
|
|
return (
|
|
<>
|
|
<div
|
|
className={cn('preview flex min-h-[350px] w-full justify-center p-10', {
|
|
'items-center': align === 'center',
|
|
'items-start': align === 'start',
|
|
'items-end': align === 'end',
|
|
})}
|
|
>
|
|
<React.Suspense
|
|
fallback={
|
|
<div className="flex items-center text-sm text-muted-foreground">Loading...</div>
|
|
}
|
|
>
|
|
{Preview}
|
|
</React.Suspense>
|
|
</div>
|
|
</>
|
|
)
|
|
}, [Preview, align])
|
|
|
|
const wideClasses = wide ? '2xl:-ml-12 2xl:-mr-12' : ''
|
|
|
|
return (
|
|
<div className={cn('mt-4 mb-12', wideClasses)}>
|
|
<div
|
|
className={cn(
|
|
'relative rounded-md border-t border-l border-r border-b bg-studio overflow-hidden'
|
|
)}
|
|
>
|
|
{showGrid && (
|
|
<div className="pointer-events-none absolute h-full w-full bg-[linear-gradient(to_right,oklch(from_var(--foreground-default)_l_c_h_/_0.02)_1px,transparent_1px),linear-gradient(to_bottom,#80808012_1px,transparent_1px)] bg-size-[24px_24px]"></div>
|
|
)}
|
|
{showDottedGrid && (
|
|
<div className="z-0 pointer-events-none absolute h-full w-full bg-[radial-gradient(oklch(from_var(--foreground-default)_l_c_h_/_0.02)_1px,transparent_1px)] bg-size-[16px_16px] mask-[radial-gradient(ellipse_50%_50%_at_50%_50%,#000_70%,transparent_100%)]"></div>
|
|
)}
|
|
<div className="z-10 relative">{ComponentPreview}</div>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|