Files: 51790a95381555fd47ee87374d11c418ee6e028a / app / html / page / gatherings.js
1116 bytesRaw
1 | const nest = require('depnest') |
2 | const pull = require('pull-stream') |
3 | const { h, Array } = require('mutant') |
4 | |
5 | exports.gives = nest({ |
6 | 'app.html': { |
7 | page: true, |
8 | menuItem: true |
9 | } |
10 | }) |
11 | |
12 | exports.needs = nest({ |
13 | 'app.html.scroller': 'first', |
14 | 'gathering.html': { |
15 | create: 'first', |
16 | render: 'first' |
17 | }, |
18 | 'gathering.pull.find': 'first' |
19 | }) |
20 | |
21 | exports.create = function (api) { |
22 | const route = '/gatherings' |
23 | return nest({ |
24 | 'app.html': { |
25 | menuItem: menuItem, |
26 | page: gatheringsPage |
27 | } |
28 | }) |
29 | |
30 | function menuItem (handleClick) { |
31 | return h('a', { |
32 | style: { order: 0 }, |
33 | 'ev-click': () => handleClick(route) |
34 | }, route) |
35 | } |
36 | |
37 | function gatheringsPage (path) { |
38 | if (path !== route) return |
39 | |
40 | const creator = api.gathering.html.create({}) |
41 | const gatherings = Array([]) |
42 | const content = h('section.content', {}, gatherings) |
43 | const { container } = api.app.html.scroller({content, prepend: [creator]}) |
44 | |
45 | pull( |
46 | api.gathering.pull.find(), |
47 | pull.drain(msg => { |
48 | gatherings.push(api.gathering.html.render(msg)) |
49 | }) |
50 | ) |
51 | |
52 | return container |
53 | } |
54 | } |
55 | |
56 | |
57 |
Built with git-ssb-web