Files
buuh/examples/vanilla/index.html
T

44 lines
1.2 KiB
HTML
Raw Normal View History

2016-07-01 11:38:53 +02:00
<html>
<head>
<title>Vanilla example</title>
</head>
<body>
<script src="../../dist/choo.min.js"></script>
2016-08-02 10:17:59 -04:00
<script src="../../dist/html.min.js"></script>
2016-07-01 11:38:53 +02:00
<script>
const app = choo()
app.model({
namespace: 'counter',
state: {
count: 0
},
reducers: {
increment: (data, state) => ({count: state.count + 1}),
decrement: (data, state) => ({count: state.count - 1})
2016-07-01 11:38:53 +02:00
}
})
const mainView = (state, prev, send) => {
return html`
2016-07-01 11:38:53 +02:00
<main class="app">
<h1>Counter example</h1>
<div>
Count: ${state.counter.count}
<button onclick=${(e) => send('counter:increment')}>+</button>
<button onclick=${(e) => send('counter:decrement')}>-</button>
</div>
</main>
`
}
app.router((route) => [
route('/', mainView)
])
const tree = app.start()
document.body.appendChild(tree)
</script>
</body>
</html>