blob: 32005c5ca4ba94fe9986729093d233bce3157084 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
// rocie - An enterprise grocery management system - Web app
//
// Copyright (C) 2026 Benedikt Peetz <benedikt.peetz@b-peetz.de>
// SPDX-License-Identifier: GPL-3.0-or-later
//
// This file is part of Rocie.
//
// You should have received a copy of the License along with this program.
// If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>.
use leptos::{
IntoView, component,
prelude::{Children, ClassAttribute, ElementChild},
view,
};
use leptos_router::components::A;
#[component]
pub fn Container(
header: impl IntoView + 'static,
buttons: Vec<(impl IntoView + 'static, &'static str)>,
children: Children,
) -> impl IntoView {
assert!(!buttons.is_empty());
// TODO: Add the direct link to the first button back. <2026-02-15>
// let first_button_path = buttons.first().expect("Should have at least on button").1;
view! {
<div class="p-4 mt-4 mr-4 ml-4 md-2 text-justify rounded-lg border-gray-600 border">
<h2 class="text-lg text-bold">{header}</h2>
{children()}
<ul class="flex flex-row gap-1 pt-2 overflow-x-auto">
{buttons
.into_iter()
.map(|(name, path)| {
view! {
<li class="bg-green-400/40 p-2 text-nowrap first:rounded-l-full last:rounded-r-full">
<A href=move || path.to_owned()>{name}</A>
</li>
}
})
.collect::<Vec<_>>()}
</ul>
</div>
}
}
|