svelte
svelte copied to clipboard
implement svelte's actions for Components
one useful thing that only DOM elements supports is: actions sometimes we need to use actions for components (for example forwardEvents).
SMUI supports this using use prop.
we can write a preprocessor which change:
<Button use:action1 use:anotherAction use:forwardEvents color="red">
Red Button
</Button>
to:
<Button use={[action1,anotherAction,forwardEvents]} color="red">
Red Button
</Button>
then in Base component (Button.svelte) we can have use prop and pass to DOM element.
ui/blob/master/packages/common/src/internal/useActions.ts)
<script>
export let use: ActionArray[] = []
</script>
<button use:useActions(use) {color}>
<slot/>
</button>
- useActions is something like this
@pournasserian What do you think about this?