git ssb

2+

mixmix / ticktack



Tree: 8f874fd336bd2bf7721b161985bb987d55bc8179

Files: 8f874fd336bd2bf7721b161985bb987d55bc8179 / styles / css.js

1027 bytesRaw
1const nest = require('depnest')
2const { each, map } = require('libnested')
3const compile = require('micro-css')
4const { assign } = Object
5
6exports.gives = nest('styles.css')
7
8exports.needs = {
9 styles: {
10 mcss: 'reduce',
11 mixins: 'reduce'
12 }
13}
14
15exports.create = function (api) {
16 return nest('styles.css', css)
17
18 function css (sofar = {}) {
19 const mcssObj = api.styles.mcss()
20 const mixinObj = api.styles.mixins()
21
22 const mcssMixinsStr = mixinsToMcss(mixinObj)
23 const cssObj = mcssToCss(mcssObj, mcssMixinsStr)
24 return assign(sofar, cssObj)
25 }
26}
27
28function mixinsToMcss (mixinsObj) {
29 var mcss = ''
30 each(mixinsObj, (mixinStr, [name]) => {
31 // QUESTION: are mixins mcss specific or should we convert to mcss here?
32 // as in, mixins are dom style objects and we use something like `inline-style` package
33 mcss += mixinStr + '\n'
34 })
35 return mcss
36}
37
38function mcssToCss (mcssObj, mixinsStr) {
39 return map(mcssObj, (mcssStr, [name]) => {
40 return compile(mixinsStr + '\n' + mcssStr)
41 })
42}
43

Built with git-ssb-web