Files: 3c980b78e2e8d16fcd4b7216a0a9cdb94115b708 / modules / page / html / render / settings.js
1825 bytesRaw
1 | var { h, computed } = require('mutant') |
2 | var nest = require('depnest') |
3 | |
4 | var themeNames = Object.keys(require('../../../../styles')) |
5 | |
6 | exports.needs = nest({ |
7 | 'settings.obs.get': 'first', |
8 | 'settings.sync.set': 'first', |
9 | }) |
10 | |
11 | exports.gives = nest('page.html.render') |
12 | |
13 | exports.create = function (api) { |
14 | return nest('page.html.render', function channel (path) { |
15 | if (path !== '/settings') return |
16 | |
17 | const currentTheme = api.settings.obs.get('patchwork.theme') |
18 | const filterFollowing = api.settings.obs.get('filters.following') |
19 | |
20 | var prepend = [ |
21 | h('PageHeading', [ |
22 | h('h1', [ |
23 | h('strong', 'Settings') |
24 | ]), |
25 | ]) |
26 | ] |
27 | |
28 | return h('Scroller', { style: { overflow: 'auto' } }, [ |
29 | h('div.wrapper', [ |
30 | h('section.prepend', prepend), |
31 | h('section.content', [ |
32 | h('section', [ |
33 | h('h2', 'Theme'), |
34 | computed(currentTheme, currentTheme => { |
35 | return themeNames.map(name => { |
36 | const style = currentTheme == name |
37 | ? { 'margin-right': '1rem', 'border-color': 'teal' } |
38 | : { 'margin-right': '1rem' } |
39 | |
40 | return h('button', { |
41 | 'ev-click': () => api.settings.sync.set({ |
42 | patchwork: {theme: name} |
43 | }), |
44 | style |
45 | }, name) |
46 | }) |
47 | }) |
48 | ]), |
49 | h('section', [ |
50 | h('h2', 'Filters'), |
51 | h('label', [ |
52 | h('input', { |
53 | type: 'checkbox', |
54 | checked: filterFollowing, |
55 | 'ev-change': (ev) => api.settings.sync.set({ |
56 | filters: {following: ev.target.checked} |
57 | }) |
58 | }), ' Hide following messages' |
59 | ]) |
60 | ]) |
61 | ]) |
62 | ]) |
63 | ]) |
64 | }) |
65 | } |
66 |
Built with git-ssb-web