git ssb

16+

Dominic / patchbay



Tree: 41ed6a5aa572f6de601bab35fc108a955657c074

Files: 41ed6a5aa572f6de601bab35fc108a955657c074 / modules_basic / message-author.js

884 bytesRaw
1const fs = require('fs')
2const h = require('../h')
3const when = require('@mmckegg/mutant/when')
4
5exports.needs = {
6 avatar_link: 'first',
7 avatar_image: 'first',
8 avatar_name: 'first',
9 timestamp: 'first'
10}
11
12exports.gives = {
13 message_author: true,
14 mcss: true
15}
16
17exports.create = function (api) {
18 return {
19 message_author,
20 mcss: () => fs.readFileSync(__filename.replace(/js$/, 'mcss'), 'utf8')
21 }
22
23 function message_author (msg, opts = {}) {
24 var { size = 'small' } = opts
25 var { value } = msg
26 var { author } = value
27
28 return h('MessageAuthor', {
29 className: `-${size}`
30 }, [
31 when(size !== 'mini',
32 h('section -image', api.avatar_link(author, api.avatar_image(author, 'thumbnail')))
33 ),
34 h('section -name', api.avatar_link(author, api.avatar_name(author))),
35 h('section -timestamp', api.timestamp(msg))
36 ])
37 }
38}
39
40

Built with git-ssb-web