nes_yew/components/
container.rs1use std::borrow::Cow;
2use yew::prelude::*;
3
4#[derive(Properties, PartialEq)]
5pub struct ContainerProps {
6 pub children: Children,
7 pub title: Option<AttrValue>,
8 #[prop_or_default]
9 pub dark: bool,
10 #[prop_or_default]
11 pub rounded: bool,
12 #[prop_or_default]
13 pub centered: bool,
14 pub class: Option<Cow<'static, str>>,
15 pub style: Option<AttrValue>,
16}
17
18#[function_component(Container)]
19pub fn container(
20 ContainerProps {
21 children,
22 class,
23 dark,
24 rounded,
25 centered,
26 title,
27 style,
28 }: &ContainerProps,
29) -> Html {
30 let class = classes!(
31 class,
32 "nes-container",
33 title.as_ref().map(|_| "with-title"),
34 if *dark { Some("is-dark") } else { None },
35 if *rounded { Some("is-rounded") } else { None },
36 if *centered { Some("is-centered") } else { None },
37 );
38
39 html! {
40 <section class={class} style={style.clone()}>
41 {title.as_ref().map(|t| html!{<h2 class="title">{t}</h2>})}
42 {children.clone()}
43 </section>
44 }
45}