-
-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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
Addon-docs: Fix 'show source' for stories with dynamic title #10959
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
const getTitle = () => `Addons/Docs/${['dynamic title'][0]}`; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we can use something more 'dynamic' but I think this is enough |
||
|
||
export default { | ||
title: getTitle(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that dynamic story titles are very common. Especially in big monorepo projects. The proposed PR doesn't directly support this it only fills the gap. I didn't see any docs in storybook about limitations to title, but indeed I could see a section in docs about using babel macros to generate title. So now it looks like feature gap. Please look at this: https://storybook.js.org/docs/basics/writing-stories/#generating-nesting-path-based-on-__dirname There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the last discussion we had about it we were tending to lean towards rather than allowing fully dynamic titles to instead to look at common systems of generating them. The primary one is of course setting titles based on filesystem paths -- are there other ways people are setting dynamic titles apart from purely based on the path of the file? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We also include package.json name. I understand that you discuss about the approach to generate titles but I don't see any other ways to fix the source code button rather than not relying on final id because looks like it is not necessary. Even if you decide to limit somehow the freedom of generating titles. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm guessing we should merge this and discuss options on what to do with the above |
||
}; | ||
|
||
export const basic = () => 'Story with title that is evaluated in runtime'; |
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.
I don't like this function but we can't use context.name as it can be overriden by CSF. The id is the only place that contains original sanitized name but it also contains story title (before -- double dash).
So I simply remove sanitized story title from id and get sanitized name