view.rs
2.25 KB
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
use mogwai::prelude::*;
use crate::data::icons::*;
use super::logic::MarkdownLogic;
pub(super) fn markdown_view( tx_logic: broadcast::Sender<MarkdownLogic>
, rx_toggle: broadcast::Receiver<bool>
, rx_patches: mpmc::Receiver<ListPatch<ViewBuilder<Dom>>>
, tx_dom: broadcast::Sender<Dom>
) -> ViewBuilder<Dom>
{
let input_filter = tx_logic
. sink()
. contra_map(|_| MarkdownLogic::Update);
let store_filter = tx_logic
. sink()
. contra_map(|_| MarkdownLogic::Store);
let toggle_filter = tx_logic
. sink()
. contra_map(|_| MarkdownLogic::Toggle);
let select_filter = tx_logic
. sink()
. contra_map(|_e| MarkdownLogic::Select);
let discard_filter = tx_logic
. sink()
. contra_map(|_| MarkdownLogic::Discard);
let toggle_map = rx_toggle
. map(|t| match t {
true => String::from("block"),
false => String::from("none") });
builder! {
<div class="input"
style:width="33%"
post:build=move |_: &mut Dom| {
tx_logic.try_broadcast(MarkdownLogic::Choose(None)).unwrap();
}
capture:view=tx_dom.sink()>
<div contenteditable="true"
style:cursor="text"
on:input=input_filter
style:display=("none", toggle_map)>
<pre></pre>
</div>
<div>
<div>
<div>
<button on:click=select_filter>{select_icon()}</button>
<ul patch:children=rx_patches>
</ul>
</div>
<button on:click=store_filter>{save_icon()}</button>
<button on:click=discard_filter>{undo_point_icon()}</button>
<button on:click=toggle_filter>{edit_icon()}</button>
</div>
<div></div>
<div></div>
</div>
</div>
}
}