-
Notifications
You must be signed in to change notification settings - Fork 216
feat: add label/value object support for Select options, streamlines normalization #573
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
base: main
Are you sure you want to change the base?
Changes from 4 commits
1e51411
d6a44ba
2eabe18
fab7c54
5579ffe
5a17d5b
ba22628
02d365f
f82ca3f
ee20297
5c7bc89
cea5ac2
13340b1
e5c74de
5011336
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 |
|---|---|---|
|
|
@@ -63,3 +63,36 @@ export const FunctionAsOptions = () => { | |
| </div> | ||
| ) | ||
| } | ||
|
|
||
| export const ValueLabelObjects = Template.bind({}) | ||
| ValueLabelObjects.args = { | ||
| value: '#f00', | ||
| options: [ | ||
| { value: '#f00', label: 'red' }, | ||
| { value: '#0f0', label: 'green' }, | ||
| { value: '#00f', label: 'blue' }, | ||
| ], | ||
| } | ||
|
|
||
| export const ValueLabelObjectsWithFunctions = () => { | ||
| const fn1 = () => console.log('Function 1') | ||
| const fn2 = () => console.log('Function 2') | ||
| const fn3 = () => console.log('Function 3') | ||
|
|
||
| const values = useControls({ | ||
| myFunction: { | ||
| options: [ | ||
| { value: fn1, label: 'First Function' }, | ||
| { value: fn2, label: 'Second Function' }, | ||
| { value: fn3, label: 'Third Function' }, | ||
| ], | ||
| }, | ||
| }) | ||
|
|
||
| return ( | ||
| <div> | ||
| <pre>Selected: {values.myFunction.name || 'anonymous function'}</pre> | ||
| <button onClick={values.myFunction}>Call selected function</button> | ||
| </div> | ||
| ) | ||
| } | ||
|
||
Uh oh!
There was an error while loading. Please reload this page.