design_system/atoms/page/
page.rs

1use css_in_rust::Style;
2use yew::prelude::*;
3
4#[derive(Debug)]
5pub struct Page {
6    link: ComponentLink<Self>,
7    style: Style,
8    props: Props,
9}
10
11#[derive(Debug)]
12pub enum Msg {}
13
14#[derive(Clone, PartialEq, Properties, Debug)]
15pub struct Props {
16    #[prop_or_default]
17    pub children: Children,
18    #[prop_or_default]
19    pub class: String,
20}
21
22impl Component for Page {
23  type Message = Msg;
24  type Properties = Props;
25
26  fn create(props: Self::Properties, link: ComponentLink<Self>) -> Self {
27    let style = Style::create("page", include_str!("page.scss")).expect("An error occured while creating the style.");
28    Page {
29      link,
30      style,
31      props: props.to_owned(),
32    }
33  }
34
35  fn update(&mut self, _msg: Self::Message) -> ShouldRender {
36    true
37  }
38
39  fn change(&mut self, _props: Self::Properties) -> ShouldRender {
40    true
41  }
42
43  fn view(&self) -> Html {
44    html! {
45      <div
46        class=Classes::from(self.props.class.to_string()).extend(self.style.to_string())
47      >
48        { self.props.children.clone() }
49      </div>
50    }
51  }
52}