git ssb

2+

mixmix / ticktack



Commit 4caad32bdc583a475ce49a53d2293c67c0f52cb6

added options configuration for sharing

andre alves garzia committed on 5/7/2018, 2:51:04 PM
Parent: 7c4fa2334f8a2d21c416cb98d7f21cd61f40e98f

Files changed

app/page/settings.jschanged
app/page/settings.mcsschanged
app/page/settings.jsView
@@ -1,6 +1,6 @@
11 const nest = require('depnest')
2-const { h, computed } = require('mutant')
2+const { h, computed, when } = require('mutant')
33 const electron = require('electron')
44 const path = require('path')
55 const { version } = require('../../package.json')
66
@@ -30,24 +30,26 @@
3030
3131 exports.create = (api) => {
3232 return nest('app.page.settings', settings)
3333
34- function settings (location) {
34+ function settings(location) {
3535 // RESET the app when the settings are changed
3636 api.settings.obs.get('language')(() => {
3737 console.log('language changed, resetting view')
3838
3939 // clear history back to start page
4040 api.history.obs.store().set([
4141 { page: 'blogIndex' }
4242 ])
43- api.history.sync.push({page: 'settings'})
43+ api.history.sync.push({ page: 'settings' })
4444 })
4545
46+ const webSharingMetricsOption = api.settings.obs.get('websharemetrics')
4647 const feed = api.keys.sync.id()
4748 const strings = api.translations.sync.strings()
4849 const currentLanguage = api.settings.sync.get('language')
4950
51+
5052 const editProfile = () => api.history.sync.push({
5153 page: 'userEdit',
5254 feed,
5355 callback: (err, didEdit) => {
@@ -83,18 +85,26 @@
8385 h('div.right', LANGUAGES.map(Language))
8486 ]),
8587 h('section -zoom', [
8688 h('div.left', strings.settingsPage.section.zoom),
87- h('div.right', [ zoomButton(-0.1, '-'), zoomButton(+0.1, '+') ])
89+ h('div.right', [zoomButton(-0.1, '-'), zoomButton(+0.1, '+')])
8890 ]),
91+ h('section -sharing', [
92+ h('div.left', 'Web Sharing Metrics'),
93+ h('div.right', [].concat(
94+ webSharingOption('public', 'publish metrics openly'),
95+ webSharingOption('author', 'publish for you and author'),
96+ webSharingOption('private', 'publish just for you')
97+ ))
98+ ]),
8999 h('section -version', [
90100 h('div.left', strings.settingsPage.section.version),
91101 h('div.right', version)
92102 ])
93103 ])
94104 ])
95105
96- function Language (lang) {
106+ function Language(lang) {
97107 const selectLang = () => api.settings.sync.set({ language: lang })
98108 const className = currentLanguage === lang ? '-strong' : ''
99109
100110 return h('Button -language',
@@ -105,9 +115,9 @@
105115 strings.languages[lang]
106116 )
107117 }
108118
109- function zoomButton (increment, symbol) {
119+ function zoomButton(increment, symbol) {
110120 const { getCurrentWebContents } = electron.remote
111121 return h('Button -zoom',
112122 {
113123 'ev-click': () => {
@@ -119,6 +129,23 @@
119129 },
120130 symbol
121131 )
122132 }
133+
134+ function webSharingOption(v, label) {
135+ let myOption = computed(webSharingMetricsOption, opt => opt === v)
136+
137+ const selectWebSharingOption = () => {
138+ api.settings.sync.set({ websharemetrics: v })
139+ }
140+
141+ return h('Button -websharingmetrics',
142+ {
143+ 'ev-click': () => selectWebSharingOption(v),
144+ className: when(myOption, '-strong', '')
145+ },
146+ label
147+ )
148+ }
149+
123150 }
124151 }
app/page/settings.mcssView
@@ -55,22 +55,37 @@
5555 margin-bottom: 2rem
5656 }
5757
5858 -version {
59- margin-top: 2rem
60-
6159 div.right {
6260 $colorFontSubtle
6361 }
6462 }
63+
64+ -sharing {
65+ div.left {
66+ align-items: flex-start
67+ }
68+ div.right {
69+ flex-direction: column
70+ align-items: flex-start
71+ }
72+ }
6573 }
6674 }
6775 }
6876
6977 Button -language {
7078 margin-right: 1rem
7179 }
7280
81+
82+Button -websharingmetrics {
83+ margin-right: 1rem
84+ display: block
85+ margin-bottom: 1rem
86+}
87+
7388 Button -zoom {
7489 margin-right: 1rem
7590 min-width: .5rem
7691 }

Built with git-ssb-web