Commit 99dc6aa464a4c1cc228a6af744517def76da134f
basic profile page with follow + dm buttons
mix irving committed on 8/16/2017, 4:26:37 AMParent: 38e0417253d2dc77736737889d97f936df7f35a0
Files changed
app/html/link.js | changed |
app/html/link.mcss | changed |
app/page/userShow.js | changed |
app/page/userShow.mcss | added |
styles/global.mcss | changed |
styles/button.mcss | added |
styles/markdown.mcss | added |
translations/sync.js | changed |
app/html/link.js | ||
---|---|---|
@@ -9,9 +9,10 @@ | ||
9 | 9 | |
10 | 10 | exports.create = (api) => { |
11 | 11 | return nest('app.html.link', (location, body) => { |
12 | 12 | 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' : '' | |
14 | 15 | }, body) |
15 | 16 | }) |
16 | 17 | } |
17 | 18 |
app/html/link.mcss | ||
---|---|---|
@@ -1,6 +1,10 @@ | ||
1 | 1 | Link { |
2 | 2 | color: blue |
3 | - :hover { | |
4 | - text-decoration: underline | |
3 | + | |
4 | + -string { | |
5 | + :hover { | |
6 | + text-decoration: underline | |
7 | + } | |
5 | 8 | } |
6 | 9 | } |
10 | + |
app/page/userShow.js | ||
---|---|---|
@@ -1,36 +1,72 @@ | ||
1 | 1 | const nest = require('depnest') |
2 | -const { h } = require('mutant') | |
2 | +const { h, computed, when } = require('mutant') | |
3 | 3 | |
4 | 4 | exports.gives = nest('app.page.userShow') |
5 | 5 | |
6 | 6 | exports.needs = nest({ |
7 | 7 | 'app.html.link': 'first', |
8 | 8 | 'app.html.nav': 'first', |
9 | 9 | 'about.html.image': 'first', |
10 | 10 | 'about.obs.name': 'first', |
11 | + 'contact.async.follow': 'first', | |
12 | + 'contact.async.unfollow': 'first', | |
13 | + 'contact.obs.followers': 'first', | |
11 | 14 | 'keys.sync.id': 'first', |
15 | + 'translations.sync.strings': 'first', | |
12 | 16 | }) |
13 | 17 | |
14 | 18 | exports.create = (api) => { |
15 | 19 | return nest('app.page.userShow', userShow) |
16 | 20 | |
17 | 21 | function userShow (location) { |
18 | 22 | |
19 | 23 | const { feed } = location |
20 | - const Link = api.app.html.link | |
21 | 24 | const myId = api.keys.sync.id() |
22 | 25 | |
26 | + const strings = api.translations.sync.strings() | |
27 | + | |
28 | + const { followers } = api.contact.obs | |
29 | + | |
30 | + const youFollowThem = computed(followers(feed), followers => followers.has(myId)) | |
31 | + const theyFollowYou = computed(followers(myId), followers => followers.has(feed)) | |
32 | + const youAreFriends = computed([youFollowThem, theyFollowYou], (a, b) => a && b) | |
33 | + | |
34 | + const ourRelationship = computed( | |
35 | + [youAreFriends, youFollowThem, theyFollowYou], | |
36 | + (youAreFriends, youFollowThem, theyFollowYou) => { | |
37 | + if (youAreFriends) return strings.userShow.state.friends | |
38 | + if (theyFollowYou) return strings.userShow.state.theyFollow | |
39 | + if (youFollowThem) return strings.userShow.state.youFollow | |
40 | + } | |
41 | + ) | |
42 | + const { unfollow, follow } = api.contact.async | |
43 | + const followButton = when(followers(myId).sync, | |
44 | + when(youFollowThem, | |
45 | + h('Button -subtle', { 'ev-click': () => unfollow(feed) }, strings.userShow.action.unfollow), | |
46 | + h('Button -primary', { 'ev-click': () => follow(feed) }, strings.userShow.action.follow) | |
47 | + ), | |
48 | + h('Button', { disabled: 'disabled' }, strings.loading ) | |
49 | + ) | |
50 | + | |
51 | + const Link = api.app.html.link | |
52 | + | |
23 | 53 | return h('Page -userShow', [ |
54 | + api.app.html.nav(), | |
24 | 55 | 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'), | |
56 | + h('div.container', [ | |
57 | + api.about.html.image(feed), | |
58 | + feed !== myId | |
59 | + ? h('div.friendship', [ | |
60 | + h('div.state', ourRelationship), | |
61 | + followButton | |
62 | + ]) : '', | |
63 | + h('div', '...friends in common'), | |
64 | + h('div', '...groups dominic is in'), | |
65 | + feed !== myId | |
66 | + ? Link({ page: 'threadNew', feed }, h('Button -primary', strings.userShow.action.directMessage)) | |
67 | + : '', | |
68 | + h('div', 'conversations you\'ve had with dominic'), | |
69 | + ]) | |
34 | 70 | ]) |
35 | 71 | } |
36 | 72 | } |
app/page/userShow.mcss | ||
---|---|---|
@@ -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.mcss | ||
---|---|---|
@@ -17,16 +17,7 @@ | ||
17 | 17 | img { |
18 | 18 | max-width: 100% |
19 | 19 | } |
20 | 20 | |
21 | -Markdown { | |
22 | - word-break: break-word | |
23 | - | |
24 | - (img) { | |
25 | - margin: .5rem 0 | |
26 | - border-radius: .5rem | |
27 | - } | |
28 | -} | |
29 | - | |
30 | 21 | button { |
31 | 22 | width: 100% |
32 | 23 | } |
styles/button.mcss | ||
---|---|---|
@@ -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.mcss | ||
---|---|---|
@@ -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.js | ||
---|---|---|
@@ -1,13 +1,28 @@ | ||
1 | +const nest = require('depnest') | |
1 | 2 | |
2 | -exports.gives = {translations: {sync: {strings: true}}} | |
3 | +exports.gives = nest('translations.sync.strings') | |
3 | 4 | |
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' | |
11 | 25 | } |
12 | - }}}} | |
26 | + } | |
13 | 27 | } |
28 | + |
Built with git-ssb-web