@figma-export/output-components-as-es6
Advanced tools
Comparing version 1.2.0 to 2.0.0-alpha.0
26
index.js
@@ -5,9 +5,7 @@ const fs = require('fs'); | ||
const svgToMiniDataURI = require('mini-svg-data-uri'); | ||
const { camelCase } = require('@figma-export/output-components-utils'); | ||
const { getVariableName } = require('./utils'); | ||
module.exports = ({ | ||
output, | ||
variablePrefix = '', | ||
variableSuffix = '', | ||
getVariableName = (options) => camelCase(options.componentName.trim()), | ||
useBase64 = false, | ||
@@ -21,7 +19,16 @@ useDataUrl = false, | ||
components.forEach(({ name: componentName, svg }) => { | ||
const variableName = getVariableName(`${variablePrefix} ${componentName} ${variableSuffix}`); | ||
let variableValue = svg; | ||
components.forEach(({ name: componentName, svg, figmaExport }) => { | ||
const options = { | ||
pageName, | ||
componentName, | ||
...figmaExport, | ||
}; | ||
// eslint-disable-next-line default-case | ||
const variableName = getVariableName(options); | ||
let variableValue; | ||
if (/^[\d]+/.test(variableName)) { | ||
throw new Error(`"${componentName.trim()}" thrown an error: component names cannot start with a number.`); | ||
} | ||
switch (true) { | ||
@@ -34,2 +41,5 @@ case useBase64: | ||
break; | ||
default: | ||
variableValue = svg; | ||
break; | ||
} | ||
@@ -36,0 +46,0 @@ |
@@ -7,2 +7,3 @@ /* eslint-disable no-console */ | ||
const fs = require('fs'); | ||
const { camelCase } = require('@figma-export/output-components-utils'); | ||
@@ -40,4 +41,3 @@ const figmaDocument = require('../core/lib/_config.test'); | ||
output: 'output', | ||
variablePrefix: 'i', | ||
variableSuffix: 'my ico', | ||
getVariableName: (options) => camelCase(`i ${options.componentName} my ico`), | ||
})(pages); | ||
@@ -44,0 +44,0 @@ |
{ | ||
"name": "@figma-export/output-components-as-es6", | ||
"version": "1.2.0", | ||
"version": "2.0.0-alpha.0", | ||
"description": "Outputter for @figma-export that exports components in javascript file", | ||
@@ -17,6 +17,7 @@ "main": "index.js", | ||
"dependencies": { | ||
"@figma-export/output-components-utils": "^2.0.0-alpha.0", | ||
"make-dir": "~3.0.0", | ||
"mini-svg-data-uri": "~1.1.3" | ||
}, | ||
"gitHead": "b084462214ea7a479208f6ebaffe089798cd5b42" | ||
"gitHead": "5829e7cabc31421abc415a1383bb2721c3e23246" | ||
} |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
10316
3
5
147
2
+ Added@figma-export/output-components-utils@2.2.0(transitive)