算法艺术创作
algorithmic-art
通过代码和可调参数创作生成艺术与交互式视觉效果。
storybook【设计与创意】Use whenever creating, configuring, or extending Storybook for a TS/React component library — covers main.ts/preview.ts setup, CSF3 story authoring, args/argTypes/controls, decorators and providers, MSW and module mocking, play-function interaction tests via the Vitest addon, the @storybook/addon-a11y workflow (axe-core), autodocs vs MDX docs, design…
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
*.stories.tsx, .storybook/main.ts, or .storybook/preview.ts. Targets Storybook 9+/10 (modern storybook/test import, Vitest addon, CSF3 + satisfies Meta). Does NOT cover generic React patterns (use the react skill), generic Testing Library queries (use react-testing-library), or WCAG primer (points at addon-a11y + axe rule config).Comprehensive guide for using Storybook 9+ as the workshop and test bench for a TypeScript/React component library. 52 rules across 8 categories, ordered by the lifecycle of a component in your design system: a wrong .storybook/main.ts cascades into every story; a malformed CSF Meta blocks autodocs, controls, tests, and the a11y panel for that file.
main.ts, preview.ts, framework selection (Vite vs Webpack, Next.js vs React-only), addon installation via the CLI, staticDirs.satisfies Meta<typeof Component>, named exports = stories, tags: ['autodocs'] placement, when render is appropriate, story naming conventions.control: 'select', fn() from storybook/test for callbacks, args vs parameters vs globals.preview.ts, MSW for network mocks, subpath-import module mocking (Storybook 9+), decorator signature pitfalls.play functions, the storybook/test import path (NOT @storybook/test), destructured canvas/userEvent, findBy* over waitFor, addon-vitest for CI, portable stories.axe-core via @storybook/addon-a11y) — parameters.a11y.test = 'error' as a real gate, per-rule disables, runOnly scoped to your WCAG target, portal context, globals.a11y.manual for intentional-violation fixtures.<Canvas of={...} />, status tags, design tokens as stories, Figma links via parameters.design.Reach for this skill when:
*.stories.tsx, *.mdx, .storybook/main.ts, .storybook/preview.ts, or vitest.config.ts that loads storybookTest.npx storybook init follow-up).play functions and the Vitest addon.Skip this skill and use:
react-optimise / clean-code-ts-react for the underlying component design.react-testing-library for render/screen/userEvent semantics outside Storybook.aria-labelledby does and tells you how addon-a11y checks it.Order reflects the component lifecycle (configure → author → wire → decorate → test → audit → document → ship). Earlier stages cascade.
| Priority | Category | Impact | Prefix | Rules |
|---|---|---|---|---|
| 1 | Setup & Configuration | CRITICAL | config- | 8 |
| 2 | Story Authoring (CSF3) | CRITICAL | csf- | 8 |
| 3 | Args, ArgTypes & Controls | HIGH | args- | 5 |
| 4 | Decorators & Composition | HIGH | deco- | 7 |
| 5 | Interaction Testing | HIGH | test- | 7 |
| 6 | Accessibility (axe) | HIGH | axe- | 5 |
| 7 | Documentation & Design System | MEDIUM-HIGH | docs- | 5 |
| 8 | Build, Performance & Deployment | MEDIUM | build- | 7 |
config-typed-main-config — Type main.ts with satisfies StorybookConfigconfig-pick-the-right-framework-package — Use the framework package that matches your build (@storybook/nextjs-vite for Next.js, etc.)config-narrow-stories-glob — Narrow the stories glob to story files onlyconfig-typed-preview — Type preview.ts with the framework's Preview typeconfig-add-addons-via-cli — Install addons with npx storybook add, never by handconfig-static-dirs-not-bundler-imports — Serve assets via staticDirs, not bundler importsconfig-tokens-css-vars-in-preview — Wire Style Dictionary / Tokens Studio output into preview.ts as CSS variablesconfig-story-sort-for-large-libraries — parameters.options.storySort order for design-system sidebars (Foundations → Components → Patterns)csf-satisfies-meta-not-typed — satisfies Meta<typeof Component>, never : Meta<typeof Component>csf-prefer-args-over-render — Default to args; reserve render for compound storiescsf-set-meta-component-explicitly — Always set meta.component (autodocs/controls/types depend on it)csf-name-stories-by-state — Name stories by user-visible state, not by prop valuecsf-tags-autodocs-on-meta — tags: ['autodocs'] belongs on the meta, not per-storycsf-co-locate-stories-with-component — Co-locate Component.stories.tsx next to Component.tsxcsf-default-export-is-the-meta — Default export = meta; named exports = storiescsf-title-hierarchy-for-design-systems — Meta title: 'Components/Inputs/Button' taxonomy (Foundations / Components / Patterns / Examples)args-derive-from-component-props — Let argTypes be inferred; declare only what inference can't seeargs-use-fn-for-callbacks — Use fn() from storybook/test for callback argsargs-explicit-control-for-unions — Declare control + options for unions inference can't reachargs-no-jsx-in-args — No JSX in args; compose JSX in renderargs-pick-args-vs-parameters-vs-globals — args = component inputs, parameters = addon config, globals = toolbar statedeco-global-providers-in-preview — Theme/QueryClient/Intl providers go in preview.tsdeco-msw-for-network-mocks — Mock the network layer with MSW; don't stub the SDKdeco-mock-modules-with-subpath-imports — Mock non-network modules via package.json#importsdeco-decorator-component-not-call — Render decorators as <Story />, not {story()}deco-context-aware-decorators — Read globals and parameters from context for reactive wrappersdeco-themes-addon-for-multi-brand — Use @storybook/addon-themes withThemeByClassName/withThemeByDataAttribute for multi-brand switchingdeco-rtl-direction-toggle — Toolbar dir toggle that wraps every story with dir="rtl" for bidi regressiontest-import-from-storybook-test — Import from storybook/test (Storybook 9+), not @storybook/testtest-await-every-userevent-call — await every userEvent calltest-use-canvas-from-play-arg — Destructure canvas/userEvent from the play argtest-fn-for-spied-callbacks — args: { onSubmit: fn() }, then assert with expect(args.onSubmit).toHaveBeenCalledWith(...)test-findby-over-waitfor — Prefer findByRole over waitFor + getByRoletest-vitest-addon-for-ci — Run plays in CI via @storybook/addon-vitest, not the legacy test-runnertest-portable-stories-for-rtl — Reuse stories in RTL/Vitest tests via composeStoriesaxe-set-test-error-globally — parameters.a11y.test = 'error' as a real gate, in preview.tsaxe-disable-rules-not-stories — Disable specific rules; never test: 'off' on a whole storyaxe-restrict-runonly-to-wcag-aa — Scope runOnly to your WCAG target (typically AA)axe-context-for-portals — Set parameters.a11y.context for components that render into portalsaxe-globals-manual-for-intentional-violations — globals.a11y.manual: true for fixtures that intentionally violatedocs-autodocs-vs-mdx — Autodocs for component pages, MDX for cross-cutting docsdocs-mdx-references-stories — <Canvas of={Story} /> instead of inline rendersdocs-component-status-tags — Surface lifecycle with status tags + sidebar badgesdocs-design-tokens-as-stories — Document tokens as stories for visual regressiondocs-figma-link-via-design-addon — Link each story to its Figma frame via parameters.designbuild-prefer-vite-over-webpack — Vite-based framework packages over legacy Webpackbuild-trim-test-bundle — Trim the Vitest-addon test build via main.ts build.test configbuild-deploy-static-build-to-shareable-host — Deploy storybook build to Chromatic/Vercel for every PRbuild-cache-storybook-in-ci — Cache the Vite/Webpack and Playwright layers in CIbuild-storybook-composition-refs — refs in main.ts to compose multi-package design systems into one host Storybookbuild-manager-brand — .storybook/manager.ts with create() for logo, brand link, and sidebar palettebuild-chromatic-modes-multi-theme — Snapshot every story across themes / viewports / direction via Chromatic modesconfig- rules then csf-.csf- and args-.test- and deco-msw-for-network-mocks.axe- rules.config-tokens-css-vars-in-preview, config-story-sort-for-large-libraries, csf-title-hierarchy-for-design-systems, deco-themes-addon-for-multi-brand, build-manager-brand, build-chromatic-modes-multi-theme. Then docs-component-status-tags and docs-design-tokens-as-stories for the governance + token-display layer.build-storybook-composition-refs first, then the design-system path above.deco-rtl-direction-toggle then build-chromatic-modes-multi-theme to wire RTL into visual regression.gotchas.md: failure modes discovered over time; always check before debugging an obscure issue.assets/templates/_template.md.| File | Description |
|---|---|
| references/_sections.md | Category definitions and ordering |
| assets/templates/_template.md | Template for adding new rules |
| gotchas.md | Failure modes accumulated over time |
| metadata.json | Version, references, abstract |
clean-code-ts-react — Underlying component design quality (naming, function shape, abstraction).react-testing-library — RTL queries and patterns when used outside Storybook.web-interface-guidelines — Vercel Web Interface Guidelines for the components you're documenting.