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.

refactor: enhance ComponentCode integration in HomePdfShowcase and improve styling options

Aniket-5082db39c0b37f5
diff --git a/components/component-code.tsx b/components/component-code.tsx
index c60cb2f..0f16ee5 100644
--- a/components/component-code.tsx
+++ b/components/component-code.tsx
@@ -1,18 +1,26 @@
import { CopyButton } from "@/components/copy-button";
import { getIconForLanguageExtension } from "@/components/icons";
+import { cn } from "@/lib/utils";
export const ComponentCode = ({
code,
highlightedCode,
language,
title,
+ className,
+ copyButtonClassName,
}: {
code: string;
highlightedCode: string;
language: string;
title: string | undefined;
+ className?: string;
+ copyButtonClassName?: string;
}) => (
- <figure data-rehype-pretty-code-figure="" className="[&>pre]:max-h-96">
+ <figure
+ data-rehype-pretty-code-figure=""
+ className={cn("[&>pre]:max-h-96", className)}
+ >
{title ? (
<figcaption
className="text-code-foreground flex items-center gap-2 [&_svg]:size-4 [&_svg]:opacity-70"
@@ -23,7 +31,11 @@ export const ComponentCode = ({
{title}
</figcaption>
) : null}
- <CopyButton event="copy_primitive_code" value={code} />
+ <CopyButton
+ event="copy_primitive_code"
+ value={code}
+ className={copyButtonClassName}
+ />
<div dangerouslySetInnerHTML={{ __html: highlightedCode }} />
</figure>
);
diff --git a/components/home-pdf-showcase.tsx b/components/home-pdf-showcase.tsx
index c5939b0..8bc2de5 100644
--- a/components/home-pdf-showcase.tsx
+++ b/components/home-pdf-showcase.tsx
@@ -6,7 +6,7 @@ import Link from "next/link";
import { useEffect, useState } from "react";
import { CodeBlockCommand } from "@/components/code-block-command";
-import { CopyButton } from "@/components/copy-button";
+import { ComponentCode } from "@/components/component-code";
import {
getHomePdfSource,
homePdfBases,
@@ -85,11 +85,7 @@ const CodeViewer = ({
highlightedCode?: string;
isLoading?: boolean;
}) => (
- <div className="relative h-full min-h-[560px] bg-code text-code-foreground lg:min-h-0">
- <div className="absolute right-2 top-2 z-10">
- <CopyButton className="bg-transparent" value={code ?? ""} />
- </div>
-
+ <div className="relative h-full min-h-140 bg-code text-code-foreground lg:min-h-0">
<div className="no-scrollbar min-h-0 flex-1 overflow-auto">
{isLoading ? (
<div
@@ -108,12 +104,14 @@ const CodeViewer = ({
</div>
) : null}
{highlightedCode && !isLoading ? (
- <figure
- data-rehype-pretty-code-figure=""
- className="!m-0 min-h-full !rounded-none text-sm [&>div]:min-h-full [&_pre]:min-h-full"
- >
- <div dangerouslySetInnerHTML={{ __html: highlightedCode }} />
- </figure>
+ <ComponentCode
+ code={code ?? ""}
+ highlightedCode={highlightedCode}
+ language="tsx"
+ title={undefined}
+ className="mt-0"
+ copyButtonClassName="right-4"
+ />
) : null}
</div>
</div>
@@ -298,7 +296,7 @@ export const HomePdfShowcase = () => {
<Separator />
- <CardContent className="p-0 lg:grid lg:h-[720px] lg:grid-cols-[14rem_minmax(0,1fr)_20rem]">
+ <CardContent className="p-0 lg:grid lg:h-180 lg:grid-cols-[14rem_minmax(0,1fr)_20rem]">
<aside
aria-label="PDF examples"
className="hidden flex-col bg-card lg:flex lg:border-r"