git ssb

0+

alanz / patchwork



forked from Matt McKegg / patchwork

Commit a9d64b445268934597b0f1a9bcc2c433e1d994c0

profile: display other assigned names and images

Matt McKegg committed on 2/16/2017, 5:25:10 AM
Parent: 5cd9c24978c2e556596ba08fa0cc17a1d2ba0dc8

Files changed

modules/page/html/render/profile.jschanged
styles/profile-header.mcsschanged
styles/profile-list.mcsschanged
styles/split-view.mcsschanged
styles/picker.mcssadded
modules/page/html/render/profile.jsView
@@ -1,19 +1,26 @@
11 var nest = require('depnest')
22 var ref = require('ssb-ref')
3-var {Value, h, when, computed, map, send} = require('mutant')
3+var {Value, h, when, computed, map, send, dictToCollection} = require('mutant')
44 var extend = require('xtend')
55
66 exports.needs = nest({
7- 'about.obs.name': 'first',
7+ 'about.obs': {
8+ name: 'first',
9+ names: 'first',
10+ images: 'first',
11+ color: 'first'
12+ },
13+ 'blob.sync.url': 'first',
814 'about.html.image': 'first',
915 'feed.html.rollup': 'first',
1016 'sbot.pull.userFeed': 'first',
1117 'sbot.async.publish': 'first',
1218 'keys.sync.id': 'first',
1319 'profile.obs': {
1420 followers: 'first',
15- following: 'first'
21+ following: 'first',
22+ names: 'first'
1623 }
1724 })
1825 exports.gives = nest('page.html.render')
1926
@@ -53,30 +60,71 @@
5360 var youFollow = computed([yourFollows], function (youFollow) {
5461 return youFollow.has(id)
5562 })
5663
64+ var names = api.about.obs.names(id)
65+ var images = api.about.obs.images(id)
66+
67+ var namePicker = h('div', {className: 'Picker'}, [
68+ map(dictToCollection(names), (item) => {
69+ var isSelf = computed(item.value, (ids) => ids.includes(id))
70+ var isAssigned = computed(item.value, (ids) => ids.includes(yourId))
71+ return h('a.name', {
72+ classList: [
73+ when(isSelf, '-self'),
74+ when(isAssigned, '-assigned')
75+ ],
76+ title: nameList(when(isSelf, 'Self Assigned', 'Assigned By'), item.value)
77+ }, [
78+ item.key
79+ ])
80+ })
81+ ])
82+
83+ var imagePicker = h('div', {className: 'Picker'}, [
84+ map(dictToCollection(images), (item) => {
85+ var isSelf = computed(item.value, (ids) => ids.includes(id))
86+ var isAssigned = computed(item.value, (ids) => ids.includes(yourId))
87+ return h('a.name', {
88+ classList: [
89+ when(isSelf, '-self'),
90+ when(isAssigned, '-assigned')
91+ ],
92+ title: nameList(when(isSelf, 'Self Assigned', 'Assigned By'), item.value)
93+ }, [
94+ h('img', {
95+ className: 'Avatar',
96+ style: { 'background-color': api.about.obs.color(id) },
97+ src: computed(item.key, api.blob.sync.url)
98+ })
99+ ])
100+ })
101+ ])
102+
57103 var prepend = h('header', {className: 'ProfileHeader'}, [
58104 h('div.image', api.about.html.image(id)),
59- h('div.title', [
60- h('h1', ['@', name])
61- ]),
62- h('div.meta', [
63- when(id === yourId, [
64- h('a.-disabled', 'This is you!')
65- ], [
66- when(youFollow,
67- h('a.ToggleButton.-unsubscribe', {
68- 'href': '#',
69- 'title': 'Click to unfollow',
70- 'ev-click': send(unfollow, id)
71- }, when(isFriends, 'Friends', 'Following')),
72- h('a.ToggleButton.-subscribe', {
73- 'href': '#',
74- 'ev-click': send(follow, id)
75- }, when(followsYou, 'Follow Back', 'Follow'))
76- )
77- ])
78-
105+ h('div.main', [
106+ h('div.title', [
107+ h('h1', ['@', name]),
108+ h('div.meta', [
109+ when(id === yourId, [
110+ h('a.-disabled', 'This is you!')
111+ ], [
112+ when(youFollow,
113+ h('a.ToggleButton.-unsubscribe', {
114+ 'href': '#',
115+ 'title': 'Click to unfollow',
116+ 'ev-click': send(unfollow, id)
117+ }, when(isFriends, 'Friends', 'Following')),
118+ h('a.ToggleButton.-subscribe', {
119+ 'href': '#',
120+ 'ev-click': send(follow, id)
121+ }, when(followsYou, 'Follow Back', 'Follow'))
122+ )
123+ ])
124+ ])
125+ ]),
126+ h('section', [ namePicker, imagePicker ])
79127 ])
80128 ])
81129
82130 return h('div', {className: 'SplitView'}, [
@@ -109,9 +157,9 @@
109157 href: id
110158 }, [
111159 h('div.avatar', [api.about.html.image(id)]),
112160 h('div.main', [
113- h('div.name', [ api.about.obs.name(id) ])
161+ h('div.name', [ '@', api.about.obs.name(id) ])
114162 ])
115163 ])
116164 }, {
117165 idle: true
@@ -134,5 +182,12 @@
134182 contact: id,
135183 following: false
136184 })
137185 }
186+
187+ function nameList (prefix, ids) {
188+ var items = map(ids, api.about.obs.name)
189+ return computed([prefix, items], (prefix, names) => {
190+ return (prefix ? (prefix + '\n') : '') + names.map((n) => `- ${n}`).join('\n')
191+ })
192+ }
138193 }
styles/profile-header.mcssView
@@ -14,8 +14,14 @@
1414 width: 100%
1515 }
1616 }
1717
18- div.title {
18+ div.main {
1919 flex: 1
20+ div.title {
21+ display: flex
22+ h1 {
23+ flex: 1
24+ }
25+ }
2026 }
2127 }
styles/profile-list.mcssView
@@ -3,9 +3,9 @@
33 display: flex;
44 padding: 4px;
55 font-size: 110%;
66 margin: 4px 0;
7- background: rgba(255, 255, 255, 0.22);
7+ background: rgba(255, 255, 255, 0.74);
88 border-radius: 5px;
99 position: relative
1010 text-decoration: none
1111 transition: background-color 0.2s
@@ -30,8 +30,9 @@
3030 div.avatar {
3131 img {
3232 width: 40px
3333 height: 40px
34+ display: block
3435 }
3536 }
3637
3738 div.main {
@@ -42,9 +43,9 @@
4243 justify-content: center
4344 div.name {
4445 font-weight: bold
4546 font-size: 110%
46- color: #333
47+ color: #636363
4748 -webkit-mask-image: linear-gradient(90deg, rgba(0,0,0,1) 90%, rgba(0,0,0,0))
4849 }
4950 }
5051 }
styles/split-view.mcssView
@@ -9,16 +9,16 @@
99 }
1010 div.side {
1111 width: 280px;
1212 padding: 20px;
13- background: linear-gradient(100deg, #cee4ef, #efebeb);
13+ background: linear-gradient(81deg, #d2f0ff, #ffffff);
1414 border-right: 1px solid #dcdcdc;
1515 overflow-y: auto;
1616
1717 -right {
1818 border: none
1919 border-left: 1px solid #dcdcdc
20- background: linear-gradient(100deg, #ffffff, #efebeb)
20+ background: linear-gradient(100deg, #ffffff, #f9ecca);
2121 }
2222
2323 h2 {
2424 margin-top: 20px
styles/picker.mcssView
@@ -1,0 +1,29 @@
1+Picker {
2+ a {
3+ padding: 5px;
4+ display: inline-block;
5+ background: #fff;
6+ margin: 3px;
7+ border: 1px solid #EEE;
8+
9+ img {
10+ width: 50px
11+ height: 50px
12+ display: block
13+ }
14+
15+ -self {
16+ border-color: #b3d6bd;
17+ background: #fbfffb;
18+ color: #719a68;
19+ }
20+
21+ -assigned {
22+ padding: 3px;
23+ border: 2px solid #ffa800;
24+ box-shadow: 0px 1px 4px #ff8d00;
25+ color: #a8702a;
26+ font-weight: bold;
27+ }
28+ }
29+}

Built with git-ssb-web