git ssb

2+

mixmix / ticktack



Commit e4aaa311b7efe7bf2540be819c77348f258eb18d

add working addressBook sections, styling

mix committed on 1/30/2018, 3:44:32 AM
Parent: 0b0275502152a806a995b36fd4d29e8c3df1195e

Files changed

app/html/sideNav/sideNavAddressBook.jschanged
app/html/topNav/topNavAddressBook.jschanged
app/html/topNav/topNavAddressBook.mcsschanged
app/page/addressBook.jschanged
app/page/addressBook.mcsschanged
contact/html/follow.jschanged
styles/button.mcsschanged
translations/en.jschanged
app/html/sideNav/sideNavAddressBook.jsView
@@ -14,9 +14,9 @@
1414 // 'app.html.scroller': 'first',
1515 // 'about.html.avatar': 'first',
1616 // 'about.obs.name': 'first',
1717 // 'feed.pull.private': 'first',
18- // 'history.sync.push': 'first',
18+ 'history.sync.push': 'first',
1919 // 'message.html.subject': 'first',
2020 // 'sbot.obs.localPeers': 'first',
2121 'translations.sync.strings': 'first',
2222 // 'unread.sync.isUnread': 'first'
@@ -28,10 +28,12 @@
2828 })
2929
3030 function sideNav (location, relationships) {
3131 if (location.page !== 'addressBook') return
32+ if (!location.section) location.section = 'friends'
3233
3334 const strings = api.translations.sync.strings().addressBook
35+ const goTo = (loc) => () => api.history.sync.push(loc)
3436
3537 // TODO - show local peers?
3638 // var nearby = api.sbot.obs.localPeers()
3739
@@ -39,40 +41,47 @@
3941 LevelOneSideNav(),
4042 ])
4143
4244 function LevelOneSideNav () {
43- function count (relationshipType) {
44- return computed(relationships, rels => rels[relationshipType].length)
45- }
46-
4745 return h('div.level.-one', [
4846 h('section', [
49- h('Option', [
50- h('Button -primary', {}, strings.action.addUser),
47+ SectionOption('search', [
48+ h('Button -primary', {}, strings.action.addUser)
5149 ]),
5250 h('hr'),
5351 ]),
5452
5553 //Friends
5654 h('section', [
5755 h('header',strings.heading.people),
58- h('Option', [
59- h('i.fa.fa-angle-right'),
60- strings.section.friends,
61- h('div.count', count('friends'))
62- ]),
63- h('Option',[
64- h('i.fa.fa-angle-right'),
65- strings.section.following,
66- h('div.count', count('following'))
67- ]),
68- h('Option',[
69- h('i.fa.fa-angle-right'),
70- strings.section.followers,
71- h('div.count', count('followers'))
72- ]),
56+ SectionOption('friends'),
57+ SectionOption('following'),
58+ SectionOption('followers'),
7359 ])
7460 ])
7561 }
62+
63+ function SectionOption (section, body) {
64+ const className = section === location.section
65+ ? '-selected'
66+ : ''
67+ return h('Option',
68+ { className, 'ev-click': goTo({page: 'addressBook', section }) },
69+ body || defaulBody(section)
70+ )
71+
72+ function defaulBody (section) {
73+ return [
74+ h('i.fa.fa-angle-right'),
75+ strings.section[section],
76+ h('div.count', count(section))
77+ ]
78+ }
79+ }
80+
81+ function count (relationshipType) {
82+ return computed(relationships, rels => rels[relationshipType].length)
83+ }
7684 }
7785 }
7886
87+
app/html/topNav/topNavAddressBook.jsView
@@ -17,9 +17,9 @@
1717 return h('TopNav -addressBook', [
1818 h('div.search', [
1919 h('i.fa.fa-search'),
2020 h('input', {
21- placeholder: strings.userFind.action.findAUser,
21+ placeholder: strings.addressBook.action.find[location.section],
2222 autofocus: 'autofocus',
2323 'ev-input': e => input.set(e.target.value)
2424 }),
2525 ])
app/html/topNav/topNavAddressBook.mcssView
@@ -1,6 +1,7 @@
11 TopNav -addressBook {
22 div.search {
3+ flex-grow: 1
34 $backgroundPrimaryText
45
56 margin-bottom: .5rem
67
app/page/addressBook.jsView
@@ -12,12 +12,14 @@
1212
1313 exports.needs = nest({
1414 'about.html.avatar': 'first',
1515 'about.async.suggest': 'first',
16+ 'about.obs.name': 'first',
1617 'app.html.topNav': 'first',
1718 // 'app.html.scroller': 'first',
1819 'app.html.sideNav': 'first',
1920 'app.html.topNav': 'first',
21+ 'contact.html.follow': 'first',
2022 'contact.obs.relationships': 'first',
2123 'history.sync.push': 'first',
2224 'keys.sync.id': 'first',
2325 'translations.sync.strings': 'first',
@@ -37,26 +39,37 @@
3739
3840 const input = Value()
3941
4042 const suggester = api.about.async.suggest()
41- const users = computed(input, input => suggester(input))
42- // might further prune this based on section
43+ const users = computed([relationships, input], (relationships, input) => {
44+ if (section === SEARCH)
45+ return suggester(input)
46+ else {
47+ const sectionRels = relationships[section]
48+ if (!input) // show all e.g. friends
49+ return sectionRels.map(id => {
50+ return { id, title: api.about.obs.name(id) }
51+ })
52+ else // show suggestions, and filter just the ones we want e.g. friends
53+ return suggester(input).filter(user => sectionRels.includes(user.id))
54+ }
55+ })
4356
57+ const goTo = (loc) => () => api.history.sync.push(loc)
4458
45- // const goTo = (loc) => () => api.history.sync.push(loc)
46-
4759 return h('Page -addressBook', [
4860 api.app.html.sideNav(location, relationships),
4961 h('Scroller.content', [
5062 h('section.top', [
5163 api.app.html.topNav(location, input),
5264 ]),
5365 h('section.content', [
5466 h('div.results', map(users, user => {
55- return h('div.result', [
67+ return h('div.result', { 'ev-click': goTo({page: 'userShow', feed: user.id}) }, [
5668 api.about.html.avatar(user.id),
5769 h('div.alias', user.title),
58- h('pre.key', user.id),
70+ // h('pre.key', user.id),
71+ api.contact.html.follow(user.id)
5972 ])
6073 })),
6174 ])
6275 ])
app/page/addressBook.mcssView
@@ -6,13 +6,18 @@
66 position: sticky
77 }
88
99 section.content {
10+ $maxWidthSmaller
11+
1012 div.results {
13+ flex-grow: 1
14+
1115 $maxWidthSmaller
1216
1317 div.result {
1418 $backgroundPrimaryText
19+ cursor: pointer
1520
1621 padding: .5rem
1722
1823 display: flex
@@ -32,8 +37,10 @@
3237 color: #999
3338
3439 }
3540
41+ div.Follow {}
42+
3643 :hover {
3744 background-color: #eee
3845
3946 }
contact/html/follow.jsView
@@ -23,16 +23,23 @@
2323 const { followers } = api.contact.obs
2424 const theirFollowers = followers(feed)
2525 const youFollowThem = computed(theirFollowers, followers => followers.includes(myId))
2626
27- const { unfollow, follow } = api.contact.async
2827 const className = when(youFollowThem, '-following')
28+ const follow = (feed) => ev => {
29+ ev.stopPropagation()
30+ api.contact.async.follow(feed)
31+ }
32+ const unfollow = (feed) => ev => {
33+ ev.stopPropagation()
34+ api.contact.async.unfollow(feed)
35+ }
2936
3037 return h('Follow', { className },
3138 when(theirFollowers.sync,
3239 when(youFollowThem,
33- h('Button', { 'ev-click': () => unfollow(feed) }, strings.userShow.action.unfollow),
34- h('Button', { 'ev-click': () => follow(feed) }, strings.userShow.action.follow)
40+ h('Button', { 'ev-click': unfollow(feed) }, strings.userShow.action.unfollow),
41+ h('Button -strong', { 'ev-click': follow(feed) }, strings.userShow.action.follow)
3542 ),
3643 h('Button', { disabled: 'disabled' }, strings.loading )
3744 )
3845 )
styles/button.mcssView
@@ -36,9 +36,8 @@
3636 -strong {
3737 $colorPrimary
3838 $font
3939 $borderPrimary
40-
4140 }
4241
4342 -channel {
4443 $backgroundPrimary
translations/en.jsView
@@ -62,9 +62,15 @@
6262 }
6363 },
6464 addressBook: {
6565 action: {
66- addUser: 'Add a user'
66+ addUser: 'Add a user',
67+ find: {
68+ friends: 'Search your friends',
69+ following: "Search people you're following",
70+ followers: 'Search your followers',
71+ search: 'Search for a user',
72+ }
6773 },
6874 heading: {
6975 people: 'People'
7076 },

Built with git-ssb-web