examples/http -> examples/mailbox

This commit is contained in:
Yoshua Wuyts
2016-05-12 15:44:33 +07:00
parent 1d14f9f26b
commit 94e8073af1
9 changed files with 0 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
const choo = require('../../../')
const mailboxes = [ 'inbox', 'spam', 'sent' ]
module.exports = function (params, state, send) {
const mailbox = params.mailbox
return choo.view`
<aside>
<ul>
<li><h2>Mailboxes</h2></li>
${mailboxes.map(function (name) {
return createLi(name, state[name + ':messages'], mailbox)
})}
</ul>
</aside>
`
}
function createLi (mailbox, messages) {
return choo.view`
<li>
<a href="/${mailbox}">
${mailbox.charAt(0).toUpperCase() + mailbox.slice(1)}
<span>${messages}</span>
</a>
</li>
`
}