git ssb

16+

Dominic / patchbay



Tree: 1462eddad93e346c412fe00dd5fb4468adf1ee04

Files: 1462eddad93e346c412fe00dd5fb4468adf1ee04 / modules_basic / message-author.js

907 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 = 'small' } = opts
26 var { value } = msg
27 var { author } = value
28
29 return h('MessageAuthor', {
30 className: `-${size}`
31 }, [
32 when(size !== 'mini',
33 h('section -image', api.avatar_link(author, api.avatar_image(author, 'thumbnail')))
34 ),
35 h('section -name', api.avatar_link(author, api.avatar_name(author))),
36 h('section -timestamp', api.timestamp(msg))
37 ])
38 }
39}
40
41

Built with git-ssb-web