Skip to content

feat(templates): ship richer default template gallery as library export#56

Merged
zhawtof merged 3 commits into
mainfrom
claude/determined-mahavira-92f9f8
May 16, 2026
Merged

feat(templates): ship richer default template gallery as library export#56
zhawtof merged 3 commits into
mainfrom
claude/determined-mahavira-92f9f8

Conversation

@zhawtof
Copy link
Copy Markdown
Contributor

@zhawtof zhawtof commented May 16, 2026

Summary

Adds a new defaultTemplates library export — a curated set of 10 polished templates spanning all three Slack surfaces (message, modal, app_home) that collectively exercise every supported block type and a wide slice of the element catalog. The live demo and Storybook fixtures now consume this shared export instead of each carrying their own short hello-world arrays.

Why

The demo at block-kitchen.tightknit.dev and the Storybook TemplatePicker stories previously each maintained their own 3-block sample arrays (header + section + divider). They were useful as a hello-world but didn't show what the platform can render. Anyone evaluating the package landed on a template gallery that visually under-sold the library's capabilities. Shipping a curated gallery as a library export means: (1) the demo and Storybook stay in sync from a single source of truth, (2) downstream consumers get a polished starting point for free, and (3) the gallery itself becomes part of the visual story for new users.

What's in the gallery

Category Template Surface Highlights
Engineering Pull request review message diff snippet, CI-status table, reviewer picker, overflow, feedback buttons
Engineering Incident report message severity pill, timeline table, rich-text next steps, button-confirm, ETA picker
Approvals Expense approval message image accessory, aligned currency table, approve / reject-with-confirm / link button
Approvals Confirm destructive action modal warning alert + type-to-confirm input
Team Daily standup message rich-text Y/T/B with inline code + links, datepicker + multi-users-select, feedback buttons
Announcements Product release message hero image + markdown block with GFM table + 3-card carousel
Forms Customer feedback intake modal 8 inputs: every text variant, radio, checkboxes, rich_text_input, file_input, email
Scheduling Schedule meeting modal info alert + 9 inputs incl. url_text_input + bounded number_input + channels_select
Home tabs Welcome / onboarding app_home hero, ordered rich-text checklist, resource carousel, primary + link CTAs
Home tabs Team dashboard app_home status with image accessory, per-service rows with button / overflow accessories, recent-items carousel

Surface compatibility is respected throughout — alert only in modals, no table / markdown / carousel / context_actions in modals, no table / markdown / context_actions on home tabs, file_input only in modals.

Files changed

  • New: src/lib/default-templates.ts — the 10 templates and a TEMPLATE_CATEGORIES constant.
  • src/index.ts — exports defaultTemplates and TEMPLATE_CATEGORIES.
  • demo/src/App.tsx — imports defaultTemplates (replaces the inline TEMPLATES array).
  • src/components/template-picker.stories.tsx — imports defaultTemplates; new FilteredToAppHomeSurface story; ClickCardInvokesHandler retargeted to expense-approval.
  • test/public-api.test.ts — new describe('default templates') block: id uniqueness, non-empty blocks, valid surface enum, surface-compatibility (mirroring the validator's forbidden-blocks-per-surface rules), and toSlackBlocks roundtrip.

Test plan

  • pnpm typecheck
  • pnpm test — 214/214 pass (up from 193)
  • pnpm builddefaultTemplates and TEMPLATE_CATEGORIES appear in dist/index.d.ts
  • Live demo via local Vite: gallery renders all 10 with rich live thumbnails grouped by 7 categories; clicking a template loads its blocks into the builder; message-surface templates show zero validation issues; modal surface chrome (title bar + close) renders correctly when the toolbar surface is switched; dark theme renders cleanly; no console errors.

Notes for reviewer

  • Pre-commit biome-fix reformatted some long lines and re-ordered the new src/index.ts export (defaultTemplates alphabetized before TEMPLATE_CATEGORIES) — those tweaks are intentional, not stale code.
  • main is 4 commits ahead of this branch (most relevantly feat(theme): add eclectic preset themes (feat(theme): add eclectic preset themes (Slack, Ocean, Sunset, Mono, Cyberpunk) #50) which also edits demo/src/App.tsx — adds a BrandPreset picker in the header). The two edits don't overlap (preset picker is in the header <button> area; my change is only to the templates <aside> and the imports list), so the merge should be clean.

🤖 Generated with Claude Code

Adds `defaultTemplates` — a curated set of 10 polished templates covering
all three Slack surfaces (message / modal / app_home) and exercising every
supported block type (section, header, divider, context, actions, image,
markdown, rich_text, table, alert, card, carousel, context_actions, input)
plus the full element catalog (every select type, all date/time pickers,
all text-input variants, file input, rich text input, feedback / icon
buttons, image accessories, overflow menus, button confirm dialogs).

Previously the live demo and Storybook each maintained their own short,
3-block sample arrays (header + section + divider only) — useful for a
hello-world but did not show what the platform can render. Both now
import `defaultTemplates` from the package so the demo, Storybook, and
downstream consumers share a single polished gallery.

Template lineup (grouped by category):
- Engineering: Pull request review, Incident report
- Approvals: Expense approval, Confirm destructive action
- Team: Daily standup
- Announcements: Product release
- Forms: Customer feedback intake
- Scheduling: Schedule meeting
- Home tabs: Welcome / onboarding, Team dashboard

Also adds public-API tests for the new export: id uniqueness, non-empty
blocks, valid surface enum, surface-compatibility (mirroring the
validator's forbidden-blocks-per-surface rules), and `toSlackBlocks`
roundtrip.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@cloudflare-workers-and-pages
Copy link
Copy Markdown
Contributor

cloudflare-workers-and-pages Bot commented May 16, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
block-kitchen dbeaf7e Commit Preview URL

Branch Preview URL
May 16 2026, 05:16 PM

zhawtof and others added 2 commits May 16, 2026 13:11
Per review: templates are use-case examples (an "Expense approval" is for
an approvals product, a "Daily standup" is for a team product) and don't
belong in the library bundle. Unlike `defaultPalette`, which is core
builder functionality auto-applied to `<BlockKitchen>` when no `palette`
prop is passed, templates are something each consuming app configures for
its own use case.

- Move `src/lib/default-templates.ts` → `demo/src/templates.ts`, rename
  the export to `demoTemplates`, and reword the doc comment to make clear
  this is the demo's config (not a shipped default).
- Drop the `defaultTemplates` + `TEMPLATE_CATEGORIES` exports from
  `src/index.ts`. The library no longer ships any templates.
- `demo/src/App.tsx` now imports `demoTemplates` from `./templates`.
- Revert `template-picker.stories.tsx` to inline lightweight fixtures —
  stories exist to exercise the picker UI (categories, surface filter,
  empty state, dark theme), not to be a marketing showcase.
- Drop the `defaultTemplates` describe block from `public-api.test.ts`
  since templates are no longer part of the public API.

The library ESM bundle drops from 266 KB → 228 KB and the typed dist
from 26.75 KB → 25.19 KB as a result.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…avira-92f9f8

# Conflicts:
#	demo/src/App.tsx
@zhawtof zhawtof merged commit a0c4886 into main May 16, 2026
12 checks passed
@zhawtof zhawtof deleted the claude/determined-mahavira-92f9f8 branch May 16, 2026 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant