Files: c6808ebda95764b1cdd2b287584c051d8901fb42 / app / page / books.js
995 bytesRaw
1 | const nest = require('depnest') |
2 | const pull = require('pull-stream') |
3 | const { h, Array } = require('mutant') |
4 | const Scroller = require('pull-scroll') |
5 | |
6 | exports.gives = nest({ |
7 | 'app.html.menuItem': true, |
8 | 'app.page.books': true |
9 | }) |
10 | |
11 | exports.needs = nest({ |
12 | 'app.html.scroller': 'first', |
13 | 'book.pull.getAll': 'first', |
14 | 'book.html': { |
15 | create: 'first', |
16 | render: 'first' |
17 | } |
18 | }) |
19 | |
20 | exports.create = function (api) { |
21 | return nest({ |
22 | 'app.html.menuItem': menuItem, |
23 | 'app.page.books': booksPage |
24 | }) |
25 | |
26 | function menuItem (handleClick) { |
27 | return h('a', { |
28 | style: { order: 5 }, |
29 | 'ev-click': () => handleClick({ page: 'books' }) |
30 | }, '/books') |
31 | } |
32 | |
33 | function booksPage (path) { |
34 | const creator = api.book.html.create({}) |
35 | const { container, content } = api.app.html.scroller({prepend: [creator]}) |
36 | |
37 | pull( |
38 | api.book.pull.getAll(), |
39 | Scroller(container, content, api.book.html.render, false, false) |
40 | ) |
41 | |
42 | container.title = '/books' |
43 | return container |
44 | } |
45 | } |
46 |
Built with git-ssb-web