-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
[question] How to order top-level sections? #6327
Comments
I'm not sure it's possible. Related #5827 |
we maybe could do this via parameters: addParameters({
categoryOrder: ['Category A', 'Also a category'],
}); edit: as function addParameters({
categoryOrder: (a, b) => a < b,
}); |
array version would allow manual order so i'd be in favor of that approach. for now i'm making sure the individual story files are imported in the section order i want, it works but isn't really scalable |
The demo here seems to be mostly alphabetical. https://storybooks-official.netlify.com/ Anyone know where the source for the storybook-react demo is? |
@kevinSuttle All of our netlify deploys are in the repo in the |
Thanks! Ah, I see how I missed it. I was looking for https://github.com/storybooks/storybook/tree/next/examples/official-storybook |
Closing this as a dupe to #3730 |
not sure if that is helpful to anyone but I had the same issue and solved it by simply changing the filenames of my
My setup is: I have a folder stories: ['../stories/*.stories.{js,mdx}'], Then inside my <Meta title="Atoms|my-button" parameters={{component: "my-button"}} /> I found it hard to find any documentation on this so i just share it here :) |
In the same boat as everyone else, just sharing because it was such a headache.
|
Here's a much simpler/robust method... I find it much easier to maintain. https://www.npmjs.com/package/anysort import anysort from 'anysort'
import { addParameters } from '@storybook/react'
addParameters({
options: {
/**
* display the top-level grouping as a "root" in the sidebar
* @type {Boolean}
*/
showRoots: true,
storySort: (previous, next) => {
const [previousStory, previousMeta] = previous
const [nextStory, nextMeta] = next
return anysort(previousMeta.kind, nextMeta.kind, [
'Overview/Introduction',
'Overview/Getting Started',
'Overview/Themes',
'Overview/**',
'Usage/**',
'Views/**',
'Layout/**',
'Components/**',
'Fields/**',
'Widgets/**',
])
}
},
}) I could further refine that by doing: [
'Overview/Introduction',
'Overview/Getting Started',
'Overview/Themes',
'Overview/**',
'Usage/**',
'Views/**',
'Layout/**',
'Components/Icon',
'Components/Form*',
'Components/Application*',
'Components/*',
'Fields/**',
'Widgets/**',
] |
If you fall here from Google, there's now an easier interface to sort your stories: https://github.com/storybookjs/storybook/blob/f3a9117937205f88d8da0264b59942edcfe29cb6/docs/writing-stories/naming-components-and-hierarchy.md |
Perhaps related: #10086 (comment) because I cannot reproduce what @NishargShah demonstrated here :( |
@rwieruch I did find this while stumbling on a similar issue to what you are facing: I also cannot seem to reproduce what @NishargShah and the docs (here) say about story sorting via arrays. I am using Storybook |
We've just upgraded to latest version

5.0.5
. I'm organizing stories into sections with the|
character instoriesOf()
:But the sections seem to be organized randomly. How can I declare the sections order? Thanks
The text was updated successfully, but these errors were encountered: