Commit 108d820b09fd85d159865f851eac43f82f21766f
refactor about to display name/ img/ description
mix irving authored on 12/20/2016, 5:28:20 AMMichael Williams committed on 12/23/2016, 7:27:15 AM
Parent: a5445e6bcd23a22f2da4671b84e81eedc42d81a6
Files changed
modules_basic/about.js | changed |
package.json | changed |
h.js | added |
modules_basic/about.js | ||
---|---|---|
@@ -1,15 +1,6 @@ | ||
1 … | +var h = require('../h') | |
1 | 2 … | |
2 | -var h = require('hyperscript') | |
3 | - | |
4 | -function idLink (id) { | |
5 | - return h('a', {href:'#'+id}, id) | |
6 | -} | |
7 | - | |
8 | -function asLink (ln) { | |
9 | - return 'string' === typeof ln ? ln : ln.link | |
10 | -} | |
11 | - | |
12 | 3 … | //var blob_url = require('../plugs').first(exports.blob_url = []) |
13 | 4 … | |
14 | 5 … | exports.needs = { |
15 | 6 … | blob_url: 'first' |
@@ -17,32 +8,46 @@ | ||
17 | 8 … | |
18 | 9 … | exports.gives = 'message_content' |
19 | 10 … | |
20 | 11 … | exports.create = function (api) { |
21 | - | |
22 | 12 … | return function (msg) { |
23 | 13 … | if(msg.value.content.type !== 'about') return |
24 | 14 … | |
25 | - if(!msg.value.content.image && !msg.value.content.name) | |
26 | - return | |
27 | - | |
28 | 15 … | var about = msg.value.content |
29 | - var id = msg.value.content.about | |
30 | - return h('p', | |
31 | - about.about === msg.value.author | |
32 | - ? h('span', 'self-identifies ') | |
33 | - : h('span', 'identifies ', idLink(id)), | |
34 | - ' as ', | |
35 | - h('a', {href:"#"+about.about}, | |
36 | - about.name || null, | |
37 | - about.image | |
38 | - ? h('img.avatar--fullsize', {src: api.blob_url(about.image)}) | |
39 | - : null | |
40 | - ) | |
41 | - ) | |
16 … | + var { about: aboutId, name, image, description } = about | |
42 | 17 … | |
18 … | + // if(!image && !name) return | |
19 … | + | |
20 … | + return h('.About', {}, [ | |
21 … | + verb({ aboutId, authorId: msg.value.author }), | |
22 … | + profile({ aboutId, name, image, description }) | |
23 … | + ]) | |
43 | 24 … | } |
25 … | +} | |
44 | 26 … | |
27 … | + | |
28 … | +function verb ({ aboutId, authorId }) { | |
29 … | + return authorId === aboutId | |
30 … | + ? h('span', 'self-identifies as') | |
31 … | + : h('span', ['identifies ', idLink(aboutId), ' as ']) | |
45 | 32 … | } |
46 | 33 … | |
34 … | +function profile ({ aboutId, name, image, description }) { | |
35 … | + return h('div', [ | |
36 … | + name | |
37 … | + ? h('a', {href:'#'+aboutId}, name) | |
38 … | + : null, | |
39 … | + image | |
40 … | + ? h('a', {href:'#'+aboutId}, h('img.avatar--fullsize', {src: api.blob_url(image)})) | |
41 … | + : null, | |
42 … | + description || null | |
43 … | + ]) | |
44 … | +} | |
47 | 45 … | |
46 … | +function idLink (id) { | |
47 … | + return h('a', {href:'#'+id}, id) | |
48 … | +} | |
48 | 49 … | |
50 … | +function asLink (ln) { | |
51 … | + return typeof ln === 'string' ? ln : ln.link | |
52 … | +} | |
53 … | + |
package.json | ||
---|---|---|
@@ -7,8 +7,9 @@ | ||
7 | 7 … | "type": "git", |
8 | 8 … | "url": "git://github.com/dominictarr/patchbay.git" |
9 | 9 … | }, |
10 | 10 … | "dependencies": { |
11 … | + "@mmckegg/mutant": "^3.10.1", | |
11 | 12 … | "cont": "^1.0.3", |
12 | 13 … | "dataurl-": "^0.1.0", |
13 | 14 … | "depject": "^3.0.0", |
14 | 15 … | "hjson": "^2.0.3", |
@@ -22,8 +23,9 @@ | ||
22 | 23 … | "hypertabs": "^3.0.0", |
23 | 24 … | "is-visible": "^2.0.4", |
24 | 25 … | "kvgraph": "^0.1.0", |
25 | 26 … | "map-filter-reduce": "^3.0.1", |
27 … | + "micro-css": "^0.6.2", | |
26 | 28 … | "mime-types": "^2.1.11", |
27 | 29 … | "moment": "^2.13.0", |
28 | 30 … | "open-external": "^0.1.1", |
29 | 31 … | "peaks.js": "^0.4.7", |
Built with git-ssb-web