git ssb

0+

alanz / patchwork



forked from Matt McKegg / patchwork

Tree: 753b6207164a2a3e5e07f5ea57b29a22559f9e4d

Files: 753b6207164a2a3e5e07f5ea57b29a22559f9e4d / modules / page / html / render / settings.js

2023 bytesRaw
1var { h, computed } = require('mutant')
2var nest = require('depnest')
3
4var themeNames = Object.keys(require('../../../../styles'))
5
6exports.needs = nest({
7 'settings.obs.get': 'first',
8 'settings.sync.set': 'first',
9})
10
11exports.gives = nest('page.html.render')
12
13exports.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 computed(filterFollowing, filter => {
52 const style = filter
53 ? { 'margin-right': '1rem', 'border-color': 'teal' }
54 : { 'margin-right': '1rem' }
55
56 return [
57 h('button', {
58 'ev-click': () => api.settings.sync.set({
59 filters: {following: !filter}
60 }),
61 style
62 }, filter ? 'Hide following messages' : 'Show following messages')
63 ]
64 })
65 ])
66 ])
67 ])
68 ])
69 })
70}
71

Built with git-ssb-web