diff --git a/apps/ui-library/components/block-item-code.tsx b/apps/ui-library/components/block-item-code.tsx index 05007873138..3d0ba4f0823 100644 --- a/apps/ui-library/components/block-item-code.tsx +++ b/apps/ui-library/components/block-item-code.tsx @@ -3,9 +3,10 @@ import { RegistryNode } from '@/lib/process-registry' import { Tabs, TabsContent, TabsList, TabsTrigger } from '@ui/components/shadcn/ui/tabs' import { DynamicCodeBlock } from 'fumadocs-ui/components/dynamic-codeblock' -import { File, Folder } from 'fumadocs-ui/components/files' import { useState } from 'react' +import supabaseTheme from '../lib/themes/supabase-2.json' assert { type: 'json' } import { BlockItemPreview } from './block-item' +import { File, Folder } from './files' interface BlockItemCodeProps { files: RegistryNode[] @@ -101,7 +102,12 @@ export function BlockItemCode({ files }: BlockItemCodeProps) { value="code" className="rounded-none [&_figure]:rounded-none [&_figure]:h-full [&_div[data-radix-scroll-area-viewport]]:min-h-[600px]" > - + {selectedFileDemoUrl && } diff --git a/apps/ui-library/components/files.tsx b/apps/ui-library/components/files.tsx new file mode 100644 index 00000000000..2eb32cdeff3 --- /dev/null +++ b/apps/ui-library/components/files.tsx @@ -0,0 +1,66 @@ +'use client' + +import { cva } from 'class-variance-authority' +import { FileIcon, FolderIcon, FolderOpen } from 'lucide-react' +import { useState, type HTMLAttributes, type ReactNode } from 'react' +import { cn, Collapsible_Shadcn_, CollapsibleContent_Shadcn_, CollapsibleTrigger_Shadcn_ } from 'ui' + +const itemVariants = cva( + 'flex flex-row items-center gap-2 rounded-md px-2 py-1.5 text-sm hover:bg-fd-accent hover:text-fd-accent-foreground [&_svg]:size-4' +) + +export function Files({ className, ...props }: HTMLAttributes): React.ReactElement { + return ( +
+ {props.children} +
+ ) +} + +export interface FileProps extends HTMLAttributes { + name: string + icon?: ReactNode +} + +export interface FolderProps extends HTMLAttributes { + name: string + + disabled?: boolean + + /** + * Open folder by default + * + * @defaultValue false + */ + defaultOpen?: boolean +} + +export function File({ + name, + icon = , + className, + ...rest +}: FileProps): React.ReactElement { + return ( +
+ {icon} + {name} +
+ ) +} + +export function Folder({ name, defaultOpen = false, ...props }: FolderProps): React.ReactElement { + const [open, setOpen] = useState(defaultOpen) + + return ( + + + {open ? : } + {name} + + +
{props.children}
+
+
+ ) +} diff --git a/apps/ui-library/components/registry-block.tsx b/apps/ui-library/components/registry-block.tsx index be8ffe38cdb..9da49d30139 100644 --- a/apps/ui-library/components/registry-block.tsx +++ b/apps/ui-library/components/registry-block.tsx @@ -6,7 +6,7 @@ import { BlockItemCode } from './block-item-code' export async function RegistryBlock({ itemName }: { itemName: string }) { const registryPath = path.join(process.cwd(), 'public', 'r', `${itemName}.json`) - const tree = generateRegistryTree(itemName, registryPath) + const tree = generateRegistryTree(registryPath) return } diff --git a/apps/ui-library/lib/process-registry.ts b/apps/ui-library/lib/process-registry.ts index 11275edb020..e3b9cd7877e 100644 --- a/apps/ui-library/lib/process-registry.ts +++ b/apps/ui-library/lib/process-registry.ts @@ -25,7 +25,7 @@ const DEFAULT_PATHS = { /** * Converts a flat registry array into a hierarchical file tree structure */ -export function generateRegistryTree(blockName: string, registryPath: string): RegistryNode[] { +export function generateRegistryTree(registryPath: string): RegistryNode[] { const registry = JSON.parse(fs.readFileSync(registryPath, 'utf-8')) as { files: RegistryFile[] } const tree: RegistryNode[] = [] @@ -45,8 +45,9 @@ export function generateRegistryTree(blockName: string, registryPath: string): R // Remove any paths in the file content that point to the block directory. const content = file.content - .replaceAll(/@\/registry\/blocks\/.+?\//gi, '@/') - .replaceAll(/@\/registry\//gi, '@/') + .replaceAll(/@\/registry\/default\/blocks\/.+?\//gi, '@/') + .replaceAll(/@\/registry\/default\//gi, '@/') + .replaceAll(/@\/clients\/.+?\//gi, '@/') if (!node) { node = { @@ -76,7 +77,9 @@ function getDefaultPath(item: RegistryFile): string { const type = item.type.toLowerCase() || '' const basePath = DEFAULT_PATHS[type as keyof typeof DEFAULT_PATHS] || '' // clean all paths that start with paths specific to this repo organization - const filePath = item.path.replace(/src\/registry\/blocks\/.+?\//, '') + const filePath = item.path + .replace(/registry\/default\/blocks\/.+?\//, '') + .replace(/registry\/default\/clients\/.+?\//, '') return `${basePath}/${filePath}` } diff --git a/apps/ui-library/lib/themes/supabase-2.json b/apps/ui-library/lib/themes/supabase-2.json index 81ffd9ec7cb..d4120e118a2 100644 --- a/apps/ui-library/lib/themes/supabase-2.json +++ b/apps/ui-library/lib/themes/supabase-2.json @@ -3,7 +3,7 @@ "displayName": "Supabase Theme", "semanticHighlighting": true, "colors": { - "editor.background": "var(--code-highlight-color)", + "editor.background": "var(--background-surface-75) / 0.75", "editor.foreground": "var(--code-foreground)", "editor.lineHighlightBackground": "var(--code-highlight-color)", "editorCursor.foreground": "var(--code-foreground)",