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
use yew::prelude::*;
use super::Datum;
#[derive(Properties, PartialEq, Debug)]
pub struct HorizontalHeaderTableProps {
pub headers: Vec<String>,
pub rows: Vec<Vec<Datum>>,
}
#[function_component(HorizontalHeaderTable)]
pub fn horizontal_header_table(props: &HorizontalHeaderTableProps) -> Html {
let collapsed_hader = props.headers.join(" / ");
html! {
<table class="horizontal_header_table">
<thead>
{
props.headers.iter().map(|header| {
html! {
<th key={header.to_string()}>{header}</th>
}
}).collect::<Html>()
}
</thead>
<tbody>
{
props.rows.iter().map(|row| {
html! {
<tr>
<th>{&collapsed_hader}</th>
{
row.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>
}
}).collect::<Html>()
}
</tbody>
</table>
}
}