Skip to content

feat(book): component gallery Vite app in apps/ - #12442

Merged
guanbinrui merged 2 commits into
developfrom
feat/component-book
Sep 6, 2026
Merged

feat(book): component gallery Vite app in apps/#12442
guanbinrui merged 2 commits into
developfrom
feat/component-book

Conversation

@guanbinrui

Copy link
Copy Markdown
Member

What

Adds apps/book — a plain Vite + React SPA that renders Maskbook's shared UI components. Not Storybook (removed in #10977); this is hand-rolled and deliberately small. Plan discussion in #12439.

Components are imported from source via the mask-src export condition, so the gallery tracks the packages with no build step of their own.

How it works

  • Auto-discovery — drop a *.demo.tsx under src/demos/<section>/; import.meta.glob in src/registry.ts picks it up. First path segment = sidebar section.
  • Resolvevite.config.ts sets resolve.conditions: ['mask-src'], mirroring packages/mask/.webpack/config.ts. Without it @masknet/theme resolves to a .d.ts.
  • Providers (src/providers.tsx) — MaskThemeProvider + light/dark toggle (localStorage), DialogStackingProvider, and DisableShadowRootContext so components render in the normal DOM instead of the extension's shadow roots.
  • Router — ~20-line hash router; no rewrite config needed to deploy.
  • wasmvite-plugin-wasm is required because @masknet/shared-base re-exports @masknet/base, which loads tiny-secp256k1's wasm.

Sections

Section Demos
Foundation colors (live maskColor swatches), typography, shadows
Components ActionButton, Alert, Indicators, LoadingBase, Tabs (base/round/flexible), TextField
Icons full @masknet/icons gallery — 405 icons, filter + click-to-copy

Wiring

  • pnpm-workspace.yaml: add apps/*
  • root package.json: pnpm book (dev), pnpm book:build
  • apps/book/vercel.json for deploy (Root Directory apps/book; build/install commands cd to repo root for the workspace)

Verification

  • pnpm book:build passes (main chunk ~1.1 MB / 298 KB gzip, from the @masknet/base graph)
  • Toured all 10 routes in headless Chromium: no console errors, light + dark both render
  • Fixed one issue found in testing: this MUI fork's Stack takes alignItems only via sx, not as a prop — it was leaking to the DOM

Not in scope

Injection and Plugins sections need a mock layer (background Services.*, site-adaptor context, web3 providers) — tracked as P4/P5 in #12439.

🤖 Generated with Claude Code

https://claude.ai/code/session_013SLkuieqJXCMg1xoL98jij

A plain Vite + React SPA that renders Maskbook's shared UI components,
imported from source via the `mask-src` export condition (mirrors
packages/mask/.webpack/config.ts). No Storybook.

- apps/book: Vite app, hash router, auto-discovered `*.demo.tsx` demos
  via import.meta.glob, MaskThemeProvider + light/dark toggle
- Sections: Foundation (colors, typography, shadows), Components
  (ActionButton, Alert, Indicators, LoadingBase, Tabs, TextField),
  Icons (full @masknet/icons gallery)
- Shadow-root portals disabled for normal-DOM rendering
- vite-plugin-wasm for tiny-secp256k1 pulled in via @masknet/shared-base
- pnpm-workspace.yaml: add apps/*; root scripts: `book`, `book:build`
- vercel.json for deploy from apps/book

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013SLkuieqJXCMg1xoL98jij
@guanbinrui
guanbinrui merged commit 9ffcb06 into develop Sep 6, 2026
11 checks passed
@guanbinrui
guanbinrui deleted the feat/component-book branch September 6, 2026 04:53
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