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(web): add agent prompt to homepage

Aniket-5081804e8aacd32
diff --git a/apps/web/app/(app)/(root)/page.tsx b/apps/web/app/(app)/(root)/page.tsx
index e5989b8..f13f34f 100644
--- a/apps/web/app/(app)/(root)/page.tsx
+++ b/apps/web/app/(app)/(root)/page.tsx
@@ -1,3 +1,4 @@
+import { AgentPrompt } from "@/components/agent-prompt";
import { CommandBox } from "@/components/command-box";
import { HomeCtas } from "@/components/home-ctas";
import { HomePdfShowcase } from "@/components/home-pdf-showcase";
@@ -31,6 +32,8 @@ const IndexPage = () => (
<CommandBox className="mt-4 w-full max-w-xl" />
<HomeCtas className="mt-4" />
+
+ <AgentPrompt />
</div>
</section>
</PageTransition>
diff --git a/apps/web/components/agent-prompt.tsx b/apps/web/components/agent-prompt.tsx
new file mode 100644
index 0000000..d5ae5bc
--- /dev/null
+++ b/apps/web/components/agent-prompt.tsx
@@ -0,0 +1,56 @@
+"use client";
+
+import { CheckIcon, CopyIcon } from "lucide-react";
+import { AnimatePresence, motion } from "motion/react";
+
+import { motionIconProps } from "@/components/copy-button";
+import { Button } from "@/components/ui/button";
+import { ROUTES } from "@/constants/routes";
+import { FALLBACK_SITE_ORIGIN, SITE } from "@/constants/site";
+import { useCopyToClipboard } from "@/hooks/use-copy-to-clipboard";
+import { trackEvent } from "@/lib/events";
+import { cn } from "@/lib/utils";
+
+const installCommand = `npx shadcn@latest add ${SITE.REGISTRY}/takumi/text`;
+
+const agentInstallPrompt = `Read the pdfcn agent instructions at ${FALLBACK_SITE_ORIGIN}${ROUTES.LLMS}, then install pdfcn in this project. Use the Takumi renderer by default (components under ${SITE.REGISTRY}/takumi/*); use Forme (${SITE.REGISTRY}/forme/*) only if the project already uses @formepdf/react or the user asks for it. Run ${installCommand}. Then add a basic example that renders a Document and Page from "@/components/pdf/pdf-primitives", wraps the content in PdfcnThemeProvider from "@/components/pdf/theme-provider", and uses Text from "@/components/pdf/text". For complete documents, install a block such as ${SITE.REGISTRY}/takumi/invoice-minimal instead of building from scratch. Preserve the existing Tailwind CSS and shadcn/ui setup. Do not manually rewrite registry components unless the command fails; if it fails, inspect ${FALLBACK_SITE_ORIGIN}/r/takumi/text.json and install the listed dependencies.`;
+
+export const AgentPrompt = ({ className }: { className?: string }) => {
+ const { copyToClipboard, isCopied } = useCopyToClipboard({ timeout: 2500 });
+
+ const handleCopy = async () => {
+ const hasCopied = await copyToClipboard(agentInstallPrompt);
+
+ if (hasCopied) {
+ trackEvent({ name: "copy_agent_prompt" });
+ }
+ };
+
+ return (
+ <Button
+ type="button"
+ variant="ghost"
+ size="xs"
+ sound="copy"
+ aria-live="polite"
+ onClick={handleCopy}
+ className={cn(
+ "text-muted-foreground hover:text-foreground h-7 px-2.5",
+ className
+ )}
+ >
+ <AnimatePresence mode="popLayout" initial={false}>
+ {isCopied ? (
+ <motion.span key="done" {...motionIconProps}>
+ <CheckIcon />
+ </motion.span>
+ ) : (
+ <motion.span key="idle" {...motionIconProps}>
+ <CopyIcon />
+ </motion.span>
+ )}
+ </AnimatePresence>
+ {isCopied ? "Copied — paste into your agent" : "Copy prompt for your agent"}
+ </Button>
+ );
+};
diff --git a/apps/web/components/ui/button.tsx b/apps/web/components/ui/button.tsx
index 14cc83a..72069db 100644
--- a/apps/web/components/ui/button.tsx
+++ b/apps/web/components/ui/button.tsx
@@ -23,6 +23,7 @@ const buttonVariants = cva(
"icon-sm": "size-8",
lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",
+ xs: "h-6 gap-1 rounded-md px-2 text-xs has-[>svg]:px-1.5 [&_svg:not([class*='size-'])]:size-3",
},
variant: {
default: "bg-primary text-primary-foreground hover:bg-primary/90",
diff --git a/apps/web/lib/events.ts b/apps/web/lib/events.ts
index 6f99fb5..71732dc 100644
--- a/apps/web/lib/events.ts
+++ b/apps/web/lib/events.ts
@@ -21,6 +21,7 @@ const eventSchema = z.object({
"click_registry_add_button",
"copy_registry_command",
"keyboard_shortcut_navigate",
+ "copy_agent_prompt",
]),
properties: z
.record(