-
Notifications
You must be signed in to change notification settings - Fork 3
Description
Hey there here I am with the first questions.
I'll set a little bit of context first:
I'm quite a fan of custom elements and standards-based web dev in general so one of the first things that comes to my mind when trying out a web framework is how well are those supported.
This is a vanilla js use case I'd like to be able to do with vide
<sl-tab-group>
<sl-tab slot="nav" panel="general">General</sl-tab>
<sl-tab slot="nav" panel="custom">Custom</sl-tab>
<sl-tab slot="nav" panel="advanced">Advanced</sl-tab>
</sl-tab-group>
<button>Select advanced tab</button>And in my js something like
const btn = document.querySelector("button")
const tabGroup = document.querySelector("sl-tab-group")
btn.addEventListener('click', () => tabGroup.show("advanced"));
// here event is a CustomEvent<{ name: string }> event
tabGroup.addEventListener('sl-tab-show', (event) => { console.log("tab selected", event.detail.name) }I'm not sure if that is possible with vide right now I tried to find something in my limited experience at the moment but no luck so far
Here's how my pseudo code for vide would ideally look like
let MyTabsComponent() = vide {
custom "sl-tab-group" {
// custom element version to provide the generic
custom.oncustom<{| name: string |}>("sl-show", (fun event -> printfn "%A" event.details.name))
// alternative non-generic version as one can emit non-generic events as well
custom.onevent("sl-show", (fun (event: Event) ->
let ev = (Event :?> CustomEvent<{| name: string |}>)
printfn "%A" event.details.name))
custom "sl-tab" {
custom.slot "nav"
custom.attr("panel", "general")
"General"
}
custom "sl-tab" {
custom.slot "nav"
custom.attr("panel", "custom")
"Custom"
}
custom "sl-tab" {
custom.slot "nav"
custom.attr("panel", "advanced")
"Advanced"
}
}
button {
"Select Advanced Tab"
button.onclick (fun _ ->
// get a ref somehow here?
ref.show "advanced"
}
}In this case I'm not very familiar with the DSL yet but if this is an area I can contribute to I'd gladly step in to see what I can do.
In the case of the typings I don't mind if everything is string * obj there's a "generator" project I had for Sutil for these kinds of web component libraries, I might be able to revive it to let it generate a fully typed vide DSL as well, but my concerns are more in the out of the box experience and how can we consume these standard features that are not so F# friendly
I'll keep dropping more questions as I keep trying vide but for the moment let me know what you think about that