git ssb

16+

Dominic / patchbay



Tree: fd0e5304bd3777aa0d1bedb42467e378508b89cd

Files: fd0e5304bd3777aa0d1bedb42467e378508b89cd / message / html / layout / default.js

1339 bytesRaw
1const nest = require('depnest')
2const { h, Value } = require('mutant')
3const { isMsg } = require('ssb-ref')
4
5exports.needs = nest({
6 'message.html': {
7 backlinks: 'first',
8 author: 'first',
9 meta: 'map',
10 action: 'map',
11 timestamp: 'first'
12 },
13 'about.html.avatar': 'first'
14})
15
16exports.gives = nest('message.html.layout')
17
18exports.create = (api) => {
19 return nest('message.html.layout', messageLayout)
20
21 function messageLayout (msg, opts) {
22 if (!(opts.layout === undefined || opts.layout === 'default')) return
23
24 var { author, timestamp, meta, action, backlinks } = api.message.html
25 if (!isMsg(msg.key)) action = () => {}
26
27 var rawMessage = Value(null)
28
29 return h('Message -default', {
30 attributes: { tabindex: '0' } // needed to be able to navigate and show focus()
31 }, [
32 h('section.avatar', {}, api.about.html.avatar(msg.value.author)),
33 h('section.top', [
34 h('div.author', {}, author(msg)),
35 h('div.title', {}, opts.title),
36 h('div.meta', {}, meta(msg, { rawMessage }))
37 ]),
38 h('section.content', {}, opts.content),
39 h('section.raw-content', rawMessage),
40 h('section.bottom', [
41 h('div.timestamp', {}, timestamp(msg)),
42 h('div.actions', {}, action(msg))
43 ]),
44 h('footer.backlinks', {}, backlinks(msg))
45 ])
46 }
47}
48

Built with git-ssb-web