Commit d9e40e563621b8ed8d5c36ddadfc5c42d2a01e7e
Merge branch 'avatar_edit'
Dominic Tarr committed on 7/25/2016, 12:46:07 AMParent: 25c84eb21bc4e067eac8085385882db73bf9bde8
Parent: d6a90dfc953abdf9ee85b3f196aa569ec8bda3ac
Files changed
modules/avatar-profile.js | changed |
modules/index.js | changed |
modules/relationships.js | added |
style.css | 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 | + |
modules/index.js | ||
---|---|---|
@@ -11,8 +11,9 @@ | ||
11 | 11 | "crypto.js": require('./crypto.js'), |
12 | 12 | "feed.js": require('./feed.js'), |
13 | 13 | "file-input.js": require('./file-input.js'), |
14 | 14 | "follow.js": require('./follow.js'), |
15 | + "relationships.js": require('./relationships.js'), | |
15 | 16 | "invite.js": require('./invite.js'), |
16 | 17 | "like.js": require('./like.js'), |
17 | 18 | "markdown.js": require('./markdown.js'), |
18 | 19 | "message-confirm.js": require('./message-confirm.js'), |
modules/relationships.js | ||
---|---|---|
@@ -1,0 +1,23 @@ | ||
1 | + | |
2 | +var plugs = require('../plugs') | |
3 | + | |
4 | +var sbot_links2 = plugs.first(exports.sbot_links2 = []) | |
5 | + | |
6 | +//this is a bit crude, and doesn't actually show unfollows yet. | |
7 | + | |
8 | +exports.follows = function (id, cb) { | |
9 | + return sbot_links2({query: [ | |
10 | + {"$filter": {"source": id, "rel": ["contact", true, false] }}, | |
11 | + {"$map": "dest"} | |
12 | + ]}) | |
13 | +} | |
14 | + | |
15 | +exports.followers = function (id) { | |
16 | + return sbot_links2({query: [ | |
17 | + {"$filter": {"dest": id, "rel": ["contact", true, false] }}, | |
18 | + {"$map": "source"} | |
19 | + ]}) | |
20 | +} | |
21 | + | |
22 | + | |
23 | + |
style.css | ||
---|---|---|
@@ -22,8 +22,14 @@ | ||
22 | 22 | display: flex; |
23 | 23 | flex-direction: row; |
24 | 24 | } |
25 | 25 | |
26 | +.wrap { | |
27 | + display: flex; | |
28 | + flex-direction: row; | |
29 | + flex-wrap: wrap; | |
30 | +} | |
31 | + | |
26 | 32 | .stretch { |
27 | 33 | flex-basis: 0; |
28 | 34 | } |
29 | 35 | |
@@ -273,4 +279,13 @@ | ||
273 | 279 | |
274 | 280 | .hypercrop__canvas { |
275 | 281 | width: 100%; |
276 | 282 | } |
283 | + | |
284 | +.profile__follows img, .profile__followers img { | |
285 | + width: 40px; | |
286 | + height: 40px; | |
287 | + margin-right: 3px; | |
288 | + border: 1px solid #ccc; | |
289 | +} | |
290 | + | |
291 | + |
Built with git-ssb-web