forked from Raynos/mercury
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrender.jsx
42 lines (36 loc) · 1010 Bytes
/
render.jsx
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
/** @jsx h */
'use strict';
var mercury = require("../../../index.js");
var h = mercury.h;
module.exports = render;
function render(state) {
return <div>
<input
ev-event={mercury.changeEvent(state.events.changeText)}
name="description"
value={state.description}
/>
<button
ev-click={mercury.event(state.events.add, state.description)}
>Add</button>
<table>
{state.list.map(renderTask)}
</table>
</div>
function renderTask(item) {
return <tr>
<td>
<input
type="checkbox"
ev-click={mercury.event(state.events.toggle, {
id: item.id
})}
checked={item.done}
/>
</td>
<td style={{textDecoration: item.done ? "line-through" : "none"}}>
{item.description}
</td>
</tr>
}
}