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.

10.2 KB
Raw Blame
{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "takumi/invoice-creative",
  "title": "Invoice Creative",
  "description": "Invoice Creative PDF block (takumi)",
  "dependencies": [
    "takumi-pdf",
    "@takumi-rs/helpers"
  ],
  "registryDependencies": [
    "@pdfcn/takumi/utils",
    "@pdfcn/takumi/key-value",
    "@pdfcn/takumi/page-footer",
    "@pdfcn/takumi/page-header",
    "@pdfcn/takumi/section",
    "@pdfcn/takumi/table",
    "@pdfcn/takumi/text"
  ],
  "files": [
    {
      "path": "registry/bases/takumi/blocks/invoice-creative/invoice-creative.tsx",
      "content": "import { KeyValue } from \"@/components/pdf/key-value/key-value\";\nimport { PageFooter } from \"@/components/pdf/page-footer/page-footer\";\nimport { PageHeader } from \"@/components/pdf/page-header/page-header\";\nimport { Section } from \"@/components/pdf/section/section\";\nimport {\n  Table,\n  TableBody,\n  TableCell,\n  TableHeader,\n  TableRow,\n} from \"@/components/pdf/table/table\";\nimport { Text } from \"@/components/pdf/text/text\";\nimport {\n  PdfcnThemeProvider,\n  usePdfcnTheme,\n} from \"@/components/pdf/theme-provider\";\nimport {\n  View,\n  StyleSheet,\n  Document,\n  Page,\n} from \"@/lib/pdf-primitives\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport type { InvoiceCreativeData } from \"./invoice-creative.types\";\n\nconst sampleData: InvoiceCreativeData = {\n  billTo: {\n    address: \"250 Design District, Loft 5\",\n    email: \"[email protected]\",\n    name: \"Creative Agency Co.\",\n    phone: \"+1 (555) 321-7654\",\n  },\n  companyAddress: \"Nagpur, IN · [email protected]\",\n  companyName: \"pdfcn\",\n  dueDate: \"March 26, 2026\",\n  invoiceDate: \"February 24, 2026\",\n  invoiceNumber: \"INV-2026-005\",\n  items: [\n    { description: \"Brand Identity Design\", quantity: 1, unitPrice: 8500 },\n    {\n      description: \"Marketing Collateral Package\",\n      quantity: 1,\n      unitPrice: 4200,\n    },\n    {\n      description: \"Social Media Assets (per set)\",\n      quantity: 4,\n      unitPrice: 750,\n    },\n    { description: \"Motion Graphics (30s)\", quantity: 2, unitPrice: 3500 },\n  ],\n  notes:\n    \"Creative work is protected under copyright. Full usage rights transfer upon payment.\",\n  paymentTerms: {\n    dueDate: \"March 26, 2026\",\n    gst: \"GSTIN 456789123\",\n    method: \"Credit Card / PayPal / Stripe\",\n  },\n  subtitle: \"Innovative PDF Solutions\",\n  summary: {\n    subtotal: 22_700,\n    tax: 1475.5,\n    total: 24_175.5,\n  },\n};\n\nconst InvoiceCreativeContent = ({ data }: { data: InvoiceCreativeData }) => {\n  const theme = usePdfcnTheme();\n\n  const styles = StyleSheet.create({\n    accentBlock: {\n      backgroundColor: theme.colors.muted,\n      borderLeftColor: theme.colors.accent,\n      borderLeftStyle: \"solid\",\n      borderLeftWidth: 4,\n      marginBottom: theme.spacing.sectionGap,\n      paddingLeft: 14,\n      paddingVertical: 10,\n    },\n    badgeLabel: {\n      color: theme.colors.primaryForeground,\n      fontSize: 8,\n      fontWeight: \"bold\",\n      letterSpacing: 1.2,\n      marginBottom: 2,\n      textTransform: \"uppercase\",\n    },\n    badgeNumber: {\n      color: theme.colors.primaryForeground,\n      fontSize: 16,\n      fontWeight: \"bold\",\n    },\n    heroSection: {\n      alignItems: \"center\",\n      flexDirection: \"row\",\n      justifyContent: \"space-between\",\n      marginBottom: theme.spacing.sectionGap,\n    },\n    infoColumn: {\n      flex: 1,\n    },\n    infoGrid: {\n      flexDirection: \"row\",\n      gap: 32,\n    },\n    invoiceBadge: {\n      alignItems: \"center\",\n      backgroundColor: theme.colors.primary,\n      borderRadius: theme.primitives.borderRadius.md,\n      paddingHorizontal: 20,\n      paddingVertical: 14,\n    },\n    page: {\n      backgroundColor: theme.colors.background,\n      boxSizing: \"border-box\",\n      minHeight: 841,\n      padding: theme.spacing.page.marginTop,\n      paddingBottom: theme.spacing.page.marginBottom,\n      position: \"relative\",\n    },\n    sectionLabel: {\n      color: theme.colors.accent,\n      fontSize: 8,\n      fontWeight: \"bold\",\n      letterSpacing: 0.8,\n      marginBottom: 6,\n      textTransform: \"uppercase\",\n    },\n    summaryLeft: {\n      flex: 1,\n      paddingRight: 20,\n    },\n    summaryRight: {\n      backgroundColor: theme.colors.muted,\n      borderRadius: theme.primitives.borderRadius.sm,\n      padding: 14,\n      width: 240,\n    },\n    summarySection: {\n      flexDirection: \"row\",\n      marginTop: 24,\n    },\n  });\n\n  return (\n    <Document title={`Invoice ${data.invoiceNumber}`}>\n      <Page size=\"A4\" style={styles.page}>\n        <View style={styles.heroSection}>\n          <View style={{ flex: 1 }}>\n            <PageHeader\n              variant=\"centered\"\n              title={data.companyName}\n              subtitle={`${data.subtitle}  ·  ${data.companyAddress}`}\n              marginBottom={0}\n            />\n          </View>\n          <View style={styles.invoiceBadge}>\n            <Text style={styles.badgeLabel} noMargin>\n              Invoice\n            </Text>\n            <Text style={styles.badgeNumber} noMargin>\n              {data.invoiceNumber}\n            </Text>\n          </View>\n        </View>\n        <View style={styles.accentBlock}>\n          <View style={styles.infoGrid}>\n            <View style={styles.infoColumn}>\n              <Text style={styles.sectionLabel} noMargin>\n                Billed To\n              </Text>\n              <Text variant=\"sm\" weight=\"semibold\" noMargin>\n                {data.billTo.name}\n              </Text>\n              <Text variant=\"xs\" noMargin color=\"mutedForeground\">\n                {data.billTo.address}\n              </Text>\n              <Text variant=\"xs\" noMargin color=\"mutedForeground\">\n                {data.billTo.email} · {data.billTo.phone}\n              </Text>\n            </View>\n            <View style={styles.infoColumn}>\n              <Text style={styles.sectionLabel} noMargin>\n                Invoice Info\n              </Text>\n              <KeyValue\n                size=\"sm\"\n                items={[\n                  { key: \"Issue Date\", value: data.invoiceDate },\n                  { key: \"Due Date\", value: data.dueDate },\n                  { key: \"Payment\", value: data.paymentTerms.method },\n                ]}\n              />\n            </View>\n          </View>\n        </View>\n        <Table variant=\"striped\" zebraStripe>\n          <TableHeader>\n            <TableRow header>\n              <TableCell>Deliverable</TableCell>\n              <TableCell align=\"center\">Qty</TableCell>\n              <TableCell align=\"right\">Rate</TableCell>\n              <TableCell align=\"right\">Amount</TableCell>\n            </TableRow>\n          </TableHeader>\n          <TableBody>\n            {data.items.map((item, index) => (\n              // biome-ignore lint/suspicious/noArrayIndexKey: static PDF list, no reordering\n              <TableRow key={index}>\n                <TableCell>{item.description}</TableCell>\n                <TableCell align=\"center\">{`${item.quantity}`}</TableCell>\n                <TableCell align=\"right\">{`$${item.unitPrice.toLocaleString()}`}</TableCell>\n                <TableCell align=\"right\">{`$${(item.quantity * item.unitPrice).toLocaleString()}`}</TableCell>\n              </TableRow>\n            ))}\n          </TableBody>\n        </Table>\n        <Section noWrap style={styles.summarySection}>\n          <View style={styles.summaryLeft}>\n            <Text style={styles.sectionLabel} noMargin>\n              Notes & Terms\n            </Text>\n            <Text variant=\"xs\" color=\"mutedForeground\">\n              {data.notes}\n            </Text>\n            <Text variant=\"xs\" color=\"mutedForeground\" style={{ marginTop: 4 }}>\n              GST: {data.paymentTerms.gst}\n            </Text>\n          </View>\n          <View style={styles.summaryRight}>\n            <KeyValue\n              size=\"sm\"\n              dividerThickness={1}\n              items={[\n                {\n                  key: \"Subtotal\",\n                  value: `$${data.summary.subtotal.toLocaleString()}`,\n                },\n                { key: \"Tax (6.5%)\", value: `$${data.summary.tax.toFixed(2)}` },\n                {\n                  key: \"Total\",\n                  keyStyle: { fontSize: 13, fontWeight: \"bold\" },\n                  value: `$${data.summary.total.toFixed(2)}`,\n                  valueStyle: {\n                    color: theme.colors.accent,\n                    fontSize: 14,\n                    fontWeight: \"bold\",\n                  },\n                },\n              ]}\n              divided\n            />\n          </View>\n        </Section>\n        <PageFooter\n          variant=\"centered\"\n          centerText=\"Thank you for choosing us for your creative needs!\"\n          sticky\n          pagePadding={25}\n        />\n      </Page>\n    </Document>\n  );\n};\n\nexport const InvoiceCreativeDocument = ({\n  theme,\n  data = sampleData,\n}: {\n  theme?: PdfcnTheme;\n  data?: InvoiceCreativeData;\n}) => (\n  <PdfcnThemeProvider theme={theme}>\n    <InvoiceCreativeContent data={data} />\n  </PdfcnThemeProvider>\n);\n",
      "type": "registry:block",
      "target": "components/pdf/blocks/invoice-creative/invoice-creative.tsx"
    },
    {
      "path": "registry/bases/takumi/blocks/invoice-creative/invoice-creative.types.ts",
      "content": "export interface InvoiceCreativeData {\n  invoiceNumber: string;\n  invoiceDate: string;\n  dueDate: string;\n  companyName: string;\n  subtitle: string;\n  companyAddress: string;\n  billTo: {\n    name: string;\n    address: string;\n    email: string;\n    phone: string;\n  };\n  items: {\n    description: string;\n    quantity: number;\n    unitPrice: number;\n  }[];\n  summary: {\n    subtotal: number;\n    tax: number;\n    total: number;\n  };\n  paymentTerms: {\n    dueDate: string;\n    method: string;\n    gst: string;\n  };\n  notes?: string;\n}\n",
      "type": "registry:block",
      "target": "components/pdf/blocks/invoice-creative/invoice-creative.types.ts"
    }
  ],
  "type": "registry:block"
}