mirror of
https://github.com/adoyle0/thaw.git
synced 2025-01-25 22:49:21 -05:00
23 lines
675 B
Rust
23 lines
675 B
Rust
|
use super::use_tabs;
|
||
|
use crate::utils::mount_style::mount_style;
|
||
|
use leptos::*;
|
||
|
use stylers::style_sheet_str;
|
||
|
|
||
|
#[derive(Clone)]
|
||
|
pub(crate) struct TabOptions {
|
||
|
pub key: &'static str,
|
||
|
pub label: &'static str,
|
||
|
}
|
||
|
|
||
|
#[component]
|
||
|
pub fn Tab(cx: Scope, key: &'static str, label: &'static str, children: Children) -> impl IntoView {
|
||
|
let class_name = mount_style("tab", || style_sheet_str!("./src/tabs/tab.css"));
|
||
|
let tabs = use_tabs(cx);
|
||
|
tabs.push_tab_options(TabOptions { key, label });
|
||
|
view! { cx, class=class_name,
|
||
|
<div class="melt-tab" class=("melt-tab--hidden", move || key != tabs.get_key()) >
|
||
|
{ children(cx) }
|
||
|
</div>
|
||
|
}
|
||
|
}
|