Files: ddabf06774e3c5a4d1e76831bc096791b8795042 / app / page / settings.js
1116 bytesRaw
1 | const nest = require('depnest') |
2 | const { h } = require('mutant') |
3 | |
4 | exports.gives = nest({ |
5 | 'app.html.menuItem': true, |
6 | 'app.page.settings': true |
7 | }) |
8 | |
9 | exports.needs = nest({ |
10 | 'app.html.settings': 'map', |
11 | 'app.html.scroller': 'first', |
12 | 'app.sync.goTo': 'first' |
13 | }) |
14 | |
15 | exports.create = function (api) { |
16 | return nest({ |
17 | 'app.html.menuItem': menuItem, |
18 | 'app.page.settings': settingsPage |
19 | }) |
20 | |
21 | function menuItem () { |
22 | return h('a', { |
23 | 'ev-click': () => api.app.sync.goTo({ page: 'settings' }) |
24 | }, '/settings') |
25 | } |
26 | |
27 | function settingsPage (location) { |
28 | var page = h('SettingsPage', { title: '/settings' }, [ |
29 | h('div.container', [ |
30 | h('h1', 'Settings'), |
31 | api.app.html.settings().map(setting => { |
32 | if (!setting.title && !setting.body) throw new Error('app.html.settings requires settings in form { title, body }') |
33 | |
34 | return h('section', [ |
35 | h('h2', setting.title), |
36 | setting.body |
37 | ]) |
38 | }) |
39 | ]) |
40 | ]) |
41 | |
42 | var { container } = api.app.html.scroller({ prepend: page }) |
43 | container.title = '/settings' |
44 | return container |
45 | } |
46 | } |
47 |
Built with git-ssb-web