taro-css-to-react-native
Advanced tools
Comparing version 1.3.0-beta.5 to 1.3.0-beta.6
@@ -29,3 +29,13 @@ "use strict"; | ||
var numberMatch = value.match(numberOrLengthRe); | ||
if (numberMatch !== null) return Number(numberMatch[1]); | ||
if (numberMatch !== null) { | ||
var num = Number(numberMatch[1]); | ||
if (/px/.test(value)) { | ||
return "scalePx2dp(".concat(num, ")"); | ||
} else { | ||
return num; | ||
} | ||
} | ||
var boolMatch = input.match(boolRe); | ||
@@ -43,3 +53,4 @@ if (boolMatch !== null) return boolMatch[0].toLowerCase() === "true"; | ||
var baseTransformShorthandValue = function baseTransformShorthandValue(propName, inputValue) { | ||
var ast = (0, _postcssValueParser["default"])(inputValue.trim().replace(/PX|Px|pX$/g, "")); | ||
// const ast = parse(inputValue.trim().replace(/PX|Px|pX$/g, "")); | ||
var ast = (0, _postcssValueParser["default"])(inputValue); | ||
var tokenStream = new _TokenStream["default"](ast.nodes); | ||
@@ -46,0 +57,0 @@ return _index["default"][propName](tokenStream); |
@@ -40,3 +40,3 @@ "use strict"; | ||
var lengthRe = /^(0$|(?:[+-]?(?:\d*\.)?\d+(?:[Ee][+-]?\d+)?)(?=px$))/; | ||
var lengthRe = /^(0$|(?:[+-]?(?:\d*\.)?\d+(?:[Ee][+-]?\d+)?)((?=px$)|(?=Px$)|(?=PX$)|(?=pX$)))/; | ||
var unsupportedUnitRe = /^([+-]?(?:\d*\.)?\d+(?:[Ee][+-]?\d+)?(ch|em|ex|rem|vh|vw|vmin|vmax|cm|mm|in|pc|pt))$/; | ||
@@ -65,3 +65,8 @@ var angleRe = /^([+-]?(?:\d*\.)?\d+(?:[Ee][+-]?\d+)?(?:deg|rad))$/; | ||
var value = transform(match[1]); | ||
return value; | ||
if (/px/.test(node.value)) { | ||
return "scalePx2dp(".concat(value, ")"); | ||
} else { | ||
return value; | ||
} | ||
}; | ||
@@ -68,0 +73,0 @@ }; |
{ | ||
"name": "taro-css-to-react-native", | ||
"description": "Convert CSS text to a React Native stylesheet object", | ||
"version": "1.3.0-beta.5", | ||
"version": "1.3.0-beta.6", | ||
"main": "dist/index.js", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
@@ -18,3 +18,10 @@ /* eslint-disable no-param-reassign */ | ||
const numberMatch = value.match(numberOrLengthRe); | ||
if (numberMatch !== null) return Number(numberMatch[1]); | ||
if (numberMatch !== null) { | ||
const num = Number(numberMatch[1]); | ||
if (/px/.test(value)) { | ||
return `scalePx2dp(${num})`; | ||
} else { | ||
return num; | ||
} | ||
} | ||
@@ -34,3 +41,4 @@ const boolMatch = input.match(boolRe); | ||
const baseTransformShorthandValue = (propName, inputValue) => { | ||
const ast = parse(inputValue.trim().replace(/PX|Px|pX$/g, "")); | ||
// const ast = parse(inputValue.trim().replace(/PX|Px|pX$/g, "")); | ||
const ast = parse(inputValue); | ||
const tokenStream = new TokenStream(ast.nodes); | ||
@@ -60,3 +68,2 @@ return transforms[propName](tokenStream); | ||
: transformShorthandValue(propName, inputValue.trim()); | ||
return propValue && propValue.$merge | ||
@@ -63,0 +70,0 @@ ? propValue.$merge |
@@ -36,3 +36,3 @@ import { stringify } from "postcss-value-parser"; | ||
// Note lengthRe is sneaky: you can omit units for 0 | ||
const lengthRe = /^(0$|(?:[+-]?(?:\d*\.)?\d+(?:[Ee][+-]?\d+)?)(?=px$))/; | ||
const lengthRe = /^(0$|(?:[+-]?(?:\d*\.)?\d+(?:[Ee][+-]?\d+)?)((?=px$)|(?=Px$)|(?=PX$)|(?=pX$)))/; | ||
const unsupportedUnitRe = /^([+-]?(?:\d*\.)?\d+(?:[Ee][+-]?\d+)?(ch|em|ex|rem|vh|vw|vmin|vmax|cm|mm|in|pc|pt))$/; | ||
@@ -54,4 +54,7 @@ const angleRe = /^([+-]?(?:\d*\.)?\d+(?:[Ee][+-]?\d+)?(?:deg|rad))$/; | ||
const value = transform(match[1]); | ||
return value; | ||
if (/px/.test(node.value)) { | ||
return `scalePx2dp(${value})`; | ||
} else { | ||
return value; | ||
} | ||
}; | ||
@@ -58,0 +61,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
234838
8162