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

Wild selector level idea #2

Closed RomanFausek closed 1 year ago

RomanFausek commented 2 years ago

This saved so much time for me! 🚀

I was thinking that it would be nice for the wild selector to go to any level. Let's say I want Playground story first on any level.

Right now I have to do this:

'*': {
    playground: null,
    '*': {
      playground: null,
    },
  },

but once I introduce a new (deeper) level, this sorter won't work for it anymore

prantlf commented 1 year ago

I'm glad that you found this useful :-)

Yes, having a such selector would be useful. I'm thinking about having wild fallback selector, which would be used at the same or deeper level, if no explicit selector were provided for it. For example:

'**': {
  playground: null,
},

I'll need to test how it'd work.

prantlf commented 1 year ago

I added support for nested wildcards in 1.2.0 as I sketched it above.

It allowed simplifying this sample configuration:

const order = {
  articles: null,
  elements: {
    '*': { default: null },
  },
  components: {
    '*': { default: null },
  }
};

to this:

const order = {
  articles: null,
  elements: null,
  components: null,
  '**': { default: null }
};

Will it work for you?

RomanFausek commented 1 year ago

@prantlf I didn't notice your messages, sorry. I didn't check the implementation yet but does it support more than two levels?

'*': {
    playground: null,
    '*': {
      playground: null,
      '*': {
        playground: null,
      },
    },
  },