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
use yew::prelude::*;
use super::Datum;
#[derive(Debug, PartialEq, Clone)]
pub struct VerticalHeaderTableRow {
pub header: String,
pub data: Vec<Datum>,
}
#[derive(Properties, Debug, PartialEq)]
pub struct VerticalHeaderTableProps {
pub rows: Vec<VerticalHeaderTableRow>,
}
#[function_component(VerticalHeaderTable)]
pub fn vertical_header_table(props: &VerticalHeaderTableProps) -> Html {
html! {
<table class="vertical_header_table">
{
props.rows.clone().iter().map(|row| {
html! {
<>
<tr class="uncollapsed_row" key={row.header.to_string()}>
<th>{row.header.to_string()}</th>
{
row.data.iter().map(|datum| {
html! {
if datum.monospaced {
<td key={datum.to_string()} class="mono_text">{datum}</td>
} else {
<td key={datum.to_string()}>{datum}</td>
}
}
}).collect::<Html>()
}
</tr>
<tr class="collapsed_row">
<th>{row.header.to_string()}</th>
</tr>
{
row.data.iter().map(|datum| {
html! {
if datum.monospaced {
<tr class="collapsed_row"><td key={datum.to_string()} class="mono_text">{datum}</td></tr>
} else {
<tr class="collapsed_row"><td key={datum.to_string()}>{datum}</td></tr>
}
}
}).collect::<Html>()
}
</>
}
}).collect::<Html>()
}
</table>
}
}