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