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 shipping label block (takumi)

Lalit Madanc202713711a3
diff --git a/apps/web/content/docs/blocks/takumi/meta.json b/apps/web/content/docs/blocks/takumi/meta.json
index ed12e4d..714b03c 100644
--- a/apps/web/content/docs/blocks/takumi/meta.json
+++ b/apps/web/content/docs/blocks/takumi/meta.json
@@ -10,7 +10,8 @@
"report-financial",
"report-marketing",
"report-operations",
- "report-security"
+ "report-security",
+ "shipping-label"
],
"title": "Takumi"
}
diff --git a/apps/web/content/docs/blocks/takumi/shipping-label.mdx b/apps/web/content/docs/blocks/takumi/shipping-label.mdx
new file mode 100644
index 0000000..53cfa6c
--- /dev/null
+++ b/apps/web/content/docs/blocks/takumi/shipping-label.mdx
@@ -0,0 +1,153 @@
+---
+title: "Shipping Label"
+description: "Print-ready 4x6 shipping label with sender, recipient, barcode area, and carrier info."
+---
+
+<ComponentPreview base="takumi" name="shipping-label" 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/shipping-label
+```
+
+</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/shipping-label/shipping-label.tsx"
+ base="takumi"
+ title="components/pdf/blocks/shipping-label/shipping-label.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 { ShippingLabelDocument } from "@/components/pdf/shipping-label";
+```
+
+```tsx
+<ShippingLabelDocument
+ data={{
+ carrier: "UPS",
+ serviceLevel: "Ground",
+ trackingNumber: "1Z999AA10123456784",
+ from: {
+ name: "Acme Warehouse",
+ address: "100 Industrial Blvd",
+ city: "Seattle",
+ state: "WA",
+ zip: "98101",
+ },
+ to: {
+ name: "Jane Doe",
+ address: "456 Oak Ave, Apt 12",
+ city: "Portland",
+ state: "OR",
+ zip: "97201",
+ phone: "(503) 555-0142",
+ },
+ weight: "4.2 lbs",
+ dimensions: '12" x 8" x 6"',
+ handlingLabels: ["FRAGILE"],
+ accentColor: "#1d4ed8",
+ }}
+/>
+```
+
+### With a carrier barcode image
+
+Provide `barcodeUrl` to render a full-width barcode image instead of the QR code:
+
+```tsx
+<ShippingLabelDocument
+ data={{
+ // ...
+ trackingNumber: "1Z999AA10123456784",
+ barcodeUrl: "https://example.com/barcodes/1Z999AA10123456784.png",
+ }}
+/>
+```
+
+## Props
+
+| Prop | Type | Description |
+| ------- | ------------------- | ---------------------------------------------------------------- |
+| `data` | `ShippingLabelData` | Label content: addresses, carrier, tracking, and package details |
+| `theme` | `PdfcnTheme` | Optional theme override |
diff --git a/apps/web/examples/__index__.ts b/apps/web/examples/__index__.ts
index 0e8dcb1..cefffe3 100644
--- a/apps/web/examples/__index__.ts
+++ b/apps/web/examples/__index__.ts
@@ -63,6 +63,7 @@ import takumi_report_marketing from "@/examples/takumi/report-marketing";
import takumi_report_operations from "@/examples/takumi/report-operations";
import takumi_report_security from "@/examples/takumi/report-security";
import takumi_section from "@/examples/takumi/section";
+import takumi_shipping_label from "@/examples/takumi/shipping-label";
import takumi_signature from "@/examples/takumi/signature";
import takumi_stack from "@/examples/takumi/stack";
import takumi_table from "@/examples/takumi/table";
@@ -139,6 +140,7 @@ export const demos: Record<BaseName, DemoMap> = {
"report-operations": takumi_report_operations,
"report-security": takumi_report_security,
section: takumi_section,
+ "shipping-label": takumi_shipping_label,
signature: takumi_signature,
stack: takumi_stack,
table: takumi_table,
diff --git a/apps/web/examples/preview-config.tsx b/apps/web/examples/preview-config.tsx
index 8bb2ad3..8a78822 100644
--- a/apps/web/examples/preview-config.tsx
+++ b/apps/web/examples/preview-config.tsx
@@ -15,6 +15,7 @@ const BLOCK_NAMES = new Set([
"report-marketing",
"report-operations",
"report-security",
+ "shipping-label",
]);
const COMPONENT_MARGINS: Record<string, number> = {
@@ -42,6 +43,10 @@ const COMPONENT_SIZES: Record<
height: pointToCssPixel(240),
width: pointToCssPixel(595),
},
+ "shipping-label": {
+ height: pointToCssPixel(432),
+ width: pointToCssPixel(288),
+ },
};
export const getTakumiPreviewOptions = (name: string): RenderOptions => {
diff --git a/apps/web/examples/takumi/shipping-label.tsx b/apps/web/examples/takumi/shipping-label.tsx
new file mode 100644
index 0000000..5413f53
--- /dev/null
+++ b/apps/web/examples/takumi/shipping-label.tsx
@@ -0,0 +1,4 @@
+import { ShippingLabelDocument } from "@/registry/bases/takumi/blocks/shipping-label/shipping-label";
+
+const Demo = () => <ShippingLabelDocument />;
+export default Demo;
diff --git a/apps/web/public/r/registry.json b/apps/web/public/r/registry.json
index 349a0dc..6a5a3e2 100644
--- a/apps/web/public/r/registry.json
+++ b/apps/web/public/r/registry.json
@@ -758,6 +758,31 @@
"title": "Report Security",
"type": "registry:block"
},
+ {
+ "dependencies": ["takumi-pdf", "@takumi-rs/helpers", "qrcode"],
+ "description": "Shipping Label PDF block (takumi)",
+ "files": [
+ {
+ "path": "registry/bases/takumi/blocks/shipping-label/shipping-label.tsx",
+ "type": "registry:block",
+ "target": "components/pdf/blocks/shipping-label/shipping-label.tsx"
+ },
+ {
+ "path": "registry/bases/takumi/blocks/shipping-label/shipping-label.types.ts",
+ "type": "registry:block",
+ "target": "components/pdf/blocks/shipping-label/shipping-label.types.ts"
+ }
+ ],
+ "name": "takumi/shipping-label",
+ "registryDependencies": [
+ "@pdfcn/takumi/utils",
+ "@pdfcn/takumi/pdf-image",
+ "@pdfcn/takumi/qrcode",
+ "@pdfcn/takumi/text"
+ ],
+ "title": "Shipping Label",
+ "type": "registry:block"
+ },
{
"description": "professional theme tokens",
"files": [
diff --git a/apps/web/public/r/takumi/shipping-label.json b/apps/web/public/r/takumi/shipping-label.json
new file mode 100644
index 0000000..eedc70a
--- /dev/null
+++ b/apps/web/public/r/takumi/shipping-label.json
@@ -0,0 +1,32 @@
+{
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
+ "name": "takumi/shipping-label",
+ "title": "Shipping Label",
+ "description": "Shipping Label PDF block (takumi)",
+ "dependencies": [
+ "takumi-pdf",
+ "@takumi-rs/helpers",
+ "qrcode"
+ ],
+ "registryDependencies": [
+ "@pdfcn/takumi/utils",
+ "@pdfcn/takumi/pdf-image",
+ "@pdfcn/takumi/qrcode",
+ "@pdfcn/takumi/text"
+ ],
+ "files": [
+ {
+ "path": "registry/bases/takumi/blocks/shipping-label/shipping-label.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 {\n ShippingLabelAddress,\n ShippingLabelData,\n} from \"./shipping-label.types\";\n\n// Sample data — replace with your own props or data source\nconst sampleData: ShippingLabelData = {\n carrier: \"UPS\",\n dimensions: '12\" x 8\" x 6\"',\n from: {\n address: \"456 Industrial Blvd\",\n city: \"Los Angeles\",\n country: \"USA\",\n name: \"ACME Corporation\",\n state: \"CA\",\n zip: \"90001\",\n },\n handlingLabels: [\"FRAGILE\", \"THIS SIDE UP\"],\n packageCount: 1,\n postage: \"$18.40\",\n serviceLevel: \"Ground\",\n to: {\n address: \"123 Main Street, Apt 4B\",\n city: \"New York\",\n country: \"USA\",\n name: \"John Doe\",\n phone: \"(503) 555-0142\",\n state: \"NY\",\n zip: \"10001\",\n },\n trackingNumber: \"TRACK123456789US\",\n weight: \"2.5 kg\",\n};\n\n// Standard 4\" x 6\" shipping label, expressed in PDF points (72 dpi)\nconst LABEL_SIZE = { height: 432, width: 288 };\n\nconst formatCityLine = (party: ShippingLabelAddress) => {\n const cityStateZip = `${party.city}, ${party.state} ${party.zip}`;\n return party.country ? `${cityStateZip}, ${party.country}` : cityStateZip;\n};\n\nconst formatStreetLine = (party: ShippingLabelAddress) => party.address;\n\n// Shared address block — same treatment for both parties (10pt, bold name)\nconst AddressLines = ({\n party,\n}: {\n party: ShippingLabelAddress & { phone?: string };\n}) => (\n <>\n <Text noMargin variant=\"xs\" weight=\"bold\">\n {party.name}\n </Text>\n <Text noMargin variant=\"xs\">\n {formatStreetLine(party)}\n </Text>\n <Text noMargin variant=\"xs\">\n {formatCityLine(party)}\n </Text>\n {party.phone && (\n <Text noMargin variant=\"xs\" color=\"mutedForeground\">\n {party.phone}\n </Text>\n )}\n </>\n);\n\nconst ShippingLabelContent = ({ data }: { data: ShippingLabelData }) => {\n const theme = usePdfcnTheme();\n\n const accent = resolveColor(\n data.accentColor ?? theme.colors.primary,\n theme.colors\n );\n\n const detailRows = [\n ...(data.weight ? [{ key: \"Weight\", value: data.weight }] : []),\n ...(data.dimensions ? [{ key: \"Dimensions\", value: data.dimensions }] : []),\n ...(typeof data.packageCount === \"number\"\n ? [{ key: \"Packages\", value: `${data.packageCount}` }]\n : []),\n { key: \"Postage\", value: data.postage ?? \"PAID\" },\n ];\n\n const styles = StyleSheet.create({\n addresses: { flex: 1, flexDirection: \"row\" },\n badgesRow: {\n flexDirection: \"row\",\n flexWrap: \"wrap\",\n gap: 6,\n marginTop: 8,\n },\n barcodeArea: { alignItems: \"center\", marginTop: 10 },\n carrierName: { fontSize: 16, fontWeight: \"bold\" },\n fromColumn: { flex: 1, paddingLeft: 12 },\n handlingTag: {\n alignItems: \"center\",\n backgroundColor: theme.colors.foreground,\n justifyContent: \"center\",\n paddingHorizontal: 8,\n paddingVertical: 4,\n },\n handlingTagText: {\n color: theme.colors.background,\n fontSize: 8,\n fontWeight: \"bold\",\n letterSpacing: 1,\n textTransform: \"uppercase\",\n },\n headerRow: {\n alignItems: \"center\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n },\n label: {\n borderColor: theme.colors.foreground,\n borderStyle: \"solid\",\n borderWidth: 2,\n flex: 1,\n padding: 10,\n },\n page: {\n backgroundColor: theme.colors.background,\n flexDirection: \"column\",\n height: LABEL_SIZE.height,\n overflow: \"hidden\",\n padding: 8,\n width: LABEL_SIZE.width,\n },\n rule: {\n backgroundColor: theme.colors.foreground,\n height: 2,\n marginVertical: 6,\n },\n sectionLabel: {\n color: accent,\n fontSize: 8,\n fontWeight: \"bold\",\n letterSpacing: 1,\n marginBottom: 4,\n textTransform: \"uppercase\",\n },\n serviceRight: { alignItems: \"flex-end\" },\n shipToColumn: {\n borderRightColor: theme.colors.foreground,\n borderRightStyle: \"solid\",\n borderRightWidth: 2,\n flex: 1.4,\n paddingRight: 12,\n },\n table: {\n borderColor: theme.colors.foreground,\n borderStyle: \"solid\",\n borderWidth: 2,\n },\n tableKey: {\n color: theme.colors.mutedForeground,\n fontSize: 8,\n fontWeight: \"bold\",\n letterSpacing: 0.5,\n textTransform: \"uppercase\",\n width: 84,\n },\n tableRow: {\n alignItems: \"center\",\n borderBottomColor: theme.colors.border,\n borderBottomStyle: \"solid\",\n borderBottomWidth: 1,\n flexDirection: \"row\",\n paddingHorizontal: 8,\n paddingVertical: 3,\n },\n tableRowLast: {\n alignItems: \"center\",\n flexDirection: \"row\",\n paddingHorizontal: 8,\n paddingVertical: 3,\n },\n tableValue: { flex: 1 },\n trackingText: {\n fontWeight: \"bold\",\n letterSpacing: 2,\n marginTop: 6,\n textTransform: \"uppercase\",\n },\n });\n\n return (\n <Document title={`Shipping Label ${data.trackingNumber}`}>\n <Page size={LABEL_SIZE} style={styles.page}>\n <View style={styles.label}>\n <View style={styles.headerRow}>\n <Text noMargin style={styles.carrierName}>\n {data.carrier}\n </Text>\n <View style={styles.serviceRight}>\n <Text noMargin style={styles.sectionLabel}>\n {data.serviceLevel}\n </Text>\n </View>\n </View>\n\n <View style={styles.rule} />\n\n <View style={styles.addresses}>\n <View style={styles.shipToColumn}>\n <Text noMargin style={styles.sectionLabel}>\n Ship To\n </Text>\n <AddressLines party={data.to} />\n </View>\n <View style={styles.fromColumn}>\n <Text noMargin style={styles.sectionLabel}>\n From\n </Text>\n <AddressLines party={data.from} />\n </View>\n </View>\n\n <View style={styles.rule} />\n\n <View style={styles.table}>\n {detailRows.map((row, index) => (\n <View\n key={row.key}\n style={\n index === detailRows.length - 1\n ? styles.tableRowLast\n : styles.tableRow\n }\n >\n <Text noMargin style={styles.tableKey}>\n {row.key}\n </Text>\n <Text noMargin style={styles.tableValue} variant=\"xs\">\n {row.value}\n </Text>\n </View>\n ))}\n </View>\n\n {data.handlingLabels && data.handlingLabels.length > 0 && (\n <View style={styles.badgesRow}>\n {data.handlingLabels.map((label, index) => (\n <View key={`${label}-${index}`} style={styles.handlingTag}>\n <Text noMargin style={styles.handlingTagText}>\n {label}\n </Text>\n </View>\n ))}\n </View>\n )}\n\n <View style={styles.barcodeArea}>\n {data.barcodeUrl ? (\n <PdfImage\n fit=\"contain\"\n height={72}\n src={data.barcodeUrl}\n width=\"100%\"\n />\n ) : (\n <PdfQRCode\n backgroundColor=\"#ffffff\"\n color=\"#000000\"\n size={80}\n value={data.trackingNumber}\n />\n )}\n <Text\n noMargin\n style={styles.trackingText}\n variant=\"xs\"\n weight=\"bold\"\n >\n {data.trackingNumber}\n </Text>\n </View>\n </View>\n </Page>\n </Document>\n );\n};\n\nexport const ShippingLabelDocument = ({\n theme,\n data = sampleData,\n}: {\n theme?: PdfcnTheme;\n data?: ShippingLabelData;\n}) => (\n <PdfcnThemeProvider theme={theme}>\n <ShippingLabelContent data={data} />\n </PdfcnThemeProvider>\n);\n",
+ "type": "registry:block",
+ "target": "components/pdf/blocks/shipping-label/shipping-label.tsx"
+ },
+ {
+ "path": "registry/bases/takumi/blocks/shipping-label/shipping-label.types.ts",
+ "content": "export interface ShippingLabelAddress {\n name: string;\n address: string;\n city: string;\n state: string;\n zip: string;\n country?: string;\n}\n\nexport interface ShippingLabelDestination extends ShippingLabelAddress {\n phone?: string;\n}\n\nexport interface ShippingLabelData {\n from: ShippingLabelAddress;\n to: ShippingLabelDestination;\n carrier: string;\n serviceLevel: string;\n trackingNumber: string;\n barcodeUrl?: string;\n weight?: string;\n dimensions?: string;\n packageCount?: number;\n handlingLabels?: string[];\n postage?: string;\n accentColor?: string;\n}\n",
+ "type": "registry:block",
+ "target": "components/pdf/blocks/shipping-label/shipping-label.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..6a5a3e2 100644
--- a/apps/web/registry.json
+++ b/apps/web/registry.json
@@ -758,6 +758,31 @@
"title": "Report Security",
"type": "registry:block"
},
+ {
+ "dependencies": ["takumi-pdf", "@takumi-rs/helpers", "qrcode"],
+ "description": "Shipping Label PDF block (takumi)",
+ "files": [
+ {
+ "path": "registry/bases/takumi/blocks/shipping-label/shipping-label.tsx",
+ "type": "registry:block",
+ "target": "components/pdf/blocks/shipping-label/shipping-label.tsx"
+ },
+ {
+ "path": "registry/bases/takumi/blocks/shipping-label/shipping-label.types.ts",
+ "type": "registry:block",
+ "target": "components/pdf/blocks/shipping-label/shipping-label.types.ts"
+ }
+ ],
+ "name": "takumi/shipping-label",
+ "registryDependencies": [
+ "@pdfcn/takumi/utils",
+ "@pdfcn/takumi/pdf-image",
+ "@pdfcn/takumi/qrcode",
+ "@pdfcn/takumi/text"
+ ],
+ "title": "Shipping Label",
+ "type": "registry:block"
+ },
{
"description": "professional theme tokens",
"files": [
diff --git a/apps/web/registry/bases/takumi/blocks/shipping-label/shipping-label.tsx b/apps/web/registry/bases/takumi/blocks/shipping-label/shipping-label.tsx
new file mode 100644
index 0000000..1dc69c0
--- /dev/null
+++ b/apps/web/registry/bases/takumi/blocks/shipping-label/shipping-label.tsx
@@ -0,0 +1,312 @@
+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 {
+ ShippingLabelAddress,
+ ShippingLabelData,
+} from "./shipping-label.types";
+
+// Sample data — replace with your own props or data source
+const sampleData: ShippingLabelData = {
+ carrier: "UPS",
+ dimensions: '12" x 8" x 6"',
+ from: {
+ address: "456 Industrial Blvd",
+ city: "Los Angeles",
+ country: "USA",
+ name: "ACME Corporation",
+ state: "CA",
+ zip: "90001",
+ },
+ handlingLabels: ["FRAGILE", "THIS SIDE UP"],
+ packageCount: 1,
+ postage: "$18.40",
+ serviceLevel: "Ground",
+ to: {
+ address: "123 Main Street, Apt 4B",
+ city: "New York",
+ country: "USA",
+ name: "John Doe",
+ phone: "(503) 555-0142",
+ state: "NY",
+ zip: "10001",
+ },
+ trackingNumber: "TRACK123456789US",
+ weight: "2.5 kg",
+};
+
+// Standard 4" x 6" shipping label, expressed in PDF points (72 dpi)
+const LABEL_SIZE = { height: 432, width: 288 };
+
+const formatCityLine = (party: ShippingLabelAddress) => {
+ const cityStateZip = `${party.city}, ${party.state} ${party.zip}`;
+ return party.country ? `${cityStateZip}, ${party.country}` : cityStateZip;
+};
+
+const formatStreetLine = (party: ShippingLabelAddress) => party.address;
+
+// Shared address block — same treatment for both parties (10pt, bold name)
+const AddressLines = ({
+ party,
+}: {
+ party: ShippingLabelAddress & { phone?: string };
+}) => (
+ <>
+ <Text noMargin variant="xs" weight="bold">
+ {party.name}
+ </Text>
+ <Text noMargin variant="xs">
+ {formatStreetLine(party)}
+ </Text>
+ <Text noMargin variant="xs">
+ {formatCityLine(party)}
+ </Text>
+ {party.phone && (
+ <Text noMargin variant="xs" color="mutedForeground">
+ {party.phone}
+ </Text>
+ )}
+ </>
+);
+
+const ShippingLabelContent = ({ data }: { data: ShippingLabelData }) => {
+ const theme = usePdfcnTheme();
+
+ const accent = resolveColor(
+ data.accentColor ?? theme.colors.primary,
+ theme.colors
+ );
+
+ const detailRows = [
+ ...(data.weight ? [{ key: "Weight", value: data.weight }] : []),
+ ...(data.dimensions ? [{ key: "Dimensions", value: data.dimensions }] : []),
+ ...(typeof data.packageCount === "number"
+ ? [{ key: "Packages", value: `${data.packageCount}` }]
+ : []),
+ { key: "Postage", value: data.postage ?? "PAID" },
+ ];
+
+ const styles = StyleSheet.create({
+ addresses: { flex: 1, flexDirection: "row" },
+ badgesRow: {
+ flexDirection: "row",
+ flexWrap: "wrap",
+ gap: 6,
+ marginTop: 8,
+ },
+ barcodeArea: { alignItems: "center", marginTop: 10 },
+ carrierName: { fontSize: 16, fontWeight: "bold" },
+ fromColumn: { flex: 1, paddingLeft: 12 },
+ handlingTag: {
+ alignItems: "center",
+ backgroundColor: theme.colors.foreground,
+ justifyContent: "center",
+ paddingHorizontal: 8,
+ paddingVertical: 4,
+ },
+ handlingTagText: {
+ color: theme.colors.background,
+ fontSize: 8,
+ fontWeight: "bold",
+ letterSpacing: 1,
+ textTransform: "uppercase",
+ },
+ headerRow: {
+ alignItems: "center",
+ flexDirection: "row",
+ justifyContent: "space-between",
+ },
+ label: {
+ borderColor: theme.colors.foreground,
+ borderStyle: "solid",
+ borderWidth: 2,
+ flex: 1,
+ padding: 10,
+ },
+ page: {
+ backgroundColor: theme.colors.background,
+ flexDirection: "column",
+ height: LABEL_SIZE.height,
+ overflow: "hidden",
+ padding: 8,
+ width: LABEL_SIZE.width,
+ },
+ rule: {
+ backgroundColor: theme.colors.foreground,
+ height: 2,
+ marginVertical: 6,
+ },
+ sectionLabel: {
+ color: accent,
+ fontSize: 8,
+ fontWeight: "bold",
+ letterSpacing: 1,
+ marginBottom: 4,
+ textTransform: "uppercase",
+ },
+ serviceRight: { alignItems: "flex-end" },
+ shipToColumn: {
+ borderRightColor: theme.colors.foreground,
+ borderRightStyle: "solid",
+ borderRightWidth: 2,
+ flex: 1.4,
+ paddingRight: 12,
+ },
+ table: {
+ borderColor: theme.colors.foreground,
+ borderStyle: "solid",
+ borderWidth: 2,
+ },
+ tableKey: {
+ color: theme.colors.mutedForeground,
+ fontSize: 8,
+ fontWeight: "bold",
+ letterSpacing: 0.5,
+ textTransform: "uppercase",
+ width: 84,
+ },
+ tableRow: {
+ alignItems: "center",
+ borderBottomColor: theme.colors.border,
+ borderBottomStyle: "solid",
+ borderBottomWidth: 1,
+ flexDirection: "row",
+ paddingHorizontal: 8,
+ paddingVertical: 3,
+ },
+ tableRowLast: {
+ alignItems: "center",
+ flexDirection: "row",
+ paddingHorizontal: 8,
+ paddingVertical: 3,
+ },
+ tableValue: { flex: 1 },
+ trackingText: {
+ fontWeight: "bold",
+ letterSpacing: 2,
+ marginTop: 6,
+ textTransform: "uppercase",
+ },
+ });
+
+ return (
+ <Document title={`Shipping Label ${data.trackingNumber}`}>
+ <Page size={LABEL_SIZE} style={styles.page}>
+ <View style={styles.label}>
+ <View style={styles.headerRow}>
+ <Text noMargin style={styles.carrierName}>
+ {data.carrier}
+ </Text>
+ <View style={styles.serviceRight}>
+ <Text noMargin style={styles.sectionLabel}>
+ {data.serviceLevel}
+ </Text>
+ </View>
+ </View>
+
+ <View style={styles.rule} />
+
+ <View style={styles.addresses}>
+ <View style={styles.shipToColumn}>
+ <Text noMargin style={styles.sectionLabel}>
+ Ship To
+ </Text>
+ <AddressLines party={data.to} />
+ </View>
+ <View style={styles.fromColumn}>
+ <Text noMargin style={styles.sectionLabel}>
+ From
+ </Text>
+ <AddressLines party={data.from} />
+ </View>
+ </View>
+
+ <View style={styles.rule} />
+
+ <View style={styles.table}>
+ {detailRows.map((row, index) => (
+ <View
+ key={row.key}
+ style={
+ index === detailRows.length - 1
+ ? styles.tableRowLast
+ : styles.tableRow
+ }
+ >
+ <Text noMargin style={styles.tableKey}>
+ {row.key}
+ </Text>
+ <Text noMargin style={styles.tableValue} variant="xs">
+ {row.value}
+ </Text>
+ </View>
+ ))}
+ </View>
+
+ {data.handlingLabels && data.handlingLabels.length > 0 && (
+ <View style={styles.badgesRow}>
+ {data.handlingLabels.map((label, index) => (
+ <View key={`${label}-${index}`} style={styles.handlingTag}>
+ <Text noMargin style={styles.handlingTagText}>
+ {label}
+ </Text>
+ </View>
+ ))}
+ </View>
+ )}
+
+ <View style={styles.barcodeArea}>
+ {data.barcodeUrl ? (
+ <PdfImage
+ fit="contain"
+ height={72}
+ src={data.barcodeUrl}
+ width="100%"
+ />
+ ) : (
+ <PdfQRCode
+ backgroundColor="#ffffff"
+ color="#000000"
+ size={80}
+ value={data.trackingNumber}
+ />
+ )}
+ <Text
+ noMargin
+ style={styles.trackingText}
+ variant="xs"
+ weight="bold"
+ >
+ {data.trackingNumber}
+ </Text>
+ </View>
+ </View>
+ </Page>
+ </Document>
+ );
+};
+
+export const ShippingLabelDocument = ({
+ theme,
+ data = sampleData,
+}: {
+ theme?: PdfcnTheme;
+ data?: ShippingLabelData;
+}) => (
+ <PdfcnThemeProvider theme={theme}>
+ <ShippingLabelContent data={data} />
+ </PdfcnThemeProvider>
+);
diff --git a/apps/web/registry/bases/takumi/blocks/shipping-label/shipping-label.types.ts b/apps/web/registry/bases/takumi/blocks/shipping-label/shipping-label.types.ts
new file mode 100644
index 0000000..dd74a22
--- /dev/null
+++ b/apps/web/registry/bases/takumi/blocks/shipping-label/shipping-label.types.ts
@@ -0,0 +1,27 @@
+export interface ShippingLabelAddress {
+ name: string;
+ address: string;
+ city: string;
+ state: string;
+ zip: string;
+ country?: string;
+}
+
+export interface ShippingLabelDestination extends ShippingLabelAddress {
+ phone?: string;
+}
+
+export interface ShippingLabelData {
+ from: ShippingLabelAddress;
+ to: ShippingLabelDestination;
+ carrier: string;
+ serviceLevel: string;
+ trackingNumber: string;
+ barcodeUrl?: string;
+ weight?: string;
+ dimensions?: string;
+ packageCount?: number;
+ handlingLabels?: string[];
+ postage?: string;
+ accentColor?: string;
+}