-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathdatatable.rs
117 lines (107 loc) · 4.4 KB
/
datatable.rs
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#![allow(unused_variables)]
#![allow(dead_code)]
#![allow(unused_imports)]
use super::to_option;
use wasm_bindgen::prelude::*;
use yew::prelude::*;
pub struct DataTable {
link: ComponentLink<Self>,
label: String,
// onsignal: Callback<()>,
}
pub enum Msg {
Clicked,
}
/// Props for [`DataTable`]
///
/// [Documentation for properties](https://github.com/material-components/material-components-web-components/tree/master/packages/button#propertiesattributes)
#[derive(Clone, PartialEq, Properties)]
pub struct DataTableProps {
pub label: String,
#[prop_or_default]
pub icon: Option<String>,
#[prop_or_default]
pub raised: bool,
#[prop_or_default]
pub unelevated: bool,
#[prop_or_default]
pub outlined: bool,
#[prop_or_default]
pub dense: bool,
#[prop_or_default]
pub disabled: bool,
#[prop_or_default]
pub trailing_icon: bool,
// #[prop_or_default]
// pub onsignal: Callback<()>,
}
// label=props.label
// icon?=props.icon.as_ref()
// raised?=to_option(props.raised)
// unelevated?=to_option(props.unelevated)
// outlined?=to_option(props.outlined)
// dense?=to_option(props.dense)
// trailingIcon?=to_option(props.trailing_icon)
// disabled=props.disabled
impl Component for DataTable {
type Message = Msg;
type Properties = DataTableProps;
fn create(props: Self::Properties, link: ComponentLink<Self>) -> Self {
Self {
link,
label: props.label,
// onsignal: props.onsignal,
}
}
fn update(&mut self, msg: Self::Message) -> ShouldRender {
match msg {
Msg::Clicked => {
// self.onsignal.emit(());
}
}
false
}
fn change(&mut self, props: Self::Properties) -> ShouldRender {
self.label = props.label;
// self.onsignal = props.onsignal;
true
}
fn view(&self) -> Html {
html! {
<div class="mdc-data-table">
<div class="mdc-data-table__table-container">
<table class="mdc-data-table__table" aria-label="Dessert calories">
<thead>
<tr class="mdc-data-table__header-row">
<th class="mdc-data-table__header-cell" role="columnheader" scope="col">{ "Dessert" }</th>
<th class="mdc-data-table__header-cell mdc-data-table__header-cell--numeric" role="columnheader" scope="col">{ "Carbs (g)" }</th>
<th class="mdc-data-table__header-cell mdc-data-table__header-cell--numeric" role="columnheader" scope="col">{ "Protein (g)" }</th>
<th class="mdc-data-table__header-cell" role="columnheader" scope="col">{ "Comments" }</th>
</tr>
</thead>
<tbody class="mdc-data-table__content">
<tr class="mdc-data-table__row">
<th class="mdc-data-table__cell" scope="row">{ "Frozen yogurt" }</th>
<td class="mdc-data-table__cell mdc-data-table__cell--numeric">{ "24" }</td>
<td class="mdc-data-table__cell mdc-data-table__cell--numeric">{ "4.0" }</td>
<td class="mdc-data-table__cell">{ "Super tasty" }</td>
</tr>
<tr class="mdc-data-table__row">
<th class="mdc-data-table__cell" scope="row">{ "Ice cream sandwich" }</th>
<td class="mdc-data-table__cell mdc-data-table__cell--numeric">{ "37" }</td>
<td class="mdc-data-table__cell mdc-data-table__cell--numeric">{ "4.33333333333" }</td>
<td class="mdc-data-table__cell">{ "I like ice cream more" }</td>
</tr>
<tr class="mdc-data-table__row">
<th class="mdc-data-table__cell" scope="row">{ "Eclair" }</th>
<td class="mdc-data-table__cell mdc-data-table__cell--numeric">{ "24" }</td>
<td class="mdc-data-table__cell mdc-data-table__cell--numeric">{ "6.0" }</td>
<td class="mdc-data-table__cell">{ "New filing flavor" }</td>
</tr>
</tbody>
</table>
</div>
</div>
}
}
}