-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDev.cpp
62 lines (60 loc) · 1.63 KB
/
Dev.cpp
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
thread_local Observed<std::vector<std::string>> names =
std::vector<std::string>{"John", "Jane", "Joe", "Jill"};
thread_local std::string name;
return div{
style = Style{
"display"_style = "flex",
"flex-direction"_style = "column",
"gap"_style = "5px",
}
}(
div{
style = Style{
"display"_style = "flex",
"gap"_style = "5px",
}
}(
input{
id = "attributeInput",
class_ = "form-control",
type = "text",
onInput = [](auto const& event) {
name = event["target"]["value"].template as<std::string>();
}
}(),
button{
onClick = [](){
names.push_back(name);
},
class_ = "btn btn-primary"
}("Add Name")
),
table{}(
thead{}(
tr{}(
th{}(""),
th{}("Number"),
th{}("Name")
)
),
tbody{}(
// range indicates that the following ElementRenderer
// is to be rendered for each item.
range(names),
[](long i, auto const& name) {
return tr{}(
td{}(
button{
onClick = [i](){
names.erase(names.begin() + i);
},
class_ = "btn btn-danger"
}("X")
),
td{}(std::to_string(i)),
td{}(name)
);
}
)
)
);