Add onclick handler to icons

This commit is contained in:
Andrew Kingston 2021-03-25 16:18:19 +00:00
parent f17e2478e2
commit dd54bc9771
3 changed files with 9 additions and 3 deletions

View File

@ -43,8 +43,8 @@ export const enrichProps = async (props, context) => {
// Enrich all data bindings in top level props // Enrich all data bindings in top level props
let enrichedProps = await enrichDataBindings(validProps, totalContext) let enrichedProps = await enrichDataBindings(validProps, totalContext)
// Enrich button actions if they exist // Enrich click actions if they exist
if (props._component?.endsWith("/button") && enrichedProps.onClick) { if (enrichedProps.onClick) {
enrichedProps.onClick = enrichButtonActions( enrichedProps.onClick = enrichButtonActions(
enrichedProps.onClick, enrichedProps.onClick,
totalContext totalContext

View File

@ -330,6 +330,11 @@
"label": "Color", "label": "Color",
"key": "color", "key": "color",
"defaultValue": "#000" "defaultValue": "#000"
},
{
"type": "event",
"label": "On Click",
"key": "onClick"
} }
] ]
}, },

View File

@ -7,6 +7,7 @@
export let icon = "" export let icon = ""
export let size = "fa-lg" export let size = "fa-lg"
export let color = "#f00" export let color = "#f00"
export let onClick
$: styles = { $: styles = {
...$component.styles, ...$component.styles,
@ -17,4 +18,4 @@
} }
</script> </script>
<i use:styleable={styles} class="{icon} {size}" /> <i use:styleable={styles} class="{icon} {size}" on:click={onClick} />