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
#![allow(unused_variables)]
#![allow(dead_code)]
#![allow(unused_imports)]
use super::to_option;
use wasm_bindgen::prelude::*;
use yew::prelude::*;
mod actions;
mod buttons;
mod media;
mod primary_action;
pub use actions::*;
pub use buttons::*;
pub use media::*;
pub use primary_action::*;
pub struct Card {
link: ComponentLink<Self>,
label: String,
}
pub enum Msg {
Clicked,
}
#[derive(Clone, PartialEq, Properties)]
pub struct CardProps {
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,
}
impl Component for Card {
type Message = Msg;
type Properties = CardProps;
fn create(props: Self::Properties, link: ComponentLink<Self>) -> Self {
Self {
link,
label: props.label,
}
}
fn update(&mut self, msg: Self::Message) -> ShouldRender {
match msg {
Msg::Clicked => {
}
}
false
}
fn change(&mut self, props: Self::Properties) -> ShouldRender {
self.label = props.label;
true
}
fn view(&self) -> Html {
html! {
<div class="mdc-card" style="max-width: 400px;">
<div class="mdc-card__primary-action">
<div class="my-card__media mdc-card__media mdc-card__media--square">
<div class="mdc-card__media-content">{ "Title" }</div>
</div>
</div>
<div class="mdc-card__actions">
<div class="mdc-card__action-buttons">
<button class="mdc-button mdc-card__action mdc-card__action--button">
<div class="mdc-button__ripple"></div>
<span class="mdc-button__label">{ "Action 1" }</span>
</button>
<button class="mdc-button mdc-card__action mdc-card__action--button">
<div class="mdc-button__ripple"></div>
<span class="mdc-button__label">{ "Action 2" }</span>
</button>
</div>
<div class="mdc-card__action-icons">
<button class="material-icons mdc-icon-button mdc-card__action mdc-card__action--icon" title="Share">{ "share" }</button>
<button class="material-icons mdc-icon-button mdc-card__action mdc-card__action--icon" title="More options">{ "more_vert" }</button>
</div>
</div>
</div>
}
}
}