Docs: Update CSF Next API reference#32341
Conversation
- Rename from CSF Factories to CSF Next - Add automatic upgrade instructions - Add Story.extend
|
View your CI Pipeline Execution ↗ for commit 1c974fe
☁️ Nx Cloud last updated this comment at |
| <details> | ||
| <summary>Builder alias</summary> | ||
|
|
||
| You can configure aliases for your builder (Vite or Webpack) in your main Storybook configuration, like so: |
There was a problem hiding this comment.
we should verify that when you use builder aliases does our static analysis still works (I think it does because it's hard-coded, but we should double check).
There was a problem hiding this comment.
I don't know, we should test this @yannbf @ghengeveld
But why are we recommending builder aliases?
I belief this snippet is not complete, they should also change their tsconfig.json.
If they are already using builder aliases, they can use/read whatever is recommended by their framework for that.
If they are not, let's recommend a standard instead.
There was a problem hiding this comment.
Good call, Kasper. I deprioritized builder aliases here.
|
|
||
| #### `<StoryName>.extend` | ||
|
|
||
| You can use the `.extend` method to create a new story based on an existing one, with the option to override or add new properties. Objects will be deep-merged; arrays and other primitives will be replaced. |
There was a problem hiding this comment.
Deep-merged is an oversimplification. I believe that Args get shallow-merged. Parameters are deep-merged except for arrays which get replaced. Tags concatenate. Decorators concatenate. We should document each one of these in their respective docs (e.g. args docs) and potentially have a canonical section somewhere about data merging, which summarizes those things and then reference that section here. Or maybe this is the canonical section.
There was a problem hiding this comment.
I like the ideas here, but I'll have to do that in a future effort. For now, I've added more clarity here.
|
|
||
| **4. Update your Vitest setup file** | ||
|
|
||
| If you're using [Storybook's Vitest addon](../../writing-tests/integrations/vitest-addon.mdx), you can remove your Vitest setup file. |
There was a problem hiding this comment.
They might have other setup stuff in there that they don't want to remove. I guess users will figure this out on their own, but perhaps there is a way to phrase it better.
There was a problem hiding this comment.
I clarified which setup file we're talking about. It seems very unlikely they're using the Storybook-specific setup file for anything else?
+ ...you can remove your Vitest setup file (`.storybook/vitest.setup.ts`).
- ...you can remove your Vitest setup file.Co-authored-by: Michael Shilman <shilman@users.noreply.github.com>
- Clean up weird applied suggestions from last commit - Add details about Story.extend's property merging - Clarify that CSF Next does not have to be used for all story files - Clarify Vitest setup file needs
* next: add kiro steering docs
- Deprioritize builder aliases
* next: (23 commits) Bump version from "10.0.0-beta.1" to "10.0.0-beta.2" [skip ci] Write changelog for 10.0.0-beta.2 [skip ci] Refactor: Use fileURLToPath for module resolution in Next.js Vite preset fix typo Update CHANGELOG.md for v9.1.4 [skip ci] Bump version from "10.0.0-beta.0" to "10.0.0-beta.1" [skip ci] Write changelog for 10.0.0-beta.1 [skip ci] Fix dts bundling external detection Tags: Remove unodocumented x-only tags Update e2e tests Replace icons Update stories Reset invert toggle when clearing filters Add invert filter toggle and visual separator between user tags and built-in tags Update dependencies and ESLint configuration Refactor extract.ts to use internal parser for Babel code parsing fix z-index on mobile and write e2e tests Fix postinstall script to handle Playwright installation errors gracefully test(angular): fix framework-cli test cases Add story count indicator to tags filter ...
Docs: Update CSF Next API reference (cherry picked from commit e0a8d9b)
What I did
Tip
Reviewers may wish to compare the original CSF Factories API reference to this one, for reference.
Checklist for Contributors
Testing
Manual testing
Documentation
MIGRATION.MD
Checklist for Maintainers
When this PR is ready for testing, make sure to add
ci:normal,ci:mergedorci:dailyGH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found incode/lib/cli-storybook/src/sandbox-templates.tsMake sure this PR contains one of the labels below:
Available labels
bug: Internal changes that fixes incorrect behavior.maintenance: User-facing maintenance tasks.dependencies: Upgrading (sometimes downgrading) dependencies.build: Internal-facing build tooling & test updates. Will not show up in release changelog.cleanup: Minor cleanup style change. Will not show up in release changelog.documentation: Documentation only changes. Will not show up in release changelog.feature request: Introducing a new feature.BREAKING CHANGE: Changes that break compatibility in some way with current major version.other: Changes that don't fit in the above categories.Greptile Summary
This PR represents a significant evolution in Storybook's Component Story Format (CSF) documentation, transitioning from the experimental "CSF Factories" to the more mature "CSF Next" API. The changes include:
Core Documentation Updates:
csf-factories.mdxfile and replacement with comprehensivecsf-next.mdxdocumentationdefineMain,definePreview,preview.meta, andmeta.storyfactory functionsEnhanced Migration Support:
storybook automigrate csf-factoriescommand across npm, pnpm, and yarnStory.extendmethod documentation for extending existing storiesDeveloper Experience Improvements:
The documentation follows Storybook's established patterns with conditional rendering for React-only content, proper package manager variants, and extensive code examples. This change represents the maturation of CSF from experimental factory functions to a production-ready API that provides full type safety for Storybook stories.
Confidence score: 4/5
csf-factories-automigrate.mdwhich may need alignment with the CSF Next rebrand