@cellarnode/ui

中文文档
0.224.0发布于 2026/11/05UNLICENSEDTypeScriptES Module近 30 天下载 9082

Shared UI components, theme tokens, and chat/offer primitives for CellarNode dashboards.

原始使用文档
文档目录12 节
  1. Contents
  2. Architecture
  3. Install
  4. Peer Dependencies
  5. Exports
  6. Theme & Design Tokens
  7. Development
  8. Writing Stories
  9. Conventions
  10. Make Commands
  11. Storybook MCP (AI Integration)
  12. Publishing

@cellarnode/ui

version react 19 typescript tailwind v4 storybook license


Shared React component library for CellarNode dashboards. Ships UI primitives, design tokens, chat components, offer components, a globe visualisation, and a Kanban drag-and-drop system — all typed, tree-shakeable, and tested via Storybook.

Contents


Architecture

src/
├── components/        UI primitives (Button, Card, Dialog, Table, Sidebar…)
├── chat/              Chat & negotiation UI (ChatShell, ChatMessageList, ConnectionBanner)
├── offer/             Offer workflow components (BeverageDetails, OrgBanner…)
├── globe/             Interactive 3-D globe visualisation (react-globe.gl)
├── hooks/             Shared hooks (useIsMobile, useToast, useKanbanDnd)
├── lib/               Utilities (cn, semantic tones, currencies, kanban transitions)
└── theme/
    └── tokens.css     Canonical Tailwind v4 design tokens

Primitive layers

LayerPackageUsed for
Radix UI@radix-ui/*Dialog, Dropdown, Select, Tabs, Toast…
Headless UI@headlessui/reactDropdown (Catalyst), Fieldset, Combobox
shadcn/uibuilt on RadixChat & offer internal variants

Install

pnpm add @cellarnode/ui

Note: This package is public on npmjs.org (publishConfig.access: "public", CEL-1983); installs need no registry auth. The repo .npmrc still routes the @cellarnode scope to registry.npmjs.org and reads ${NPM_TOKEN} if one is set.


Peer Dependencies

Install the peers your app uses:

# Always required
pnpm add react react-dom

# Optional — only needed when importing the specific sub-path
pnpm add motion                                    # animations
pnpm add @dnd-kit/react @dnd-kit/dom               # ./kanban-dnd
pnpm add @tanstack/react-query                     # chat hooks
pnpm add react-globe.gl three topojson-client world-atlas  # ./globe
pnpm add @cellarnode/beverage-utils i18n-iso-countries     # ./offer

Exports

Import pathContents
@cellarnode/uiAll UI primitives, hooks, and utilities
@cellarnode/ui/theme/tokens.cssTailwind v4 design token CSS
@cellarnode/ui/chatChatShell, ChatMessageList, ConnectionBanner, MessengerLayout, chat hooks
@cellarnode/ui/offerBeverageDetails, OrgBanner, OfferStatusBadge…
@cellarnode/ui/kanban-dndKanbanDndBoard component
@cellarnode/ui/kanban-dnd-hooksuseDraggableCard, useDroppableColumn
@cellarnode/ui/globeGlobeView component
@cellarnode/ui/animated-listAnimatedList component

Theme & Design Tokens

Import the canonical token sheet before Tailwind in your app's root CSS:

@import "@cellarnode/ui/theme/tokens.css";
@import "tailwindcss";

Tokens expose semantic CSS variables (--color-background, --color-primary, --color-brand-secondary, etc.) that are automatically mapped into Tailwind utility classes.

Light/dark mode is toggled by adding the dark class to <html>.


Development

Prerequisites: Node 20+, pnpm 9+, Playwright Chromium (for browser tests).

# Install dependencies
pnpm install

# Install Playwright browser
pnpm playwright install chromium

# Start Storybook dev server
make storybook        # → http://localhost:6006

# Type-check
make typecheck

# Lint
make lint

# Run tests (Storybook browser tests, headless)
make test

# Full build
make build

Writing Stories

Every component must have a .stories.tsx file co-located next to it.

import type { Meta, StoryObj } from "@storybook/react-vite";
import { Button } from "./button";

const meta = {
  title: "Components/Button",
  component: Button,
  tags: ["autodocs"],
} satisfies Meta<typeof Button>;

export default meta;
type Story = StoryObj<typeof meta>;

export const Default: Story = {
  args: { children: "Click me" },
};

export const Variants: Story = {
  render: () => (
    <div className="flex gap-3">
      <Button color="brand">Brand</Button>
      <Button outline>Outline</Button>
      <Button plain>Plain</Button>
    </div>
  ),
};

Conventions

  • tags: ["autodocs"] → auto-generated prop docs
  • Include a Default story + at least one variant story
  • Use argTypes for enum-like props (color, size, variant)
  • Check the A11y addon panel — fix all violations before merging
  • Toggle light / dark via the Themes toolbar
  • Write play functions for interaction testing when behaviour is complex

Make Commands

make build            Full build: lint + typecheck + compile
make clean            Remove dist/
make compile          Compile TypeScript to dist/
make lint             Run ESLint
make typecheck        TypeScript type checking (no emit)
make test             Run Storybook/Vitest browser tests (headless Chromium)
make test-watch       Run Vitest in watch mode
make storybook        Start Storybook dev server on :6006
make build-storybook  Build static Storybook to storybook-static/
make publish          Manual fallback ONLY — build and publish current version to npm (not the normal path)
make release-patch    Bump patch version, commit, and git tag (publishes after main's CI is green)
make release-minor    Bump minor version, commit, and git tag (publishes after main's CI is green)
make release-major    Bump major version, commit, and git tag (publishes after main's CI is green)

Storybook MCP (AI Integration)

When Storybook is running (make storybook), the @storybook/addon-mcp addon exposes an MCP server at http://localhost:6006/mcp.

Register it with Claude Code once:

claude mcp add storybook-mcp --transport http http://localhost:6006/mcp --scope project

Available MCP tools:

ToolDescription
get_ui_building_instructionsGuidelines for creating components and stories
get_story_urlsDirect browser links to every story

Component manifest (for AI context): http://localhost:6006/manifests/components.html


Publishing

Packages are published to npm (public access — publishConfig.access: "public", see CEL-1983) via npm Trusted Publishing (OIDC) — .github/workflows/publish.yml publishes automatically once the push-to-main CI run for the tip of main is green AND package.json's version is not on npm yet. Nobody runs npm publish by hand; there is no long-lived npm token in the publish job. Releases are cut locally via Make, then landed through a normal PR:

make release-patch   # 0.2.1 → 0.2.2
make release-minor   # 0.2.1 → 0.3.0
make release-major   # 0.2.1 → 1.0.0

Each release target: bumps version in package.json, rolls CHANGELOG.md, builds, commits, and creates a git tag ui-vX.Y.Z — it does not publish. Push the branch, open a PR, and merge it. Publishing then follows the green CI run on main's tip. make publish remains as an explicit manual fallback (needs a local npm login with publish rights); it is not the normal path.

How the gated publish behaves (CEL-2530):

  • Wait for CI. Publish to npm starts when the CI workflow of a push to main completes with success, so expect the CI wall clock (1.5-8 h on the shared runner pool) before the package appears. Watch the Publish to npm run, not the merge.
  • Merge the release PR LAST and pause other merges to main until the publish appears: only the tip of main publishes, so a later merge makes the older commit's run skip ("main has moved on") and the newer commit's own green CI decides. If CI on the tip is red or cancelled, nothing is published: fix forward or re-run CI on the tip.
  • [skip ci] tips never publish (no CI run, nothing to wait for).
  • gitHead in the published package may not equal the ui-vX.Y.Z tag commit when a later green tip published the version.
  • Recovery. Re-run the failed CI job on main's tip (the publish follows the new green result), or use the escape hatch: Actions > Publish to npm > Run workflow from main, typing the exact package.json version in confirm. The real controls on that run: it must start from main, the person who starts it must be on the actor allowlist in publish.yml (a JSON list in the job if; add a maintainer in a reviewed PR), the typed confirm must match, the commit must still be the tip of main (otherwise the run fails and you start it again), and the same "version not on npm yet" check applies. There is no environment or required-reviewers gate (not available on a private repo of this plan); keep npm's trusted-publisher "Environment" field blank.

版本与发布记录

@cellarnode/ui 共发布 460 个版本,首次发布于 2026/03/27;过去 12 个月发布了 460 个版本。

版本发布日期距今
0.224.0latest2026/11/054 天前
0.223.02026/11/045 天前
0.222.12026/11/036 天前
0.222.02026/10/3010 天前
0.221.12026/10/2812 天前
0.221.02026/10/2812 天前

关于 @cellarnode/ui 的常见问题

@cellarnode/ui 是什么?

Shared UI components, theme tokens, and chat/offer primitives for CellarNode dashboards.

如何安装 @cellarnode/ui?

在项目目录运行 npm install @cellarnode/ui,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:ably(^2.19.0)、react(^19.0.0)、react-dom(^19.0.0)、@ably/chat(^1.3.1)、@ably/spaces(^0.5.0)、@cellarnode/finance(^0.4.2)、@radix-ui/react-slot(^1.2.4)、@radix-ui/react-tabs(^1.1.13)、@radix-ui/react-label(^2.1.8)、@radix-ui/react-toast(^1.2.15)、@radix-ui/react-avatar(^1.1.11)、@radix-ui/react-dialog(^1.1.15)、@radix-ui/react-select(^2.2.6)、@radix-ui/react-slider(^1.3.6)、@radix-ui/react-switch(^1.2.6)、@radix-ui/react-popover(^1.1.15)、@radix-ui/react-tooltip(^1.2.8)、@radix-ui/react-checkbox(^1.3.3)、@radix-ui/react-accordion(^1.2.12)、@radix-ui/react-separator(^1.1.8)、@cellarnode/beverage-utils(>=0.13.0)、@radix-ui/react-hover-card(^1.1.15)、@radix-ui/react-scroll-area(^1.2.10)、@radix-ui/react-dropdown-menu(^2.1.16)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@cellarnode/ui 支持 TypeScript 吗?

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

@cellarnode/ui 支持 ESM 还是 CommonJS?

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

@cellarnode/ui 可以商用吗?

@cellarnode/ui 使用 UNLICENSED 许可。作者声明为 UNLICENSED,即不授予公开使用许可(与公共领域的 Unlicense 不同)。使用前需获得作者授权。以上为概括,不构成法律意见,请以许可原文为准。

@cellarnode/ui 的下载量有多少?

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

@cellarnode/ui 还在维护吗?

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