-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
CSF3: Generate default titles based on file path #15376
Conversation
Nx Cloud ReportCI ran the following commands for commit a1091a4. 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.
So this look good, but I guess the static build thing is a bit of a deal breaker.
Similarly, non webpack builders might have problems with a feature that relies on parameters.fileName
.
To me, it feels like this is something that will work well when we are generating stories.json
.
What's the easiest way to reproduce this behavior? It sounds like there's some mismatch between dev/prod configurations assuming it's a webpack problem. Looking at the code, it's around line |
@bebraw sorry I missed your comment. To reproduce the problem:
|
I can reproduce the issue now and I have a rough idea how you might be able to fix it. Here are a couple of screenshots to illustrate the problem. yarn storybook yarn build-storybook
I think one way to fix this would be to change webpack configuration in the latter case to include The side effect of doing this is that it will increase the bundle size slightly since names are longer than numbers but it's possible this doesn't make a big difference. |
Thanks for the tip @bebraw -- works great!!! 🙏 |
Hello @shilman , Great with this new feature, will make a lot of things cleaner in our monorepo setup. ❤️ However, I can't see the |
Found the issue, apparently, you can't specify a manual title if you use the |
@marcus13371337 If you specify the title, it uses that title verbatim. We'll document all this as part of of the 6.4 release (cc @jonniebigodes) |
Love this feature as it has allowed me to get rid of hundreds of lines of code. Just wondering if there's a way to get Storybook to flatten the sidebar folder structure when the directory name is the same as the story file name, so we can avoid having this redundant nesting that happens when the component and story are in a folder with the same name: Is there any way for me to configure that? |
@spacecakes fixed in 6.5 Try upgrading to the latest prerelease:
|
Wow, that is convenient. Thank you very much! The only issue I noticed with this is that story hoisting does not work for multi-word component names, because, say, Not a dealbreaker by any means and I realise it's prelease software, but it would be nice if this worked to avoid nesting single-story components with this setup. |
Issue: #11186
What I did
Generate default titles based on file path. With this PR the
stories
field in.storybook/main.js
can take on three possible values:''
)'*.stories.@(mdx|tsx|ts|jsx|js)'
)If you use either of the second two objects and have the
features.previewCsfV3
flag set, you no longer need to fill in thedefault.title
annotation in CSF.What I need
This currently fails in static builds of Storybook because thefileName
is rewritten as a number rather than the actual file path.self-merging @ndelangen @tmeasday with the rename of
root
totitlePrefix
per Norbert's feedbackHow to test
examples/react-ts/main.ts
/AccountForm.stories.tsx