examples: update mailbox

This commit is contained in:
Yoshua Wuyts
2016-05-23 04:00:29 +09:00
parent 24b9be7c8d
commit 300b6325a9
10 changed files with 22 additions and 19 deletions
+3 -3
View File
@@ -6,9 +6,9 @@ sf('tachyons')
const app = choo()
app.model('inbox', require('./models/inbox'))
app.model('spam', require('./models/spam'))
app.model('sent', require('./models/sent'))
app.model(require('./models/inbox'))
app.model(require('./models/spam'))
app.model(require('./models/sent'))
app.router((route) => [
route('/', require('./views/empty')),
+1 -1
View File
@@ -3,7 +3,7 @@ const choo = require('../../../')
module.exports = function (params, state, send) {
const mailbox = params.mailbox
const messages = state[mailbox + ':messages']
const messages = state[mailbox].messages
return choo.view`
<div>
<div class="db cf w-100">
+1 -1
View File
@@ -4,7 +4,7 @@ module.exports = function (params, state, send) {
const mailbox = params.mailbox
const message = params.message
const email = state[mailbox + ':messages'].filter(function (msg) {
const email = state[mailbox].messages.filter(function (msg) {
return String(msg.id) === message
})[0]
+4 -3
View File
@@ -5,9 +5,10 @@ module.exports = function () {
return function (params, state, send) {
const mailbox = params.mailbox
const message = params.message
const messages = state[mailbox].messages
if (message) {
const email = state[mailbox + ':messages'].filter(function (msg) {
const email = state[mailbox].messages.filter(function (msg) {
return String(msg.id) === message
})[0]
@@ -15,7 +16,7 @@ module.exports = function () {
<section class="fl mt4 w-80 db">
<div>
${createHeader()}
${state[mailbox + ':messages'].map(function (msg) {
${messages.map(function (msg) {
return createMessage(msg, mailbox)
})}
</div>
@@ -28,7 +29,7 @@ module.exports = function () {
return choo.view`
<section class="fl mt4 w-80 db">
${createHeader()}
${state[mailbox + ':messages'].map(function (msg) {
${messages.map(function (msg) {
return createMessage(msg, mailbox)
})}
</section>
+3 -4
View File
@@ -3,16 +3,15 @@ const choo = require('../../../')
const mailboxes = [ 'inbox', 'spam', 'sent' ]
module.exports = function (params, state, send) {
const mailbox = params.mailbox
return choo.view`
<aside class="fl mt4 w-20 db">
<ul>
<li>
<h2 class="f4 b lh0">Mailbox</h2>
</li>
${mailboxes.map(function (name) {
return createLi(name, state[name + ':messages'], mailbox)
${mailboxes.map(function (mailbox) {
const messages = mailbox.messages
return createLi(mailbox, messages, mailbox)
})}
</ul>
</aside>
+2 -1
View File
@@ -2,9 +2,10 @@ const pathname = require('pathname-match')
const choo = require('../../../')
module.exports = function (params, state, send) {
const location = state.app.location
return choo.view`
<span class="fl mt4 w-100 f4 b">
URL: ${pathname(state.location) || '/'}
URL: ${pathname(location) || '/'}
</span>
`
}
+1
View File
@@ -1,4 +1,5 @@
module.exports = {
namespace: 'inbox',
state: {
messages: [
{
+1
View File
@@ -1,4 +1,5 @@
module.exports = {
namespace: 'sent',
state: {
messages: [
{
+1
View File
@@ -1,4 +1,5 @@
module.exports = {
namespace: 'spam',
state: {
messages: [
{