jinya_ui/layout/
form.rs

1use yew::{Component, ComponentLink, Html};
2use yew::prelude::*;
3
4pub fn get_css<'a>() -> &'a str {
5    // language=CSS
6    "
7.jinya-form {
8    width: 100%;
9    padding-top: 0.5rem;
10    padding-bottom: 0.5rem;
11    display: flex;
12    flex-wrap: wrap;
13}
14
15.jinya-form > div {
16    flex: 0 0 100%;
17}
18"
19}
20
21pub struct Form {
22    children: Children,
23}
24
25#[derive(Clone, PartialEq, Properties)]
26pub struct FormProps {
27    pub children: Children,
28}
29
30impl Component for Form {
31    type Message = ();
32    type Properties = FormProps;
33
34    fn create(props: Self::Properties, _link: ComponentLink<Self>) -> Self {
35        Form {
36            children: props.children,
37        }
38    }
39
40    fn update(&mut self, _msg: Self::Message) -> bool {
41        false
42    }
43
44    fn change(&mut self, _props: Self::Properties) -> bool {
45        self.children = _props.children;
46        true
47    }
48
49    fn view(&self) -> Html {
50        html! {
51            <div class="jinya-form">
52                {for self.children.iter().enumerate().map(|(_, mut child)| {
53                    child
54                })}
55            </div>
56        }
57    }
58}