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.0 KB
Raw Blame
{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "forme/gift-certificate",
  "title": "Gift Certificate",
  "description": "Gift Certificate PDF block (forme)",
  "dependencies": [
    "@formepdf/react",
    "@formepdf/core"
  ],
  "registryDependencies": [
    "@pdfcn/forme/utils",
    "@pdfcn/forme/pdf-image",
    "@pdfcn/forme/section",
    "@pdfcn/forme/text"
  ],
  "files": [
    {
      "path": "registry/bases/forme/blocks/gift-certificate/gift-certificate.tsx",
      "content": "import { Document, Page, StyleSheet, View } from \"@formepdf/react\";\n\nimport { PdfImage } from \"@/components/pdf/pdf-image/pdf-image\";\nimport { Section } from \"@/components/pdf/section/section\";\nimport { Text } from \"@/components/pdf/text/text\";\nimport {\n  PdfcnThemeProvider,\n  usePdfcnTheme,\n} from \"@/components/pdf/theme-provider\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport type { GiftCertificateData } from \"./gift-certificate.types\";\n\n// Sample data — replace with your own props or data source\nconst sampleData: GiftCertificateData = {\n  accentColor: \"#000000\",\n  amount: 50,\n  certificateCode: \"PDFCN-GC-2026-00891\",\n  companyLogo: \"/favicon.png\",\n  companyName: \"pdfcn\",\n  currency: \"USD\",\n  expiryDate: \"March 31, 2027\",\n  message: \"Happy Birthday! Enjoy a coffee on us.\",\n  recipientName: \"Sarah\",\n  redemptionInstructions: \"Present this certificate at any pdfcn location.\",\n  senderName: \"Mom & Dad\",\n  terms: \"No cash value. Non-refundable. One use per visit.\",\n};\n\nconst GiftCertificateContent = ({ data }: { data: GiftCertificateData }) => {\n  const theme = usePdfcnTheme();\n  const accentColor = data.accentColor || \"#000000\";\n  const currencySymbol = data.currency === \"USD\" ? \"$\" : data.currency || \"$\";\n\n  const styles = StyleSheet.create({\n    amount: {\n      color: accentColor,\n      fontSize: 36,\n      fontWeight: \"bold\",\n    },\n    amountContainer: {\n      alignItems: \"center\",\n      backgroundColor: theme.colors.muted,\n      borderColor: accentColor,\n      borderRadius: theme.primitives.borderRadius.md,\n      borderStyle: \"solid\",\n      borderWidth: 2,\n      marginBottom: 10,\n      marginTop: 10,\n      paddingHorizontal: 20,\n      paddingVertical: 12,\n    },\n    code: {\n      color: theme.colors.foreground,\n      fontFamily: \"Courier\",\n      fontSize: 13,\n      fontWeight: \"bold\",\n      letterSpacing: 1.2,\n    },\n    codeBox: {\n      alignItems: \"center\",\n      backgroundColor: theme.colors.background,\n      borderColor: theme.colors.border,\n      borderRadius: theme.primitives.borderRadius.sm,\n      borderStyle: \"solid\",\n      borderWidth: 1,\n      marginBottom: 8,\n      marginTop: 8,\n      paddingHorizontal: 14,\n      paddingVertical: 8,\n    },\n    decorativeBorder: {\n      borderColor: accentColor,\n      borderRadius: theme.primitives.borderRadius.lg,\n      borderStyle: \"solid\",\n      borderWidth: 3,\n      padding: 16,\n      position: \"relative\",\n    },\n    fieldLabel: {\n      color: theme.colors.mutedForeground,\n      fontSize: 9,\n      fontWeight: \"bold\",\n      letterSpacing: 1,\n      marginBottom: 4,\n      textTransform: \"uppercase\",\n    },\n    fieldValue: {\n      color: theme.colors.foreground,\n      fontSize: 14,\n      fontWeight: 500,\n    },\n    header: {\n      alignItems: \"center\",\n      marginBottom: 8,\n    },\n    innerBorder: {\n      borderColor: accentColor,\n      borderRadius: theme.primitives.borderRadius.md,\n      borderStyle: \"dashed\",\n      borderWidth: 1,\n      padding: 18,\n    },\n    instructionsBox: {\n      marginTop: 8,\n    },\n    logo: {\n      height: 28,\n      marginBottom: 6,\n      width: 28,\n    },\n    messageBox: {\n      backgroundColor: theme.colors.muted,\n      borderRadius: theme.primitives.borderRadius.sm,\n      marginBottom: 8,\n      marginTop: 8,\n      padding: 10,\n    },\n    page: {\n      backgroundColor: theme.colors.background,\n    },\n    termsText: {\n      color: theme.colors.mutedForeground,\n      fontSize: 8,\n      lineHeight: 1.4,\n      textAlign: \"center\",\n    },\n    title: {\n      color: accentColor,\n      fontSize: 22,\n      fontWeight: \"bold\",\n      letterSpacing: 2,\n      textAlign: \"center\",\n      textTransform: \"uppercase\",\n    },\n  });\n\n  return (\n    <Document title={`Gift Certificate ${data.certificateCode}`}>\n      <Page margin={24} size=\"A4\">\n        <View style={styles.page as never}>\n          <View style={styles.decorativeBorder as never}>\n            <View style={styles.innerBorder as never}>\n              <Section noWrap style={styles.header}>\n                {data.companyLogo && (\n                  <PdfImage\n                    src={data.companyLogo ?? \"/favicon.png\"}\n                    style={styles.logo}\n                  />\n                )}\n                <Text style={styles.title} noMargin>\n                  Gift Certificate\n                </Text>\n                {data.companyName && (\n                  <Text\n                    style={{\n                      color: theme.colors.foreground,\n                      fontSize: 13,\n                      fontWeight: 500,\n                      marginTop: 4,\n                      textAlign: \"center\",\n                    }}\n                    noMargin\n                  >\n                    {data.companyName}\n                  </Text>\n                )}\n              </Section>\n\n              <Section noWrap style={styles.amountContainer}>\n                <Text style={styles.amount} noMargin>\n                  {currencySymbol}\n                  {data.amount.toFixed(2)}\n                </Text>\n              </Section>\n\n              <Section\n                noWrap\n                style={{\n                  flexDirection: \"row\",\n                  gap: 28,\n                  marginBottom: 8,\n                }}\n              >\n                <View style={{ flex: 1 }}>\n                  <Text style={styles.fieldLabel} noMargin>\n                    To\n                  </Text>\n                  <Text style={styles.fieldValue} noMargin>\n                    {data.recipientName}\n                  </Text>\n                </View>\n                <View style={{ flex: 1 }}>\n                  <Text style={styles.fieldLabel} noMargin>\n                    From\n                  </Text>\n                  <Text style={styles.fieldValue} noMargin>\n                    {data.senderName}\n                  </Text>\n                </View>\n              </Section>\n\n              {data.message && (\n                <Section noWrap style={styles.messageBox}>\n                  <Text\n                    style={{\n                      color: theme.colors.foreground,\n                      fontSize: 10,\n                      fontStyle: \"italic\",\n                      lineHeight: 1.4,\n                      textAlign: \"center\",\n                    }}\n                    noMargin\n                  >\n                    \"{data.message}\"\n                  </Text>\n                </Section>\n              )}\n\n              <Section noWrap style={styles.codeBox}>\n                <Text style={styles.fieldLabel} noMargin>\n                  Certificate Code\n                </Text>\n                <Text style={styles.code} noMargin>\n                  {data.certificateCode}\n                </Text>\n              </Section>\n\n              <Section\n                noWrap\n                style={{\n                  alignItems: \"center\",\n                  marginBottom: 8,\n                }}\n              >\n                <Text style={styles.fieldLabel} noMargin>\n                  Valid Until\n                </Text>\n                <Text\n                  style={{\n                    color: accentColor,\n                    fontSize: 12,\n                    fontWeight: \"bold\",\n                  }}\n                  noMargin\n                >\n                  {data.expiryDate}\n                </Text>\n              </Section>\n\n              {data.redemptionInstructions && (\n                <Section noWrap style={styles.instructionsBox}>\n                  <Text\n                    style={{\n                      color: theme.colors.foreground,\n                      fontSize: 9,\n                      lineHeight: 1.3,\n                      textAlign: \"center\",\n                    }}\n                    noMargin\n                  >\n                    {data.redemptionInstructions}\n                  </Text>\n                </Section>\n              )}\n\n              {data.terms && (\n                <Section\n                  noWrap\n                  style={{\n                    marginTop: 10,\n                  }}\n                >\n                  <Text style={styles.termsText} noMargin>\n                    {data.terms}\n                  </Text>\n                </Section>\n              )}\n            </View>\n          </View>\n        </View>\n      </Page>\n    </Document>\n  );\n};\n\nexport const GiftCertificateDocument = ({\n  theme,\n  data = sampleData,\n}: {\n  theme?: PdfcnTheme;\n  data?: GiftCertificateData;\n}) => (\n  <PdfcnThemeProvider theme={theme}>\n    <GiftCertificateContent data={data} />\n  </PdfcnThemeProvider>\n);\n",
      "type": "registry:block",
      "target": "components/pdf/blocks/gift-certificate/gift-certificate.tsx"
    },
    {
      "path": "registry/bases/forme/blocks/gift-certificate/gift-certificate.types.ts",
      "content": "export interface GiftCertificateData {\n  companyName: string;\n  companyLogo?: string;\n  amount: number;\n  currency?: string;\n  recipientName: string;\n  senderName: string;\n  message?: string;\n  certificateCode: string;\n  expiryDate: string;\n  redemptionInstructions?: string;\n  terms?: string;\n  companyContact?: string;\n  accentColor?: string;\n  renderingBase?: \"takumi\" | \"forme\";\n}\n",
      "type": "registry:block",
      "target": "components/pdf/blocks/gift-certificate/gift-certificate.types.ts"
    }
  ],
  "type": "registry:block"
}