feat(components): build item list component

This commit is contained in:
Ryan Mwangi 2024-12-05 14:18:49 +03:00
parent 6cbc98d76d
commit 02a888be57
1 changed files with 23 additions and 0 deletions

View File

@ -0,0 +1,23 @@
use leptos::*;
use crate::models::item::Item;
#[component]
pub fn ItemsList(cx: Scope, items: Vec<Item>) -> impl IntoView {
view! { cx,
<div>
<h2>{ "Items" }</h2>
<ul>
{items.iter().map(|item| view! { cx,
<li>
<strong>{ &item.name }</strong> - { &item.description }
<ul>
{item.tags.iter().map(|(key, value)| view! { cx,
<li>{ key.clone() + ": " + value }</li>
}).collect::<Vec<_>>()}
</ul>
</li>
}).collect::<Vec<_>>()}
</ul>
</div>
}
}