All files / src/adapters react-fela.js

100% Statements 5/5
100% Branches 2/2
100% Functions 2/2
100% Lines 5/5
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34  3x   3x 1x     2x           2x                                        
function stringifyDeclaration(declaration) {
  const prop = '"' +declaration.property + '":'
 
  if (typeof declaration.value === 'object') {
    return prop + '{' + declaration.value.map(stringifyDeclaration).join(',\n') + '}'
  }
 
  return prop + 'props.' + declaration.value
}
 
export default {
  name: 'react-fela',
  stringify: (declarations, className) =>
    "import './" +
    className +
    ".elodin.css'\n" +
    "import { createComponent } from 'react-fela'\n\n" +
    'function ' +
    className +
    '(props)' +
    ' {\n  ' +
    'return {\n    ' +
    "_className: '" +
    className +
    "',\n    " +
    declarations
      .map(stringifyDeclaration)
      .join(',\n    ') +
    '\n  }\n}\n\n' +
    'export default createComponent(' +
    className +
    ')',
}