git ssb

2+

mixmix / ticktack



Commit ec8cfe66cd3dbfa8ddc119bae4546fb25f8c8fd5

Merge pull request #16 from ticktackim/profile

Profile
mix irving authored on 8/16/2017, 6:30:20 AM
GitHub committed on 8/16/2017, 6:30:20 AM
Parent: 38e0417253d2dc77736737889d97f936df7f35a0
Parent: 31dca712149ea746e5ee65adb698bb4ce4a82c4e

Files changed

app/html/link.jschanged
app/html/link.mcsschanged
app/html/thread-card.jschanged
app/html/thread-card.mcssadded
app/page/home.jschanged
app/page/home.mcsschanged
app/page/userShow.jschanged
app/page/userShow.mcssadded
styles/global.mcsschanged
styles/button.mcssadded
styles/markdown.mcssadded
translations/sync.jschanged
app/html/link.jsView
@@ -9,9 +9,10 @@
99
1010 exports.create = (api) => {
1111 return nest('app.html.link', (location, body) => {
1212 return h('Link', {
13- 'ev-click': () => api.history.sync.push(location)
13+ 'ev-click': () => api.history.sync.push(location),
14+ className: typeof body === 'string' ? '-string' : ''
1415 }, body)
1516 })
1617 }
1718
app/html/link.mcssView
@@ -1,6 +1,10 @@
11 Link {
22 color: blue
3- :hover {
4- text-decoration: underline
3+
4+ -string {
5+ :hover {
6+ text-decoration: underline
7+ }
58 }
69 }
10+
app/html/thread-card.jsView
@@ -88,9 +88,9 @@
8888 const onClick = opts.onClick || function () { api.history.sync.push(thread) }
8989 const id = `${thread.key}-${JSON.stringify(opts)}`
9090 // id is only here to help morphdom morph accurately
9191
92- return h('div.thread', { 'ev-click': onClick, id }, [
92+ return h('ThreadCard', { 'ev-click': onClick, id }, [
9393 h('div.context', threadIcon(thread)),
9494 h('div.content', [
9595 subjectEl,
9696 replySample ? h('div.reply', [
app/html/thread-card.mcssView
@@ -1,0 +1,42 @@
1+ThreadCard {
2+ display: flex
3+ align-items: center
4+
5+ margin-bottom: .5rem
6+
7+ div.context {
8+ display: flex
9+ margin-right: 1rem
10+
11+ img {
12+ $smallAvatar
13+ margin-right: .5rem
14+ }
15+ }
16+
17+ div.content {
18+ flex-grow: 1
19+ background: #fff
20+ padding: 1rem
21+ border: 1px solid #ddd
22+ border-radius: 2px
23+
24+ div.subject {
25+ font-size: 1.2rem
26+ margin-bottom: .3rem
27+
28+ $largeMarkdown
29+ }
30+ div.reply {
31+ display: flex
32+ color: #444
33+
34+ div.replySymbol {
35+ margin-left: .7rem
36+ margin-right: .3rem
37+ }
38+
39+ $smallMarkdown
40+ }
41+ }
42+}
app/page/home.jsView
@@ -30,9 +30,8 @@
3030 return nest('app.page.home', function (location) {
3131 // location here can expected to be: { page: 'home' }
3232 var strings = api.translations.sync.strings()
3333
34- var container = h('div.container', [])
3534
3635 // function filterForThread (thread) {
3736 // if(thread.value.private)
3837 // return {private: toRecpGroup(thread)}
@@ -69,8 +68,9 @@
6968 morePlease = true
7069 requestIdleCallback(threadsObs.more)
7170 }
7271
72+ var container = h('div.container', [])
7373 var threadsHtmlObs = More(
7474 threadsObsDebounced,
7575 function render (threads) {
7676
@@ -106,21 +106,19 @@
106106 h('div.container', [
107107 //private section
108108 h('section.updates -directMessage', [
109109 h('div.threads',
110- groupedThreads
111- .map(function (thread) {
110+ groupedThreads.map(thread => {
111+ const channel = thread.value.content.channel
112+ const onClick = channel
113+ ? (ev) => api.history.sync.push({ channel })
114+ : null // threadCard will install default onClick
112115
113- const channel = thread.value.content.channel
114- const onClick = channel
115- ? (ev) => api.history.sync.push({ channel })
116- : null // threadCard will install default onClick
117-
118- return api.app.html.threadCard(thread, { onClick })
116+ return api.app.html.threadCard(thread, { onClick })
119117 })
120118 )
121- ]),
122- ])
119+ ])
120+ ])
123121 )
124122
125123 return container
126124 }
app/page/home.mcssView
@@ -9,9 +9,9 @@
99 -directMessage {
1010 $homePageSection
1111
1212 div.threads {
13- div.thread {
13+ div.ThreadCard {
1414 div.content {
1515 div.subject {
1616 display: flex
1717
@@ -33,9 +33,9 @@
3333 -channel {
3434 $homePageSection
3535
3636 div.threads {
37- div.thread {
37+ div.ThreadCard {
3838 div.context {
3939 background: #fff
4040 min-width: 8rem
4141 padding: .1rem .3rem
@@ -73,48 +73,7 @@
7373 margin-bottom: .4rem
7474 }
7575
7676 div.threads {
77- div.thread {
78- display: flex
79- align-items: center
80-
81- margin-bottom: .5rem
82-
83- div.context {
84- display: flex
85- margin-right: 1rem
86-
87- img {
88- $smallAvatar
89- margin-right: .5rem
90- }
91- }
92-
93- div.content {
94- flex-grow: 1
95- background: #fff
96- padding: 1rem
97- border: 1px solid #ddd
98- border-radius: 2px
99-
100- div.subject {
101- font-size: 1.2rem
102- margin-bottom: .3rem
103-
104- $largeMarkdown
105- }
106- div.reply {
107- display: flex
108- color: #444
109-
110- div.replySymbol {
111- margin-left: .7rem
112- margin-right: .3rem
113- }
114-
115- $smallMarkdown
116- }
117- }
118- }
77+ div.ThreadCard {}
11978 }
12079 }
app/page/userShow.jsView
@@ -1,36 +1,97 @@
11 const nest = require('depnest')
2-const { h } = require('mutant')
2+const { h, Array: MutantArray, computed, when, map } = require('mutant')
3+const pull = require('pull-stream')
4+const get = require('lodash/get')
35
46 exports.gives = nest('app.page.userShow')
57
68 exports.needs = nest({
79 'app.html.link': 'first',
810 'app.html.nav': 'first',
11+ 'app.html.threadCard': 'first',
912 'about.html.image': 'first',
1013 'about.obs.name': 'first',
14+ 'contact.async.follow': 'first',
15+ 'contact.async.unfollow': 'first',
16+ 'contact.obs.followers': 'first',
17+ 'feed.pull.private': 'first',
18+ 'feed.pull.rollup': 'first',
1119 'keys.sync.id': 'first',
20+ 'state.obs.threads': 'first',
21+ 'translations.sync.strings': 'first',
1222 })
1323
1424 exports.create = (api) => {
1525 return nest('app.page.userShow', userShow)
1626
1727 function userShow (location) {
1828
1929 const { feed } = location
20- const Link = api.app.html.link
2130 const myId = api.keys.sync.id()
2231
32+ const strings = api.translations.sync.strings()
33+
34+ const { followers } = api.contact.obs
35+
36+ const youFollowThem = computed(followers(feed), followers => followers.has(myId))
37+ const theyFollowYou = computed(followers(myId), followers => followers.has(feed))
38+ const youAreFriends = computed([youFollowThem, theyFollowYou], (a, b) => a && b)
39+
40+ const ourRelationship = computed(
41+ [youAreFriends, youFollowThem, theyFollowYou],
42+ (youAreFriends, youFollowThem, theyFollowYou) => {
43+ if (youAreFriends) return strings.userShow.state.friends
44+ if (theyFollowYou) return strings.userShow.state.theyFollow
45+ if (youFollowThem) return strings.userShow.state.youFollow
46+ }
47+ )
48+ const { unfollow, follow } = api.contact.async
49+ const followButton = when(followers(myId).sync,
50+ when(youFollowThem,
51+ h('Button -subtle', { 'ev-click': () => unfollow(feed) }, strings.userShow.action.unfollow),
52+ h('Button -primary', { 'ev-click': () => follow(feed) }, strings.userShow.action.follow)
53+ ),
54+ h('Button', { disabled: 'disabled' }, strings.loading )
55+ )
56+
57+
58+ const threads = MutantArray()
59+ pull(
60+ // next(api.feed.pull.private, {reverse: true, limit: 100, live: false}, ['value', 'timestamp']),
61+ // api.feed.pull.private({reverse: true, limit: 100, live: false}),
62+ api.feed.pull.private({reverse: true, live: false}),
63+ pull.filter(msg => {
64+ const recps = get(msg, 'value.content.recps')
65+ if (!recps) return
66+
67+ return recps
68+ .map(r => typeof r === 'object' ? r.link : r)
69+ .includes(feed)
70+ }),
71+ api.feed.pull.rollup(),
72+ pull.drain(threads.push)
73+ // Scroller(container, content, render, false, false)
74+ )
75+
76+ const Link = api.app.html.link
77+
2378 return h('Page -userShow', [
79+ api.app.html.nav(),
2480 h('h1', api.about.obs.name(feed)),
25- api.app.html.nav(),
26- api.about.html.image(feed),
27- h('div', 'follow button'),
28- h('div', 'friends in common'),
29- feed !== myId
30- ? Link({ page: 'threadNew', feed }, 'New Thread')
31- : '',
32- h('div', 'conversations you\'ve had with dominic'),
33- h('div', 'groups dominic is in'),
81+ h('div.container', [
82+ api.about.html.image(feed),
83+ feed !== myId
84+ ? h('div.friendship', [
85+ h('div.state', ourRelationship),
86+ followButton
87+ ]) : '',
88+ h('div', '...friends in common'),
89+ h('div', '...groups this person is in'),
90+ feed !== myId
91+ ? Link({ page: 'threadNew', feed }, h('Button -primary', strings.userShow.action.directMessage))
92+ : '',
93+ h('div.threads', map(threads, api.app.html.threadCard))
94+ ])
3495 ])
3596 }
3697 }
app/page/userShow.mcssView
@@ -1,0 +1,17 @@
1+Page -userShow {
2+ div.container {
3+
4+ div.friendship {
5+ display: flex
6+ align-items: center
7+
8+ margin-bottom: 1rem
9+
10+ div.state { flex-basis: 12rem }
11+ div.Button {}
12+ }
13+
14+
15+ }
16+}
17+
styles/global.mcssView
@@ -17,16 +17,7 @@
1717 img {
1818 max-width: 100%
1919 }
2020
21-Markdown {
22- word-break: break-word
23-
24- (img) {
25- margin: .5rem 0
26- border-radius: .5rem
27- }
28-}
29-
3021 button {
3122 width: 100%
3223 }
styles/button.mcssView
@@ -1,0 +1,27 @@
1+Button {
2+ font-family: arial
3+ text-align: center
4+
5+ cursor: pointer
6+
7+ padding: .2rem 2rem
8+ min-width: 4rem
9+ border: 1px #b9b9b9 solid
10+
11+ -subtle {
12+ color: #b9b9b9
13+ :hover {
14+ color: #222
15+ }
16+ }
17+ -primary {
18+ $primaryColor
19+
20+ :hover {
21+ opacity: .9
22+ }
23+
24+ border: none
25+ }
26+}
27+
styles/markdown.mcssView
@@ -1,0 +1,10 @@
1+Markdown {
2+ word-break: break-word
3+
4+ (img) {
5+ margin: .5rem 0
6+ border-radius: .5rem
7+ }
8+}
9+
10+
translations/sync.jsView
@@ -1,13 +1,28 @@
1+const nest = require('depnest')
12
2-exports.gives = {translations: {sync: {strings: true}}}
3+exports.gives = nest('translations.sync.strings')
34
4-exports.create = function () {
5- return {translations: {sync: {strings: function () {
6- return {
7- showMore: "Show More",
8- channels: "Channels",
9- directMessages: "Direct Messages",
10- replySymbol: "> "
5+exports.create = (api) => {
6+ return nest('translations.sync.strings', () => en)
7+}
8+
9+const en = {
10+ loading: 'Loading...',
11+ showMore: 'Show More',
12+ channels: 'Channels',
13+ directMessages: 'Direct Messages',
14+ replySymbol: '> ',
15+ userShow: {
16+ action: {
17+ follow: 'Follow',
18+ unfollow: 'Unfollow',
19+ directMessage: 'New Direct Message'
20+ },
21+ state: {
22+ friends: 'You are friends',
23+ youFollow: 'You follow them',
24+ theyFollow: 'They follow you'
1125 }
12- }}}}
26+ }
1327 }
28+

Built with git-ssb-web