Files: 25a8b716544bd1f58eeba52a1feb6bb5a6eb78ae / modules_basic / message-author.js
907 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 = '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