Files: bf151ff4528b0df5c2c8b3fed75d405d104481bf / app / page / settings.js
1143 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 | style: { order: 1 }, |
24 | 'ev-click': () => api.app.sync.goTo({ page: 'settings' }) |
25 | }, '/settings') |
26 | } |
27 | |
28 | function settingsPage (location) { |
29 | var page = h('SettingsPage', { title: '/settings' }, [ |
30 | h('div.container', [ |
31 | h('h1', 'Settings'), |
32 | api.app.html.settings().map(setting => { |
33 | if (!setting.title && !setting.body) throw new Error('app.html.settings requires settings in form { title, body }') |
34 | |
35 | return h('section', [ |
36 | h('h2', setting.title), |
37 | setting.body |
38 | ]) |
39 | }) |
40 | ]) |
41 | ]) |
42 | |
43 | var { container } = api.app.html.scroller({ prepend: page }) |
44 | container.title = '/settings' |
45 | return container |
46 | } |
47 | } |
48 |
Built with git-ssb-web