so://phie

figure

The vanilla alternative for writing JSX-based React applications
git clone git://soophie.de/figure

blob: dbf95755178b336dc1bbc0057b84bbbb74525013 (837 bytes)[doc][blame][raw]

1export const defCss = ({html, compose, feed}) => {

2 return (parts, ...props) => {

3 const [css, refs] = compose(parts, props);

4 return html`

5 <style type="text/css">

6 ${feed(css, refs).join('')}

7 </style>

8 `;

9 };

10}

11

12export const defStyle = ({compose, feed}) => {

13 return (parts, ...props) => {

14 const [css, refs] = compose(parts, props);

15 const styles = {};

16 for(const item of css.split(';')) {

17 if(item.trim().length === 0) {

18 break;

19 }

20 let [key, value] = item.split(':');

21 key = key.trim();

22 let match = null;

23 if((match = /-(\w)/.exec(key)) !== null) {

24 const char = match[1];

25 key = key.replace(`-${char}`, char.toUpperCase());

26 }

27 value = value.trim();

28 styles[key] = feed(value, refs).join('');

29 }

30 return styles;

31 };

32}