-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Allow custom argType sorting #28565
base: next
Are you sure you want to change the base?
Allow custom argType sorting #28565
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,3 +31,14 @@ export const None = { parameters: { controls: { sort: 'none' } } }; | |
export const Alpha = { parameters: { controls: { sort: 'alpha' } } }; | ||
|
||
export const RequiredFirst = { parameters: { controls: { sort: 'requiredFirst' } } }; | ||
|
||
export const CustomSort = { | ||
parameters: { | ||
controls: { | ||
sort: (a, b) => | ||
a.table?.category?.localeCompare(b.table?.category) || | ||
(a.type?.required === b.type?.required ? 0 : a.type?.required ? 1 : -1) || | ||
0, | ||
}, | ||
Comment on lines
+37
to
+42
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question (blocking): @kylegach @jonniebigodes just asking you both because GitHub suggests you both I tested to pass a callback function here, however There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Shinigami92 parameters are loaded into Storybook's "preview" (the inner iframe that renders the stories). They are then serialized across a channel into the "manager" (the outer iframe that's Storybook's actual UI) using a library called Historically, telejson serialized pure functions by default. But then we started getting complaints about the use of If you want a function to be available in the server, your best bet is to have users set it in I'm open to suggestions for better ways to approach this -- it's definitely an area that could use work. We're talking about some architectural changes next year that could solve this in a very different way. But nothing in the short term. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @shilman OH 😲 this makes a lot of sense! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ndelangen another good use case for the annotation server |
||
}, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
// FIXME: sort this out, maybe with package.json exports map | ||
// https://medium.com/swlh/npm-new-package-json-exports-field-1a7d1f489ccf | ||
export { ArgsTable as PureArgsTable } from './components'; | ||
export type { SortType } from './components'; | ||
export type { SortFn, SortType } from './components'; | ||
|
||
export * from './blocks'; | ||
export * from './controls'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: @shilman how is it possible to somehow access inside
ControlsPanel
a custom provided function? (I mean one that wont be a string like'(a,b)=>a.compare(b)'
, and then put that intoeval(myFn)
, because this would be hilarious 😆)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shilman @kylegach @jonniebigodes any ideas?