prantlf / storybook-multilevel-sort

Applies specific sort order to more than two levels of chapters and stories in Storybook.
https://storybook.js.org/addons/storybook-multilevel-sort/
Other
8 stars 4 forks source link

Update to storybook v7 API #9

Closed gatsbimantico closed 1 year ago

gatsbimantico commented 1 year ago

It fixes https://github.com/prantlf/storybook-multilevel-sort/issues/7

gatsbimantico commented 1 year ago

There's information around the changes in their migration guide: https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#v7-style-story-sort

gatsbimantico commented 1 year ago

This may still not work. Storybook seems to keep asking for the function to be inlined and fails to recognise the import of this library.

prantlf commented 1 year ago

Thank you for your contribution, @gatsbimantico! You did half of the work - the new documentation and adaptation to the new interface of storySort.

What remains is dealing with the new processing of the whole preview.js, which isn't an executable JavaScript module any more. It's just a source of an exported objects, which appears to be just parsed out of it. I'm going to write more about it to the issue #8.

You got this error, because you cannot refer to any external code out of the storySort callback:

ERR! Error: Error sorting stories with sort parameter (story1, story2) => sort(order, story1, story2):
ERR!
ERR! > sort is not defined
ERR!
ERR! Are you using a V6-style sort function in V7 mode?

The function sort and variable order from the sample project don't exist in the code, where the storySort implementation is injected.

I'm sorry, I'm not going to merge your changes. But my pull request #10 uses the fix that you found. I'm adding you to the package contributors too.

prantlf commented 1 year ago

This change is included and extended in #10.