-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Core: Built-in static stories.json
support
#14945
Conversation
Nx Cloud ReportCI ran the following commands for commit 02e7491. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this branch
Sent with 💌 from NxCloud. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good. A bunch of smaller things
interface ExtractedStory { | ||
id: string; | ||
kind: string; | ||
name: string; | ||
parameters: Record<string, any>; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't want to use our existing types for this? Last thing we need is yet-another-story type definition.
} | ||
const csf = (await readCsf(csfFile)).parse(); | ||
csf.stories.forEach((story) => { | ||
stories[story.id] = { ...story, kind: csf.meta.title }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we be only pulling out the exact parameters
we want here? Also will the csf tools eventually return other stuff on the story object apart from parameters
?
interface Meta { | ||
title?: string; | ||
includeStories?: string[] | RegExp; | ||
excludeStories?: string[] | RegExp; | ||
} | ||
|
||
interface Story { | ||
id: string; | ||
name: string; | ||
parameters: Record<string, any>; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
arggh more types
ExportDefaultDeclaration: { | ||
enter({ node }) { | ||
if (t.isObjectExpression(node.declaration)) { | ||
// export default { ... }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about const meta = {}; export default meta;
?
ExportNamedDeclaration: { | ||
enter({ node }) { | ||
if (t.isVariableDeclaration(node.declaration)) { | ||
// export const X = ...; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about const Story = {}; export { Story };
}?
stories.json
support
Issue: N/A
What I did
@storybook/csf-tools
for statically analyzing CSF filesstories.json
parameters.fileName
self-merging to unblock @tmeasday
Current limitations
Moved => #14966
What I need
Since lots of story metadata is NOT statically analyzable, we might need to redesign
stories.json
and/or composition to accommodate static resultsHow to test
Manual test cases in
html-kitchen-sink
(akaH
) /react-ts
(akaR
) examples. Uncomment the appropriate line's inH
'smain.js
config.yarn storybook
inR
,yarn storybook
inH
in another terminalyarn build-storybook
inR
,yarn storybook
inH
in another terminalUnit tests:
yarn test CsfFile