Skip to content
This repository has been archived by the owner on Feb 26, 2023. It is now read-only.

implement svelte's actions for Components #529

Open
TheHadiAhmadi opened this issue Sep 23, 2022 · 0 comments
Open

implement svelte's actions for Components #529

TheHadiAhmadi opened this issue Sep 23, 2022 · 0 comments

Comments

@TheHadiAhmadi
Copy link
Collaborator

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?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant