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.

8.0 KB
Raw Blame
{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "takumi/press-release",
  "title": "Press Release",
  "description": "Press Release PDF block (takumi)",
  "dependencies": [
    "takumi-pdf",
    "@takumi-rs/helpers"
  ],
  "registryDependencies": [
    "@pdfcn/takumi/utils",
    "@pdfcn/takumi/page-footer",
    "@pdfcn/takumi/page-header",
    "@pdfcn/takumi/pdf-image",
    "@pdfcn/takumi/section",
    "@pdfcn/takumi/text"
  ],
  "files": [
    {
      "path": "registry/bases/takumi/blocks/press-release/press-release.tsx",
      "content": "import { PageFooter } from \"@/components/pdf/page-footer/page-footer\";\nimport { PageHeader } from \"@/components/pdf/page-header/page-header\";\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 {\n  Document,\n  Page,\n  StyleSheet,\n} from \"@/lib/pdf-primitives\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport type { PressReleaseProps } from \"./press-release.types\";\n\n// Sample data — replace with your own props or data source\nconst sampleData: PressReleaseProps = {\n  accentColor: \"#1e40af\",\n  address: \"123 Market St, San Francisco, CA 94103\",\n  body: [\n    \"Acme Corp today announced the launch of pdfcn, an open-source React component library for generating professional PDF documents.\",\n    \"pdfcn is designed to work seamlessly with shadcn/ui and follows the same registry-based distribution model, letting developers add print-ready document blocks with a single CLI command.\",\n  ],\n  boilerplate:\n    \"Acme Corp is a leading provider of developer tools and open-source software.\",\n  companyName: \"Acme Corp\",\n  date: \"September 10, 2026\",\n  dateline: { city: \"San Francisco\", state: \"CA\" },\n  headline: \"Acme Corp Launches Revolutionary PDF Toolkit for Developers\",\n  mediaContact: {\n    email: \"[email protected]\",\n    name: \"Press Team\",\n    phone: \"(555) 123-4567\",\n  },\n  quotes: [\n    {\n      author: \"Jane Doe\",\n      text: \"We built pdfcn because generating PDFs in React was unnecessarily painful. Now it feels like writing any other component.\",\n      title: \"CTO, Acme Corp\",\n    },\n  ],\n  socialLinks: [\n    { platform: \"GitHub\", url: \"https://github.com/acme\" },\n    { platform: \"X\", url: \"https://x.com/acme\" },\n  ],\n  subheadline:\n    \"New open-source library makes generating professional PDFs in React effortless\",\n};\n\nconst PressReleaseContent = ({ data }: { data: PressReleaseProps }) => {\n  const theme = usePdfcnTheme();\n\n  const styles = StyleSheet.create({\n    columnHeading: {\n      fontSize: 9,\n      fontWeight: \"bold\",\n      marginBottom: 2,\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  });\n\n  return (\n    <Document title={`Press Release — ${data.companyName}`}>\n      <Page size=\"A4\" style={styles.page}>\n        <PageHeader\n          variant=\"logo-left\"\n          logo={\n            data.companyLogo ? (\n              <PdfImage src={data.companyLogo} style={{ margin: 0 }} />\n            ) : undefined\n          }\n          title={data.companyName}\n          rightText={data.date}\n          style={{ marginBottom: 0 }}\n        />\n        <Section spacing=\"none\">\n          <Text\n            variant=\"xs\"\n            weight=\"bold\"\n            transform=\"uppercase\"\n            color={data.accentColor ?? \"mutedForeground\"}\n            noMargin\n          >\n            For Immediate Release\n          </Text>\n          <Text variant=\"2xl\" weight=\"bold\" noMargin>\n            {data.headline}\n          </Text>\n          {data.subheadline && (\n            <Text variant=\"lg\" color=\"mutedForeground\" noMargin>\n              {data.subheadline}\n            </Text>\n          )}\n        </Section>\n        <Section spacing=\"none\">\n          <Text variant=\"sm\" weight=\"semibold\" transform=\"uppercase\" noMargin>\n            {`${data.dateline.city}, ${data.dateline.state} — ${data.date}`}\n          </Text>\n          {data.body.map((paragraph) => (\n            <Text key={paragraph.slice(0, 24)} variant=\"sm\">\n              {paragraph}\n            </Text>\n          ))}\n        </Section>\n        {data.quotes?.map((quote) => (\n          <Section\n            key={quote.author}\n            spacing=\"sm\"\n            variant=\"callout\"\n            accentColor={data.accentColor}\n          >\n            <Text variant=\"base\" italic noMargin>\n              {`“${quote.text}”`}\n            </Text>\n            <Text variant=\"xs\" color=\"mutedForeground\" noMargin>\n              {`— ${quote.author}, ${quote.title}`}\n            </Text>\n          </Section>\n        ))}\n        <Section spacing=\"sm\">\n          <Text\n            style={styles.columnHeading}\n            color=\"mutedForeground\"\n            transform=\"uppercase\"\n            noMargin\n          >\n            {`About ${data.companyName}`}\n          </Text>\n          <Text variant=\"sm\" noMargin>\n            {data.boilerplate}\n          </Text>\n        </Section>\n        <Section spacing=\"none\">\n          <Text\n            style={styles.columnHeading}\n            color=\"mutedForeground\"\n            transform=\"uppercase\"\n            noMargin\n          >\n            Media Contact\n          </Text>\n          <Text noMargin variant=\"xs\">\n            {data.mediaContact.name}\n          </Text>\n          <Text noMargin variant=\"xs\">\n            {data.mediaContact.email}\n          </Text>\n          <Text noMargin variant=\"xs\">\n            {data.mediaContact.phone}\n          </Text>\n          {data.mediaContact.website && (\n            <Text noMargin variant=\"xs\">\n              {data.mediaContact.website}\n            </Text>\n          )}\n        </Section>\n        <Text align=\"center\" variant=\"sm\" weight=\"medium\" noMargin>\n          ###\n        </Text>\n        <PageFooter\n          leftText={data.address ?? data.companyName}\n          rightText={\n            data.socialLinks?.length\n              ? data.socialLinks.map((link) => link.platform).join(\" · \")\n              : undefined\n          }\n          sticky\n          pagePadding={25}\n        />\n      </Page>\n    </Document>\n  );\n};\n\nexport const PressReleaseDocument = ({\n  theme,\n  data,\n  ...props\n}: {\n  theme?: PdfcnTheme;\n  data?: PressReleaseProps;\n} & Partial<PressReleaseProps>) => (\n  <PdfcnThemeProvider theme={theme}>\n    <PressReleaseContent data={{ ...sampleData, ...data, ...props }} />\n  </PdfcnThemeProvider>\n);\n",
      "type": "registry:block",
      "target": "components/pdf/blocks/press-release/press-release.tsx"
    },
    {
      "path": "registry/bases/takumi/blocks/press-release/press-release.types.ts",
      "content": "export interface PressReleaseDateline {\n  city: string;\n  state: string;\n}\n\nexport interface PressReleaseQuote {\n  text: string;\n  author: string;\n  title: string;\n}\n\nexport interface PressReleaseMediaContact {\n  name: string;\n  email: string;\n  phone: string;\n  website?: string;\n}\n\nexport interface PressReleaseSocialLink {\n  platform: string;\n  url: string;\n}\n\nexport interface PressReleaseProps {\n  companyName: string;\n  companyLogo?: string;\n  date: string;\n  headline: string;\n  subheadline?: string;\n  dateline: PressReleaseDateline;\n  body: string[];\n  quotes?: PressReleaseQuote[];\n  boilerplate: string;\n  mediaContact: PressReleaseMediaContact;\n  address?: string;\n  socialLinks?: PressReleaseSocialLink[];\n  accentColor?: string;\n  renderingBase?: \"takumi\" | \"forme\";\n}\n",
      "type": "registry:block",
      "target": "components/pdf/blocks/press-release/press-release.types.ts"
    }
  ],
  "type": "registry:block"
}