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: add event ticket block (takumi)

Lalit Madand7b251f043bb
diff --git a/apps/web/content/docs/blocks/takumi/event-ticket.mdx b/apps/web/content/docs/blocks/takumi/event-ticket.mdx
new file mode 100644
index 0000000..f448a2e
--- /dev/null
+++ b/apps/web/content/docs/blocks/takumi/event-ticket.mdx
@@ -0,0 +1,146 @@
+---
+title: "Event Ticket"
+description: "Print-ready event admission ticket with event details, seat info, QR code scan-in area, and branding strip."
+---
+
+<ComponentPreview base="takumi" name="event-ticket" hideCode />
+
+## Installation
+
+<CodeTabs>
+
+<TabsList>
+ <TabsTrigger value="cli">Command</TabsTrigger>
+ <TabsTrigger value="manual">Manual</TabsTrigger>
+</TabsList>
+
+<TabsContent value="cli">
+
+```bash
+npx shadcn@latest add @pdfcn/takumi/event-ticket
+```
+
+</TabsContent>
+
+<TabsContent value="manual">
+
+<Steps>
+
+<Step>Install the following dependencies:</Step>
+
+```bash
+npm install takumi-pdf @takumi-rs/helpers qrcode
+```
+
+<Step>Copy and paste the following code into your project.</Step>
+
+<ComponentSource
+ src="registry/bases/takumi/blocks/event-ticket/event-ticket.tsx"
+ base="takumi"
+ title="components/pdf/blocks/event-ticket/event-ticket.tsx"
+/>
+
+<ComponentSource
+ src="registry/bases/takumi/components/theme-provider.tsx"
+ base="takumi"
+ title="components/pdf/theme-provider.tsx"
+/>
+
+<ComponentSource
+ src="registry/bases/takumi/lib/resolve-color.ts"
+ base="takumi"
+ title="lib/resolve-color.ts"
+/>
+
+<ComponentSource
+ src="registry/bases/takumi/lib/pdf-primitives.tsx"
+ base="takumi"
+ title="lib/pdf-primitives.tsx"
+/>
+
+<ComponentSource
+ src="registry/bases/takumi/lib/pdf-svg.tsx"
+ base="takumi"
+ title="lib/pdf-svg.tsx"
+/>
+
+<ComponentSource
+ src="registry/themes/professional.ts"
+ base="takumi"
+ title="lib/pdf-themes/professional.ts"
+/>
+
+<ComponentSource
+ src="registry/themes/primitives.ts"
+ base="takumi"
+ title="lib/pdf-themes/primitives.ts"
+/>
+
+<ComponentSource
+ src="registry/types/pdf-themes.ts"
+ base="takumi"
+ title="types/pdf-themes.ts"
+/>
+
+<ComponentSource
+ src="registry/types/pdf-components.ts"
+ base="takumi"
+ title="types/pdf-components.ts"
+/>
+
+<Step>Update the import paths to match your project setup.</Step>
+
+</Steps>
+
+</TabsContent>
+
+</CodeTabs>
+
+## Usage
+
+```tsx
+import { EventTicketDocument } from "@/components/pdf/event-ticket";
+```
+
+```tsx
+<EventTicketDocument
+ data={{
+ eventName: "ShadCN Labs Conf",
+ eventDate: "May 15, 2026",
+ eventTime: "9:00 AM",
+ venue: "Convention Center",
+ address: "123 Main St, Las Vegas, NV",
+ doorsOpen: "8:00 AM",
+ ticketType: "VIP",
+ ticketNumber: "TKT-00142",
+ seat: { section: "A", row: "3", number: "12" },
+ organizer: "ShadCN Labs",
+ socialLinks: [
+ { platform: "X", url: "x.com/shadcn" },
+ { platform: "Instagram", url: "instagram.com/shadcn" },
+ ],
+ accentColor: "#52525b",
+ }}
+/>
+```
+
+### With a pre-rendered QR image
+
+Provide `qrCodeUrl` to render an image instead of the generated QR code:
+
+```tsx
+<EventTicketDocument
+ data={{
+ // ...
+ ticketNumber: "TKT-00142",
+ qrCodeUrl: "https://example.com/qr/TKT-00142.png",
+ }}
+/>
+```
+
+## Props
+
+| Prop | Type | Description |
+| ------- | ----------------- | -------------------------------------------------------------------------------- |
+| `data` | `EventTicketData` | Ticket content: event, venue, times, seat, ticket type/number, and footer fields |
+| `theme` | `PdfcnTheme` | Optional theme override |
diff --git a/apps/web/content/docs/blocks/takumi/meta.json b/apps/web/content/docs/blocks/takumi/meta.json
index 18b8d23..bc84acb 100644
--- a/apps/web/content/docs/blocks/takumi/meta.json
+++ b/apps/web/content/docs/blocks/takumi/meta.json
@@ -1,6 +1,7 @@
{
"pages": [
"index",
+ "event-ticket",
"invoice-classic",
"invoice-consultant",
"invoice-corporate",
diff --git a/apps/web/examples/__index__.ts b/apps/web/examples/__index__.ts
index 0e8dcb1..b247e88 100644
--- a/apps/web/examples/__index__.ts
+++ b/apps/web/examples/__index__.ts
@@ -39,6 +39,7 @@ import takumi_badge from "@/examples/takumi/badge";
import takumi_card from "@/examples/takumi/card";
import takumi_data_table from "@/examples/takumi/data-table";
import takumi_divider from "@/examples/takumi/divider";
+import takumi_event_ticket from "@/examples/takumi/event-ticket";
import takumi_form from "@/examples/takumi/form";
import takumi_graph from "@/examples/takumi/graph";
import takumi_heading from "@/examples/takumi/heading";
@@ -115,6 +116,7 @@ export const demos: Record<BaseName, DemoMap> = {
card: takumi_card,
"data-table": takumi_data_table,
divider: takumi_divider,
+ "event-ticket": takumi_event_ticket,
form: takumi_form,
graph: takumi_graph,
heading: takumi_heading,
diff --git a/apps/web/examples/preview-config.tsx b/apps/web/examples/preview-config.tsx
index 8bb2ad3..24cb74c 100644
--- a/apps/web/examples/preview-config.tsx
+++ b/apps/web/examples/preview-config.tsx
@@ -5,6 +5,7 @@ import { pointToCssPixel } from "@/registry/bases/takumi/lib/pdf-primitives";
const DEFAULT_MARGIN = 40;
const BLOCK_NAMES = new Set([
+ "event-ticket",
"invoice-classic",
"invoice-consultant",
"invoice-corporate",
@@ -34,6 +35,10 @@ const COMPONENT_SIZES: Record<
Extract<RenderOptions, { viewport?: never }>["size"]
> = {
badge: { height: pointToCssPixel(200), width: pointToCssPixel(595) },
+ "event-ticket": {
+ height: pointToCssPixel(252),
+ width: pointToCssPixel(504),
+ },
"page-footer": {
height: pointToCssPixel(300),
width: pointToCssPixel(595),
diff --git a/apps/web/examples/takumi/event-ticket.tsx b/apps/web/examples/takumi/event-ticket.tsx
new file mode 100644
index 0000000..dfe0bc0
--- /dev/null
+++ b/apps/web/examples/takumi/event-ticket.tsx
@@ -0,0 +1,4 @@
+import { EventTicketDocument } from "@/registry/bases/takumi/blocks/event-ticket/event-ticket";
+
+const Demo = () => <EventTicketDocument />;
+export default Demo;
diff --git a/apps/web/public/r/registry.json b/apps/web/public/r/registry.json
index 349a0dc..38ba32c 100644
--- a/apps/web/public/r/registry.json
+++ b/apps/web/public/r/registry.json
@@ -446,6 +446,31 @@
"title": "Watermark",
"type": "registry:ui"
},
+ {
+ "dependencies": ["takumi-pdf", "@takumi-rs/helpers", "qrcode"],
+ "description": "Event Ticket PDF block (takumi)",
+ "files": [
+ {
+ "path": "registry/bases/takumi/blocks/event-ticket/event-ticket.tsx",
+ "type": "registry:block",
+ "target": "components/pdf/blocks/event-ticket/event-ticket.tsx"
+ },
+ {
+ "path": "registry/bases/takumi/blocks/event-ticket/event-ticket.types.ts",
+ "type": "registry:block",
+ "target": "components/pdf/blocks/event-ticket/event-ticket.types.ts"
+ }
+ ],
+ "name": "takumi/event-ticket",
+ "registryDependencies": [
+ "@pdfcn/takumi/pdf-image",
+ "@pdfcn/takumi/qrcode",
+ "@pdfcn/takumi/text",
+ "@pdfcn/takumi/utils"
+ ],
+ "title": "Event Ticket",
+ "type": "registry:block"
+ },
{
"dependencies": ["takumi-pdf", "@takumi-rs/helpers"],
"description": "Invoice Classic PDF block (takumi)",
diff --git a/apps/web/public/r/takumi/event-ticket.json b/apps/web/public/r/takumi/event-ticket.json
new file mode 100644
index 0000000..0534fa1
--- /dev/null
+++ b/apps/web/public/r/takumi/event-ticket.json
@@ -0,0 +1,32 @@
+{
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
+ "name": "takumi/event-ticket",
+ "title": "Event Ticket",
+ "description": "Event Ticket PDF block (takumi)",
+ "dependencies": [
+ "takumi-pdf",
+ "@takumi-rs/helpers",
+ "qrcode"
+ ],
+ "registryDependencies": [
+ "@pdfcn/takumi/pdf-image",
+ "@pdfcn/takumi/qrcode",
+ "@pdfcn/takumi/text",
+ "@pdfcn/takumi/utils"
+ ],
+ "files": [
+ {
+ "path": "registry/bases/takumi/blocks/event-ticket/event-ticket.tsx",
+ "content": "import { PdfImage } from \"@/registry/bases/takumi/components/pdf-image/pdf-image\";\nimport { PdfQRCode } from \"@/registry/bases/takumi/components/qrcode/qrcode\";\nimport { Text } from \"@/registry/bases/takumi/components/text/text\";\nimport {\n PdfcnThemeProvider,\n usePdfcnTheme,\n} from \"@/registry/bases/takumi/components/theme-provider\";\nimport {\n View,\n StyleSheet,\n Document,\n Page,\n} from \"@/registry/bases/takumi/lib/pdf-primitives\";\nimport { resolveColor } from \"@/registry/bases/takumi/lib/resolve-color\";\nimport type { PdfcnTheme } from \"@/registry/types/pdf-themes\";\n\nimport type { EventTicketData } from \"./event-ticket.types\";\n\n// Sample data — replace with your own props or data source\nconst sampleData: EventTicketData = {\n accentColor: \"#52525b\",\n address: \"123 Main St, Las Vegas, NV\",\n doorsOpen: \"8:00 AM\",\n eventDate: \"May 15, 2026\",\n eventName: \"ShadCN Labs Conf\",\n eventTime: \"9:00 AM\",\n logoUrl: \"/favicon.png\",\n organizer: \"ShadCN Labs\",\n seat: { number: \"12\", row: \"3\", section: \"A\" },\n socialLinks: [\n { platform: \"X\", url: \"x.com/shadcn\" },\n { platform: \"Instagram\", url: \"instagram.com/shadcn\" },\n ],\n terms: \"Ticket is non-transferable. All sales final. No re-entry.\",\n ticketNumber: \"TKT-00142\",\n ticketType: \"VIP\",\n venue: \"Convention Center\",\n};\n\n// Standard event ticket, 7\" x 3.5\", expressed in PDF points (72 dpi)\nconst TICKET_SIZE = { height: 252, width: 504 };\n\nconst STUB_WIDTH = 120;\n\nconst STRIPE_WIDTH = 8;\n\nconst NOTCH_RADIUS = 8;\n\nconst hexRgb = (color: string): [number, number, number] | null => {\n const hex = color.trim().replace(/^#/, \"\");\n\n if (/^[0-9a-f]{3}$/i.test(hex)) {\n return [\n Number.parseInt(hex[0] + hex[0], 16),\n Number.parseInt(hex[1] + hex[1], 16),\n Number.parseInt(hex[2] + hex[2], 16),\n ];\n }\n\n if (/^[0-9a-f]{6}([0-9a-f]{2})?$/i.test(hex)) {\n return [\n Number.parseInt(hex.slice(0, 2), 16),\n Number.parseInt(hex.slice(2, 4), 16),\n Number.parseInt(hex.slice(4, 6), 16),\n ];\n }\n\n return null;\n};\n\nconst inkOnAccent = (accent: string, light: string, dark: string) => {\n const rgb = hexRgb(accent);\n\n if (!rgb) {\n return dark;\n }\n\n const [r, g, b] = rgb;\n const luminance = (0.2126 * r + 0.7152 * g + 0.0722 * b) / 255;\n\n return luminance > 0.55 ? dark : light;\n};\n\nconst socialHandle = (url: string) => {\n const clean = url\n .replace(/^https?:\\/\\//i, \"\")\n .replace(/^www\\./i, \"\")\n .replace(/\\/$/, \"\");\n const parts = clean.split(\"/\").filter(Boolean);\n const handle = parts.at(-1);\n\n if (parts.length > 1 && handle) {\n return handle.startsWith(\"@\") ? handle : `@${handle}`;\n }\n\n return clean;\n};\n\nconst EventTicketContent = ({ data }: { data: EventTicketData }) => {\n const theme = usePdfcnTheme();\n const paper = theme.colors.background;\n const ink = theme.colors.foreground;\n const quiet = theme.colors.mutedForeground;\n\n const accent = resolveColor(\n data.accentColor ?? theme.colors.primary,\n theme.colors\n );\n const onAccent = inkOnAccent(accent, paper, ink);\n\n const styles = StyleSheet.create({\n admit: {\n color: onAccent,\n fontSize: 7,\n fontWeight: \"bold\",\n letterSpacing: 2,\n textTransform: \"uppercase\",\n },\n body: {\n flex: 1,\n justifyContent: \"space-between\",\n paddingBottom: 16,\n paddingLeft: 20,\n paddingRight: 18,\n paddingTop: 18,\n },\n brand: {\n alignItems: \"center\",\n flexDirection: \"row\",\n gap: 8,\n marginBottom: 14,\n },\n fact: {\n flexShrink: 1,\n minWidth: 0,\n paddingRight: 12,\n },\n facts: {\n flexDirection: \"row\",\n },\n footer: {\n alignItems: \"center\",\n flexDirection: \"row\",\n gap: 12,\n marginTop: 10,\n },\n label: {\n color: quiet,\n fontSize: 7,\n fontWeight: \"bold\",\n letterSpacing: 1.2,\n marginBottom: 3,\n textTransform: \"uppercase\",\n },\n logo: { borderRadius: 3, height: 14, width: 14 },\n notch: {\n backgroundColor: paper,\n borderRadius: NOTCH_RADIUS,\n height: NOTCH_RADIUS * 2,\n left: TICKET_SIZE.width - STUB_WIDTH - NOTCH_RADIUS,\n position: \"absolute\",\n width: NOTCH_RADIUS * 2,\n },\n organizer: {\n color: quiet,\n fontSize: 8,\n fontWeight: \"bold\",\n letterSpacing: 1.1,\n textTransform: \"uppercase\",\n },\n page: {\n backgroundColor: paper,\n boxSizing: \"border-box\",\n flexDirection: \"row\",\n height: TICKET_SIZE.height,\n overflow: \"hidden\",\n position: \"relative\",\n width: TICKET_SIZE.width,\n },\n pill: {\n backgroundColor: accent,\n borderRadius: 9,\n marginLeft: \"auto\",\n paddingHorizontal: 8,\n paddingVertical: 3,\n },\n pillText: {\n color: onAccent,\n fontSize: 7,\n fontWeight: \"bold\",\n letterSpacing: 1.2,\n textTransform: \"uppercase\",\n },\n qr: {\n backgroundColor: \"#ffffff\",\n borderRadius: 6,\n padding: 5,\n },\n serial: {\n color: onAccent,\n fontSize: 7,\n fontWeight: \"bold\",\n letterSpacing: 1.1,\n textTransform: \"uppercase\",\n },\n socialItem: {\n alignItems: \"center\",\n flexDirection: \"row\",\n gap: 4,\n },\n socialLabel: {\n color: quiet,\n fontSize: 6.5,\n fontWeight: \"bold\",\n letterSpacing: 0.4,\n textTransform: \"uppercase\",\n },\n socialList: {\n alignItems: \"center\",\n flexDirection: \"row\",\n gap: 8,\n },\n socialValue: {\n color: quiet,\n fontSize: 6.5,\n },\n stripe: {\n backgroundColor: accent,\n width: STRIPE_WIDTH,\n },\n stub: {\n alignItems: \"center\",\n backgroundColor: accent,\n borderLeftColor: paper,\n borderLeftStyle: \"dashed\",\n borderLeftWidth: 1.5,\n justifyContent: \"space-between\",\n paddingBottom: 14,\n paddingHorizontal: 12,\n paddingTop: 16,\n width: STUB_WIDTH,\n },\n terms: {\n color: quiet,\n flex: 1,\n fontSize: 6.5,\n lineHeight: 1.4,\n paddingRight: 8,\n },\n title: {\n color: ink,\n fontSize: 26,\n fontWeight: \"bold\",\n letterSpacing: -0.6,\n lineHeight: 1.08,\n marginBottom: 8,\n },\n value: {\n color: ink,\n fontSize: 12,\n fontWeight: \"bold\",\n },\n venue: {\n color: quiet,\n fontSize: 10,\n lineHeight: 1.4,\n },\n });\n\n return (\n <Document title={`${data.eventName} ${data.ticketNumber}`}>\n <Page size={TICKET_SIZE} style={styles.page}>\n <View style={styles.stripe} />\n\n <View style={styles.body}>\n <View>\n <View style={styles.brand}>\n {data.logoUrl && (\n <PdfImage\n fit=\"contain\"\n src={data.logoUrl}\n style={styles.logo}\n />\n )}\n <Text noMargin style={styles.organizer}>\n {data.organizer ?? \"Event ticket\"}\n </Text>\n <View style={styles.pill}>\n <Text noMargin style={styles.pillText}>\n {data.ticketType}\n </Text>\n </View>\n </View>\n <Text noMargin style={styles.title}>\n {data.eventName}\n </Text>\n <Text noMargin style={styles.venue}>\n {data.venue}\n </Text>\n <Text noMargin style={styles.venue}>\n {data.address}\n </Text>\n </View>\n\n <View>\n <View style={styles.facts}>\n <View style={styles.fact}>\n <Text noMargin style={styles.label}>\n Date\n </Text>\n <Text noMargin style={styles.value}>\n {data.eventDate}\n </Text>\n </View>\n <View style={styles.fact}>\n <Text noMargin style={styles.label}>\n Time\n </Text>\n <Text noMargin style={styles.value}>\n {data.eventTime}\n </Text>\n </View>\n {data.doorsOpen && (\n <View style={styles.fact}>\n <Text noMargin style={styles.label}>\n Doors\n </Text>\n <Text noMargin style={styles.value}>\n {data.doorsOpen}\n </Text>\n </View>\n )}\n {data.seat && (\n <View style={styles.fact}>\n <Text noMargin style={styles.label}>\n Seat\n </Text>\n <Text noMargin style={styles.value}>\n {`${data.seat.section}–${data.seat.row}–${data.seat.number}`}\n </Text>\n </View>\n )}\n </View>\n {(data.terms ||\n (data.socialLinks && data.socialLinks.length > 0)) && (\n <View style={styles.footer}>\n {data.terms && (\n <Text noMargin style={styles.terms}>\n {data.terms}\n </Text>\n )}\n {data.socialLinks && data.socialLinks.length > 0 && (\n <View style={styles.socialList}>\n {data.socialLinks.map((link) => (\n <View\n key={`${link.platform}-${link.url}`}\n style={styles.socialItem}\n >\n <Text noMargin style={styles.socialLabel}>\n {link.platform}\n </Text>\n <Text noMargin style={styles.socialValue}>\n {socialHandle(link.url)}\n </Text>\n </View>\n ))}\n </View>\n )}\n </View>\n )}\n </View>\n </View>\n\n <View style={styles.stub}>\n <Text noMargin style={styles.admit}>\n Admit one\n </Text>\n <View style={styles.qr}>\n {data.qrCodeUrl ? (\n <PdfImage\n fit=\"contain\"\n height={68}\n src={data.qrCodeUrl}\n width={68}\n />\n ) : (\n <PdfQRCode\n backgroundColor=\"#ffffff\"\n color=\"#000000\"\n size={68}\n value={data.ticketNumber}\n />\n )}\n </View>\n <Text noMargin style={styles.serial}>\n {data.ticketNumber}\n </Text>\n </View>\n\n <View style={[styles.notch, { top: -NOTCH_RADIUS }]} />\n <View style={[styles.notch, { bottom: -NOTCH_RADIUS }]} />\n </Page>\n </Document>\n );\n};\n\nexport const EventTicketDocument = ({\n theme,\n data = sampleData,\n}: {\n theme?: PdfcnTheme;\n data?: EventTicketData;\n}) => (\n <PdfcnThemeProvider theme={theme}>\n <EventTicketContent data={data} />\n </PdfcnThemeProvider>\n);\n",
+ "type": "registry:block",
+ "target": "components/pdf/blocks/event-ticket/event-ticket.tsx"
+ },
+ {
+ "path": "registry/bases/takumi/blocks/event-ticket/event-ticket.types.ts",
+ "content": "export interface EventTicketSeat {\n number: string;\n row: string;\n section: string;\n}\n\nexport interface EventTicketSocialLink {\n platform: string;\n url: string;\n}\n\nexport interface EventTicketData {\n accentColor?: string;\n address: string;\n doorsOpen?: string;\n eventName: string;\n eventDate: string;\n eventTime: string;\n logoUrl?: string;\n organizer?: string;\n qrCodeUrl?: string;\n seat?: EventTicketSeat;\n socialLinks?: EventTicketSocialLink[];\n terms?: string;\n ticketNumber: string;\n ticketType: string;\n venue: string;\n}\n",
+ "type": "registry:block",
+ "target": "components/pdf/blocks/event-ticket/event-ticket.types.ts"
+ }
+ ],
+ "type": "registry:block"
+}
\ No newline at end of file
diff --git a/apps/web/registry.json b/apps/web/registry.json
index 349a0dc..38ba32c 100644
--- a/apps/web/registry.json
+++ b/apps/web/registry.json
@@ -446,6 +446,31 @@
"title": "Watermark",
"type": "registry:ui"
},
+ {
+ "dependencies": ["takumi-pdf", "@takumi-rs/helpers", "qrcode"],
+ "description": "Event Ticket PDF block (takumi)",
+ "files": [
+ {
+ "path": "registry/bases/takumi/blocks/event-ticket/event-ticket.tsx",
+ "type": "registry:block",
+ "target": "components/pdf/blocks/event-ticket/event-ticket.tsx"
+ },
+ {
+ "path": "registry/bases/takumi/blocks/event-ticket/event-ticket.types.ts",
+ "type": "registry:block",
+ "target": "components/pdf/blocks/event-ticket/event-ticket.types.ts"
+ }
+ ],
+ "name": "takumi/event-ticket",
+ "registryDependencies": [
+ "@pdfcn/takumi/pdf-image",
+ "@pdfcn/takumi/qrcode",
+ "@pdfcn/takumi/text",
+ "@pdfcn/takumi/utils"
+ ],
+ "title": "Event Ticket",
+ "type": "registry:block"
+ },
{
"dependencies": ["takumi-pdf", "@takumi-rs/helpers"],
"description": "Invoice Classic PDF block (takumi)",
diff --git a/apps/web/registry/bases/takumi/blocks/event-ticket/event-ticket.tsx b/apps/web/registry/bases/takumi/blocks/event-ticket/event-ticket.tsx
new file mode 100644
index 0000000..aff838b
--- /dev/null
+++ b/apps/web/registry/bases/takumi/blocks/event-ticket/event-ticket.tsx
@@ -0,0 +1,417 @@
+import { PdfImage } from "@/registry/bases/takumi/components/pdf-image/pdf-image";
+import { PdfQRCode } from "@/registry/bases/takumi/components/qrcode/qrcode";
+import { Text } from "@/registry/bases/takumi/components/text/text";
+import {
+ PdfcnThemeProvider,
+ usePdfcnTheme,
+} from "@/registry/bases/takumi/components/theme-provider";
+import {
+ View,
+ StyleSheet,
+ Document,
+ Page,
+} from "@/registry/bases/takumi/lib/pdf-primitives";
+import { resolveColor } from "@/registry/bases/takumi/lib/resolve-color";
+import type { PdfcnTheme } from "@/registry/types/pdf-themes";
+
+import type { EventTicketData } from "./event-ticket.types";
+
+// Sample data — replace with your own props or data source
+const sampleData: EventTicketData = {
+ accentColor: "#52525b",
+ address: "123 Main St, Las Vegas, NV",
+ doorsOpen: "8:00 AM",
+ eventDate: "May 15, 2026",
+ eventName: "ShadCN Labs Conf",
+ eventTime: "9:00 AM",
+ logoUrl: "/favicon.png",
+ organizer: "ShadCN Labs",
+ seat: { number: "12", row: "3", section: "A" },
+ socialLinks: [
+ { platform: "X", url: "x.com/shadcn" },
+ { platform: "Instagram", url: "instagram.com/shadcn" },
+ ],
+ terms: "Ticket is non-transferable. All sales final. No re-entry.",
+ ticketNumber: "TKT-00142",
+ ticketType: "VIP",
+ venue: "Convention Center",
+};
+
+// Standard event ticket, 7" x 3.5", expressed in PDF points (72 dpi)
+const TICKET_SIZE = { height: 252, width: 504 };
+
+const STUB_WIDTH = 120;
+
+const STRIPE_WIDTH = 8;
+
+const NOTCH_RADIUS = 8;
+
+const hexRgb = (color: string): [number, number, number] | null => {
+ const hex = color.trim().replace(/^#/, "");
+
+ if (/^[0-9a-f]{3}$/i.test(hex)) {
+ return [
+ Number.parseInt(hex[0] + hex[0], 16),
+ Number.parseInt(hex[1] + hex[1], 16),
+ Number.parseInt(hex[2] + hex[2], 16),
+ ];
+ }
+
+ if (/^[0-9a-f]{6}([0-9a-f]{2})?$/i.test(hex)) {
+ return [
+ Number.parseInt(hex.slice(0, 2), 16),
+ Number.parseInt(hex.slice(2, 4), 16),
+ Number.parseInt(hex.slice(4, 6), 16),
+ ];
+ }
+
+ return null;
+};
+
+const inkOnAccent = (accent: string, light: string, dark: string) => {
+ const rgb = hexRgb(accent);
+
+ if (!rgb) {
+ return dark;
+ }
+
+ const [r, g, b] = rgb;
+ const luminance = (0.2126 * r + 0.7152 * g + 0.0722 * b) / 255;
+
+ return luminance > 0.55 ? dark : light;
+};
+
+const socialHandle = (url: string) => {
+ const clean = url
+ .replace(/^https?:\/\//i, "")
+ .replace(/^www\./i, "")
+ .replace(/\/$/, "");
+ const parts = clean.split("/").filter(Boolean);
+ const handle = parts.at(-1);
+
+ if (parts.length > 1 && handle) {
+ return handle.startsWith("@") ? handle : `@${handle}`;
+ }
+
+ return clean;
+};
+
+const EventTicketContent = ({ data }: { data: EventTicketData }) => {
+ const theme = usePdfcnTheme();
+ const paper = theme.colors.background;
+ const ink = theme.colors.foreground;
+ const quiet = theme.colors.mutedForeground;
+
+ const accent = resolveColor(
+ data.accentColor ?? theme.colors.primary,
+ theme.colors
+ );
+ const onAccent = inkOnAccent(accent, paper, ink);
+
+ const styles = StyleSheet.create({
+ admit: {
+ color: onAccent,
+ fontSize: 7,
+ fontWeight: "bold",
+ letterSpacing: 2,
+ textTransform: "uppercase",
+ },
+ body: {
+ flex: 1,
+ justifyContent: "space-between",
+ paddingBottom: 16,
+ paddingLeft: 20,
+ paddingRight: 18,
+ paddingTop: 18,
+ },
+ brand: {
+ alignItems: "center",
+ flexDirection: "row",
+ gap: 8,
+ marginBottom: 14,
+ },
+ fact: {
+ flexShrink: 1,
+ minWidth: 0,
+ paddingRight: 12,
+ },
+ facts: {
+ flexDirection: "row",
+ },
+ footer: {
+ alignItems: "center",
+ flexDirection: "row",
+ gap: 12,
+ marginTop: 10,
+ },
+ label: {
+ color: quiet,
+ fontSize: 7,
+ fontWeight: "bold",
+ letterSpacing: 1.2,
+ marginBottom: 3,
+ textTransform: "uppercase",
+ },
+ logo: { borderRadius: 3, height: 14, width: 14 },
+ notch: {
+ backgroundColor: paper,
+ borderRadius: NOTCH_RADIUS,
+ height: NOTCH_RADIUS * 2,
+ left: TICKET_SIZE.width - STUB_WIDTH - NOTCH_RADIUS,
+ position: "absolute",
+ width: NOTCH_RADIUS * 2,
+ },
+ organizer: {
+ color: quiet,
+ fontSize: 8,
+ fontWeight: "bold",
+ letterSpacing: 1.1,
+ textTransform: "uppercase",
+ },
+ page: {
+ backgroundColor: paper,
+ boxSizing: "border-box",
+ flexDirection: "row",
+ height: TICKET_SIZE.height,
+ overflow: "hidden",
+ position: "relative",
+ width: TICKET_SIZE.width,
+ },
+ pill: {
+ backgroundColor: accent,
+ borderRadius: 9,
+ marginLeft: "auto",
+ paddingHorizontal: 8,
+ paddingVertical: 3,
+ },
+ pillText: {
+ color: onAccent,
+ fontSize: 7,
+ fontWeight: "bold",
+ letterSpacing: 1.2,
+ textTransform: "uppercase",
+ },
+ qr: {
+ backgroundColor: "#ffffff",
+ borderRadius: 6,
+ padding: 5,
+ },
+ serial: {
+ color: onAccent,
+ fontSize: 7,
+ fontWeight: "bold",
+ letterSpacing: 1.1,
+ textTransform: "uppercase",
+ },
+ socialItem: {
+ alignItems: "center",
+ flexDirection: "row",
+ gap: 4,
+ },
+ socialLabel: {
+ color: quiet,
+ fontSize: 6.5,
+ fontWeight: "bold",
+ letterSpacing: 0.4,
+ textTransform: "uppercase",
+ },
+ socialList: {
+ alignItems: "center",
+ flexDirection: "row",
+ gap: 8,
+ },
+ socialValue: {
+ color: quiet,
+ fontSize: 6.5,
+ },
+ stripe: {
+ backgroundColor: accent,
+ width: STRIPE_WIDTH,
+ },
+ stub: {
+ alignItems: "center",
+ backgroundColor: accent,
+ borderLeftColor: paper,
+ borderLeftStyle: "dashed",
+ borderLeftWidth: 1.5,
+ justifyContent: "space-between",
+ paddingBottom: 14,
+ paddingHorizontal: 12,
+ paddingTop: 16,
+ width: STUB_WIDTH,
+ },
+ terms: {
+ color: quiet,
+ flex: 1,
+ fontSize: 6.5,
+ lineHeight: 1.4,
+ paddingRight: 8,
+ },
+ title: {
+ color: ink,
+ fontSize: 26,
+ fontWeight: "bold",
+ letterSpacing: -0.6,
+ lineHeight: 1.08,
+ marginBottom: 8,
+ },
+ value: {
+ color: ink,
+ fontSize: 12,
+ fontWeight: "bold",
+ },
+ venue: {
+ color: quiet,
+ fontSize: 10,
+ lineHeight: 1.4,
+ },
+ });
+
+ return (
+ <Document title={`${data.eventName} ${data.ticketNumber}`}>
+ <Page size={TICKET_SIZE} style={styles.page}>
+ <View style={styles.stripe} />
+
+ <View style={styles.body}>
+ <View>
+ <View style={styles.brand}>
+ {data.logoUrl && (
+ <PdfImage
+ fit="contain"
+ src={data.logoUrl}
+ style={styles.logo}
+ />
+ )}
+ <Text noMargin style={styles.organizer}>
+ {data.organizer ?? "Event ticket"}
+ </Text>
+ <View style={styles.pill}>
+ <Text noMargin style={styles.pillText}>
+ {data.ticketType}
+ </Text>
+ </View>
+ </View>
+ <Text noMargin style={styles.title}>
+ {data.eventName}
+ </Text>
+ <Text noMargin style={styles.venue}>
+ {data.venue}
+ </Text>
+ <Text noMargin style={styles.venue}>
+ {data.address}
+ </Text>
+ </View>
+
+ <View>
+ <View style={styles.facts}>
+ <View style={styles.fact}>
+ <Text noMargin style={styles.label}>
+ Date
+ </Text>
+ <Text noMargin style={styles.value}>
+ {data.eventDate}
+ </Text>
+ </View>
+ <View style={styles.fact}>
+ <Text noMargin style={styles.label}>
+ Time
+ </Text>
+ <Text noMargin style={styles.value}>
+ {data.eventTime}
+ </Text>
+ </View>
+ {data.doorsOpen && (
+ <View style={styles.fact}>
+ <Text noMargin style={styles.label}>
+ Doors
+ </Text>
+ <Text noMargin style={styles.value}>
+ {data.doorsOpen}
+ </Text>
+ </View>
+ )}
+ {data.seat && (
+ <View style={styles.fact}>
+ <Text noMargin style={styles.label}>
+ Seat
+ </Text>
+ <Text noMargin style={styles.value}>
+ {`${data.seat.section}–${data.seat.row}–${data.seat.number}`}
+ </Text>
+ </View>
+ )}
+ </View>
+ {(data.terms ||
+ (data.socialLinks && data.socialLinks.length > 0)) && (
+ <View style={styles.footer}>
+ {data.terms && (
+ <Text noMargin style={styles.terms}>
+ {data.terms}
+ </Text>
+ )}
+ {data.socialLinks && data.socialLinks.length > 0 && (
+ <View style={styles.socialList}>
+ {data.socialLinks.map((link) => (
+ <View
+ key={`${link.platform}-${link.url}`}
+ style={styles.socialItem}
+ >
+ <Text noMargin style={styles.socialLabel}>
+ {link.platform}
+ </Text>
+ <Text noMargin style={styles.socialValue}>
+ {socialHandle(link.url)}
+ </Text>
+ </View>
+ ))}
+ </View>
+ )}
+ </View>
+ )}
+ </View>
+ </View>
+
+ <View style={styles.stub}>
+ <Text noMargin style={styles.admit}>
+ Admit one
+ </Text>
+ <View style={styles.qr}>
+ {data.qrCodeUrl ? (
+ <PdfImage
+ fit="contain"
+ height={68}
+ src={data.qrCodeUrl}
+ width={68}
+ />
+ ) : (
+ <PdfQRCode
+ backgroundColor="#ffffff"
+ color="#000000"
+ size={68}
+ value={data.ticketNumber}
+ />
+ )}
+ </View>
+ <Text noMargin style={styles.serial}>
+ {data.ticketNumber}
+ </Text>
+ </View>
+
+ <View style={[styles.notch, { top: -NOTCH_RADIUS }]} />
+ <View style={[styles.notch, { bottom: -NOTCH_RADIUS }]} />
+ </Page>
+ </Document>
+ );
+};
+
+export const EventTicketDocument = ({
+ theme,
+ data = sampleData,
+}: {
+ theme?: PdfcnTheme;
+ data?: EventTicketData;
+}) => (
+ <PdfcnThemeProvider theme={theme}>
+ <EventTicketContent data={data} />
+ </PdfcnThemeProvider>
+);
diff --git a/apps/web/registry/bases/takumi/blocks/event-ticket/event-ticket.types.ts b/apps/web/registry/bases/takumi/blocks/event-ticket/event-ticket.types.ts
new file mode 100644
index 0000000..20e88e8
--- /dev/null
+++ b/apps/web/registry/bases/takumi/blocks/event-ticket/event-ticket.types.ts
@@ -0,0 +1,28 @@
+export interface EventTicketSeat {
+ number: string;
+ row: string;
+ section: string;
+}
+
+export interface EventTicketSocialLink {
+ platform: string;
+ url: string;
+}
+
+export interface EventTicketData {
+ accentColor?: string;
+ address: string;
+ doorsOpen?: string;
+ eventName: string;
+ eventDate: string;
+ eventTime: string;
+ logoUrl?: string;
+ organizer?: string;
+ qrCodeUrl?: string;
+ seat?: EventTicketSeat;
+ socialLinks?: EventTicketSocialLink[];
+ terms?: string;
+ ticketNumber: string;
+ ticketType: string;
+ venue: string;
+}