Skip to content

armgit / pdfcn

Public Imported from GitHub
0

Beautiful pdf components, built on Takumi and Forme. 100% Free, Zero config, one command setup.

feat: enhance theme builder with base-specific routing and font preview functionality

Aniket-50884d1a555ded0
diff --git a/app/(builder)/theme-builder/[base]/page.tsx b/app/(builder)/theme-builder/[base]/page.tsx
new file mode 100644
index 0000000..f0f3428
--- /dev/null
+++ b/app/(builder)/theme-builder/[base]/page.tsx
@@ -0,0 +1,46 @@
+import type { Metadata } from "next";
+import { notFound } from "next/navigation";
+
+import { ThemeBuilder } from "@/components/theme-builder/theme-builder";
+import { BASE_NAMES } from "@/registry/bases";
+import type { BaseName } from "@/registry/bases";
+import { createPageMetadata } from "@/seo/metadata";
+
+export const dynamicParams = false;
+
+const BASE_COPY: Record<BaseName, string> = {
+ forme:
+ "Design and export a reusable pdfcn theme with a live PDF preview powered by Forme.",
+ takumi:
+ "Design and export a reusable pdfcn theme with a live PDF preview powered by Takumi.",
+};
+
+interface ThemeBuilderBasePageProps {
+ params: Promise<{ base: BaseName }>;
+}
+
+export const generateStaticParams = () => BASE_NAMES.map((base) => ({ base }));
+
+export const generateMetadata = async ({
+ params,
+}: ThemeBuilderBasePageProps): Promise<Metadata> => {
+ const { base } = await params;
+
+ return createPageMetadata({
+ description: BASE_COPY[base],
+ path: `/theme-builder/${base}`,
+ title: "Theme Builder",
+ });
+};
+
+const ThemeBuilderBasePage = async ({ params }: ThemeBuilderBasePageProps) => {
+ const { base } = await params;
+
+ if (!BASE_NAMES.includes(base)) {
+ notFound();
+ }
+
+ return <ThemeBuilder base={base} />;
+};
+
+export default ThemeBuilderBasePage;
diff --git a/app/(builder)/theme-builder/page.tsx b/app/(builder)/theme-builder/page.tsx
deleted file mode 100644
index 561385b..0000000
--- a/app/(builder)/theme-builder/page.tsx
+++ /dev/null
@@ -1,16 +0,0 @@
-import type { Metadata } from "next";
-
-import { ThemeBuilder } from "@/components/theme-builder/theme-builder";
-import { ROUTES } from "@/constants/routes";
-import { createPageMetadata } from "@/seo/metadata";
-
-export const metadata: Metadata = createPageMetadata({
- description:
- "Customize pdfcn colors, typography, spacing, and page settings with a live PDF preview, then export a reusable theme.",
- path: ROUTES.THEME_BUILDER,
- title: "Theme Builder",
-});
-
-const ThemeBuilderPage = () => <ThemeBuilder />;
-
-export default ThemeBuilderPage;
diff --git a/app/sitemap.ts b/app/sitemap.ts
index c51f7cf..cf57b41 100644
--- a/app/sitemap.ts
+++ b/app/sitemap.ts
@@ -22,7 +22,13 @@ const sitemap = (): MetadataRoute.Sitemap => {
changeFrequency: "weekly",
lastModified: new Date(),
priority: 0.8,
- url: `${SITE.URL}${ROUTES.THEME_BUILDER}`,
+ url: `${SITE.URL}${ROUTES.THEME_BUILDER_FORME}`,
+ },
+ {
+ changeFrequency: "weekly",
+ lastModified: new Date(),
+ priority: 0.8,
+ url: `${SITE.URL}${ROUTES.THEME_BUILDER_TAKUMI}`,
},
];
diff --git a/components/pdf-preview.tsx b/components/pdf-preview.tsx
index 721178e..f2e50ee 100644
--- a/components/pdf-preview.tsx
+++ b/components/pdf-preview.tsx
@@ -8,6 +8,11 @@ import { cn } from "@/lib/utils";
import type { BaseName } from "@/registry/bases";
import type { PdfcnTheme } from "@/registry/themes";
+import {
+ getPreviewFonts,
+ getPreviewFontUrls,
+} from "./theme-builder/preview-fonts";
+
const PREVIEW_LOGO_PATH = "/favicon.png";
let takumiWasmReady: Promise<unknown> | undefined;
@@ -122,6 +127,12 @@ export const PdfPreview = ({
await initializeTakumi(initialize);
const buffer = await render(element, {
...getTakumiPreviewOptions(name),
+ fonts: theme
+ ? getPreviewFontUrls([
+ theme.typography.body.fontFamily,
+ theme.typography.heading.fontFamily,
+ ])
+ : undefined,
images,
});
pdfBytes = new Uint8Array(buffer);
@@ -139,6 +150,13 @@ export const PdfPreview = ({
const document = replacePreviewImageSources(
serialize(createElement(InvoiceClassicDocument, { theme }))
);
+ const previewFonts = getPreviewFonts([
+ theme.typography.body.fontFamily,
+ theme.typography.heading.fontFamily,
+ ]);
+ if (previewFonts.length > 0) {
+ document.fonts = [...(document.fonts ?? []), ...previewFonts];
+ }
const buffer = await renderSerializedDoc(
document as unknown as Record<string, unknown>
);
diff --git a/components/theme-builder/preview-fonts.ts b/components/theme-builder/preview-fonts.ts
new file mode 100644
index 0000000..476858d
--- /dev/null
+++ b/components/theme-builder/preview-fonts.ts
@@ -0,0 +1,83 @@
+import type { FormeFont } from "@formepdf/react";
+
+const FONT_CDN = "https://cdn.jsdelivr.net/npm/@fontsource";
+
+interface FontFace {
+ italic?: boolean;
+ weight: number;
+}
+
+interface GoogleFontDefinition {
+ fileFamily: string;
+ packageName: string;
+}
+
+const GOOGLE_FONT_FACES: Record<string, FontFace[]> = {
+ Inter: [{ weight: 400 }, { weight: 500 }, { weight: 600 }, { weight: 700 }],
+ "JetBrains Mono": [{ weight: 400 }, { weight: 700 }],
+ Lato: [{ weight: 400 }, { weight: 700 }],
+ Lora: [{ weight: 400 }, { weight: 700 }],
+ Merriweather: [{ weight: 400 }, { weight: 700 }],
+ Nunito: [{ weight: 400 }, { weight: 600 }, { weight: 700 }],
+ "Open Sans": [{ weight: 400 }, { weight: 600 }, { weight: 700 }],
+ "Playfair Display": [{ weight: 400 }, { weight: 700 }],
+ "Source Code Pro": [{ weight: 400 }, { weight: 700 }],
+};
+
+const GOOGLE_FONT_PACKAGES: Record<string, GoogleFontDefinition> =
+ Object.fromEntries(
+ Object.keys(GOOGLE_FONT_FACES).map((family) => [
+ family,
+ {
+ fileFamily: family.toLowerCase().replaceAll(" ", "-"),
+ packageName: family.toLowerCase().replaceAll(" ", "-"),
+ },
+ ])
+ );
+
+export const getPreviewFonts = (families: (string | undefined)[]) => {
+ const fonts: FormeFont[] = [];
+
+ for (const family of families) {
+ const definition = family ? GOOGLE_FONT_PACKAGES[family] : undefined;
+ if (!definition || !family) {
+ continue;
+ }
+
+ for (const { italic, weight } of GOOGLE_FONT_FACES[family]) {
+ fonts.push({
+ family,
+ italic: italic ?? false,
+ src: `${FONT_CDN}/${definition.packageName}@4/files/${definition.fileFamily}-latin-${weight}-${italic ? "italic" : "normal"}.woff`,
+ weight,
+ });
+ }
+ }
+
+ return fonts;
+};
+
+export const getRemoteFontFamilies = (families: (string | undefined)[]) =>
+ [...new Set(families)].filter(
+ (family): family is string =>
+ family !== undefined && family in GOOGLE_FONT_PACKAGES
+ );
+
+export const getPreviewFontUrls = (families: (string | undefined)[]) => {
+ const urls: string[] = [];
+
+ for (const family of families) {
+ const definition = family ? GOOGLE_FONT_PACKAGES[family] : undefined;
+ if (!definition || !family) {
+ continue;
+ }
+
+ for (const { weight } of GOOGLE_FONT_FACES[family]) {
+ urls.push(
+ `${FONT_CDN}/${definition.packageName}@4/files/${definition.fileFamily}-latin-${weight}-normal.woff2`
+ );
+ }
+ }
+
+ return urls;
+};
diff --git a/components/theme-builder/theme-builder.tsx b/components/theme-builder/theme-builder.tsx
index acf8009..98b46ce 100644
--- a/components/theme-builder/theme-builder.tsx
+++ b/components/theme-builder/theme-builder.tsx
@@ -1,6 +1,7 @@
"use client";
import {
+ ChevronRight,
Code2,
Download,
ExternalLink,
@@ -10,21 +11,21 @@ import {
SlidersHorizontal,
Undo2,
} from "lucide-react";
+import Link from "next/link";
import { useCallback, useDeferredValue, useEffect, useState } from "react";
import { toast } from "sonner";
+import { FormeIcon, TakumiIcon } from "@/components/icons";
import { PdfPreview } from "@/components/pdf-preview-wrapper";
-import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import { Separator } from "@/components/ui/separator";
import {
- Sheet,
- SheetContent,
- SheetDescription,
- SheetHeader,
- SheetTitle,
-} from "@/components/ui/sheet";
-import { THEMES } from "@/registry/themes";
+ Tooltip,
+ TooltipContent,
+ TooltipTrigger,
+} from "@/components/ui/tooltip";
+import { cn } from "@/lib/utils";
+import type { BaseName } from "@/registry/bases";
import { ThemeCodeDialog } from "./theme-code-dialog";
import { ThemeControls } from "./theme-controls";
@@ -33,15 +34,20 @@ import { useThemeBuilder } from "./use-theme-builder";
const PERSIST_DELAY_MS = 300;
-export const ThemeBuilder = () => {
+const BASE_SWITCHER = [
+ { icon: TakumiIcon, name: "takumi" as const },
+ { icon: FormeIcon, name: "forme" as const },
+];
+
+export const ThemeBuilder = ({ base }: { base: BaseName }) => {
const { actions, basePreset, canRedo, canUndo, hydrated, theme } =
useThemeBuilder();
const previewTheme = useDeferredValue(theme);
const [codeOpen, setCodeOpen] = useState(false);
const [customizerOpen, setCustomizerOpen] = useState(false);
const [pdfUrl, setPdfUrl] = useState<string | null>(null);
+ const [sidebarOpen, setSidebarOpen] = useState(true);
- const activePreset = THEMES.find(({ name }) => name === basePreset);
const safeThemeName =
theme.name
.trim()
@@ -109,120 +115,193 @@ export const ThemeBuilder = () => {
return (
<div className="flex h-[calc(100svh-var(--header-height))] min-h-[680px] flex-col overflow-hidden border-t bg-background">
- <div className="flex min-h-14 shrink-0 flex-wrap items-center justify-between gap-2 border-b px-3 py-2 sm:px-5">
- <div className="flex min-w-0 items-center gap-2.5">
- <div className="min-w-0">
- <h1 className="truncate text-sm font-semibold">Theme Builder</h1>
- </div>
- <Badge
- className="hidden gap-1.5 capitalize md:inline-flex"
- variant="secondary"
- >
- <span
- className="size-1.5 rounded-full"
- style={{ backgroundColor: activePreset?.theme.colors.primary }}
- />
- {activePreset?.title}
- </Badge>
- </div>
-
- <div className="flex items-center gap-2">
- <div className="flex items-center gap-1">
- <Button
- aria-label="Undo theme change"
- disabled={!canUndo}
- onClick={actions.undo}
- size="icon-sm"
- title="Undo (⌘Z)"
- variant="ghost"
- >
- <Undo2 />
- </Button>
+ <div className="flex shrink-0 flex-wrap items-center justify-between gap-2 border-b px-6 py-2 max-lg:flex-nowrap max-lg:overflow-x-auto **:data-[slot=separator]:h-5!">
+ <div
+ className="flex shrink-0 items-center gap-0.5 rounded-lg bg-muted p-0.5"
+ role="radiogroup"
+ aria-label="PDF renderer base"
+ >
+ {BASE_SWITCHER.map(({ icon: Icon, name }) => (
<Button
- aria-label="Redo theme change"
- disabled={!canRedo}
- onClick={actions.redo}
- size="icon-sm"
- title="Redo (⌘⇧Z)"
+ key={name}
+ asChild
+ className={cn(
+ "h-7 gap-1.5 border border-transparent px-2 text-sm capitalize",
+ base === name
+ ? "bg-background text-foreground shadow-sm hover:bg-background hover:text-foreground"
+ : "text-muted-foreground"
+ )}
+ size="sm"
variant="ghost"
>
- <Redo2 />
+ <Link
+ aria-current={base === name}
+ href={`/theme-builder/${name}`}
+ >
+ <Icon aria-hidden="true" />
+ {name}
+ </Link>
</Button>
- </div>
+ ))}
+ </div>
- <Separator
- className="mx-2 data-[orientation=vertical]:h-5"
- orientation="vertical"
- />
+ <Separator className="md:hidden" orientation="vertical" />
- <Button
- onClick={() => actions.loadPreset(basePreset)}
- size="sm"
- title={`Reset to ${activePreset?.title ?? basePreset}`}
- variant="outline"
- >
- <RotateCcw />
- <span className="hidden sm:inline">Reset</span>
- </Button>
+ <div className="flex items-center gap-2">
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <Button
+ aria-label="Undo theme change"
+ disabled={!canUndo}
+ onClick={actions.undo}
+ size="icon-sm"
+ variant="ghost"
+ >
+ <Undo2 />
+ </Button>
+ </TooltipTrigger>
+ <TooltipContent>Undo (⌘Z)</TooltipContent>
+ </Tooltip>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <Button
+ aria-label="Redo theme change"
+ disabled={!canRedo}
+ onClick={actions.redo}
+ size="icon-sm"
+ variant="ghost"
+ >
+ <Redo2 />
+ </Button>
+ </TooltipTrigger>
+ <TooltipContent>Redo (⌘⇧Z)</TooltipContent>
+ </Tooltip>
- <Separator
- className="mx-2 data-[orientation=vertical]:h-5"
- orientation="vertical"
- />
-
- {pdfUrl ? (
- <Button asChild size="sm" variant="outline">
- <a href={pdfUrl} rel="noopener noreferrer" target="_blank">
- Open in new
- <ExternalLink />
- </a>
- </Button>
- ) : (
- <Button disabled size="sm" variant="outline">
- Open in new
- <ExternalLink />
- </Button>
- )}
+ <Separator orientation="vertical" />
- <Button onClick={shareTheme} size="sm" variant="outline">
- <Share2 />
- <span className="hidden sm:inline">Share</span>
- </Button>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <Button
+ aria-label="Reset to preset defaults"
+ onClick={() => actions.loadPreset(basePreset)}
+ size="sm"
+ variant="outline"
+ >
+ <RotateCcw />
+ <span className="hidden sm:inline">Reset</span>
+ </Button>
+ </TooltipTrigger>
+ <TooltipContent>Reset to preset defaults</TooltipContent>
+ </Tooltip>
- <Separator
- className="mx-2 data-[orientation=vertical]:h-5"
- orientation="vertical"
- />
-
- {pdfUrl ? (
- <Button asChild size="sm" variant="outline">
- <a download={`${safeThemeName}-preview.pdf`} href={pdfUrl}>
- <Download />
- <span className="hidden md:inline">Download</span>
- </a>
- </Button>
- ) : (
- <Button disabled size="sm" variant="outline">
- <Download />
- <span className="hidden md:inline">Download</span>
- </Button>
- )}
+ <Separator orientation="vertical" />
- <Button onClick={() => setCodeOpen(true)} size="sm">
- <Code2 />
- <span className="hidden sm:inline">Get code</span>
- </Button>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ {pdfUrl ? (
+ <Button asChild size="sm" variant="outline">
+ <a
+ aria-label="Open PDF in new tab"
+ href={pdfUrl}
+ rel="noopener noreferrer"
+ target="_blank"
+ >
+ <span className="hidden sm:inline">Open</span>
+ <ExternalLink />
+ </a>
+ </Button>
+ ) : (
+ <Button
+ aria-label="Open PDF in new tab"
+ disabled
+ size="sm"
+ variant="outline"
+ >
+ <span className="hidden sm:inline">Open</span>
+ <ExternalLink />
+ </Button>
+ )}
+ </TooltipTrigger>
+ <TooltipContent>Open PDF in new tab</TooltipContent>
+ </Tooltip>
+
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <Button
+ aria-label="Copy share link"
+ onClick={shareTheme}
+ size="sm"
+ variant="outline"
+ >
+ <Share2 />
+ <span className="hidden sm:inline">Share</span>
+ </Button>
+ </TooltipTrigger>
+ <TooltipContent>Share theme</TooltipContent>
+ </Tooltip>
+
+ <Separator orientation="vertical" />
+
+ <Tooltip>
+ <TooltipTrigger asChild>
+ {pdfUrl ? (
+ <Button asChild size="sm" variant="outline">
+ <a
+ aria-label="Download preview PDF"
+ download={`${safeThemeName}-preview.pdf`}
+ href={pdfUrl}
+ >
+ <Download />
+ <span className="hidden md:inline">Download</span>
+ </a>
+ </Button>
+ ) : (
+ <Button
+ aria-label="Download preview PDF"
+ disabled
+ size="sm"
+ variant="outline"
+ >
+ <Download />
+ <span className="hidden md:inline">Download</span>
+ </Button>
+ )}
+ </TooltipTrigger>
+ <TooltipContent>Download PDF</TooltipContent>
+ </Tooltip>
+
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <Button
+ aria-label="Get theme code"
+ className="gap-1.5"
+ onClick={() => setCodeOpen(true)}
+ size="sm"
+ >
+ <Code2 />
+ Code
+ </Button>
+ </TooltipTrigger>
+ <TooltipContent>Get theme code</TooltipContent>
+ </Tooltip>
</div>
</div>
- <div className="grid min-h-0 flex-1 lg:grid-cols-[minmax(0,1fr)_390px]">
+ <div
+ className={cn(
+ "grid min-h-0 flex-1 transition-[grid-template-columns] duration-300 ease-in-out",
+ sidebarOpen
+ ? "lg:grid-cols-[minmax(0,1fr)_390px]"
+ : "lg:grid-cols-[minmax(0,1fr)_0px]"
+ )}
+ >
<section
- className="relative min-h-0 overflow-hidden bg-muted/35 p-2 sm:p-4"
+ className="relative min-h-0 overflow-hidden bg-muted/35 p-6"
aria-label="Live PDF preview"
>
<div className="mx-auto h-full max-w-5xl overflow-hidden rounded-xl border bg-background shadow-sm">
<PdfPreview
- base="forme"
+ base={base}
className="h-full rounded-none border-0"
height="100%"
name="invoice-classic"
@@ -232,58 +311,100 @@ export const ThemeBuilder = () => {
</div>
<Button
- className="absolute right-5 bottom-5 shadow-lg lg:hidden"
+ className="absolute right-6 bottom-6 shadow-lg lg:hidden"
onClick={() => setCustomizerOpen(true)}
>
<SlidersHorizontal />
Customize
</Button>
+
+ {sidebarOpen ? null : (
+ <Button
+ className="absolute right-6 bottom-6 shadow-lg max-lg:hidden"
+ onClick={() => setSidebarOpen(true)}
+ >
+ <SlidersHorizontal />
+ Customize
+ </Button>
+ )}
+
+ <div
+ className={cn(
+ "absolute inset-y-0 right-0 z-20 flex w-full flex-col border-l bg-background shadow-2xl transition-transform duration-300 ease-in-out lg:hidden",
+ customizerOpen
+ ? "translate-x-0"
+ : "pointer-events-none translate-x-full"
+ )}
+ aria-hidden={!customizerOpen}
+ >
+ <div className="flex items-start justify-between border-b px-6 py-3">
+ <div className="min-w-0">
+ <h2 className="text-sm font-semibold">Customize theme</h2>
+ <p className="text-xs text-muted-foreground">
+ Changes render in the preview automatically.
+ </p>
+ </div>
+ <Button
+ aria-label="Close customize panel"
+ onClick={() => setCustomizerOpen(false)}
+ size="icon-sm"
+ title="Hide panel"
+ variant="ghost"
+ >
+ <ChevronRight />
+ </Button>
+ </div>
+ <div className="min-h-0 flex-1 overflow-y-auto overscroll-contain">
+ <ThemeControls
+ actions={actions}
+ basePreset={basePreset}
+ idPrefix="mobile"
+ theme={theme}
+ />
+ </div>
+ </div>
</section>
<aside
- className="hidden min-h-0 flex-col border-l bg-background lg:flex"
+ className={cn(
+ "hidden min-h-0 flex-col overflow-hidden bg-background lg:flex",
+ sidebarOpen && "border-l"
+ )}
+ aria-hidden={!sidebarOpen}
aria-label="Theme controls"
>
- <div className="border-b px-4 py-3">
- <h2 className="text-sm font-semibold">Customize</h2>
- <p className="text-xs text-muted-foreground">
- Changes render in the preview automatically.
- </p>
- </div>
- <div className="min-h-0 flex-1 overflow-y-auto overscroll-contain">
- <ThemeControls
- actions={actions}
- basePreset={basePreset}
- idPrefix="desktop"
- theme={theme}
- />
+ <div className="flex h-full w-[390px] min-h-0 flex-col">
+ <div className="flex items-start justify-between border-b px-6 py-3">
+ <div className="min-w-0">
+ <h2 className="text-sm font-semibold">Customize</h2>
+ <p className="text-xs text-muted-foreground">
+ Changes render in the preview automatically.
+ </p>
+ </div>
+ <Button
+ aria-label="Close customize panel"
+ onClick={() => setSidebarOpen(false)}
+ size="icon-sm"
+ title="Hide panel"
+ variant="ghost"
+ >
+ <ChevronRight />
+ </Button>
+ </div>
+ <div className="min-h-0 flex-1 overflow-y-auto overscroll-contain">
+ <ThemeControls
+ actions={actions}
+ basePreset={basePreset}
+ idPrefix="desktop"
+ theme={theme}
+ />
+ </div>
</div>
</aside>
</div>
- <Sheet onOpenChange={setCustomizerOpen} open={customizerOpen}>
- <SheetContent
- className="w-full gap-0 p-0 sm:max-w-md lg:hidden"
- side="right"
- >
- <SheetHeader className="border-b pr-12">
- <SheetTitle>Customize theme</SheetTitle>
- <SheetDescription>
- Changes render in the preview automatically.
- </SheetDescription>
- </SheetHeader>
- <div className="min-h-0 flex-1 overflow-y-auto overscroll-contain">
- <ThemeControls
- actions={actions}
- basePreset={basePreset}
- idPrefix="mobile"
- theme={theme}
- />
- </div>
- </SheetContent>
- </Sheet>
-
<ThemeCodeDialog
+ basePreset={basePreset}
onOpenChange={setCodeOpen}
open={codeOpen}
theme={theme}
diff --git a/components/theme-builder/theme-code-dialog.tsx b/components/theme-builder/theme-code-dialog.tsx
index 00913db..77d989c 100644
--- a/components/theme-builder/theme-code-dialog.tsx
+++ b/components/theme-builder/theme-code-dialog.tsx
@@ -1,7 +1,7 @@
"use client";
import { Check, Copy, Download } from "lucide-react";
-import { useMemo, useState } from "react";
+import { useEffect, useMemo, useState } from "react";
import { toast } from "sonner";
import { Button } from "@/components/ui/button";
@@ -12,29 +12,78 @@ import {
DialogHeader,
DialogTitle,
} from "@/components/ui/dialog";
-import type { PdfcnTheme } from "@/registry/themes";
+import { cn } from "@/lib/utils";
+import type { PdfcnTheme, ThemePresetName } from "@/registry/themes";
+
+import { getRemoteFontFamilies } from "./preview-fonts";
+import { generateDeltaCode, generateThemeCode } from "./theme-code";
+
+type CodeTab = "delta" | "full";
interface ThemeCodeDialogProps {
+ basePreset: ThemePresetName;
onOpenChange: (open: boolean) => void;
open: boolean;
theme: PdfcnTheme;
}
export const ThemeCodeDialog = ({
+ basePreset,
onOpenChange,
open,
theme,
}: ThemeCodeDialogProps) => {
const [copied, setCopied] = useState(false);
+ const [highlightedCode, setHighlightedCode] = useState<string | null>(null);
+ const [tab, setTab] = useState<CodeTab>("full");
+
const code = useMemo(
() =>
- `import type { PdfcnTheme } from "@/registry/themes";\n\nexport const customTheme: PdfcnTheme = ${JSON.stringify(theme, null, 2)};\n`,
- [theme]
+ tab === "full"
+ ? generateThemeCode(theme)
+ : generateDeltaCode(theme, basePreset),
+ [basePreset, tab, theme]
);
+ const remoteFonts = useMemo(
+ () =>
+ getRemoteFontFamilies([
+ theme.typography.body.fontFamily,
+ theme.typography.heading.fontFamily,
+ ]),
+ [theme.typography.body.fontFamily, theme.typography.heading.fontFamily]
+ );
+
+ useEffect(() => {
+ if (!open) {
+ return;
+ }
+
+ let cancelled = false;
+
+ (async () => {
+ const { highlightCode } = await import("@/lib/highlight-code");
+ const html = await highlightCode(code, "ts");
+ if (!cancelled) {
+ setHighlightedCode(html);
+ }
+ })();
+
+ return () => {
+ cancelled = true;
+ };
+ }, [code, open]);
+
+ const safeName =
+ theme.name
+ .trim()
+ .toLowerCase()
+ .replaceAll(/[^a-z0-9-]+/g, "-") || "custom-theme";
+
const handleOpenChange = (nextOpen: boolean) => {
if (!nextOpen) {
setCopied(false);
+ setTab("full");
}
onOpenChange(nextOpen);
};
@@ -54,11 +103,6 @@ export const ThemeCodeDialog = ({
new Blob([code], { type: "text/typescript;charset=utf-8" })
);
const link = document.createElement("a");
- const safeName =
- theme.name
- .trim()
- .toLowerCase()
- .replaceAll(/[^a-z0-9-]+/g, "-") || "custom-theme";
link.download = `${safeName}.ts`;
link.href = objectUrl;
link.click();
@@ -69,20 +113,48 @@ export const ThemeCodeDialog = ({
<Dialog onOpenChange={handleOpenChange} open={open}>
<DialogContent className="gap-0 overflow-hidden p-0 sm:max-w-3xl">
<DialogHeader className="border-b p-5 pr-12">
- <DialogTitle>Theme code</DialogTitle>
+ <DialogTitle>Generated theme code</DialogTitle>
<DialogDescription>
- Copy this object into your project and pass it to any themed pdfcn
- document.
+ Copy into{" "}
+ <code className="rounded bg-muted px-1 py-0.5 font-mono text-[10px]">
+ src/lib/{safeName}.ts
+ </code>{" "}
+ in your project and pass it to any themed pdfcn document.
</DialogDescription>
</DialogHeader>
- <div className="flex items-center justify-between border-b bg-muted/40 px-4 py-2">
- <span className="font-mono text-xs text-muted-foreground">
- {theme.name || "custom-theme"}.ts
- </span>
+ <div className="flex flex-wrap items-center justify-between gap-2 border-b bg-muted/40 px-4 py-2">
+ <div className="flex overflow-hidden rounded-lg border bg-background">
+ <Button
+ className={cn(
+ "h-7 rounded-none border-0 px-3 text-xs",
+ tab === "full"
+ ? "bg-foreground text-background hover:bg-foreground hover:text-background"
+ : "text-muted-foreground"
+ )}
+ onClick={() => setTab("full")}
+ size="sm"
+ variant="ghost"
+ >
+ Full theme
+ </Button>
+ <Button
+ className={cn(
+ "h-7 rounded-none border-l px-3 text-xs",
+ tab === "delta"
+ ? "bg-foreground text-background hover:bg-foreground hover:text-background"
+ : "text-muted-foreground"
+ )}
+ onClick={() => setTab("delta")}
+ size="sm"
+ variant="ghost"
+ >
+ Delta from <span className="capitalize">{basePreset}</span>
+ </Button>
+ </div>
<div className="flex items-center gap-2">
<Button onClick={downloadCode} size="sm" variant="ghost">
<Download />
- Download
+ Download .ts
</Button>
<Button onClick={copyCode} size="sm" variant="outline">
{copied ? <Check /> : <Copy />}
@@ -90,9 +162,37 @@ export const ThemeCodeDialog = ({
</Button>
</div>
</div>
- <pre className="max-h-[65svh] overflow-auto bg-zinc-950 p-5 font-mono text-xs leading-relaxed text-zinc-100">
- <code>{code}</code>
- </pre>
+ {tab === "full" && remoteFonts.length > 0 ? (
+ <div className="border-b border-amber-500/20 bg-amber-500/10 px-5 py-3">
+ <p className="text-[11px] text-amber-900 dark:text-amber-200">
+ <strong className="font-semibold">Production note:</strong> this
+ theme uses {remoteFonts.map((font) => `'${font}'`).join(" and ")}{" "}
+ from jsDelivr at runtime. For offline or restricted deployments,
+ self-host those font files or switch to built-in fonts before
+ release.
+ </p>
+ </div>
+ ) : null}
+ <div className="max-h-[60svh] overflow-auto [&_pre]:m-0">
+ {highlightedCode ? (
+ <div
+ dangerouslySetInnerHTML={{ __html: highlightedCode }}
+ dir="ltr"
+ />
+ ) : (
+ <pre className="bg-code p-5 font-mono text-xs leading-relaxed text-code-foreground">
+ <code>{code}</code>
+ </pre>
+ )}
+ </div>
+ <div className="border-t bg-muted/20 px-5 py-3">
+ <p className="text-[11px] text-muted-foreground">
+ <strong className="text-foreground/70">Tip:</strong> use the{" "}
+ <strong className="text-foreground/70">Delta</strong> tab if you
+ only changed a few values — it shows a minimal override to merge
+ with your base preset.
+ </p>
+ </div>
</DialogContent>
</Dialog>
);
diff --git a/components/theme-builder/theme-code.ts b/components/theme-builder/theme-code.ts
new file mode 100644
index 0000000..8d7fc9e
--- /dev/null
+++ b/components/theme-builder/theme-code.ts
@@ -0,0 +1,45 @@
+import type { PdfcnTheme, ThemePresetName } from "@/registry/themes";
+import { themePresets } from "@/registry/themes";
+
+type Json = boolean | Json[] | null | number | string | { [key: string]: Json };
+
+const deepDiff = (base: Json, next: Json): Json | undefined => {
+ if (Array.isArray(base) || Array.isArray(next)) {
+ return JSON.stringify(base) === JSON.stringify(next) ? undefined : next;
+ }
+
+ if (
+ base !== null &&
+ next !== null &&
+ typeof base === "object" &&
+ typeof next === "object"
+ ) {
+ const result: Record<string, Json> = {};
+
+ for (const key of Object.keys(next)) {
+ const delta = deepDiff(base[key], next[key]);
+ if (delta !== undefined) {
+ result[key] = delta;
+ }
+ }
+
+ return Object.keys(result).length > 0 ? result : undefined;
+ }
+
+ return base === next ? undefined : next;
+};
+
+export const generateThemeCode = (theme: PdfcnTheme) =>
+ `import type { PdfcnTheme } from "@/registry/themes";\n\nexport const customTheme: PdfcnTheme = ${JSON.stringify(theme, null, 2)};\n`;
+
+export const generateDeltaCode = (
+ theme: PdfcnTheme,
+ basePreset: ThemePresetName
+) => {
+ const overrides = deepDiff(
+ themePresets[basePreset] as unknown as Json,
+ theme as unknown as Json
+ );
+
+ return `// Spread this over the '${basePreset}' preset:\nconst overrides = ${JSON.stringify(overrides ?? {}, null, 2)};\n`;
+};
diff --git a/components/theme-builder/theme-controls.tsx b/components/theme-builder/theme-controls.tsx
index 777821c..aa521b3 100644
--- a/components/theme-builder/theme-controls.tsx
+++ b/components/theme-builder/theme-controls.tsx
@@ -1,15 +1,9 @@
"use client";
-import { Check, LayoutTemplate, Palette, Type } from "lucide-react";
+import { LayoutTemplate, Palette, Shuffle, Type } from "lucide-react";
+import { Fragment } from "react";
import { Button } from "@/components/ui/button";
-import {
- Card,
- CardContent,
- CardDescription,
- CardHeader,
- CardTitle,
-} from "@/components/ui/card";
import { Input } from "@/components/ui/input";
import {
Select,
@@ -18,6 +12,7 @@ import {
SelectTrigger,
SelectValue,
} from "@/components/ui/select";
+import { Separator } from "@/components/ui/separator";
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
import { cn } from "@/lib/utils";
import type { PdfcnTheme, ThemePresetName } from "@/registry/themes";
@@ -32,21 +27,30 @@ import type {
} from "./use-theme-builder";
const COLOR_FIELDS = [
- { key: "background", label: "Background" },
- { key: "foreground", label: "Foreground" },
- { key: "primary", label: "Primary" },
- { key: "primaryForeground", label: "Primary foreground" },
- { key: "muted", label: "Muted" },
- { key: "mutedForeground", label: "Muted foreground" },
- { key: "accent", label: "Accent" },
- { key: "border", label: "Border" },
- { key: "destructive", label: "Destructive" },
- { key: "success", label: "Success" },
- { key: "warning", label: "Warning" },
- { key: "info", label: "Info" },
+ { description: "Primary text", key: "foreground", label: "Foreground" },
+ { description: "Page background", key: "background", label: "Background" },
+ { description: "Brand emphasis", key: "primary", label: "Primary" },
+ {
+ description: "Text on primary",
+ key: "primaryForeground",
+ label: "Primary foreground",
+ },
+ { description: "Secondary fill", key: "muted", label: "Muted" },
+ {
+ description: "Captions, footnotes",
+ key: "mutedForeground",
+ label: "Muted foreground",
+ },
+ { description: "Links, highlights", key: "accent", label: "Accent" },
+ { description: "Dividers, table lines", key: "border", label: "Border" },
+ { description: "Errors", key: "destructive", label: "Destructive" },
+ { description: "Success states", key: "success", label: "Success" },
+ { description: "Warning states", key: "warning", label: "Warning" },
+ { description: "Info states", key: "info", label: "Info" },
] as const satisfies readonly {
key: ColorTokenName;
label: string;
+ description: string;
}[];
const FONT_OPTIONS = [
@@ -121,44 +125,69 @@ const NumberField = ({
);
interface ColorFieldProps {
+ description: string;
label: string;
onCommit: (value: string) => void;
value: string;
}
-const ColorField = ({ label, onCommit, value }: ColorFieldProps) => (
- <div className="flex items-center gap-3 rounded-lg border bg-card p-2.5">
+const ColorField = ({
+ description,
+ label,
+ onCommit,
+ value,
+}: ColorFieldProps) => (
+ <div className="flex items-center gap-3">
+ <div className="min-w-0 flex-1">
+ <span className="block truncate text-xs font-medium">{label}</span>
+ <span className="block truncate text-[10px] text-muted-foreground">
+ {description}
+ </span>
+ </div>
<Input
aria-label={`Choose ${label.toLowerCase()} color`}
- className="size-9 cursor-pointer rounded-md border-0 p-0.5 shadow-none"
+ className="size-8 shrink-0 cursor-pointer rounded-md border-0 bg-transparent p-0.5 shadow-none"
onChange={(event) => onCommit(event.currentTarget.value)}
type="color"
value={value}
/>
- <label className="min-w-0 flex-1">
- <span className="block truncate text-xs font-medium">{label}</span>
- <Input
- key={`${label}-${value}`}
- aria-label={`${label} hex value`}
- className="mt-1 h-7 px-2 font-mono text-[11px] uppercase"
- defaultValue={value}
- maxLength={7}
- onBlur={(event) => {
- const nextValue = event.currentTarget.value.trim();
- if (/^#[0-9a-f]{6}$/i.test(nextValue)) {
- onCommit(nextValue.toLowerCase());
- } else {
- event.currentTarget.value = value;
- }
- }}
- onKeyDown={(event) => {
- if (event.key === "Enter") {
- event.currentTarget.blur();
- }
- }}
- spellCheck={false}
- />
- </label>
+ <Input
+ key={`${label}-${value}`}
+ aria-label={`${label} hex value`}
+ className="h-8 w-[5.5rem] shrink-0 px-2 font-mono text-[11px] uppercase"
+ defaultValue={value}
+ maxLength={7}
+ onBlur={(event) => {
+ const nextValue = event.currentTarget.value.trim();
+ if (/^#[0-9a-f]{6}$/i.test(nextValue)) {
+ onCommit(nextValue.toLowerCase());
+ } else {
+ event.currentTarget.value = value;
+ }
+ }}
+ onKeyDown={(event) => {
+ if (event.key === "Enter") {
+ event.currentTarget.blur();
+ }
+ }}
+ spellCheck={false}
+ />
+ </div>
+);
+
+interface SectionProps {
+ children: React.ReactNode;
+ description: string;
+ title: string;
+}
+
+const Section = ({ children, description, title }: SectionProps) => (
+ <div>
+ <div className="mb-3 space-y-0.5">
+ <h3 className="text-sm font-semibold">{title}</h3>
+ <p className="text-xs text-muted-foreground">{description}</p>
+ </div>
+ {children}
</div>
);
@@ -177,95 +206,90 @@ export const ThemeControls = ({
idPrefix,
theme,
}: ThemeControlsProps) => (
- <div className={cn("space-y-5 p-4", className)}>
- <Card className="gap-4 py-4 shadow-none">
- <CardHeader className="gap-1 px-4">
- <CardTitle className="text-sm">Theme</CardTitle>
- <CardDescription className="text-xs">
- Start from a built-in pdfcn preset.
- </CardDescription>
- </CardHeader>
- <CardContent className="space-y-4 px-4">
- <label
- className="grid gap-1.5 text-xs font-medium"
- htmlFor={`${idPrefix}-theme-name`}
- >
- Export name
- <Input
- key={theme.name}
- id={`${idPrefix}-theme-name`}
- className="h-8"
- defaultValue={theme.name}
- maxLength={48}
- onBlur={(event) => {
- const nextName = event.currentTarget.value.trim();
- if (nextName) {
- actions.setName(nextName);
- } else {
- event.currentTarget.value = theme.name;
- }
- }}
- onKeyDown={(event) => {
- if (event.key === "Enter") {
- event.currentTarget.blur();
- }
- }}
- />
- </label>
+ <div className={cn("space-y-4 py-4", className)}>
+ <div className="space-y-3 border-b px-6 pb-4">
+ <label
+ className="grid gap-1.5 text-xs font-medium"
+ htmlFor={`${idPrefix}-theme-name`}
+ >
+ Export name
+ <Input
+ key={theme.name}
+ id={`${idPrefix}-theme-name`}
+ className="h-8"
+ defaultValue={theme.name}
+ maxLength={48}
+ onBlur={(event) => {
+ const nextName = event.currentTarget.value.trim();
+ if (nextName) {
+ actions.setName(nextName);
+ } else {
+ event.currentTarget.value = theme.name;
+ }
+ }}
+ onKeyDown={(event) => {
+ if (event.key === "Enter") {
+ event.currentTarget.blur();
+ }
+ }}
+ />
+ </label>
- <div className="grid grid-cols-3 gap-2">
- {THEMES.map(({ name, theme: presetTheme, title }) => {
- const selected = name === basePreset;
- return (
- <Button
- key={name}
- aria-pressed={selected}
- className={cn(
- "relative h-auto min-w-0 flex-col items-stretch gap-2 px-2.5 py-2.5 text-left",
- selected && "border-primary bg-primary/5"
- )}
- onClick={() => actions.loadPreset(name)}
- size="sm"
- variant="outline"
- >
- <span className="flex w-full items-center gap-1">
+ <div className="flex items-center gap-1.5">
+ <Select
+ onValueChange={(value) =>
+ actions.loadPreset(value as ThemePresetName)
+ }
+ value={basePreset}
+ >
+ <SelectTrigger
+ className="w-full flex-1"
+ id={`${idPrefix}-preset`}
+ size="sm"
+ >
+ <SelectValue />
+ </SelectTrigger>
+ <SelectContent>
+ {THEMES.map(({ name, theme: presetTheme, title }) => (
+ <SelectItem key={name} value={name}>
+ <span className="flex items-center gap-2">
<span
- className="size-3.5 shrink-0 rounded-full border"
+ className="size-2.5 shrink-0 rounded-full border"
style={{ backgroundColor: presetTheme.colors.primary }}
/>
- <span className="truncate text-[11px]">{title}</span>
- {selected ? <Check className="ml-auto size-3" /> : null}
- </span>
- <span className="flex gap-0.5" aria-hidden="true">
- {[
- presetTheme.colors.background,
- presetTheme.colors.foreground,
- presetTheme.colors.muted,
- presetTheme.colors.accent,
- ].map((color) => (
- <span
- key={color}
- className="h-1.5 flex-1 rounded-full border"
- style={{ backgroundColor: color }}
- />
- ))}
+ {title}
</span>
- </Button>
- );
- })}
- </div>
- </CardContent>
- </Card>
+ </SelectItem>
+ ))}
+ </SelectContent>
+ </Select>
+ <Button
+ aria-label="Pick a random preset"
+ onClick={() => {
+ const others = THEMES.filter(({ name }) => name !== basePreset);
+ const next = others[Math.floor(Math.random() * others.length)];
+ if (next) {
+ actions.loadPreset(next.name);
+ }
+ }}
+ size="icon-sm"
+ title="Pick a random preset"
+ variant="outline"
+ >
+ <Shuffle />
+ </Button>
+ </div>
+ </div>
- <Tabs defaultValue="colors">
+ <Tabs className="gap-4 px-6" defaultValue="colors">
<TabsList className="grid w-full grid-cols-3">
<TabsTrigger value="colors">
<Palette />
Colors
</TabsTrigger>
- <TabsTrigger value="type">
+ <TabsTrigger value="typography">
<Type />
- Type
+ Typography
</TabsTrigger>
<TabsTrigger value="layout">
<LayoutTemplate />
@@ -273,28 +297,26 @@ export const ThemeControls = ({
</TabsTrigger>
</TabsList>
- <TabsContent className="mt-3" value="colors">
- <div className="grid gap-2 sm:grid-cols-2 lg:grid-cols-1 xl:grid-cols-2">
- {COLOR_FIELDS.map(({ key, label }) => (
+ <TabsContent value="colors">
+ {COLOR_FIELDS.map(({ key, label, description }, index) => (
+ <Fragment key={key}>
+ {index > 0 ? <Separator className="my-3" /> : null}
<ColorField
- key={key}
+ description={description}
label={label}
onCommit={(value) => actions.setColor(key, value)}
value={theme.colors[key]}
/>
- ))}
- </div>
+ </Fragment>
+ ))}
</TabsContent>
- <TabsContent className="mt-3 space-y-3" value="type">
- <Card className="gap-4 py-4 shadow-none">
- <CardHeader className="gap-1 px-4">
- <CardTitle className="text-sm">Body</CardTitle>
- <CardDescription className="text-xs">
- Base type used across paragraphs and tables.
- </CardDescription>
- </CardHeader>
- <CardContent className="grid gap-3 px-4 sm:grid-cols-2 lg:grid-cols-1 xl:grid-cols-2">
+ <TabsContent value="typography">
+ <Section
+ description="Base type used across paragraphs and tables."
+ title="Body"
+ >
+ <div className="grid gap-3 sm:grid-cols-2 lg:grid-cols-1 xl:grid-cols-2">
<label
className="grid gap-1.5 text-xs font-medium sm:col-span-2 lg:col-span-1 xl:col-span-2"
htmlFor={`${idPrefix}-body-font`}
@@ -305,8 +327,9 @@ export const ThemeControls = ({
value={theme.typography.body.fontFamily}
>
<SelectTrigger
- className="h-8 w-full"
+ className="w-full"
id={`${idPrefix}-body-font`}
+ size="sm"
>
<SelectValue />
</SelectTrigger>
@@ -335,17 +358,16 @@ export const ThemeControls = ({
step={0.05}
value={theme.typography.body.lineHeight}
/>
- </CardContent>
- </Card>
+ </div>
+ </Section>
+
+ <Separator className="my-4" />
- <Card className="gap-4 py-4 shadow-none">
- <CardHeader className="gap-1 px-4">
- <CardTitle className="text-sm">Headings</CardTitle>
- <CardDescription className="text-xs">
- Display type, weight, and scale.
- </CardDescription>
- </CardHeader>
- <CardContent className="grid gap-3 px-4 sm:grid-cols-2 lg:grid-cols-1 xl:grid-cols-2">
+ <Section
+ description="Display type, weight, and scale."
+ title="Headings"
+ >
+ <div className="grid gap-3 sm:grid-cols-2 lg:grid-cols-1 xl:grid-cols-2">
<label
className="grid gap-1.5 text-xs font-medium sm:col-span-2 lg:col-span-1 xl:col-span-2"
htmlFor={`${idPrefix}-heading-font`}
@@ -356,8 +378,9 @@ export const ThemeControls = ({
value={theme.typography.heading.fontFamily}
>
<SelectTrigger
- className="h-8 w-full"
+ className="w-full"
id={`${idPrefix}-heading-font`}
+ size="sm"
>
<SelectValue />
</SelectTrigger>
@@ -382,8 +405,9 @@ export const ThemeControls = ({
value={String(theme.typography.heading.fontWeight)}
>
<SelectTrigger
- className="h-8 w-full"
+ className="w-full"
id={`${idPrefix}-heading-weight`}
+ size="sm"
>
<SelectValue />
</SelectTrigger>
@@ -417,19 +441,13 @@ export const ThemeControls = ({
value={theme.typography.heading.fontSize[level]}
/>
))}
- </CardContent>
- </Card>
+ </div>
+ </Section>
</TabsContent>
- <TabsContent className="mt-3 space-y-3" value="layout">
- <Card className="gap-4 py-4 shadow-none">
- <CardHeader className="gap-1 px-4">
- <CardTitle className="text-sm">Page</CardTitle>
- <CardDescription className="text-xs">
- Paper format and reading direction.
- </CardDescription>
- </CardHeader>
- <CardContent className="grid grid-cols-2 gap-3 px-4">
+ <TabsContent value="layout">
+ <Section description="Paper format and reading direction." title="Page">
+ <div className="grid grid-cols-2 gap-3">
<label
className="grid gap-1.5 text-xs font-medium"
htmlFor={`${idPrefix}-page-size`}
@@ -442,8 +460,9 @@ export const ThemeControls = ({
value={theme.page.size}
>
<SelectTrigger
- className="h-8 w-full"
+ className="w-full"
id={`${idPrefix}-page-size`}
+ size="sm"
>
<SelectValue />
</SelectTrigger>
@@ -468,8 +487,9 @@ export const ThemeControls = ({
value={theme.page.orientation}
>
<SelectTrigger
- className="h-8 w-full capitalize"
+ className="w-full capitalize"
id={`${idPrefix}-page-orientation`}
+ size="sm"
>
<SelectValue />
</SelectTrigger>
@@ -479,17 +499,16 @@ export const ThemeControls = ({
</SelectContent>
</Select>
</label>
- </CardContent>
- </Card>
+ </div>
+ </Section>
+
+ <Separator className="my-4" />
- <Card className="gap-4 py-4 shadow-none">
- <CardHeader className="gap-1 px-4">
- <CardTitle className="text-sm">Margins</CardTitle>
- <CardDescription className="text-xs">
- Space between content and every page edge.
- </CardDescription>
- </CardHeader>
- <CardContent className="grid grid-cols-2 gap-3 px-4">
+ <Section
+ description="Space between content and every page edge."
+ title="Margins"
+ >
+ <div className="grid grid-cols-2 gap-3">
{(
[
["marginTop", "Top"],
@@ -508,17 +527,16 @@ export const ThemeControls = ({
value={theme.spacing.page[edge]}
/>
))}
- </CardContent>
- </Card>
+ </div>
+ </Section>
- <Card className="gap-4 py-4 shadow-none">
- <CardHeader className="gap-1 px-4">
- <CardTitle className="text-sm">Rhythm</CardTitle>
- <CardDescription className="text-xs">
- Vertical spacing between document elements.
- </CardDescription>
- </CardHeader>
- <CardContent className="grid gap-3 px-4 sm:grid-cols-3 lg:grid-cols-1 xl:grid-cols-3">
+ <Separator className="my-4" />
+
+ <Section
+ description="Vertical spacing between document elements."
+ title="Rhythm"
+ >
+ <div className="grid gap-3 sm:grid-cols-3 lg:grid-cols-1 xl:grid-cols-3">
{(
[
["sectionGap", "Sections"],
@@ -536,8 +554,8 @@ export const ThemeControls = ({
value={theme.spacing[key]}
/>
))}
- </CardContent>
- </Card>
+ </div>
+ </Section>
</TabsContent>
</Tabs>
</div>
diff --git a/constants/routes.ts b/constants/routes.ts
index e1ba650..941530f 100644
--- a/constants/routes.ts
+++ b/constants/routes.ts
@@ -25,4 +25,6 @@ export const ROUTES = {
SITEMAP: "/sitemap.xml",
SPONSOR: "/sponsor",
THEME_BUILDER: "/theme-builder",
+ THEME_BUILDER_FORME: "/theme-builder/forme",
+ THEME_BUILDER_TAKUMI: "/theme-builder/takumi",
} as const;
diff --git a/next.config.mjs b/next.config.mjs
index 1ea555f..afad03c 100644
--- a/next.config.mjs
+++ b/next.config.mjs
@@ -52,6 +52,11 @@ const nextConfig = {
permanent: true,
source: ROUTES.DOCS_THEMING,
},
+ {
+ destination: ROUTES.THEME_BUILDER_TAKUMI,
+ permanent: false,
+ source: ROUTES.THEME_BUILDER,
+ },
];
},
serverExternalPackages: ["@formepdf/core"],