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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
use yew::events::MouseEvent;
use yew::prelude::*;
#[derive(Clone, Debug, Properties, PartialEq)]
pub struct PanelProps {
#[prop_or_default]
pub children: Children,
#[prop_or_default]
pub classes: Classes,
#[prop_or_default]
pub heading: Html,
}
#[function_component(Panel)]
pub fn panel(props: &PanelProps) -> Html {
let class = classes!("panel", props.classes.clone());
html! {
<nav {class}>
<p class="panel-heading">{props.heading.clone()}</p>
{props.children.clone()}
</nav>
}
}
#[derive(Clone, Debug, Properties, PartialEq)]
pub struct PanelTabsProps {
#[prop_or_default]
pub children: Children,
}
#[function_component(PanelTabs)]
pub fn panel_tabs(props: &PanelTabsProps) -> Html {
html! { <p class="panel-tabs">{props.children.clone()}</p> }
}
#[derive(Clone, Debug, Properties, PartialEq)]
pub struct PanelBlockProps {
#[prop_or_default]
pub children: Children,
#[prop_or_else(|| "div".into())]
pub tag: String,
#[prop_or_default]
pub active: bool,
#[prop_or_default]
pub onclick: Callback<MouseEvent>,
}
#[function_component(PanelBlock)]
pub fn panel_block(props: &PanelBlockProps) -> Html {
let class = classes!("panel-block", props.active.then_some("is-active"));
html! {
<@{props.tag.clone()} {class} onclick={props.onclick.clone()}>
{props.children.clone()}
</@>
}
}