Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .mcp.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"mcpServers": {
"storybook": {
"type": "http",
"url": "http://localhost:6006/mcp"
}
}
}
6 changes: 4 additions & 2 deletions .storybook/clean-code-snippet.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
export default function cleanCodeSnippet(code) {
// Extract template content from render functions or template tags
let cleaned = code;
// Drop the <script setup> import block Storybook adds to generated snippets.
// The imports are still included in the component manifests for AI agents.
let cleaned = code.replace(/<script\b[^>]*>[\s\S]*?<\/script>/, '');

// Handle render function format
const renderMatch = code.match(/template:\s*`([\s\S]*?)`/);
if (renderMatch) {
cleaned = renderMatch[1];
} else {
// Handle simple template format
cleaned = code.replace(/<template>([\s\S]*?)<\/template>/, '$1');
cleaned = cleaned.replace(/<template>([\s\S]*?)<\/template>/, '$1');
}

// Split into lines and remove common leading whitespace
Expand Down
7 changes: 6 additions & 1 deletion .storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,14 @@ const config: StorybookConfig = {
addons: [
'@storybook/addon-docs',
'@storybook/addon-a11y',
'@storybook/addon-vitest'
'@storybook/addon-vitest',
'@storybook/addon-mcp'
],
staticDirs: ['./public'],
features: {
componentsManifest: true,
experimentalDocgenServer: true,
},
framework: {
name: '@storybook/vue3-vite',
options: {
Expand Down
11 changes: 11 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,17 @@ The project uses Vite for asset compilation with separate configs:
- The node module is defined in `packages/cms` and resolves everything through the `window` object.
- Code needs to be in the `window` object to prevent addon bundles from re-including our code, and from needing to recompile our source files.

## UI Components & Storybook

- UI components live in `resources/js/components/ui/` and are available to addons via `@statamic/cms/ui`. They are documented with Storybook at [ui.statamic.dev](https://ui.statamic.dev).
- Stories live in `resources/js/stories/*.stories.ts`, their docs pages in `resources/js/stories/docs/*.mdx`.
- `npm run storybook` starts Storybook along with its MCP server at `http://localhost:6006/mcp` (configured in `.mcp.json`).
- Use its documentation tools to look up a component's props, stories and usage before using or changing a UI component.
- After changing components or stories, run the story tests through the MCP server or with `npx vitest run --project storybook`.
- Storybook generates component manifests for AI agents from stories, MDX docs and component source. Inspect them at `http://localhost:6006/manifests/components.html`.
- Document props with JSDoc comments. They end up in the manifest.
- Every story file's `meta` needs a JSDoc `@import` tag with the public import path, e.g. `@import import { Button } from '@statamic/cms/ui';`. Otherwise snippets use the internal `@ui` alias.

## For PR Reviews

- All user-facing strings should be localized.
Expand Down
Loading
Loading