-
Notifications
You must be signed in to change notification settings - Fork 216
Open
Description
currently the code in Button.tsx is
export function Button({ onClick, settings, label }: ButtonProps) {
const store = useStoreContext()
return (
<Row>
<StyledButton disabled={settings.disabled} onClick={() => onClick(store.get)}>
{label}
</StyledButton>
</Row>
)
}
But when called
useControls({red: button(onChange) {label: "blue"} )
The value "blue" is passed to Button() in settings. So {settings.label === "blue"} and label === "red".
The button shows "red" and ignores the parameter.
In order to support both cases, a function similar to ButtonGroup().getOpts() needs to be added to override label with {settings.label}. Je ne parle pas typescript, but I think the idea is the same.
const getOpts = ({ label: _label, opts: _opts }: ButtonGroupInternalOpts) => {
let label = typeof _label === 'string' ? (_label.trim() === '' ? null : _label) : _label
let opts = _opts
if (typeof _opts.opts === 'object') {
if (opts.label !== undefined) {
label = _opts.label as any
}
opts = _opts.opts
}
return { label, opts: opts as ButtonGroupOpts }
}
Metadata
Metadata
Assignees
Labels
No labels