diff --git a/.gitignore b/.gitignore index 725c6881..3fbb8b82 100644 --- a/.gitignore +++ b/.gitignore @@ -27,5 +27,4 @@ test/**/next-env.d.ts **/.idea **/.vscode -public build \ No newline at end of file diff --git a/jest.config.js b/jest.config.js index c152beaf..5bcd2934 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,7 +1,11 @@ module.exports = { preset: 'ts-jest', testEnvironment: 'node', - "modulePaths": [ - "" - ], + globals: { + 'ts-jest': { + diagnostics: { + ignoreCodes: ["151001"] + } + } + } }; \ No newline at end of file diff --git a/package.json b/package.json index 4659c9a0..21856da8 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "watch": "rollup -c -w", "release": "rollup -c --environment INCLUDE_DEPS,BUILD:production", "postbuild": "purgecss -c purgecss.config.js -o public", - "wp": "npx webpack --mode=development --watch", + "wp": "webpack --mode=development --watch", "test": "jest", "coverage": "jest --coverage", "start": "sirv public" @@ -25,9 +25,6 @@ "tailwindcss": "^1.4.6" }, "devDependencies": { - "@babel/core": "^7.10.3", - "@babel/preset-env": "^7.10.3", - "@babel/preset-typescript": "^7.10.1", "@fullhuman/postcss-purgecss": "^2.3.0", "@rollup/plugin-commonjs": "^11.0.2", "@rollup/plugin-image": "^2.0.4", diff --git a/parent b/parent deleted file mode 100644 index bdebb5b0..00000000 --- a/parent +++ /dev/null @@ -1,4 +0,0 @@ - Invalid testPattern /Users/bernardoferrari/Documents/figma_to_code/src/test/tailwind/builderImpl/tailwindSize.test.ts|size|+|stroke|sizecd /Users/bernardoferrari/Documents/figma_to_code -node /Users/bernardoferrari/Documents/figma_to_code/node_modules/.bin/jest /Users/bernardoferrari/Documents/figma_to_code/src/test/tailwind/builderImpl/tailwindSize.test.ts -t Tailwind|Builder|adjust|parent|if|childrens size \+ stroke > parent size supplied. Running all tests instead. - Invalid testPattern /Users/bernardoferrari/Documents/figma_to_code/src/test/tailwind/builderImpl/tailwindSize.test.ts|size|+|stroke|sizecd /Users/bernardoferrari/Documents/figma_to_code -node /Users/bernardoferrari/Documents/figma_to_code/node_modules/.bin/jest /Users/bernardoferrari/Documents/figma_to_code/src/test/tailwind/builderImpl/tailwindSize.test.ts -t Tailwind|Builder|adjust|parent|if|childrens size \+ stroke > parent size supplied. Running all tests instead. diff --git a/public/README.md b/public/README.md new file mode 100644 index 00000000..0f2d3b42 --- /dev/null +++ b/public/README.md @@ -0,0 +1,3 @@ +# Public Directory + +This directory is empty for a reason: [Rollup](https://rollupjs.org/) needs it, else it fails. This is where the output will be. diff --git a/src/flutter/make_container.ts b/src/flutter/make_container.ts index c15971b2..df97486a 100644 --- a/src/flutter/make_container.ts +++ b/src/flutter/make_container.ts @@ -24,7 +24,7 @@ export const makeContainer = ( const size = nodeWidthHeight(node, false); let propWidth = size.width ? `width: ${size.width}, ` : ""; let propHeight = size.height ? `height: ${size.height}, ` : ""; - const propWidthHeight: string = `SizedBox(${propWidth}${propHeight})`; + const propWidthHeight: string = `${propWidth}${propHeight}`; if (node.fills !== figma.mixed && node.fills.length > 0) { let fill = node.fills[0]; diff --git a/src/flutter/make_material.ts b/src/flutter/make_material.ts index 35e3632f..bfaa25a2 100644 --- a/src/flutter/make_material.ts +++ b/src/flutter/make_material.ts @@ -4,7 +4,7 @@ import { AltFrameNode, } from "../common/altMixins"; import { rgbaTohex, flutterColor } from "./flutter_helpers"; -import { getContainerSizeProp } from "./make_container"; +import { nodeWidthHeight } from "../common/nodeWidthHeight"; // https://api.flutter.dev/flutter/material/Material-class.html export const makeMaterial = ( @@ -61,7 +61,11 @@ export const makeMaterial = ( const material = `\nMaterial(${color}${elevation}${shadowColor}${shape}${clipContent}${padChild}),`; - const propWidthHeight: string = getContainerSizeProp(node); + const size = nodeWidthHeight(node, false); + let propWidth = size.width ? `width: ${size.width}, ` : ""; + let propHeight = size.height ? `height: ${size.height}, ` : ""; + const propWidthHeight: string = `${propWidth}${propHeight}`; + if (propWidthHeight) { return `SizedBox(${propWidthHeight}child: ${material}),`; } diff --git a/src/tailwind/builderText.ts b/src/tailwind/builderText.ts index 22040ac4..b3ea05a4 100644 --- a/src/tailwind/builderText.ts +++ b/src/tailwind/builderText.ts @@ -97,7 +97,7 @@ export class tailwindTextNodeBuilder extends tailwindDefaultBuilder { * example: font-extrabold * example: italic */ - fontStyle = (node: AltTextNode): this => { + fontStyle(node: AltTextNode): this { if (node.fontName !== figma.mixed) { const lowercaseStyle = node.fontName.style.toLowerCase(); @@ -118,13 +118,13 @@ export class tailwindTextNodeBuilder extends tailwindDefaultBuilder { this.attributes += `font-${value} `; } return this; - }; + } /** * https://tailwindcss.com/docs/letter-spacing/ * example: tracking-widest */ - letterSpacing = (node: AltTextNode): this => { + letterSpacing(node: AltTextNode): this { if (node.letterSpacing !== figma.mixed) { if ( node.letterSpacing.unit === "PIXELS" && @@ -142,7 +142,7 @@ export class tailwindTextNodeBuilder extends tailwindDefaultBuilder { } } return this; - }; + } /** * https://tailwindcss.com/docs/line-height/ diff --git a/tsconfig.json b/tsconfig.json index 980b88fb..16e7d350 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,7 +4,6 @@ "module": "es6", "sourceMap": true, "target": "es6", - "moduleResolution": "node", "typeRoots": ["./node_modules/@types", "./node_modules/@figma"] } }