Files: 14d54b356c1ef57cc1dca625f3b0886b7c31de34 / modules_basic / message-author.js
908 bytesRaw
1 | var fs = require('fs') |
2 | var Path = require('path') |
3 | var h = require('../h') |
4 | var when = require('@mmckegg/mutant/when') |
5 | |
6 | exports.needs = { |
7 | avatar_link: 'first', |
8 | avatar_image: 'first', |
9 | avatar_name: 'first', |
10 | timestamp: 'first' |
11 | } |
12 | |
13 | exports.gives = { |
14 | message_author: true, |
15 | mcss: true |
16 | } |
17 | |
18 | exports.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