marc2332 / freya

Cross-platform GUI library for 🦀 Rust powered by 🧬 Dioxus and 🎨 Skia.
https://freyaui.dev/
MIT License
1.34k stars 51 forks source link

idea: Use `#[component]` macro for built-in components #447

Open tigerros opened 8 months ago

tigerros commented 8 months ago

I know marc wanted the properties to be documented at the component function, which the new Dioxus 0.4.3 #[component] macro does (if inlined props are used). I think inline props should always be available (i.e. we shouldn't ever need a separate struct), since I made some parsing improvements to the macro. See https://github.com/DioxusLabs/dioxus/pull/1565 for how this may look like.

We should also replace #[inline_props] with #[component], and add #[component] for components that have struct props to enforce UpperCamelCase names and some other stuff.

marc2332 commented 8 months ago

We should also replace #[inline_props] with #[component]

I already did that, make sure you have the latest changes in your branch

add #[component] for components

I really dislike the idea of using the component macro for all the components, last time I tried it looked very verbose for large components such as ScrollView

tigerros commented 8 months ago

I really dislike the idea of using the component macro for all the components, last time I tried it looked very verbose for large components such as ScrollView

Really? It's just one attribute. You might be thinking of inlining all props, but the macro doesn't require that. It would just enforce some component standards. Also, I thought you wanted the documentation...

marc2332 commented 8 months ago

You might be thinking of inlining all props, but the macro doesn't require that.

Ah, it doesn't? then it's fine!

tigerros commented 8 months ago

Oh it also suppresses the non_snake_case warning, which is everywhere.

tigerros commented 4 months ago

Depends on https://github.com/DioxusLabs/dioxus/pull/2289 because Freya uses the struct pattern syntax (fn Foo(FooProps { bar }: FooProps)) which is not supported right now