git ssb

1+

dinoworm ๐Ÿ› / catstack



Tree: 5652ef769b3e044a8a6243890c8a014dd296e9f6

Files: 5652ef769b3e044a8a6243890c8a014dd296e9f6 / css / index.js

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

Built with git-ssb-web