choo: add href / history handling

This commit is contained in:
Yoshua Wuyts
2016-05-12 14:45:20 +07:00
parent 049d8f0cee
commit 53a1e6026a
4 changed files with 61 additions and 34 deletions
+5 -2
View File
@@ -5,7 +5,7 @@ sf('css-wipe/dest/bundle')
sf('tachyons')
const mainView = require('./views/main')
const navElement = require('./elements/nav')
const nav = require('./elements/nav')
const app = choo()
@@ -14,7 +14,10 @@ app.model('spam', require('./models/spam'))
app.model('sent', require('./models/sent'))
app.router((route) => [
route('/', mainView(navElement))
route('/', mainView(nav)),
route('/:mailbox', mainView(nav), [
route('/:message_id', mainView(nav))
])
])
const tree = app.start()
+15
View File
@@ -0,0 +1,15 @@
module.exports = {
state: {
messages: [
{
id: 4,
subject: 'Should I use Ember',
from: 'user@example.com',
to: 'tomster@emberjs.com',
date: new Date(),
body: 'Ember looks pretty good, should I use it?'
}
]
},
reducers: { }
}
+2 -1
View File
@@ -3,9 +3,10 @@ const choo = require('../../../')
module.exports = function (nav) {
return function (params, state, send) {
console.log(state)
return choo.view`
<main class="app">
<span>URL: ${pathname(state.location) || '/'}</span>
<span>URL: ${'/' + pathname(state.location)}</span>
${nav(params, state, send)}
<section>
<table>