-
-
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
Add easy-to-use options to storySort #9188
Conversation
This pull request is being automatically deployed with ZEIT Now (learn more). 🔍 Inspect: https://zeit.co/storybook/monorepo/17ss924k9 |
MIGRATION.md
Outdated
@@ -256,7 +256,7 @@ For example, here's how to sort by story ID using `storySort`: | |||
addParameters({ | |||
options: { | |||
storySort: (a, b) => | |||
a[1].kind === b[1].kind ? 0 : a[1].id.localeCompare(b[1].id, { numeric: true }), | |||
a[1].kind === b[1].kind ? 0 : a[1].id.localeCompare(b[1].id, undefined, { numeric: true }), |
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.
FYI, in localeCompare(), the options
array is the 3rd parameter, not the 2nd one. MDN shows an example usage of "2".localeCompare("10", undefined, {numeric: true});
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.
😱
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.
🙀
This looks pretty awesome @JohnAlbin! 🙌 We're out of time on 5.3, but it's now in the queue for 6.0 which will start in early Jan. Thanks for the contribution ... and being patient! |
Yep. I saw the announcement in Discord this week. No worries. |
options: { | ||
storySort: { | ||
method: 'alphabetical', // Optional, defaults to 'configure'. | ||
sort: ['Intro', 'Components'], // Optional, defaults to []. |
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 see the PR merged in next-6.0.0
, but not seeing the changes reflected there. I wanted to point out the sort
key here is wrong. The storySort
method in this PR uses order
to override the order.
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.
Cc @ndelangen
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.
Yeah, this doc seems to be outdated. There's order
in tests.
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.
@hasparus would you be able to make a PR fixing the docs for this?
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.
yup, no biggie
Issue: #9185
What I did
Adds the
storySort
object parameter described in #9185.How to test