MD button onclick hooked
This commit is contained in:
parent
bb4a7d1f4a
commit
bd8c1a43a5
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
const cb = new ClassBuilder("button", ["primary", "medium", "text"])
|
const cb = new ClassBuilder("button", ["primary", "medium", "text"])
|
||||||
|
|
||||||
export let onClick = () => {}
|
export let onClick
|
||||||
|
|
||||||
export let variant = "text"
|
export let variant = "text"
|
||||||
export let colour = "primary"
|
export let colour = "primary"
|
||||||
|
@ -20,6 +20,8 @@
|
||||||
export let text = ""
|
export let text = ""
|
||||||
export let disabled = false
|
export let disabled = false
|
||||||
|
|
||||||
|
export let _bb
|
||||||
|
|
||||||
let modifiers = {}
|
let modifiers = {}
|
||||||
let customs = { size, colour }
|
let customs = { size, colour }
|
||||||
|
|
||||||
|
@ -30,6 +32,8 @@
|
||||||
let blockClasses = cb.build({ props })
|
let blockClasses = cb.build({ props })
|
||||||
const labelClass = cb.elem("label")
|
const labelClass = cb.elem("label")
|
||||||
|
|
||||||
|
const clicked = () => _bb.call(onClick)
|
||||||
|
|
||||||
$: if (icon) {
|
$: if (icon) {
|
||||||
setContext("BBMD:icon:context", "button")
|
setContext("BBMD:icon:context", "button")
|
||||||
}
|
}
|
||||||
|
@ -39,7 +43,7 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if href}
|
{#if href}
|
||||||
<a class={blockClasses} {href} on:click={onClick}>
|
<a class={blockClasses} {href} on:click={clicked}>
|
||||||
<span class={labelClass}>{text}</span>
|
<span class={labelClass}>{text}</span>
|
||||||
</a>
|
</a>
|
||||||
{:else}
|
{:else}
|
||||||
|
@ -48,7 +52,7 @@
|
||||||
class={blockClasses}
|
class={blockClasses}
|
||||||
class:fullwidth
|
class:fullwidth
|
||||||
{disabled}
|
{disabled}
|
||||||
on:click={onClick}>
|
on:click={clicked}>
|
||||||
{#if renderLeadingIcon}
|
{#if renderLeadingIcon}
|
||||||
<Icon {icon} />
|
<Icon {icon} />
|
||||||
{/if}
|
{/if}
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
H1,
|
H1,
|
||||||
Overline,
|
Overline,
|
||||||
Button,
|
Button,
|
||||||
|
BodyBoundToStore,
|
||||||
Textfield,
|
Textfield,
|
||||||
Checkbox,
|
Checkbox,
|
||||||
Checkboxgroup,
|
Checkboxgroup,
|
||||||
|
@ -28,6 +29,7 @@
|
||||||
H1,
|
H1,
|
||||||
Overline,
|
Overline,
|
||||||
Button,
|
Button,
|
||||||
|
BodyBoundToStore,
|
||||||
Textfield,
|
Textfield,
|
||||||
Checkbox,
|
Checkbox,
|
||||||
Checkboxgroup,
|
Checkboxgroup,
|
||||||
|
|
|
@ -43,7 +43,15 @@ export const props = {
|
||||||
fullwidth: false,
|
fullwidth: false,
|
||||||
text: "I am button",
|
text: "I am button",
|
||||||
disabled: false,
|
disabled: false,
|
||||||
onClick: () => alert`Button Clicked`,
|
onClick: [
|
||||||
|
{
|
||||||
|
"##eventHandlerType": "Set State",
|
||||||
|
parameters: {
|
||||||
|
path: "surname",
|
||||||
|
value: "hi",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
Icon: {
|
Icon: {
|
||||||
_component: "@budibase/materialdesign-components/Icon",
|
_component: "@budibase/materialdesign-components/Icon",
|
||||||
|
@ -58,7 +66,11 @@ export const props = {
|
||||||
fullwidth: true,
|
fullwidth: true,
|
||||||
maxLength: 500,
|
maxLength: 500,
|
||||||
helperText: "Add Surname",
|
helperText: "Add Surname",
|
||||||
onChange: text => console.log("Text: ", text),
|
value: "store.surname",
|
||||||
|
},
|
||||||
|
BodyBoundToStore: {
|
||||||
|
_component: "@budibase/materialdesign-components/Body1",
|
||||||
|
text: "store.surname",
|
||||||
},
|
},
|
||||||
Checkbox: {
|
Checkbox: {
|
||||||
_component: "@budibase/materialdesign-components/Checkbox",
|
_component: "@budibase/materialdesign-components/Checkbox",
|
||||||
|
|
Loading…
Reference in New Issue