-
-
Notifications
You must be signed in to change notification settings - Fork 341
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Export action
in components for custom events
#422
Comments
I think this is definitely something we can/should do! |
My initial thoughts are we want this to be type-safe and flexible. I think taking inspiration from SMUI is a good idea to see how they handle it. It appears as though they accept an array of actions, but I need to investigate further how they go about handling/typing the params in that way. We could also accept a single action, since actions are just functions, you can apply multiple "actions" within a single action, for example: import externalAction from 'wherever'
function myCustomAction(node) {
const actReturn = externalAction(node)
return {
destroy() {
if (actReturn?.destroy) {
actReturn.destroy()
}
}
}
} |
i would like to contribute on this if thats ok @huntabyte edit: i also think is worth looking at the smui approach |
How do you plan to implement/type this and how will |
i was planning on doing some proof of concept first regarding the types, im aware that typesafety is a must regarding the update i was going to ask for guidance on the discord channel but links are expired |
@huntabyte i was just checking on this issue and of course i tried first to add an action to the Button component this is the shadcn-svelte Button
and this in this case the shadcn-svelte Button is taking a Builder array so its possible to pass actions to the component... just not by using
or pass extra arguments
though i think there could be an implementation to use the |
some components like |
My workaround to the cards listen onclick events was: <Card.Content class="h-1/2">
<div role="presentation"
on:click={(e) => onClickCardHandler(e,"some useful value")} class="h-full w-full my-3">
Contents...
</div>
</Card.Content> Basically I fill the content with a div... ok, not good, but is an alternative meanwhile the builders or another solution is not present. |
This isn't something we plan to add across the entire project at the moment. You can get a reference to the underlying element using the |
Describe the feature in detail (code, mocks, or screenshots encouraged)
I was adding in addResizedColumns to the Data Table and needed to pass
use:props.resize
to theTable.Head
component.<Table.Head {...attrs} use:props.resize>
. This gives an error, "Actions can only be applied to DOM elements, not componentssvelte(invalid-action)".To fix it, I modified table-head.svelte to this:
Now you can pass props.resize like so:
<Table.Head {...attrs} action={props.resize}>
SMUI and I'm assuming others, do something similar to this for all the components.
What type of pull request would this be?
New Feature
Provide relevant links or additional information.
No response
The text was updated successfully, but these errors were encountered: