Commit fde7d979deffdab338ae5365f6fde27e502bf01a
show follow, unfollow link, and show follows/followers
Dominic Tarr committed on 7/25/2016, 12:35:23 AMParent: b67ed19d6fbf76c870c96c70cb920c9eda385257
Files changed
modules/avatar-profile.js | changed |
modules/avatar-profile.js | ||
---|---|---|
@@ -1,19 +1,59 @@ | ||
1 | 1 | var h = require('hyperscript') |
2 | 2 | var plugs = require('../plugs') |
3 | +var pull = require('pull-stream') | |
3 | 4 | |
4 | - | |
5 | 5 | var avatar_image = plugs.first(exports.avatar_image = []) |
6 | 6 | var avatar_name = plugs.first(exports.avatar_name = []) |
7 | 7 | var avatar_action = plugs.map(exports.avatar_action = []) |
8 | 8 | var avatar_edit = plugs.first(exports.avatar_edit = []) |
9 | 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.unique(function (e) { return e }), | |
17 | + pull.drain(function (item) { | |
18 | + if(item) el.appendChild(item) | |
19 | + }) | |
20 | + ) | |
21 | + return el | |
22 | +} | |
23 | + | |
24 | +function image_link (id) { | |
25 | + return h('a', {href:'#'+id}, avatar_image(id)) | |
26 | +} | |
27 | + | |
10 | 28 | exports.avatar_profile = function (id) { |
11 | - return avatar_edit(id) | |
29 | + return h('div.column.profile', | |
30 | + avatar_edit(id), | |
31 | + avatar_action(id), | |
12 | 32 | |
13 | - return h('div.row.profile', | |
14 | - avatar_image(id), | |
15 | - h('div.profile__info', | |
16 | - h('strong', avatar_name(id)), | |
17 | - avatar_action(id)) | |
33 | + h('div.profile__relationships.column', | |
34 | + | |
35 | + h('strong', 'follows'), | |
36 | + streamToList(pull( | |
37 | + follows(id), | |
38 | + pull.unique(), | |
39 | + pull.map(image_link) | |
40 | + ), h('div.profile__follows.wrap')), | |
41 | + | |
42 | + h('strong', 'followers'), | |
43 | + streamToList(pull( | |
44 | + followers(id), | |
45 | + pull.unique(), | |
46 | + pull.map(image_link) | |
47 | + ), h('div.profile__followers.wrap')) | |
48 | + ) | |
18 | 49 | ) |
19 | 50 | } |
51 | + | |
52 | + | |
53 | + | |
54 | + | |
55 | + | |
56 | + | |
57 | + | |
58 | + | |
59 | + |
Built with git-ssb-web