leptonic icon indicating copy to clipboard operation
leptonic copied to clipboard

Add Attribute Spreading

Open over-light opened this issue 8 months ago • 1 comments

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

over-light avatar Jun 27 '24 12:06 over-light