From dd54bc97714cd108cf355512c3a4a412e61370dd Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Thu, 25 Mar 2021 16:18:19 +0000 Subject: [PATCH] Add onclick handler to icons --- packages/client/src/utils/componentProps.js | 4 ++-- packages/standard-components/manifest.json | 5 +++++ packages/standard-components/src/Icon.svelte | 3 ++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/client/src/utils/componentProps.js b/packages/client/src/utils/componentProps.js index 161565e789..559fc54486 100644 --- a/packages/client/src/utils/componentProps.js +++ b/packages/client/src/utils/componentProps.js @@ -43,8 +43,8 @@ export const enrichProps = async (props, context) => { // Enrich all data bindings in top level props let enrichedProps = await enrichDataBindings(validProps, totalContext) - // Enrich button actions if they exist - if (props._component?.endsWith("/button") && enrichedProps.onClick) { + // Enrich click actions if they exist + if (enrichedProps.onClick) { enrichedProps.onClick = enrichButtonActions( enrichedProps.onClick, totalContext diff --git a/packages/standard-components/manifest.json b/packages/standard-components/manifest.json index 9cd8999088..93752f8082 100644 --- a/packages/standard-components/manifest.json +++ b/packages/standard-components/manifest.json @@ -330,6 +330,11 @@ "label": "Color", "key": "color", "defaultValue": "#000" + }, + { + "type": "event", + "label": "On Click", + "key": "onClick" } ] }, diff --git a/packages/standard-components/src/Icon.svelte b/packages/standard-components/src/Icon.svelte index 3ae9ffe6dd..51e4f5d50b 100644 --- a/packages/standard-components/src/Icon.svelte +++ b/packages/standard-components/src/Icon.svelte @@ -7,6 +7,7 @@ export let icon = "" export let size = "fa-lg" export let color = "#f00" + export let onClick $: styles = { ...$component.styles, @@ -17,4 +18,4 @@ } - +