git ssb

16+

Dominic / patchbay



Commit d3dcc2d7640822834366e1c87af9581a92ef545e

re-style the friends/ followers/ follows

mix irving committed on 1/25/2017, 8:07:55 AM
Parent: 6eca4b03ca9a3af5f7c0fdae5472d5910db9b768

Files changed

modules_basic/avatar/profile.jschanged
modules_basic/avatar/profile.mcssadded
modules_basic/avatar/profile.jsView
@@ -1,79 +1,87 @@
1-var h = require('hyperscript')
2-var pull = require('pull-stream')
1 +const fs = require('fs')
2 +const h = require('../../h')
3 +const pull = require('pull-stream')
4 +const { unique, collect, drain } = pull
35
6 +
47 exports.needs = {
58 avatar_image_link: 'first',
69 avatar_action: 'map',
710 avatar_edit: 'first',
811 follows: 'first',
912 followers: 'first'
1013 }
1114
12-exports.gives = 'avatar_profile'
13-
14-function streamToList(stream, el) {
15- pull(
16- stream,
17- pull.drain(function (item) {
18- if(item) el.appendChild(item)
19- })
20- )
21- return el
15 +exports.gives = {
16 + avatar_profile: true,
17 + mcss: true
2218 }
2319
2420 exports.create = function (api) {
25-
26- function image_link (id) {
27- return api.avatar_image_link(id, 'thumbnail')
21 + return {
22 + avatar_profile,
23 + mcss: () => fs.readFileSync(__filename.replace(/js$/, 'mcss'), 'utf8')
2824 }
2925
30- return function (id) {
26 + function avatar_profile (id) {
3127
32- var follows_el = h('div.profile__follows.wrap')
33- var friends_el = h('div.profile__friendss.wrap')
34- var followers_el = h('div.profile__followers.wrap')
28 + var friends_el = h('div.friends', [
29 + h('header', 'Friends')
30 + ])
31 + var follows_el = h('div.follows', [
32 + h('header', 'Follows')
33 + ])
34 + var followers_el = h('div.followers', [
35 + h('header', 'Followers')
36 + ])
3537 var a, b
3638
37- pull(api.follows(id), pull.unique(), pull.collect(function (err, ary) {
38- a = ary || []; next()
39- }))
40- pull(api.followers(id), pull.unique(), pull.collect(function (err, ary) {
41- b = ary || {}; next()
42- }))
39 + pull(
40 + api.follows(id),
41 + unique(),
42 + collect((err, ary = []) => {
43 + a = ary; next()
44 + })
45 + )
46 + pull(
47 + api.followers(id),
48 + unique(),
49 + collect((err, ary = {}) => {
50 + b = ary; next()
51 + })
52 + )
4353
4454 function next () {
4555 if(!(a && b)) return
4656 var _c = [], _a = [], _b = []
4757
48- a.forEach(function (id) {
58 + a.forEach(id => {
4959 if(!~b.indexOf(id)) _a.push(id)
5060 else _c.push(id)
5161 })
52- b.forEach(function (id) {
62 + b.forEach(id => {
5363 if(!~_c.indexOf(id)) _b.push(id)
5464 })
55- function add (ary, el) {
56- ary.forEach(function (id) { el.appendChild(image_link(id)) })
57- }
5865
66 + add(_c, friends_el)
5967 add(_a, follows_el)
60- add(_c, friends_el)
6168 add(_b, followers_el)
69 +
70 + function add (ary, el) {
71 + ary.forEach(id => el.appendChild(api.avatar_image_link(id)) )
72 + }
6273 }
6374
6475
65- return h('div.column.profile',
66- api.avatar_edit(id),
67- api.avatar_action(id),
68- h('div.profile__relationships.column',
69- h('strong', 'follows'),
76 + return h('Profile', [
77 + h('section.edit', api.avatar_edit(id)),
78 + h('section.action', api.avatar_action(id)),
79 + h('section.relationships', [
80 + friends_el,
7081 follows_el,
71- h('strong', 'friends'),
72- friends_el,
73- h('strong', 'followers'),
7482 followers_el
75- )
76- )
83 + ])
84 + ])
7785 }
7886
7987 }
modules_basic/avatar/profile.mcssView
@@ -1,0 +1,69 @@
1 +Profile {
2 + section.edit {
3 +
4 + }
5 +
6 + section.action {
7 +
8 + }
9 +
10 + section.relationships {
11 + div {
12 + display: flex
13 + flex-wrap: wrap
14 + justify-content: space-between
15 + align-content: flex-start
16 +
17 + min-height: 5rem
18 + margin: 1rem 0
19 +
20 + header {
21 + flex-basis: 100%
22 +
23 + margin-bottom: .2rem
24 + }
25 +
26 + a {
27 + margin-right: .1rem
28 +
29 +
30 + img { $avatar-small }
31 + }
32 +
33 +
34 + }
35 +
36 + div.friends {
37 + a {
38 + margin: 0 .15rem 0.2rem 0
39 +
40 + img {
41 + $avatar-large
42 + }
43 + }
44 +
45 + }
46 +
47 + div.follows {
48 +
49 + }
50 +
51 + div.followers {
52 +
53 + }
54 + }
55 +}
56 +
57 +$avatar-portrait {
58 +}
59 +
60 +$avatar-large {
61 + width: 58px
62 + height: 58px
63 +}
64 +
65 +$avatar-small {
66 + width: 32px
67 + height: 32px
68 +}
69 +

Built with git-ssb-web