mirror of
https://github.com/hanzo-docs/docs.git
synced 2026-10-30 14:41:16 +00:00
Finish the fumadocs→Hanzo Docs rebrand: rename the remaining fuma-named
workspace packages and every reference so the framework is uniformly
@hanzo/docs-*. One brand, no Fuma in package names or product surface.
Package renames (name field + all refs: deps, imports, CSS @import,
configs, .changeset, next/vite build config):
fumadocs-core → @hanzo/docs-core
fumadocs-mdx → @hanzo/docs-mdx
fumadocs-ui → @hanzo/docs-ui (packages/radix-ui)
fumadocs-openapi → @hanzo/docs-openapi
fumadocs-preview → @hanzo/docs-preview
@fumadocs/base-ui → @hanzo/docs-base-ui
@fumadocs/basehub → @hanzo/docs-basehub
@fumadocs/language → @hanzo/docs-language
@fumadocs/local-md → @hanzo/docs-local-md
@fumadocs/sanity → @hanzo/docs-sanity
@fumadocs/shadcn → @hanzo/docs-shadcn
@fumadocs/vite → @hanzo/docs-vite
@fumari/stf → @hanzo/docs-stf
create-fumadocs-app → @hanzo/create-docs
create-fumadocs-versions → @hanzo/docs-create-versions
Stale @fumadocs/{cli,story,tailwind,mdx-remote,...} references collapsed to
their existing @hanzo/docs-* canonical packages (no dup created).
De-branded product strings: Fumadocs/Fuma prose → Hanzo Docs/Hanzo; site
branding, CLI output, doc copy, AI-assistant name, metadata. URLs
fumadocs.dev → docs.hanzo.ai, repo fuma-nama/fumadocs → hanzoai/docs.
Filesystem renames: packages/python/fumapy → hanzodocs_py, preview config,
what-is-fumadocs.mdx → what-is-hanzo-docs.mdx, api/fumadocs-ui route.
KEPT (real external npm deps / attribution — NOT renamed):
fuma-cli, fuma-content, @fumari/json-schema-ts (published upstream pkgs),
typesense-/trieve-fumadocs-adapter (3rd-party search adapters),
LICENSE "Copyright (c) 2023 Fuma" (OSS attribution, all 7 LICENSE files
untouched), CHANGELOG.md history (accurate release records, left as-is).
Build: node 24, pnpm install clean; all 4 target apps next build GREEN
(spec, gui-docs, zen-docs, base-docs) + full package closure (18/18 turbo).
Gate: zero @hanzo-package fumadocs-/@fumadocs/ references remain.
121 lines
4.1 KiB
TypeScript
121 lines
4.1 KiB
TypeScript
'use client';
|
|
|
|
import { cn } from '@/utils/cn';
|
|
import { useStf, StfProvider, useDataEngine, useListener } from '@hanzo/docs-stf';
|
|
import { Select, SelectTrigger, SelectValue, SelectContent, SelectItem } from './components/select';
|
|
import { buttonVariants } from '@hanzo/docs-base-ui/components/ui/button';
|
|
import { AlertCircle } from 'lucide-react';
|
|
import { FC, useState, useRef, useDeferredValue, Suspense } from 'react';
|
|
import { ErrorBoundary } from 'react-error-boundary';
|
|
import { FieldSet } from './arg-form';
|
|
import type { TypeNode } from '@/type-tree/types';
|
|
import { useTranslations } from './i18n';
|
|
|
|
export interface WithControlProps {
|
|
displayName?: string;
|
|
Component: FC;
|
|
presets: (VariantInfo & {
|
|
controls: TypeNode;
|
|
defaultValues?: Record<string, unknown>;
|
|
})[];
|
|
}
|
|
|
|
export interface VariantInfo {
|
|
variant: string;
|
|
description?: string;
|
|
}
|
|
|
|
export function WithControl({ presets, displayName, Component }: WithControlProps) {
|
|
const t = useTranslations();
|
|
const [variant, setVariant] = useState(presets[0].variant);
|
|
const preset = presets.find((preset) => preset.variant === variant);
|
|
const stf = useStf({
|
|
defaultValues: preset?.defaultValues,
|
|
});
|
|
|
|
return (
|
|
<StfProvider value={stf}>
|
|
<div className="not-prose flex flex-col gap-1 p-1 border rounded-md shadow-sm bg-fd-card text-fd-card-foreground">
|
|
<div className="flex flex-row items-center gap-2 empty:hidden">
|
|
{displayName && <p className="text-sm font-medium px-1.5">{displayName}</p>}
|
|
{presets.length > 1 && (
|
|
<Select
|
|
value={variant}
|
|
onValueChange={(value) => {
|
|
const preset = presets.find((preset) => preset.variant === value);
|
|
if (preset) {
|
|
setVariant(value);
|
|
stf.dataEngine.reset(preset.defaultValues ?? {});
|
|
}
|
|
}}
|
|
>
|
|
<SelectTrigger
|
|
variant="ghost"
|
|
className="w-fit ms-auto text-fd-muted-foreground text-xs font-medium"
|
|
>
|
|
<SelectValue placeholder={t.noVariant}>{preset?.variant}</SelectValue>
|
|
</SelectTrigger>
|
|
<SelectContent>
|
|
{presets.map((item) => (
|
|
<SelectItem key={item.variant} value={item.variant}>
|
|
<p className="text-xs font-medium">{item.variant}</p>
|
|
<p className="text-xs text-fd-muted-foreground">{item.description}</p>
|
|
</SelectItem>
|
|
))}
|
|
</SelectContent>
|
|
</Select>
|
|
)}
|
|
</div>
|
|
<StoryComponent Component={Component} />
|
|
{preset && (
|
|
<FieldSet
|
|
key={variant}
|
|
field={preset.controls}
|
|
fieldName={[]}
|
|
name={t.props}
|
|
className="max-h-[600px] overflow-auto"
|
|
/>
|
|
)}
|
|
</div>
|
|
</StfProvider>
|
|
);
|
|
}
|
|
|
|
function StoryComponent({ Component }: { Component: FC }) {
|
|
const t = useTranslations();
|
|
const engine = useDataEngine();
|
|
const timerRef = useRef(0);
|
|
const [args, setArgs] = useState(() => engine.getData());
|
|
const deferredArgs = useDeferredValue(args);
|
|
useListener({
|
|
onUpdate() {
|
|
if (timerRef.current) window.clearTimeout(timerRef.current);
|
|
timerRef.current = window.setTimeout(() => setArgs({ ...engine.getData() }), 100);
|
|
},
|
|
});
|
|
|
|
return (
|
|
<ErrorBoundary
|
|
fallbackRender={({ error, resetErrorBoundary }) => (
|
|
<div className="p-3 border rounded-lg bg-fd-card text-fd-card-foreground text-sm">
|
|
<p className="inline-flex items-center gap-2 font-medium mb-2">
|
|
<AlertCircle className="text-fd-error size-4" />
|
|
{t.renderError}
|
|
</p>
|
|
<p className="text-fd-muted-foreground mb-2">{String(error)}</p>
|
|
<button
|
|
className={cn(buttonVariants({ variant: 'primary', size: 'sm' }))}
|
|
onClick={() => resetErrorBoundary()}
|
|
>
|
|
{t.reset}
|
|
</button>
|
|
</div>
|
|
)}
|
|
>
|
|
<Suspense>
|
|
<Component {...deferredArgs} key={undefined} />
|
|
</Suspense>
|
|
</ErrorBoundary>
|
|
);
|
|
}
|