-
-
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
UI: Support *
wildcard option in storySort order array
#14531
Conversation
@shilman This is my first contribution. I tested everything through Jest, but I'm not super sure how to do a manual test of it in a demo instance, so the Jest tests are all I've done so far. Please let me know if there's any more steps I should take. Thanks! |
@randak this is awesome! i'll give it a whirl in the next few days. in the meantime, if you want to test it out yourself in the monorepo, you can modify the settings in
As you adjust the settings in the example you might need to re-run storybook, but you shouldn't need to bootstrap. See |
*
wildcard option in storySort order array
Thanks, I did read the contributing guide but I missed that part. The label, "Working with the kitchen sink apps," is a little confusing for a newcomer and I didn't realize it was relevant. Testing now. |
There was an issue in my development environment and I missed a step in the contributing guide. After testing, I can confirm that this does work correctly for the example storybook 🎉 |
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.
Fantastic job. Great feature, great tests, documentation... really cool 💯
// Stories with a shorter depth should go first.
if (!storyKindA[depth]) { return -1; } When you have a story file that exports multiple named stories, the title does not include the inferred story names export default {
title: 'Components/MyComponent',
component: MyComponent,
} as Meta;
export const VariantOne = (args) => {}
export const VariantTwo = (args) => {} According to the short-out sorting logic, these will always appear higher than other docs that have a defined name in the title <Meta title="Components/MyComponent/Intro" /> But what if I what the "Intro" to be sorted higher than the other story variants, without grouping the inferred stories further under some path like |
Issue: #14353
What I did
This PR adds support for a
*
option in theorder
array of thestorySort
function. When present, stories that do not match any of the kinds listed in theorder
array will be sorted to the location of the*
option rather than sorted to the end of the list.Example:
With the following order set, all stories will be sorted between
Getting Started
andWIP
. The order within the*
will depend on themethod
setting.order: ['Getting Started', '*', 'WIP', 'Internal']
How to test
Is this testable with Jest or Chromatic screenshots?
This is testable with Jest. New tests have been added to validate the updated capability of the
storySort
function.Does this need a new example in the kitchen sink apps?
No
Does this need an update to the documentation?
Yes, the documentation update is included in this PR.