PurpleKingdomGames / tyrian

Elm-inspired Scala UI library.
https://tyrian.indigoengine.io/
MIT License
346 stars 26 forks source link

#228 HTMX attributes prototype #250

Closed JPonte closed 7 months ago

JPonte commented 8 months ago

I was intrigued by this issue #228 and decided to see what the fuss is all about with this htmx.

I found it quite interesting to use Tyrian exclusively in the server and ship only the htmx.js to provide client side logic so I created a sandbox with JVM only that does that. I'm no expert in htmx and there are way more features that I'd like to explore in the future, for now this is really barebones.

One thing I'm not happy with is the Trigger part for the hx-trigger.

Trigger(tyrian.htmx.Event.Input)
  .withModifiers(Modifier.Changed, Modifier.Delay("300ms")),
Trigger(tyrian.htmx.Event.KeyDown)
  .withFilter("key=='Enter'")
  .withModifiers(Modifier.From("body"))

gets correctly "compiled" to input changed delay:1500ms, keydown[key=='Enter'] from:body but feels a bit too verbose.

I'm not sure if this is of any use and if it's what you had in mind in the issue but I thought I'd share anyway😅

davesmith00000 commented 8 months ago

This is exactly what I had in mind, amazing! You are a hero. :bow: :1st_place_medal:

JPonte commented 7 months ago

I added a few more examples, including one with websockets and server side SVG generation which I found quite fun and maybe useful to someone 😄 I think there are lot more features that I didn't explore yet but these basic attributes seem already enough to do some interesting things.

davesmith00000 commented 7 months ago

htmx-game-of-life Love it. :grin:

JPonte commented 7 months ago

Yes, I think I'm happy as it is right now.

I hope to actually use it myself soon in more personal projects. I really liked remaining fully on the server side for the whole stack 😀

Maybe I'll have something else to add later but for now, I think it's a good start.