pre-style icon indicating copy to clipboard operation
pre-style copied to clipboard

Add PreStyle method-like syntax and utility

Open soluml opened this issue 8 years ago • 0 comments

Where all template strings are treated as code blocks. Optionally import on PreStyle for a simple method that filters and joins strings.

Example:

import PreStyle from 'pre-style';

const attrs = {
  className: PreStyle(
    `
      font-weight: bold;
      text-align: center;
    `,
    (val === 0 && `color: $color1;`),
    (val === 1 && `color: $color2;`),
    (val === 2 && `color: $color3;`)
  )
};

Would Become:

import PreStyle from 'pre-style';

const attrs = {
  className: PreStyle("A B", "C", "D", "E") //"C", "D" or "E" depending on which is true. Falsey values are stripped by PreStyle method
};

soluml avatar Apr 07 '17 20:04 soluml