lpotthast / leptonic

Leptos component framework.
https://leptonic.dev
Apache License 2.0
240 stars 38 forks source link

Add Attribute Spreading #70

Open over-light opened 1 week ago

over-light commented 1 week ago

I think attribute spreading must be added to leptonic. Attribute spreading was added to leptos 0.6.12 I tried to use this, but it not works for Link of leptonic

use leptonic::prelude::*;
use leptos::*;

#[component]
pub fn NavLink(
    #[prop(into)] link: String,
    #[prop(into)] icon: MaybeSignal<icondata::Icon>,
    #[prop(into)] text: String,
    #[prop(attrs)] attrs: Vec<(&'static str, Attribute)>,
) -> impl IntoView {
    view! {
        <Link {attr} href=link>
            <div class="flex gap-2">
                <Icon icon=icon class="text-2xl"/>
                <div>{text}</div>
            </div>
        </Link>
    }
}

Then we can use like this;

<NavLink link="/" icon=icondata::BsHouse text="Home" attr:class="w-full"/>

https://docs.rs/leptos_router/latest/src/leptos_router/components/link.rs.html#64
https://github.com/lpotthast/leptonic/blob/6c2959f7336dd80e13a3ae8c05671d05ecd38d02/leptonic/src/components/link.rs#L11

I think it is very important feature and must be quickly added to leptonic

ActuallyHappening commented 3 days ago

I 100% concur, you currently can't set type = "submit" on the Button component as provided by leptonic currently

If I get the time, I'll try to add this feature, but as @over-light said this should be added since it is stabilised in Leptos already! but I guess 0.7 will roll around anyway