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

Props should be allowed to be sorted #167

Open
bryce-larson opened this issue Jun 6, 2020 · 0 comments
Open

Props should be allowed to be sorted #167

bryce-larson opened this issue Jun 6, 2020 · 0 comments

Comments

@bryce-larson
Copy link

Our components share a lot of props, so we follow best practices and try to extend interfaces where possible. In Playroom, we would like to display props in order of most importance, however the default order of props is currently the order of the given interface.

Add support for a sorting of props in the playroom config.

Ideas:

  • Allow support for a custom sorting function, this would need need access to the required prop from react-docgen-typescript.

  • Allow for a smart sorting option, in our case it would be required props, then optional props, then developer props, such as onXXXX(onClick, onFocus), id, data-XXXX, aria-XXXX, other dom props.

Adding a new option called propSortOrder that would except the following:

  • default - current implementation
  • required - required props followed by optional props, stable sort does not change order
  • requiredAlphabetical - required props followed by optional props, in alphabetical order
  • custom function - ({ componentName, propName, required }) => number, the number would determine the sort order for a given componentName, ties would be broken alphabetically

If you are interested, I could raise a PR.

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

2 participants