Skip to content
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: Naming consistency for Story blocks #7164

Closed
shilman opened this issue Jun 21, 2019 · 3 comments
Closed

Addon-docs: Naming consistency for Story blocks #7164

shilman opened this issue Jun 21, 2019 · 3 comments
Labels
Milestone

Comments

@shilman
Copy link
Member

shilman commented Jun 21, 2019

As raised in @ndelangen 's review of #7119. We currently define stories in MDX as:

<Story name="some name">...</Story>

However, in the module format we can override the story title as:

export const story = () => ...
story.title = "some name"

Should we rename the Story's name attribute to title for consistency? Or rename title to name?

@shilman shilman added maintenance User-facing maintenance tasks addon: docs labels Jun 21, 2019
@shilman shilman added this to the 5.2.0 milestone Jun 21, 2019
@tmeasday
Copy link
Member

Or the other way (use name for both)

@shilman
Copy link
Member Author

shilman commented Jun 26, 2019

We run into a problem when trying to do:

export const foo = () => <Foo />;
foo.name = 'foo bar'

=> Cannot assign to read only property 'name' of function 'function(){return _ref2}'

New proposal:

export const foo = () => <Foo />;
foo.story = {
  name: 'foo bar',
  parameters: ...
};

This is pure JS, allows us to stuff anything we want into story without worrying about name collisions, preserves "story name" which is widely used in storybook, and is only slightly more verbose.

@shilman
Copy link
Member Author

shilman commented Jun 27, 2019

Whoopee!! I just released https://github.com/storybookjs/storybook/releases/tag/v5.2.0-alpha.31 containing PR #7202 that references this issue. Upgrade today to try it out!

You can find this prerelease on the @next NPM tag.

Closing this issue. Please re-open if you think there's still more to do.

@shilman shilman closed this as completed Jun 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants