-
-
Notifications
You must be signed in to change notification settings - Fork 586
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better styling for router related components #477
Better styling for router related components #477
Conversation
Oh I like this a lot. I should probably do the same thing for class, properties, and views. I think we should export a type alias for this to make it easier to use. Something like |
|
Ouh I have something to make it even better! |
Btw is it intended that I have to say class=class and can't just say class in the attributes? |
You have to love Rust for this conversion trait magic 🪄 This works now:#[component]
pub fn MyHeading(
cx: Scope,
text: String,
#[prop(optional, into)]
class: Option<AttributeValue>
) -> impl IntoView {
view!{
cx,
<h1 class=class>{text}</h1>
}
} |
On this particular point, this is just to maintain compatibility with the way Boolean attributes work in HTML.
I may add a shorthand syntax in the |
Yeah that's what I was thinking. |
Ah I see that makes sense.
Yeah thats debatable. I was just a bit confused as I expected it to work because the syntax works for custom components. |
Should I change anything or is this ready to merge? |
Nope looks good! Merging now. |
Made a few changes to
IntoAttribute
to make it usable asBox<dyn IntoAttribute>
to support styling similar to native tags.Before the
<A>
tag took aMaybeSignal<String>
so you needed to do:Now you can do:
And it also works for
Form
,ActionForm
andMultiActionForm
I tried really hard to implement this using generics, but it does not seem possible. The type of the generic parameter needs to be inferred even if its value is
None
because it needs to know whatOption::<T>::None
it is.