Containers support onClick

This commit is contained in:
Mel O'Hagan 2022-05-11 14:03:08 +01:00
parent 54f750e225
commit 7151f6df66
2 changed files with 17 additions and 1 deletions

View File

@ -219,6 +219,11 @@
"showInBar": true, "showInBar": true,
"barIcon": "ModernGridView", "barIcon": "ModernGridView",
"barTitle": "Wrap" "barTitle": "Wrap"
},
{
"type": "event",
"label": "On Click",
"key": "onClick"
} }
] ]
}, },

View File

@ -10,22 +10,30 @@
export let size export let size
export let gap export let gap
export let wrap export let wrap
export let onClick
$: directionClass = direction ? `valid-container direction-${direction}` : "" $: directionClass = direction ? `valid-container direction-${direction}` : ""
$: hAlignClass = hAlign ? `hAlign-${hAlign}` : "" $: hAlignClass = hAlign ? `hAlign-${hAlign}` : ""
$: vAlignClass = vAlign ? `vAlign-${vAlign}` : "" $: vAlignClass = vAlign ? `vAlign-${vAlign}` : ""
$: sizeClass = size ? `size-${size}` : "" $: sizeClass = size ? `size-${size}` : ""
$: gapClass = gap ? `gap-${gap}` : "" $: gapClass = gap ? `gap-${gap}` : ""
$: clickableClass = onClick ? "clickable" : ""
$: classNames = [ $: classNames = [
directionClass, directionClass,
hAlignClass, hAlignClass,
vAlignClass, vAlignClass,
sizeClass, sizeClass,
gapClass, gapClass,
clickableClass,
].join(" ") ].join(" ")
</script> </script>
<div class={classNames} use:styleable={$component.styles} class:wrap> <div
class={classNames}
use:styleable={$component.styles}
class:wrap
on:click={onClick}
>
<slot /> <slot />
</div> </div>
@ -104,4 +112,7 @@
.wrap { .wrap {
flex-wrap: wrap; flex-wrap: wrap;
} }
.clickable {
cursor: pointer;
}
</style> </style>