git ssb

16+

Dominic / patchbay



Tree: b4a12543a07fd041ced6d5f8589af61a578fc331

Files: b4a12543a07fd041ced6d5f8589af61a578fc331 / modules_basic / about.js

1458 bytesRaw
1var h = require('../h')
2
3//var blob_url = require('../plugs').first(exports.blob_url = [])
4
5exports.needs = {
6 blob_url: 'first'
7}
8
9exports.gives = {
10 mcss: true,
11 message_content: true
12}
13
14var mcss = `
15 About {
16 display: flex
17 flex-wrap: wrap
18
19 header {
20 margin-right: .4rem
21 }
22 }
23`
24
25exports.create = function (api) {
26 return {
27 message_content,
28 mcss: function () { return mcss }
29 }
30
31 function message_content (msg) {
32 if(msg.value.content.type !== 'about') return
33
34 var about = msg.value.content
35 var { about: aboutId, name, image, description } = about
36
37 // if(!image && !name) return
38
39 return h('div', {className: 'About'}, [
40 verb({ aboutId, authorId: msg.value.author }),
41 profile({ aboutId, name, image, description, api })
42 ])
43 }
44}
45
46
47function verb ({ aboutId, authorId }) {
48 var content = authorId === aboutId
49 ? 'self-identifies as'
50 : ['identifies ', idLink(aboutId), ' as']
51
52 return h('header', content)
53}
54
55function profile ({ aboutId, name, image, description, api }) {
56 return h('div', [
57 name
58 ? h('a', {href:'#'+aboutId}, name)
59 : null,
60 image
61 ? h('a', {href:'#'+aboutId}, h('img.avatar--fullsize', {src: api.blob_url(image)}))
62 : null,
63 description || null
64 ])
65}
66
67function idLink (id) {
68 if (!id) return null
69
70 return h('a', {href:'#'+id}, id.slice(0,9) + '...')
71}
72
73function asLink (ln) {
74 return typeof ln === 'string' ? ln : ln.link
75}
76
77

Built with git-ssb-web