git ssb

2+

mixmix / ticktack



Commit ef08c9119e733198510e57b49ae441a7d0c8cae7

Merge pull request #35 from ticktackim/onboarding

Onboarding
mix irving authored on 8/28/2017, 12:11:20 AM
GitHub committed on 8/28/2017, 12:11:20 AM
Parent: 0052f2414e13f7d307466526f1eeceabc0d27695
Parent: 6d1b6dfb2973eaadaa459fee0d6bd1716214712f

Files changed

app/html/app.jschanged
app/html/header.jschanged
app/page/groupFind.mcsschanged
app/page/settings.jschanged
app/page/settings.mcsschanged
app/page/userEdit.jschanged
app/page/userEdit.mcsschanged
app/page/userFind.mcsschanged
app/page/userShow.jschanged
app/page/userShow.mcsschanged
package.jsonchanged
styles/mixins.jschanged
translations/en.jschanged
translations/zh.jschanged
app/html/app.jsView
@@ -8,20 +8,23 @@
88 const h = require('mutant/h')
99
1010 exports.gives = nest({
1111 'app.html.app': true,
12- 'history.obs.location': true,
12+ 'history.obs.history': true,
1313 'history.sync.push': true,
1414 'history.sync.back': true,
1515 })
1616
1717 exports.needs = nest({
18+ 'about.async.suggest': 'first',
1819 'app.html.header': 'first',
1920 'app.async.catchLinkClick': 'first',
21+ 'channel.async.suggest': 'first',
22+ 'keys.sync.id': 'first',
2023 'router.sync.router': 'first',
24+ 'settings.sync.get': 'first',
25+ 'settings.sync.set': 'first',
2126 'styles.css': 'reduce',
22- 'about.async.suggest': 'first',
23- 'channel.async.suggest': 'first',
2427 })
2528
2629 exports.create = (api) => {
2730 var nav = null
@@ -45,14 +48,31 @@
4548 api.router.sync.router,
4649 api.app.html.header
4750 )
4851
49- nav.push({page: 'home'})
52+ const isOnboarded = api.settings.sync.get('onboarded')
53+ if (isOnboarded)
54+ nav.push({page: 'home'})
55+ else {
56+ nav.push({
57+ page:'userEdit',
58+ feed: api.keys.sync.id(),
59+ callback: (err, didEdit) => {
60+ if (err) throw new Error ('Error editing profile', err)
61+
62+ if (didEdit)
63+ api.settings.sync.set({ onboarded: true })
64+
65+ nav.push({ page: 'home' })
66+ }
67+ })
68+ }
69+
5070 return nav
5171 },
5272 'history.sync.push': (location) => nav.push(location),
5373 'history.sync.back': () => nav.back(),
54- 'history.obs.location': () => nav.history,
74+ 'history.obs.history': () => nav.history,
5575 })
5676 }
5777
5878
app/html/header.jsView
@@ -16,9 +16,9 @@
1616 // FUTURE breadcrumb here ?
1717 // h('h1', computed(nav.location, e => e.element.title)),
1818
1919 h('div.tools', [
20- h('i.fa.fa-user', { 'ev-click': () => nav.push({page:'userEdit', feed: api.keys.sync.id()}) }), // TEMP
20+ // h('i.fa.fa-user', { 'ev-click': () => nav.push({page:'userEdit', feed: api.keys.sync.id()}) }), // TEMP
2121 h('i.fa.fa-address-book', { 'ev-click': () => nav.push({page:'userFind'}) }),
2222 h('i.fa.fa-hashtag', { 'ev-click': () => nav.push({page:'groupFind'}) }),
2323 h('i.fa.fa-gear', { 'ev-click': () => nav.push({page:'settings'}) })
2424 ])
app/page/groupFind.mcssView
@@ -1,7 +1,7 @@
11 Page -groupFind {
22 div.container {
3- max-width: 40rem
3+ $maxWidthSmaller
44 div.search {
55 background-color: #fff
66
77 margin-bottom: 1rem
@@ -25,9 +25,9 @@
2525 }
2626
2727
2828 div.results {
29- max-width: 40rem
29+ $maxWidthSmaller
3030
3131 div.Link {
3232 div.result {
3333 background-color: #fff
app/page/settings.jsView
@@ -3,31 +3,77 @@
33
44 exports.gives = nest('app.page.settings')
55
66 exports.needs = nest({
7+ 'about.html.image': 'first',
8+ 'about.obs.name': 'first',
9+ 'history.sync.push': 'first',
10+ 'history.obs.history': 'first',
11+ 'keys.sync.id': 'first',
712 'settings.sync.get': 'first',
813 'settings.sync.set': 'first',
914 'settings.obs.get': 'first',
1015 'translations.sync.strings': 'first',
1116 })
1217
1318 const LANGUAGES = ['zh', 'en']
14-const DEFAULT_SETTINGS = {
15- language: 'zh'
16-}
1719
20+// TODO - this needs moving somewhere upstream
21+// const DEFAULT_SETTINGS = {
22+// onboarded: false,
23+// language: 'zh'
24+// }
25+
1826 exports.create = (api) => {
1927 return nest('app.page.settings', settings)
2028
2129 function settings (location) {
30+
2231 // RESET the app when the settings are changed
23- api.settings.obs.get()(() => {
24- window.location.reload()
32+ api.settings.obs.get('language')(() => {
33+ console.log('language changed, resetting view')
34+
35+ api.history.obs.history().set([]) // wipe nav cache
36+ api.history.sync.push({page: 'home'}) // queue up basic pages
37+ api.history.sync.push({page: 'settings'})
2538 })
2639
40+ const feed = api.keys.sync.id()
2741 const strings = api.translations.sync.strings()
2842 const currentLanguage = api.settings.sync.get('language')
2943
44+ const editProfile = () => api.history.sync.push({
45+ page:'userEdit',
46+ feed,
47+ callback: (err, didEdit) => {
48+ if (err) throw new Error ('Error editing profile', err)
49+ api.history.sync.push({ page: 'settings' })
50+ }
51+ })
52+
53+ return h('Page -settings', [
54+ h('div.container', [
55+ h('h1', strings.settingsPage.title),
56+ h('section -profile', [
57+ h('header', strings.settingsPage.section.profile),
58+ h('div.profile', [
59+ h('div.name', api.about.obs.name(feed)),
60+ api.about.html.image(feed),
61+ ]),
62+ h('div.actions', [
63+ h('Button', { 'ev-click': editProfile }, [
64+ strings.settingsPage.action.edit,
65+ h('i.fa.fa-pencil')
66+ ])
67+ ])
68+ ]),
69+ h('section -language', [
70+ h('header', strings.settingsPage.section.language),
71+ h('div.languages', LANGUAGES.map(Language))
72+ ])
73+ ])
74+ ])
75+
3076 function Language (lang) {
3177 const selectLang = () => api.settings.sync.set({ language: lang })
3278 const className = currentLanguage === lang ? '-primary' : ''
3379
@@ -39,13 +85,7 @@
3985 lang
4086 )
4187 }
4288
43- return h('Page -settings', [
44- h('div.container', [
45- h('h1', strings.settings),
46- h('div.languages', LANGUAGES.map(Language))
47- ])
48- ])
4989 }
5090 }
5191
app/page/settings.mcssView
@@ -1,15 +1,58 @@
11 Page -settings {
2+ padding-top: 1rem
3+
24 div.container {
3- div.languages {
4- background: #fff
5- padding: 1rem
6- padding-bottom: 14rem
5+ background: #fff
6+ padding: 1rem
7+ $maxWidthSmaller
78
8- display: flex
9+ h1 {
10+ margin-top: 0
911 }
12+
13+ section {
14+ padding-bottom: 2rem
15+ margin-bottom: 2rem
16+
17+ header {
18+ font-size: 1.4rem
19+ margin-bottom: 1rem
20+ }
21+
22+ -profile {
23+ div.profile {
24+ display: flex
25+ flex-direction: column
26+
27+ div.name {
28+ margin-bottom: .5rem
29+ }
30+ img.Avatar {
31+ width: 8rem
32+ height: 8rem
33+ }
34+ margin-bottom: .5rem
35+ }
36+
37+ div.actions {
38+ display:flex
39+
40+ div.Button {
41+ i.fa { margin-left: .4rem }
42+ }
43+ }
44+ }
45+
46+ -language {
47+ div.languages {
48+ display: flex
49+ }
50+ }
51+ }
1052 }
1153 }
1254
1355 Button -language {
1456 margin-right: 1rem
1557 }
58+
app/page/userEdit.jsView
@@ -12,10 +12,10 @@
1212 exports.create = (api) => {
1313 return nest('app.page.userEdit', userEdit)
1414
1515 function userEdit (location) {
16- // location is an object { feed, page: 'userEdit' }
17- const { feed } = location
16+ // location is an object { feed, page: 'userEdit', callback }
17+ var { feed, callback } = location
1818
1919 const strings = api.translations.sync.strings()
2020
2121 const options = Object.assign({}, location, {
@@ -29,13 +29,16 @@
2929 save: strings.userEdit.action.save,
3030 }
3131 })
3232
33- const callback = (err, didEdit) => {
33+ const defaultCallback = (err, didEdit) => {
3434 if (err) throw new Error ('Error editing profile', err)
3535
3636 api.history.sync.push({ page: 'userShow', feed })
3737 }
38+ callback = typeof callback == 'function'
39+ ? callback
40+ : defaultCallback
3841
3942 return h('Page -userEdit', {}, [
4043 h('div.container', [
4144 api.about.page.edit(options, callback)
app/page/userEdit.mcssView
@@ -1,7 +1,7 @@
11 Page -userEdit {
22 div.container {
3- max-width: 40rem
3+ $maxWidthSmaller
44
55 }
66 }
77
app/page/userFind.mcssView
@@ -1,7 +1,7 @@
11 Page -userFind {
22 div.container {
3- max-width: 40rem
3+ $maxWidthSmaller
44 div.search {
55 background-color: #fff
66
77 margin-bottom: 1rem
@@ -25,9 +25,9 @@
2525 }
2626
2727
2828 div.results {
29- max-width: 40rem
29+ $maxWidthSmaller
3030
3131 div.Link {
3232 div.result {
3333 background-color: #fff
app/page/userShow.jsView
@@ -78,9 +78,11 @@
7878 return h('Page -userShow', {title: name}, [
7979 h('div.container', [
8080 h('header', [
8181 h('h1', name),
82- Link({ page: 'userEdit', feed }, h('i.fa.fa-pencil'))
82+ feed === myId // Only expose own profile editing right now
83+ ? Link({ page: 'userEdit', feed }, h('i.fa.fa-pencil'))
84+ : ''
8385 ]),
8486 api.about.html.image(feed),
8587 feed !== myId
8688 ? h('div.friendship', [
app/page/userShow.mcssView
@@ -14,9 +14,12 @@
1414 }
1515 }
1616 }
1717
18- img.Avatar {}
18+ img.Avatar {
19+ width: 30rem
20+ height: 30rem
21+ }
1922
2023 div.friendship {
2124 display: flex
2225 align-items: center
package.jsonView
@@ -1,7 +1,7 @@
11 {
22 "name": "ticktack",
3- "version": "1.0.0",
3+ "version": "0.1.1",
44 "description": "",
55 "main": "index.js",
66 "scripts": {
77 "rebuild": "cross-script npm rebuild --runtime=electron \"--target=$(electron -v)\" \"--abi=$(electron --abi)\" --disturl=https://atom.io/download/atom-shell",
styles/mixins.jsView
@@ -19,8 +19,12 @@
1919 $maxWidth {
2020 max-width: 1200px
2121 }
2222
23+$maxWidthSmaller {
24+ max-width: 40rem
25+}
26+
2327 $colorPrimary {
2428 color: white
2529 background-color: #3dc8c3
2630
translations/en.jsView
@@ -25,9 +25,18 @@
2525 createFirstThread: 'Start this group by posting the first thread.'
2626 }
2727 },
2828 groupIndex: "Group Index",
29- settings: "Settings",
29+ settingsPage: {
30+ title: "Settings",
31+ action: {
32+ edit: 'Edit',
33+ },
34+ section: {
35+ language: 'Language',
36+ profile: 'Profile',
37+ }
38+ },
3039 threadNew: {
3140 pageTitle: 'New Thread',
3241 field: {
3342 to: 'To',
translations/zh.jsView
@@ -25,9 +25,11 @@
2525 createFirstThread: '发布第一个话题来开始群组讨论'
2626 }
2727 },
2828 groupIndex: '群组列表',
29- settings: '设置',
29+ settingsPage: {
30+ title: '设置',
31+ },
3032 threadNew: {
3133 pageTitle: '新建话题',
3234 field: {
3335 to: '发送给',

Built with git-ssb-web