From 61b665b384affecb6129120b773d684a60a2a231 Mon Sep 17 00:00:00 2001 From: Conor Mack Date: Fri, 14 Feb 2020 14:00:12 +0000 Subject: [PATCH] Proper even handling for buttons and textfields --- .../src/Button/Button.svelte | 64 ++++++++++--------- .../src/Test/props.js | 3 +- .../src/Textfield/Textfield.svelte | 8 ++- 3 files changed, 40 insertions(+), 35 deletions(-) diff --git a/packages/materialdesign-components/src/Button/Button.svelte b/packages/materialdesign-components/src/Button/Button.svelte index c0c9ceb7e2..c3649f6d34 100644 --- a/packages/materialdesign-components/src/Button/Button.svelte +++ b/packages/materialdesign-components/src/Button/Button.svelte @@ -1,49 +1,45 @@ - - {#if href} - + {text} {:else} @@ -52,7 +48,7 @@ class={blockClasses} class:fullwidth {disabled} - on:click> + on:click={onClick}> {#if renderLeadingIcon} {/if} @@ -62,3 +58,9 @@ {/if} {/if} + + diff --git a/packages/materialdesign-components/src/Test/props.js b/packages/materialdesign-components/src/Test/props.js index 9b244480c8..0b71ceaee2 100644 --- a/packages/materialdesign-components/src/Test/props.js +++ b/packages/materialdesign-components/src/Test/props.js @@ -22,6 +22,7 @@ export const props = { fullwidth: false, text: "I am button", disabled: false, + onClick: () => alert`Button Clicked`, }, icon: { _component: "@budibase/materialdesign-components/icon", @@ -33,10 +34,10 @@ export const props = { _children: [], label: "First", colour: "secondary", - textarea: true, fullwidth: true, helperText: "Add Surname", useCharCounter: true, + onChange: text => console.log("Text: ", text), }, checkbox: { _component: "@budibase/materialdesign-components/checkbox", diff --git a/packages/materialdesign-components/src/Textfield/Textfield.svelte b/packages/materialdesign-components/src/Textfield/Textfield.svelte index 54a207c33d..6ea943f94c 100644 --- a/packages/materialdesign-components/src/Textfield/Textfield.svelte +++ b/packages/materialdesign-components/src/Textfield/Textfield.svelte @@ -21,6 +21,8 @@ } }) + export let onChange = text => {} + export let label = "" export let variant = "standard" //outlined | filled | standard export let disabled = false @@ -112,7 +114,7 @@ TODO:Needs error handling - this will depend on how Budibase handles errors {placeholder} {minLength} {maxLength} - on:change /> + on:change={e => onChange(e.target.value)} /> {:else} {#if renderLeadingIcon} @@ -120,7 +122,6 @@ TODO:Needs error handling - this will depend on how Budibase handles errors + on:focus={focus} + on:change={e => onChange(e.target.value)} /> {#if renderTrailingIcon} {/if}