edezhic / prest

Progressive RESTful framework
https://prest.blog
54 stars 2 forks source link

adapt maud for usage with tailwind and htmx => strong upvote! #2

Closed webhype closed 3 months ago

webhype commented 5 months ago

That's all, just this feature request...

Love this project! Hope one day I can contribute...

edezhic commented 5 months ago

Glad to hear that, if you have time we can probably find something you can help with

This feature is actually the next thing I'm thinking about - integrating railwind straight into the macro to keep it rusty

webhype commented 5 months ago

How do you feel about https://docs.rs/minijinja/ ? From what I understand it doesn't require a round-trip through the compiler for every change (in debug / dev mode)... not sure if this is accurately echoed...

edezhic commented 5 months ago

it looks nice, and I understand how frustrating rust compile times can be, but this compiler is also what makes rust great and I want to leverage its type safety etc even in the templates, especially the powerful macro system which can generate styles/scripts inside markup

there is quite a lot of ongoing work to make rust compiler faster at each step - parallel frontend, cranelift backend, hotreloading by dioxuslabs, and mold linker. I believe that together these efforts will aleviate most of the pain related to the constant usage of rustc

edezhic commented 4 months ago

Happy to announce that I've just merged support for tailwind classes in html macro and eliminated default external css to speed up page loads

I haven't properly updated docs and other examples yet, but you can check it out in the blog's code - https://github.com/edezhic/prest/blob/main/examples/blog/src/lib.rs

edezhic commented 3 months ago

Basic examples have been updated to use tailwind classes, added re-exports from axum-htmx and embedded hyperscript in the default scripts along with htmx, so it's already pretty easy to maintain locality of behaviour

This approach to styling is quite unusual these days but I think it makes a lot of sense unless you're building a game or smth very heavy - page is rendered pretty much instantly and bandwidth overhead is negligible in modern networks. It's still missing support for some of the tailwind classes but most of them can be included relatively easily. Regarding templating - I think maud got it right syntax-wise and it's pretty damn performant.

Regarding further htmx and hyperscript integration - I just don't have good ideas what to do with them. I thought about adding shorthands for their attributes or smth alike, but they are already pretty minimalistic and concise. If anyone has any ideas how to make them look better with maud - please reach out!

In the future I'd love to replace htmx and hyperscript with some rust->wasm alternative and keep only html+css for cross-platform UIs, but as of now manipulating DOM with rust is quite painful. Yew and Dioxus have made it significantly better but in my view they aren't good enough - both follow react way of building UIs but neither have an ecosystem to compete with it. Hopefully their efforts will blossom one day and especially hot reloading that dioxuslabs folks have built for their templates because it might dramatically improve FE DX for prest apps as well. But for now some form of react integration in the islands architecture fashion makes more sense in my view

I'm closing this as the basis has been laid out and no more work is planned in this direction in the near future