git ssb

16+

Dominic / patchbay



Tree: f71fea8e1b697393fa7ec2d89f4d95256309882b

Files: f71fea8e1b697393fa7ec2d89f4d95256309882b / styles / css.js

1028 bytesRaw
1const { each, map } = require('libnested')
2const nest = require('depnest')
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
44

Built with git-ssb-web