git ssb

1+

dinoworm ๐Ÿ› / catstack



Tree: 7bf5ec33ab5ac86937dc5fc28941ed05996aeddd

Files: 7bf5ec33ab5ac86937dc5fc28941ed05996aeddd / css / index.js

1745 bytesRaw
1const nest = require('depnest')
2const assign = require('object-assign')
3const { createRenderer, combineRules, enhance } = require('fela')
4const { render } = require('fela-dom')
5const devPlugins = require('fela-preset-dev')
6const webPlugins = require('fela-preset-web')
7
8module.exports = {
9 gives: nest('css', [
10 'config',
11 'render',
12 'renderer',
13 'renderRule'
14 ]),
15 needs: nest({
16 'config.all': 'first',
17 css: {
18 config: 'reduce',
19 renderer: 'first'
20 }
21 }),
22 create: (api) => {
23 var renderer
24 return nest('css', {
25 config: (sofar = {}) => assign({}, sofar, {
26 plugins: [
27 ...(sofar.plugins || []),
28 ...webPlugins,
29 // TODO
30 //...(api.config.all().nodeDev === 'development' ? devPlugins : [])
31 ...devPlugins
32 ]
33 }),
34 combineRules,
35 enhance,
36 renderer: () => {
37 if (!renderer) renderer = createRenderer(api.css.config())
38 return renderer
39 },
40 render: (mountNode) => render(api.css.renderer(), mountNode),
41 renderRule: (rule, props) => {
42 return api.css.renderer().renderRule(rule, props)
43 },
44 renderKeyframe: (keyframe, props) => {
45 return api.css.renderer().renderKeyframe(keyframe, props)
46 },
47 renderFont: (family, files, properties) => {
48 return api.css.renderer().renderFont(family, files, properties)
49 },
50 renderStatic: (style, selector) => {
51 return api.css.renderer().renderStatic(style, selector)
52 },
53 renderToString: () => api.css.renderer().renderToString(),
54 subscribe: (listener) => {
55 return api.css.renderer().subscribe(listener)
56 },
57 clear: () => api.css.renderer().clear()
58 })
59 }
60}
61

Built with git-ssb-web