mcai_workflow/components/
field.rs1use css_in_rust_next::Style;
2use yew::{html, Children, Component, Context, Html, Properties};
3
4#[derive(PartialEq, Properties)]
5pub struct FieldProperties {
6 pub label: String,
7 #[prop_or_default]
8 pub children: Children,
9}
10
11pub struct Field {
12 style: Style,
13}
14
15impl Component for Field {
16 type Message = ();
17 type Properties = FieldProperties;
18
19 fn create(_ctx: &Context<Self>) -> Self {
20 let style = Style::create(
21 "Component",
22 r#"
23 label.fieldTitle,
24 span.fieldInner {
25 vertical-align: bottom;
26 line-height: 23px;
27 padding: 3px;
28 }
29
30 label.fieldTitle {
31 display: inline-block;
32 width: 200px;
33 overflow: hidden;
34 }
35 "#,
36 )
37 .unwrap();
38
39 Self { style }
40 }
41
42 fn view(&self, ctx: &Context<Self>) -> Html {
43 html!(
44 <div class={self.style.clone()}>
45 <label class="fieldTitle">
46 {&ctx.props().label}
47 </label>
48 <span class="fieldInner">
49 { for ctx.props().children.iter() }
50 </span>
51 </div>
52 )
53 }
54}