Skip to content
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

Addon-controls: Custom sort function #12126

Closed
giladgray opened this issue Aug 19, 2020 · 6 comments
Closed

Addon-controls: Custom sort function #12126

giladgray opened this issue Aug 19, 2020 · 6 comments

Comments

@giladgray
Copy link

giladgray commented Aug 19, 2020

👋 great stuff! huge fan. love the automatic-ness of the new features in v6, especially with typescript. it's the documentalist's dream!

Is your feature request related to a problem? Please describe.
I use Storybook with React and Typescript. The ordering of props in the ArgsTable seems somewhat based on declaration in the interface with a healthy does of "why are you here." This is quite confusing for a long list of props.

I would like to sort them all alphabetically, but I can't seem to find an option to do this.

Describe the solution you'd like

// preview.js
export const parameters = {
  controls: { alphabetize: true },
};

just like https://storybook.js.org/docs/react/essentials/controls#show-full-documentation-for-each-property

Describe alternatives you've considered
I've looked through all the docs and react-docgen-typescript and can't find anything to control the actual ordering of the controls.

Are you able to assist bring the feature to reality?
yes, with guidance / directions in the codebase.

Additional context
current state of things (this isn't even the full list):

@stale
Copy link

stale bot commented Sep 11, 2020

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

@stale stale bot added the inactive label Sep 11, 2020
@astorije
Copy link
Contributor

Hey stale bot, I think this would still be very valuable! Especially when using auto-generated controls: when doing so, manually configuring some controls will always position these at the top, even if the configuration is simply to disable the controls, so all auto-generated controls we disabled appear at the top.

@stale stale bot removed the inactive label Sep 11, 2020
@shilman shilman added the todo label Sep 11, 2020
@giladgray
Copy link
Author

Worth noting that the former addon-knobs approach does automatically alphabetize its knobs, so I was dismayed to discover that controls do not share this behavior.

If you point me in the right direction, I'm happy to write some code.

@shilman
Copy link
Member

shilman commented Sep 11, 2020

@giladgray what do you think about the non-function interface here

https://storybook.js.org/docs/react/writing-stories/naming-components-and-hierarchy#sorting-stories

@giladgray
Copy link
Author

@shilman you're suggesting this sort of thing?

export const parameters = {
  options: {
    storySort: {
      method: '',
      order: [], 
      locales: '', 
    },
  },
};

seems reasonable, if a bit verbose for just alphabetizing. i do like the potential of precise sorting, like i could push the as and ref props to the bottom and alph everything else.

i would love to see a single docs page that notes every single option supported by parameters, a la https://www.typescriptlang.org/docs/handbook/compiler-options.html

@shilman shilman changed the title sort controls alphabetically Addon-controls: Custom sort function Sep 25, 2020
@shilman shilman modified the milestones: 6.1 args, 6.2 args Oct 13, 2020
@shilman
Copy link
Member

shilman commented Nov 24, 2020

Closing as dupe to #9917

@shilman shilman closed this as completed Nov 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants