calico
calico copied to clipboard
Make it easier to define userland "components"
See also:
- https://github.com/armanbilge/calico/issues/207
- https://github.com/armanbilge/calico/issues/205
Consider this Laminar-style example:
def MyComponent(mods: Mod[HtmlElement]*) =
div(
cls := "decoration",
mods
)
At the moment this wouldn't work great with Calico, because modifiers are typeclass-based (https://github.com/armanbilge/calico/issues/207). Another issue is that if the caller of MyComponent
wants to add additional cls
values, it would override the cls := "decoration"
(https://github.com/armanbilge/calico/issues/205). It doesn't compose well.
The composition issue in particular bugs me, since it's not just about the class
attribute but basically any attribute. It's too easy to mess up the "component"'s internals when doing things externally.
Hence why I say "component", because it's not really well encapsulated. I feel like the answer might be https://github.com/armanbilge/calico/issues/37: that we should make it easy to define true Web Components, that have proper encapsulation of their internals. Web Components specifically solves this issue of encapsulation.