Files: c7e6d29b42d5c8650b1fdc63b08926ade061eb38 / modules / avatar-profile.js
1220 bytesRaw
1 | var h = require('hyperscript') |
2 | var plugs = require('../plugs') |
3 | var pull = require('pull-stream') |
4 | |
5 | var avatar_image = plugs.first(exports.avatar_image = []) |
6 | var avatar_name = plugs.first(exports.avatar_name = []) |
7 | var avatar_action = plugs.map(exports.avatar_action = []) |
8 | var avatar_edit = plugs.first(exports.avatar_edit = []) |
9 | |
10 | var follows = plugs.first(exports.follows = []) |
11 | var followers = plugs.first(exports.followers = []) |
12 | |
13 | function streamToList(stream, el) { |
14 | pull( |
15 | stream, |
16 | pull.drain(function (item) { |
17 | if(item) el.appendChild(item) |
18 | }) |
19 | ) |
20 | return el |
21 | } |
22 | |
23 | function image_link (id) { |
24 | return h('a', {href:'#'+id}, avatar_image(id, 'thumbnail')) |
25 | } |
26 | |
27 | exports.avatar_profile = function (id) { |
28 | return h('div.column.profile', |
29 | avatar_edit(id), |
30 | avatar_action(id), |
31 | |
32 | h('div.profile__relationships.column', |
33 | |
34 | h('strong', 'follows'), |
35 | streamToList(pull( |
36 | follows(id), |
37 | pull.unique(), |
38 | pull.map(image_link) |
39 | ), h('div.profile__follows.wrap')), |
40 | |
41 | h('strong', 'followers'), |
42 | streamToList(pull( |
43 | followers(id), |
44 | pull.unique(), |
45 | pull.map(image_link) |
46 | ), h('div.profile__followers.wrap')) |
47 | ) |
48 | ) |
49 | } |
50 | |
51 |
Built with git-ssb-web