@clay-design-system/email

中文文档
0.3.12发布于 2026/11/10TypeScriptES Module近 30 天下载 2166

The Lifecycle / Email tier of the Clay Design System — responsive, Outlook-safe HTML emails authored in MJML and composed from the shared Clay foundation tokens.

原始使用文档
文档目录4 节
  1. Why MJML + inlined tokens
  2. Structure
  3. Scripts
  4. What the npm package ships

@clay-design-system/email

The Lifecycle / Email tier of the Clay Design System — responsive, Outlook-safe HTML emails authored in MJML and composed from the shared Clay foundation tokens.

Why MJML + inlined tokens

Email clients (notably Outlook) do not support CSS custom properties (var(--clay-*)). So this package never ships var() — instead a build step reads the resolved literal token values from @clay-design-system/tokens (the dist/tokens.js ES export) and inlines them into MJML at build time.

@clay-design-system/tokens (JS literals)
   ↓  src/tokens/build-email-tokens.ts   (generates)
src/generated/base-head.mjml   ← <mj-head>: fonts, mj-class roles, dark-mode
src/generated/email-tokens.ts  ← inline-able constants + px() helper
   ↓  MJML sections + container
src/build/compile.ts  (mjml2html)
   ↓
dist/emails/<name>.html         ← standalone, previewable
dist/emails/<name>.braze.html   ← Braze full-template variant (unsubscribe token)
dist/emails/<name>.static.html  ← hand-authored fallback (no MJML)
dist/catalog.json               ← Storybook + docs source

Structure

  • src/container/ — the shared email shell (page bg → 640px card → 560px inner, preheader, responsive + dark/light). Every email reuses it.
  • src/sections/ — MJML section partials (logo-header, hero, feature-rows, icon-feature-list, buttons-primary, footer).
  • src/emails/ — full email compositions (container + sections) plus a static-HTML fallback. Gitignored / local-only: every composed email is a generation, so it stays on the machine that made it and contributors never see each other's campaigns. The build globs this folder at compile time, so generating into it works unchanged — it is simply never committed. A fresh clone starts empty here; src/examples/ holds the committed Email Love → Braze reference exports.
  • src/tokens/ — the token→email bridge codegen.
  • src/build/ — MJML compile + Braze transform + catalog.

Scripts

pnpm --filter @clay-design-system/email build          # tokens bridge → tsc → compile MJML
pnpm --filter @clay-design-system/email dev            # watch + recompile MJML
pnpm --filter @clay-design-system/email tokens:check   # fail if generated token artifacts drift
pnpm --filter @clay-design-system/email test           # vitest

What the npm package ships

Only the public surface: dist/index.js + types (the inline token constants), @clay-design-system/email/catalog.json, …/emails/* (compiled HTML, Braze and static variants). Source maps, dist/build, dist/examples and dist/exports (the Braze campaign exports with their images, ~11 MB) stay in the repo: they are build output, not importable through the exports map. package.json files is an allowlist, so new build output is not published until it is added there.

Documented in Storybook under Lifecycle/Email/.

版本与发布记录

@clay-design-system/email 共发布 18 个版本,首次发布于 2026/10/13;过去 12 个月发布了 18 个版本。

版本发布日期距今
0.3.12latest2026/11/10今天
0.3.112026/11/064 天前
0.3.102026/10/2218 天前
0.3.92026/10/2218 天前
0.3.72026/10/2119 天前
0.3.62026/10/2020 天前

关于 @clay-design-system/email 的常见问题

@clay-design-system/email 是什么?

The Lifecycle / Email tier of the Clay Design System — responsive, Outlook-safe HTML emails authored in MJML and composed from the shared Clay foundation tokens.

如何安装 @clay-design-system/email?

在项目目录运行 npm install @clay-design-system/email,或使用 pnpm add / yarn add / bun add。

@clay-design-system/email 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@clay-design-system/email 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@clay-design-system/email 可以商用吗?

@clay-design-system/email 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@clay-design-system/email 的下载量有多少?

根据 npm 官方下载统计,@clay-design-system/email 在 2026/10/10 – 2026/11/08 这 30 天内被下载 2,166 次,日均约 72 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@clay-design-system/email 还在维护吗?

最新版本 0.3.12 发布于 2026/11/10(今天);至今共发布 18 个版本,其中过去 12 个月发布了 18 个;首次发布于 2026/10/13。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。