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,
/// The HTML content of this panel's heading; it is automatically wrapped in a `p.panel-heading`.
#[prop_or_default]
pub heading: Html,
}
/// A composable panel, for compact controls.
///
/// [https://bulma.io/documentation/components/panel/](https://bulma.io/documentation/components/panel/)
#[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,
}
/// A container for the navigation tabs of a panel.
///
/// [https://bulma.io/documentation/components/panel/](https://bulma.io/documentation/components/panel/)
#[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,
/// The HTML tag to use for this component.
#[prop_or_else(|| "div".into())]
pub tag: String,
/// Make this element the active / highlighted element.
#[prop_or_default]
pub active: bool,
/// The click handler for this element.
#[prop_or_default]
pub onclick: Callback<MouseEvent>,
}
/// An individual element of the panel.
///
/// [https://bulma.io/documentation/components/panel/](https://bulma.io/documentation/components/panel/)
#[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()}
</@>
}
}