Files: 9ad609d054fd59c134b3aac1b801d0aa7d8d0e5a / app / sync / initialise / styles.js
880 bytesRaw
1 | const nest = require('depnest') |
2 | // const insertCss = require('insert-css') |
3 | const compileCss = require('micro-css') |
4 | const { h, computed } = require('mutant') |
5 | |
6 | exports.gives = nest('app.sync.initialise') |
7 | |
8 | exports.needs = nest({ |
9 | 'styles.css': 'reduce', |
10 | 'settings.obs.get': 'first' |
11 | }) |
12 | |
13 | exports.create = function (api) { |
14 | return nest('app.sync.initialise', styles) |
15 | |
16 | function styles () { |
17 | const css = values(api.styles.css()).join('\n') |
18 | |
19 | document.head.appendChild( |
20 | h('style', { |
21 | innerHTML: computed(api.settings.obs.get('patchbay.customStyles', ''), styles => { |
22 | const customStyles = compileCss(styles) |
23 | |
24 | // apply styles twice so our mixins 'win' |
25 | return [customStyles, css, customStyles].join('\n') |
26 | }) |
27 | }) |
28 | ) |
29 | } |
30 | } |
31 | |
32 | function values (object) { |
33 | const keys = Object.keys(object) |
34 | return keys.map(k => object[k]) |
35 | } |
36 | |
37 |
Built with git-ssb-web