git ssb

16+

Dominic / patchbay



Tree: deef6f4525d00a84b10de760ede55bf07c561630

Files: deef6f4525d00a84b10de760ede55bf07c561630 / app / sync / initialise / styles.js

1590 bytesRaw
1const nest = require('depnest')
2const compileCss = require('micro-css')
3const { h, computed } = require('mutant')
4const get = require('lodash/get')
5
6exports.gives = nest('app.sync.initialise')
7
8exports.needs = nest({
9 'styles.css': 'reduce',
10 'settings.obs.get': 'first'
11})
12
13exports.create = function (api) {
14 return nest('app.sync.initialise', styles)
15
16 function styles () {
17 const css = values(api.styles.css()).join('\n')
18 const custom = api.settings.obs.get('patchbay.customStyles', '')
19 const accessibility = api.settings.obs.get('patchbay.accessibility', '')
20
21 document.head.appendChild(
22 h('style', {
23 innerHTML: computed([custom, accessibility], (custom, accessibility) => {
24 return [
25 css,
26 compileCss(custom),
27 compileCss(accessibilityMcss(accessibility))
28 ].join('\n')
29 })
30 })
31 )
32 }
33}
34
35// ////////////////////////////
36// The parts that feed into this are in app/html/settings/accessibility.js
37
38function accessibilityMcss (settings) {
39 const invert = get(settings, 'invert')
40 const saturation = get(settings, 'saturation', 100)
41 const brightness = get(settings, 'brightness', 100)
42 const contrast = get(settings, 'contrast', 100)
43
44 return `
45 body {
46 filter: ${invert ? 'invert()' : ''} saturate(${saturation}%) brightness(${brightness}%) contrast(${contrast}%)
47
48 (img) {
49 filter: ${invert ? 'invert()' : ''}
50 }
51
52 }
53 `
54}
55// ////////////////////////////
56
57function values (object) {
58 const keys = Object.keys(object)
59 return keys.map(k => object[k])
60}
61

Built with git-ssb-web