git ssb

2+

mixmix / ticktack



Tree: 0dbf73654513a31bdd3cab71a2047f263c054072

Files: 0dbf73654513a31bdd3cab71a2047f263c054072 / app / page / settings.js

1165 bytesRaw
1const nest = require('depnest')
2const { h } = require('mutant')
3
4exports.gives = nest('app.page.settings')
5
6exports.needs = nest({
7 'settings.sync.get': 'first',
8 'settings.sync.set': 'first',
9 'settings.obs.get': 'first',
10 'translations.sync.strings': 'first',
11})
12
13const LANGUAGES = ['zh', 'en']
14const DEFAULT_SETTINGS = {
15 language: 'zh'
16}
17
18exports.create = (api) => {
19 return nest('app.page.settings', settings)
20
21 function settings (location) {
22 // RESET the app when the settings are changed
23 api.settings.obs.get()(() => {
24 window.location.reload()
25 })
26
27 const strings = api.translations.sync.strings()
28 const currentLanguage = api.settings.sync.get('language')
29
30 function Language (lang) {
31 const selectLang = () => api.settings.sync.set({ language: lang })
32 const className = currentLanguage === lang ? '-primary' : ''
33
34 return h('div.language', { 'ev-click': () => selectLang(lang) },
35 h('Button', { className }, lang)
36 )
37 }
38
39 return h('Page -settings', [
40 h('div.container', [
41 h('h1', strings.settings),
42 h('div.languages', LANGUAGES.map(Language))
43 ])
44 ])
45 }
46}
47
48

Built with git-ssb-web