RAUI-labs / raui

Rust implementation of Renderer Agnostic User Interface
https://raui-labs.github.io/raui/
Other
401 stars 10 forks source link

Should We Use Builder Pattern Widgets For the Website Guide? #68

Open zicklag opened 3 years ago

zicklag commented 3 years ago

@PsichiX I was curious what you thought about using the builder-style widgets for the guide on the website. @temporalflux ran into some issues understanding the widget! macro along with the desire to be able to rustfmt the macro which isn't supported and ended up preferring the builder pattern for making widget trees.

I'm not positive which pattern I will end up preferring , but for beginners I think the builder model might make more sense because it is self-explanatory and doesn't require explaining a custom syntax.

For instance, I find the | {shared_props} syntax particularly cryptic. In a simple example showing how to use material widgets and themes with shared props I can't help but feeling like I need a code comment next to that | {shared_props} to mention that the pipe is what makes the props shared, as opposed to a : {not_shared_props}. In contrast, with the builder pattern, it explains itself with either .with_props or .with_shared_props. It gives you less to explain and think about, and is also formattable.

Any thoughts?

PsichiX commented 3 years ago

i have no preference on one over another - to me both are equal, we can go with builder pattern, it's definitely simpler :D

i have one question tho - can zola support something like conditional code blocks? like user see code block with tabs/tick options, one option is builder and another is macro and depending on which is selected, that version of the code is shown? maybe we could do something like that in the future?

zicklag commented 3 years ago

i have no preference on one over another - to me both are equal, we can go with builder pattern, it's definitely simpler :D

OK, cool. :) I'm not sure if/when I'll get the chance to update the guide, but if I end up working on another chapter or something some time I'll switch it over to the builder syntax.

i have one question tho - can zola support something like conditional code blocks? like user see code block with tabs/tick options, one option is builder and another is macro and depending on which is selected, that version of the code is shown? maybe we could do something like that in the future?

That's a good idea. Zola is pretty customizable so I'm pretty sure we could do something like that. It might take a little bit of work to make it work right, but it should be possible.