git ssb

2+

mixmix / ticktack



Commit 682cd150893709ec579d59c1835f2c86e1a71029

Merge remote-tracking branch 'origin/threadNew'

Dominic Tarr committed on 8/17/2017, 5:24:27 AM
Parent: 17795d6b64c14a6b4619d142e0f05e3e8e3b2562
Parent: a0e32e0e1ccf94a033e936e93954f133b8dc45a3

Files changed

app/html/thread.jschanged
app/html/thread.mcsschanged
app/page/page.mcsschanged
app/page/threadNew.jschanged
app/page/threadShow.jschanged
app/page/threadNew.mcssadded
message/html/compose.jschanged
message/html/compose.mcsschanged
styles/button.mcsschanged
styles/global.mcsschanged
styles/mixins.jschanged
translations/sync.jschanged
app/html/thread.jsView
@@ -50,8 +50,11 @@
5050
5151 return h('div.msg', api.message.html.markdown(raw))
5252 }
5353
54+ threadView.subject = computed(thread.messages, msgs => {
55+ return get(msgs, '[0].value.content.subject')
56+ })
5457 return threadView
5558 }
5659 }
5760
app/html/thread.mcssView
@@ -13,9 +13,9 @@
1313
1414 div.msgs {
1515 div.msg-row {
1616 div.msg {
17- $primaryColor
17+ $colorPrimary
1818
1919 (a) { color: #4d3568 }
2020 $roundLeft
2121 }
app/page/page.mcssView
@@ -1,23 +1,17 @@
11 Page {
2- h1 {
3- margin-left: 1rem
4- }
2+ $primaryBackground
53
6- div.Nav {}
7-
84 div.container {
9- $primaryBackground
5+ $maxWidth
106 padding: 1rem
7+ margin: 0 auto
118
129 div.Thread {
13- $maxWidth
14- margin: 0 auto 1rem
10+ margin-bottom: 1rem
1511 }
1612
1713 div.Compose {
18- $maxWidth
19- margin: 0 auto
2014 }
2115 }
2216 }
2317
app/page/threadNew.jsView
@@ -1,28 +1,61 @@
11 const nest = require('depnest')
2-const { h } = require('mutant')
2+const { h, Struct, Value, computed } = require('mutant')
33
44 exports.gives = nest('app.page.threadNew')
55
66 exports.needs = nest({
77 'translations.sync.strings': 'first',
88 'about.html.image': 'first',
99 'about.obs.name': 'first',
1010 'app.html.thread': 'first',
11+ 'history.sync.push': 'first',
12+ 'keys.sync.id': 'first',
13+ 'message.html.compose': 'first'
1114 })
1215
1316 exports.create = (api) => {
14- var strings = api.translations.sync.strings()
1517
1618 return nest('app.page.threadNew', threadNew)
1719
1820 function threadNew (location) {
21+ const strings = api.translations.sync.strings()
1922 const { feed } = location
23+ const name = api.about.obs.name(feed)
2024
21- return h('Page -threadNew', {title: strings.threadNew}, [
22- h('h1', ['New thread with ', api.about.obs.name(feed)]),
23- api.about.html.image(feed),
24- h('div', 'compose box') // a special one which takes us to threadShow
25+ const meta = Struct({
26+ type: 'post',
27+ recps: [
28+ api.keys.sync.id(),
29+ { link: feed, name }
30+ ],
31+ subject: Value()
32+ })
33+ const composer = api.message.html.compose(
34+ { meta, shrink: false },
35+ (err, msg) => api.history.sync.push(err ? err : msg)
36+ )
37+
38+ return h('Page -threadNew', {title: strings.threadNew.pageTitle}, [
39+ h('div.container', [
40+ h('div.field -to', [
41+ h('div.label', strings.threadNew.field.to),
42+ h('div.recps', [
43+ h('div.recp', [
44+ api.about.html.image(feed),
45+ h('div.name', name)
46+ ])
47+ ])
48+ ]),
49+ h('div.field -subject', [
50+ h('div.label', strings.threadNew.field.subject),
51+ h('input', {
52+ 'ev-input': e => meta.subject.set(e.target.value),
53+ placeholder: strings.optionalField
54+ }),
55+ ]),
56+ composer
57+ ])
2558 ])
2659 }
2760 }
2861
app/page/threadShow.jsView
@@ -1,6 +1,6 @@
11 const nest = require('depnest')
2-const { h } = require('mutant')
2+const { h, computed } = require('mutant')
33 const last = require('lodash/last')
44 const get = require('lodash/get')
55
66 exports.gives = nest('app.page.threadShow')
@@ -30,11 +30,13 @@
3030 channel: channel,
3131 recps: get(location, 'value.content.recps')
3232 }
3333 const composer = api.message.html.compose({ meta, shrink: false })
34+ const subject = computed(thread.subject, subject => subject || strings.threadShow)
3435
35- return h('Page -threadShow', {title: strings.threadShow}, [
36+ return h('Page -threadShow', [
3637 h('div.container', [
38+ h('h1', subject),
3739 thread,
3840 composer
3941 ]),
4042 ])
app/page/threadNew.mcssView
@@ -1,0 +1,52 @@
1+Page -threadNew {
2+
3+ div.container {
4+ div.field {
5+ margin-bottom: .5rem
6+
7+ display: flex
8+ align-items: center
9+
10+ div.label {
11+ flex-basis: 4rem
12+ padding-left: 1rem
13+ margin-right: 1rem
14+ }
15+
16+ input {
17+ flex-grow: 1
18+ $fontBasic
19+ padding: .6rem
20+ }
21+
22+ div.recps {
23+ display: flex
24+
25+ div.recp {
26+ padding: .3rem
27+ $borderSubtle
28+ border-radius: 6rem
29+ background-color: #fff
30+
31+ margin-right: 1rem
32+
33+ display: flex
34+ align-items: center
35+
36+ img {
37+ width: 2rem
38+ height: 2rem
39+ border-radius: 2rem
40+
41+ margin-right: .5rem
42+ }
43+
44+ div.name {
45+ margin-right: .5rem
46+ }
47+ }
48+ }
49+
50+ }
51+ }
52+}
message/html/compose.jsView
@@ -13,14 +13,17 @@
1313 'emoji.sync.names': 'first',
1414 'emoji.sync.url': 'first',
1515 'message.async.publish': 'first',
1616 // 'message.html.confirm': 'first'
17+ 'translations.sync.strings': 'first'
1718 })
1819
1920 exports.create = function (api) {
2021 return nest('message.html.compose', compose)
2122
2223 function compose ({ shrink = true, meta, prepublish, placeholder = 'Write a message' }, cb) {
24+ const strings = api.translations.sync.strings()
25+
2326 var files = []
2427 var filesById = {}
2528 var channelInputFocused = Value(false)
2629 var textAreaFocused = Value(false)
@@ -79,9 +82,9 @@
7982 })
8083
8184 fileInput.onclick = () => hasContent.set(true)
8285
83- var publishBtn = h('button', { 'ev-click': publish }, 'Publish')
86+ var publishBtn = h('Button -primary', { 'ev-click': publish }, strings.sendMessage)
8487
8588 var actions = h('section.actions', [
8689 fileInput,
8790 publishBtn
@@ -165,21 +168,25 @@
165168 content = prepublish(content)
166169 }
167170 } catch (err) {
168171 publishBtn.disabled = false
169- if (cb) cb(err)
170- else throw err
172+ handleErr(err)
171173 }
172174
173175 return api.message.async.publish(content, done)
174176 // return api.message.html.confirm(content, done)
175177
176178 function done (err, msg) {
177179 publishBtn.disabled = false
178- if (err) throw err
180+ if (err) handleErr(err)
179181 else if (msg) textArea.value = ''
180182 if (cb) cb(err, msg)
181183 }
184+
185+ function handleErr (err) {
186+ if (cb) cb(err)
187+ else throw err
188+ }
182189 }
183190 }
184191 }
185192
message/html/compose.mcssView
@@ -2,18 +2,18 @@
22 display: flex
33 flex-direction: column
44
55 textarea {
6- $basicText
6+ $fontBasic
77
88 padding: .6rem
9- border: 1px solid gainsboro
9+ $borderSubtle
1010 border-top-left-radius: 0
1111 border-top-right-radius: 0
1212 }
1313
1414 input.channel {
15- border: 1px solid gainsboro
15+ $borderSubtle
1616 border-bottom: none
1717 border-bottom-left-radius: 0
1818 border-bottom-right-radius: 0
1919 padding: .5rem
@@ -48,9 +48,9 @@
4848 visibility: hidden
4949 }
5050
5151 ::before {
52- $composeButton
52+ $attachButton
5353 padding-top: .3rem
5454
5555 content: '๐Ÿ“Ž'
5656 font-size: 1rem
@@ -65,14 +65,9 @@
6565 box-shadow: none
6666 }
6767 }
6868
69- button {
70- $composeButton
71-
72- text-transform: uppercase
73- font-weight: bold
74- font-size: .7rem
69+ div.Button {
7570 }
7671 }
7772
7873 -expanded {
@@ -106,14 +101,12 @@
106101 }
107102
108103 }
109104
110-$composeButton {
105+$attachButton {
111106 background: #fff
112107 color: #666
113- border: 1px solid #bbb
114- border-radius: .5rem
108+ border: 1px solid #b9b9b9
115109 padding: .5rem
116110 margin: 0
117111 cursor: pointer
118112 }
119-
styles/button.mcssView
@@ -14,9 +14,9 @@
1414 color: #222
1515 }
1616 }
1717 -primary {
18- $primaryColor
18+ $colorPrimary
1919
2020 :hover {
2121 opacity: .9
2222 }
styles/global.mcssView
@@ -1,6 +1,6 @@
11 body {
2- $basicText
2+ $fontBasic
33 background-color: #fff
44
55 margin: 0
66
@@ -17,7 +17,4 @@
1717 img {
1818 max-width: 100%
1919 }
2020
21-button {
22- width: 100%
23-}
styles/mixins.jsView
@@ -9,18 +9,18 @@
99 })
1010 }
1111
1212 const mainMixins = `
13-$basicText {
13+$fontBasic {
1414 font-family: arial
1515 font-size: 1rem
1616 }
1717
1818 $maxWidth {
1919 max-width: 1200px
2020 }
2121
22-$primaryColor {
22+$colorPrimary {
2323 color: white
2424 background-color: #3dc8c3
2525 }
2626
@@ -63,8 +63,12 @@
6363 }
6464 }
6565 }
6666
67+$borderSubtle {
68+ border: 1px solid #b9b9b9
69+}
70+
6771 $roundLeft {
6872 border-top-left-radius: 1.2rem
6973 border-bottom-left-radius: 1.2rem
7074 }
translations/sync.jsView
@@ -7,8 +7,10 @@
77 }
88
99 const en = {
1010 loading: 'Loading...',
11+ optionalField: 'optional',
12+ sendMessage: 'Send',
1113 showMore: 'Show More',
1214 channels: 'Channels',
1315 directMessages: 'Direct Messages',
1416 replySymbol: '> ',
@@ -20,9 +22,16 @@
2022 groupIndex: "Group Index",
2123 //stub: should not be shown on released software!
2224 stub: "this page is a stub",
2325 settings: "Settings",
24- threadNew: 'New Thread',
26+ threadNew: {
27+ pageTitle: 'New Thread',
28+ field: {
29+ to: 'To',
30+ subject: 'Subject'
31+ }
32+
33+ },
2534 threadShow: "Direct Messages",
2635 userShow: {
2736 action: {
2837 follow: 'Follow',

Built with git-ssb-web