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

Fallback sorting method configuration #3

Open CoryDuncan opened 2 years ago

CoryDuncan commented 2 years ago

@prantlf Excellent package, thank you for this. It works well, I just had one question regarding to the "fallback sort":

Can be sorted according to this request:

  1. Elements before Components
  2. Default stories before the others
  3. Otherwise alphabetically

Is it possible to configure the fallback sort to be the order of stories defined in the file, matching the Storybook default, instead of alphabetically?

prantlf commented 1 year ago

Thanks for your kind words! I see what you mean. For example, being able to move a story to the beginning, but leaving the rest in the import order. Or ordering just the first-level groups explicitly, and leaving the stories in the import order.

It could be possible. The trick would be finding out the import order. It is not a parameter passed to te sorting method, though. I'll give it a thought, how to get or infer the import order.

prantlf commented 1 year ago

If you or somebody else wanted to give it a shot, I added support for custom comparators of group and story names in 1.2.0, which can check not only the two compared names, but also group paths, which lead to them. I would help, if the list of full story paths in the imported orders gets somehow available.