Docs: Add CSF factory API documentation#30343
Conversation
There was a problem hiding this comment.
10 file(s) reviewed, 12 comment(s)
Edit PR Review Bot Settings | Greptile
|
View your CI Pipeline Execution ↗ for commit e6e3952.
☁️ Nx Cloud last updated this comment at |
| "#.storybook/preview": { | ||
| "default": "./.storybook/preview.ts", | ||
| }, | ||
| "#*": ["./*", "./*.ts", "./*.tsx"], |
There was a problem hiding this comment.
Interesting 🤔 the codemod only adds "#*": ["./*", "./*.ts", "./*.tsx"] and assumes that users will write #.storybook/preview which will relate to <root>.storybook/preview and if they have the preview file somewhere else, they will have to adjust the import in each file to something like #some-dir/.storybook/preview.
This means users with multiple Storybooks could have multiple imports like #apps/.storybook/preview and #libs/.storybook/preview without having to change anything in their package.json.
Perhaps the codemod should set this more specific field like what Kyle wrote here instead? WDYT @kasperpeulen?
There was a problem hiding this comment.
I see! Thanks for explaining. That's tricky. I see why you did it the current way, but think the way I documented is perhaps a bit more informative? I like that if someone does a Find for #.storybook/preview, they'll come across this.
There was a problem hiding this comment.
It's tricky, I'll leave @kasperpeulen to decide
There was a problem hiding this comment.
@kasperpeulen — Did you have thoughts? I'm still inclined to think it should be the way I've documented here, because:
I like that if someone does a Find for
#.storybook/preview, they'll come across this.
There was a problem hiding this comment.
I'm not sure, I will let @shilman decide about this. :P
There was a problem hiding this comment.
Fwiw, I'm 60/40 on my proposal here vs. what was implemented. So unless someone else strongly agrees with me, we can just keep it simple.
5f60838 to
e6e01c1
Compare
e6e01c1 to
dcfab08
Compare
|
@kylegach this all looks great, thanks for working on the revisions! I can't approve since I opened the PR, so please approve it for me! |
jonniebigodes
left a comment
There was a problem hiding this comment.
This is shaping up nicely. Thank you for adding the documentation. I appreciate it 🙏 I left some items for you to look into when you can. Let me know, and we'll go from there.
Co-authored-by: jonniebigodes <joaocontadesenvolvimento@gmail.com>
Closes #30342
Closes #30329
What I did
This PR introduces documentation for the CSF Factory format.
Checklist for Contributors
Testing
Manual testing
sync-docsinstorybookjs/weblocallymain, so the page-level tabs show upDocumentation
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 introduces comprehensive documentation for the new CSF Factory API, providing examples and guidelines for creating and testing Storybook stories with improved type safety and reusability.
defineMainanddefinePreviewconfiguration examples indocs/_snippets/csf-factories-main-example.mdanddocs/_snippets/csf-factories-preview-example.mdpreview.meta()andmeta.story()indocs/_snippets/csf-factories-story-example.mddocs/_snippets/portable-stories-csf-factory-run.mdcomposedproperty