git ssb

2+

mixmix / ticktack



Tree: 453934416f185d2a473203da01c31cc7ea36e1aa

Files: 453934416f185d2a473203da01c31cc7ea36e1aa / app / page / settings.js

1193 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('Button -language',
35 {
36 'ev-click': () => selectLang(lang),
37 className
38 },
39 lang
40 )
41 }
42
43 return h('Page -settings', [
44 h('div.container', [
45 h('h1', strings.settings),
46 h('div.languages', LANGUAGES.map(Language))
47 ])
48 ])
49 }
50}
51
52

Built with git-ssb-web