--- name: storybook-story description: | Write or update Storybook stories and docs MDX for a Radix NG primitive following project conventions. Use when: writing stories, updating docs, adding a new story, updating MDX, "обнови сторис", "напиши доки для", "update stories", "add story". Enforces: one-file-per-component rule, ?raw source imports, tailwindDemoDecorator, semantic tokens, docs MDX template. --- # Writing Storybook Stories for Radix NG Primitives ## Checklist — run through this before writing any story file 1. **Any story embedded via `` must be a standalone component — `props` do not survive a Canvas embed.** The exception is the **primary `Default` story**, which may be a small inline template using `props` + `args`, _provided_ it is surfaced in the MDX via `` / `` (never ``). This matches the `button` and `checkbox` references. ```ts // ✅ Default — small inline template with props/args, shown via in MDX export const Default: Story = { args: { disabled: false }, render: (args) => ({ props: { ...args, b: demoButton }, template: html` ` }) }; // ✅ Named example — standalone component, safe to embed via export const Variants: Story = { parameters: source(variantsSource), render: () => ({ template: html` ` }) }; // ❌ wrong — a props-based story embedded via renders blank export const WithScroll: Story = { render: () => ({ props: { r: demoRadio }, template: `
...` }) }; ``` In the MDX: surface `Default` with `` (+ ``) and add `of={Stories}` to ``; embed every other example with ``. 2. **One component → one file.** Every standalone story component gets its own file: `stories/select-default.ts`, `stories/select-with-scroll.ts`, etc. Never put multiple story components in a single `stories/.ts`. > Reason: `?raw` imports the entire file, so a shared file shows all source for every story. 3. **`?raw` import per story file.** In `.stories.ts`: ```ts import defaultSource from './select-default?raw'; export const Default: Story = { parameters: source(defaultSource), render: () => ({ template: html` ` }) }; ``` Each story export gets `parameters: source(itsOwnFile?raw)`. 4. **`tailwindDemoDecorator()`** is required in `decorators`. No `styleUrl`, no inline `