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