Skip to content

Commit ce0ef49

Browse files
authored
Merge pull request #5 from kristerkari/feature/update-css-to-react-native-to-v2.1.1
Update css-to-react-native to version 2.1.1
2 parents 15089f4 + 9768967 commit ce0ef49

File tree

5 files changed

+51
-52
lines changed

5 files changed

+51
-52
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
},
2727
"dependencies": {
2828
"css": "^2.2.1",
29-
"css-to-react-native": "^2.1.0"
29+
"css-to-react-native": "^2.1.1"
3030
},
3131
"repository": {
3232
"type": "git",

src/index.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import parseCSS from "css/lib/parse";
22
import transformCSS from "css-to-react-native";
3-
import { boxShadowToShadowProps } from "./transforms/boxShadow";
43
import { remToPx } from "./transforms/rem";
54
import { camelCase } from "./utils/camelCase";
65
import { allEqual } from "./utils/allEqual";
@@ -34,11 +33,7 @@ const transform = css => {
3433
const property = declaration.property;
3534
const value = remToPx(declaration.value);
3635

37-
// box-shadow is implemented in css-to-react-native,
38-
// but it's missing some features like rgb/rgba colors.
39-
if (property === "box-shadow") {
40-
Object.assign(styles, boxShadowToShadowProps(value));
41-
} else if (shorthandBorderProps.indexOf(property) > -1) {
36+
if (shorthandBorderProps.indexOf(property) > -1) {
4237
// transform single value shorthand border properties back to
4338
// shorthand form to support styling `Image`.
4439
const transformed = transformCSS([[property, value]]);

src/index.spec.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1407,6 +1407,40 @@ describe("box-shadow", () => {
14071407
});
14081408
});
14091409

1410+
it("supports box-shadow with hsl color", () => {
1411+
expect(
1412+
transform(`
1413+
.test {
1414+
box-shadow: 10px 20px 30px hsl(120, 100%, 50%);
1415+
}
1416+
`),
1417+
).toEqual({
1418+
test: {
1419+
shadowOffset: { width: 10, height: 20 },
1420+
shadowRadius: 30,
1421+
shadowColor: "hsl(120, 100%, 50%)",
1422+
shadowOpacity: 1,
1423+
},
1424+
});
1425+
});
1426+
1427+
it("supports box-shadow with hsla color", () => {
1428+
expect(
1429+
transform(`
1430+
.test {
1431+
box-shadow: 10px 20px 30px hsla(120, 100%, 50%, 0.7);
1432+
}
1433+
`),
1434+
).toEqual({
1435+
test: {
1436+
shadowOffset: { width: 10, height: 20 },
1437+
shadowRadius: 30,
1438+
shadowColor: "hsla(120, 100%, 50%, 0.7)",
1439+
shadowOpacity: 1,
1440+
},
1441+
});
1442+
});
1443+
14101444
it("trims values", () => {
14111445
expect(
14121446
transform(`
@@ -1530,6 +1564,18 @@ describe("box-shadow", () => {
15301564
}).toThrowError('Failed to parse declaration "boxShadow: red"');
15311565
});
15321566

1567+
it("transforms box-shadow and throws if multiple colors are used", () => {
1568+
expect(() => {
1569+
transform(`
1570+
.test {
1571+
box-shadow: 0 0 0 red yellow green blue;
1572+
}
1573+
`);
1574+
}).toThrowError(
1575+
'Failed to parse declaration "boxShadow: 0 0 0 red yellow green blue"',
1576+
);
1577+
});
1578+
15331579
it("transforms box-shadow and enforces offset-y if offset-x present", () => {
15341580
expect(() => {
15351581
transform(`

src/transforms/boxShadow.js

Lines changed: 0 additions & 42 deletions
This file was deleted.

yarn.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -966,9 +966,9 @@ css-color-keywords@^1.0.0:
966966
version "1.0.0"
967967
resolved "https://registry.yarnpkg.com/css-color-keywords/-/css-color-keywords-1.0.0.tgz#fea2616dc676b2962686b3af8dbdbe180b244e05"
968968

969-
css-to-react-native@^2.1.0:
970-
version "2.1.0"
971-
resolved "https://registry.yarnpkg.com/css-to-react-native/-/css-to-react-native-2.1.0.tgz#671b922aa3c0bc880e09f8f00e5a4bf0803928e5"
969+
css-to-react-native@^2.1.1:
970+
version "2.1.1"
971+
resolved "https://registry.yarnpkg.com/css-to-react-native/-/css-to-react-native-2.1.1.tgz#ea0f6ca3cdbc37cb40f3f4f55b49d3bb28b8a43e"
972972
dependencies:
973973
css-color-keywords "^1.0.0"
974974
fbjs "^0.8.5"

0 commit comments

Comments
 (0)