Files: 5735e273f1d15ee90fb67318abe87d354d52a937 / feed / html / feedCard.js
878 bytesRaw
1 | const nest = require('depnest') |
2 | const { h, resolve, computed } = require('mutant') |
3 | |
4 | exports.gives = nest({ |
5 | 'feed.html.feedCard': true |
6 | }) |
7 | |
8 | exports.needs = nest({ |
9 | 'message.html.render': 'first', |
10 | }) |
11 | |
12 | |
13 | exports.create = function (api) { |
14 | return nest({ |
15 | 'feed.html.feedCard': feedCard, |
16 | }) |
17 | |
18 | function feedCard (msgObs) { |
19 | const msg = resolve(msgObs) // actually the rollup |
20 | |
21 | const opts = { |
22 | attributes: { |
23 | tabindex: '0', // needed to be able to show focus on keyscroll |
24 | 'data-id': msg.key, |
25 | 'data-root': msg.value.content.root || msg.key |
26 | }, |
27 | } |
28 | return h('FeedCard', opts, [ |
29 | api.message.html.render(msg), |
30 | 'Recent replies:', |
31 | computed(msgObs, msg => { |
32 | return h('ul', msg.replies.map(reply => h('li', [ |
33 | reply.value.timestamp, |
34 | ' ', |
35 | reply.key |
36 | ]))) |
37 | }) |
38 | ]) |
39 | } |
40 | } |
41 | |
42 |
Built with git-ssb-web