git ssb

16+

Dominic / patchbay



Tree: 14d54b356c1ef57cc1dca625f3b0886b7c31de34

Files: 14d54b356c1ef57cc1dca625f3b0886b7c31de34 / modules_basic / message-author.js

908 bytesRaw
1var fs = require('fs')
2var Path = require('path')
3var h = require('../h')
4var when = require('@mmckegg/mutant/when')
5
6exports.needs = {
7 avatar_link: 'first',
8 avatar_image: 'first',
9 avatar_name: 'first',
10 timestamp: 'first'
11}
12
13exports.gives = {
14 message_author: true,
15 mcss: true
16}
17
18exports.create = function (api) {
19 return {
20 message_author,
21 mcss: () => fs.readFileSync(Path.join(__dirname, 'message-author.mcss'))
22 }
23
24 function message_author (msg, opts = {}) {
25 var { size = 1 } = opts
26 var { value } = msg
27 var { author } = value
28 return h('MessageAuthor', {
29 className: size === 0 ? '-mini' : ''
30 }, [
31 when(size > 0,
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