{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "email",
  "title": "Email",
  "description": "Primitives for emails built with React Email: a layout with your brand and footer, a title with a sentence, a dark panel for the one thing the email is about with its value, a money value with smaller cents, a usage meter drawn as table cells, a note and a button, sections a rule opens, label and value rows with a total, and a render helper that returns the HTML and its plain-text copy.",
  "dependencies": [
    "react-email"
  ],
  "registryDependencies": [
    "https://www.dashboardblocks.com/r/radix/email-theme.json"
  ],
  "files": [
    {
      "path": "registry/components/dashboardblocks/email.tsx",
      "content": "import { emailConfig, emailTheme } from '@/registry/lib/dashboardblocks/email-theme'\nimport type { ReactElement, ReactNode } from 'react'\nimport {\n  Body,\n  Button,\n  Column,\n  Container,\n  Head,\n  Heading,\n  Html,\n  Img,\n  Link,\n  Preview,\n  Row,\n  Section,\n  Tailwind,\n  Text,\n  render,\n} from 'react-email'\n\ninterface EmailBrand {\n  name: string\n  /** An absolute https URL to a square PNG or JPEG, at least 40px: mail apps don't show SVG. */\n  logo?: string\n}\n\nfunction EmailLayout({\n  brand,\n  children,\n  footer,\n  preview,\n}: {\n  brand: EmailBrand\n  children: ReactNode\n  footer: ReactNode\n  /** The line inbox lists show after the subject. */\n  preview: string\n}) {\n  return (\n    <Html lang='en' dir='ltr'>\n      <Tailwind config={emailConfig} theme={emailTheme}>\n        <Head>\n          <meta name='color-scheme' content='light' />\n          <meta name='supported-color-schemes' content='light' />\n        </Head>\n        <Body className='bg-background m-0 font-sans'>\n          <Preview>{preview}</Preview>\n          <Container className='max-w-[520px] px-6 pt-10 pb-12'>\n            <Section>\n              <Row>\n                {brand.logo ? (\n                  <Column className='w-5 align-middle'>\n                    <Img src={brand.logo} width='20' height='20' alt='' />\n                  </Column>\n                ) : (\n                  <Column className='bg-primary h-5 w-5 rounded' />\n                )}\n                <Column className='w-2' />\n                <Column className='align-middle'>\n                  <Text className='text-foreground m-0 text-base font-semibold tracking-tight'>\n                    {brand.name}\n                  </Text>\n                </Column>\n              </Row>\n            </Section>\n            {children}\n            <Section className='mt-10'>{footer}</Section>\n          </Container>\n        </Body>\n      </Tailwind>\n    </Html>\n  )\n}\n\nfunction EmailTitle({\n  children,\n  description,\n}: {\n  children: ReactNode\n  description: ReactNode\n}) {\n  return (\n    <Section className='mt-9'>\n      <Heading\n        as='h1'\n        className='text-foreground m-0 text-2xl font-semibold tracking-tight'\n      >\n        {children}\n      </Heading>\n      <Text className='text-muted-foreground m-0 mt-1 text-base'>{description}</Text>\n    </Section>\n  )\n}\n\nfunction EmailPanel({ children, label }: { children: ReactNode; label: string }) {\n  return (\n    <Section className='bg-panel mt-6 rounded-xl'>\n      <Section className='px-6 pt-5 pb-6'>\n        <Text className='text-panel-muted-foreground m-0 text-sm'>{label}</Text>\n        {children}\n      </Section>\n    </Section>\n  )\n}\n\nfunction EmailPanelValue({ children, unit }: { children: ReactNode; unit?: ReactNode }) {\n  return (\n    <Text\n      dir='ltr'\n      className='text-panel-foreground m-0 mt-2 text-5xl font-light tracking-tight tabular-nums'\n    >\n      {children}\n      {unit ? <span className='text-panel-muted-foreground text-2xl'>{unit}</span> : null}\n    </Text>\n  )\n}\n\n/** A name on the panel, where the email is about a thing rather than a number: a workspace, a first step. */\nfunction EmailPanelTitle({ children }: { children: ReactNode }) {\n  return (\n    <Text className='text-panel-foreground m-0 mt-2 text-2xl font-light tracking-tight'>\n      {children}\n    </Text>\n  )\n}\n\n/** A money value from `formatCurrency`, with its cents smaller: `$588` then `.00`. */\nfunction EmailPanelMoney({ children }: { children: string }) {\n  const decimal = children.search(/\\.\\d+$/)\n  if (decimal === -1) return <EmailPanelValue>{children}</EmailPanelValue>\n  return (\n    <EmailPanelValue unit={children.slice(decimal)}>\n      {children.slice(0, decimal)}\n    </EmailPanelValue>\n  )\n}\n\n/** A bar of how much of a limit is used, drawn as table cells, which every mail app lays out. */\nfunction EmailPanelMeter({\n  label,\n  value,\n}: {\n  /** What the bar shows, for screen readers: `85% of 10M events used`. */\n  label: string\n  /** The share used, from 0 to 1. */\n  value: number\n}) {\n  const used = Math.round(Math.min(1, Math.max(0, value)) * 100)\n  const cell = (width: number) => ({\n    fontSize: '1px',\n    lineHeight: '8px',\n    width: `${width}%`,\n  })\n  return (\n    <Section className='mt-4' aria-label={label} role='img' data-email-chart=''>\n      <Row>\n        {used > 0 ? (\n          <Column\n            className={`bg-chart-2 h-2 ${used < 100 ? 'rounded-l-sm' : 'rounded-sm'}`}\n            style={cell(used)}\n          >\n            {'\\u00a0'}\n          </Column>\n        ) : null}\n        {used < 100 ? (\n          <Column\n            className={`bg-panel-muted h-2 ${used > 0 ? 'rounded-r-sm' : 'rounded-sm'}`}\n            style={cell(100 - used)}\n          >\n            {'\\u00a0'}\n          </Column>\n        ) : null}\n      </Row>\n    </Section>\n  )\n}\n\nfunction EmailPanelNote({ children }: { children: ReactNode }) {\n  return <Text className='text-panel-muted-foreground m-0 mt-2 text-sm'>{children}</Text>\n}\n\nfunction EmailPanelButton({ children, href }: { children: ReactNode; href: string }) {\n  return (\n    <Button\n      href={href}\n      className='bg-panel-primary text-panel-primary-foreground border-panel-primary mt-5 box-border rounded-md border border-solid px-2.5 py-[9px] text-sm leading-5 font-medium'\n    >\n      <span className='leading-5'>{children}</span>\n    </Button>\n  )\n}\n\nfunction EmailSection({ children, title }: { children: ReactNode; title?: ReactNode }) {\n  return (\n    <Section className='border-border mt-8 border-0 border-t border-solid pt-5'>\n      {title ? (\n        <Heading as='h2' className='text-foreground m-0 mb-1 text-sm font-semibold'>\n          {title}\n        </Heading>\n      ) : null}\n      {children}\n    </Section>\n  )\n}\n\nfunction EmailText({ children }: { children: ReactNode }) {\n  return <Text className='text-muted-foreground m-0 text-sm'>{children}</Text>\n}\n\nfunction EmailLink({ children, href }: { children: ReactNode; href: string }) {\n  return (\n    <Link href={href} className='text-foreground underline'>\n      {children}\n    </Link>\n  )\n}\n\ninterface EmailRow {\n  label: ReactNode\n  detail?: ReactNode\n  value: ReactNode\n}\n\nfunction EmailRows({\n  rows,\n  total,\n}: {\n  rows: EmailRow[]\n  total?: Omit<EmailRow, 'detail'>\n}) {\n  return (\n    <Section>\n      {rows.map((row, index) => (\n        <Row\n          key={index}\n          data-email-rows=''\n          className={\n            index === 0 ? undefined : 'border-border border-0 border-t border-solid'\n          }\n        >\n          <Column className='py-2.5 align-top'>\n            <Text className='text-foreground m-0 text-sm'>{row.label}</Text>\n            {row.detail ? (\n              <Text className='text-muted-foreground m-0 text-sm'>{row.detail}</Text>\n            ) : null}\n          </Column>\n          <Column className='text-foreground py-2.5 pl-4 text-right align-top text-sm whitespace-nowrap tabular-nums'>\n            {row.value}\n          </Column>\n        </Row>\n      ))}\n      {total ? (\n        <Row\n          data-email-rows=''\n          className='border-foreground border-0 border-t border-solid'\n        >\n          <Column className='text-foreground py-2.5 text-sm font-semibold'>\n            {total.label}\n          </Column>\n          <Column className='text-foreground py-2.5 pl-4 text-right text-sm font-semibold whitespace-nowrap tabular-nums'>\n            {total.value}\n          </Column>\n        </Row>\n      ) : null}\n    </Section>\n  )\n}\n\nfunction EmailFooter({ children }: { children: ReactNode }) {\n  return <Text className='text-muted-foreground m-0 text-xs'>{children}</Text>\n}\n\n/** The HTML and the plain-text copy to send with it. A chart marked `data-email-chart` stays out of the plain text, which says its numbers in words. */\nasync function renderEmail(email: ReactElement) {\n  const [html, text] = await Promise.all([\n    render(email),\n    render(email, {\n      plainText: true,\n      htmlToTextOptions: {\n        selectors: [\n          { selector: 'h1', options: { uppercase: false } },\n          { selector: 'h2', options: { uppercase: false } },\n          { selector: '[data-email-chart]', format: 'skip' },\n          {\n            selector: 'table[data-email-rows]',\n            format: 'dataTable',\n            options: { uppercaseHeaderCells: false },\n          },\n        ],\n      },\n    }),\n  ])\n  return { html, text }\n}\n\nexport {\n  EmailFooter,\n  EmailLayout,\n  EmailLink,\n  EmailPanel,\n  EmailPanelButton,\n  EmailPanelMeter,\n  EmailPanelMoney,\n  EmailPanelNote,\n  EmailPanelTitle,\n  EmailPanelValue,\n  EmailRows,\n  EmailSection,\n  EmailText,\n  EmailTitle,\n  renderEmail,\n}\nexport type { EmailBrand, EmailRow }\n",
      "type": "registry:component",
      "target": "@components/dashboardblocks/email.tsx"
    }
  ],
  "type": "registry:component"
}
