Skip to content

Commit 9939097

Browse files
committed
fix: color parse error (#2498)
* fix: color parse error * chore: bump color-string * chore: add changeset
1 parent eff3a41 commit 9939097

File tree

5 files changed

+17
-6
lines changed

5 files changed

+17
-6
lines changed

.changeset/fifty-bugs-change.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@react-pdf/stylesheet': patch
3+
'@react-pdf/render': patch
4+
---
5+
6+
fix: color parse error

packages/render/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"@react-pdf/textkit": "^4.2.1",
2525
"@react-pdf/types": "^2.3.5",
2626
"abs-svg-path": "^0.1.1",
27-
"color-string": "^1.5.3",
27+
"color-string": "^1.9.1",
2828
"normalize-svg-path": "^1.1.0",
2929
"parse-svg-path": "^0.1.2",
3030
"svg-arc-to-cubic-bezier": "^3.2.0"

packages/render/src/utils/parseColor.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
import colorString from 'color-string';
22

3+
const black = { value: [0, 0, 0], opacity: 1 };
4+
35
const parseColor = hex => {
46
const parsed = colorString.get(hex);
7+
8+
if (!parsed) return black;
9+
510
const value = colorString.to.hex(parsed.value.slice(0, 3));
611
const opacity = parsed.value[3];
712

packages/stylesheet/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"@babel/runtime": "^7.20.13",
2222
"@react-pdf/fns": "2.0.1",
2323
"@react-pdf/types": "^2.3.5",
24-
"color-string": "^1.5.3",
24+
"color-string": "^1.9.1",
2525
"hsl-to-hex": "^1.0.0",
2626
"media-engine": "^1.0.3",
2727
"postcss-value-parser": "^4.1.0"

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3781,10 +3781,10 @@ color-name@^1.0.0, color-name@~1.1.4:
37813781
resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2"
37823782
integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==
37833783

3784-
color-string@^1.5.3:
3785-
version "1.5.5"
3786-
resolved "https://registry.yarnpkg.com/color-string/-/color-string-1.5.5.tgz#65474a8f0e7439625f3d27a6a19d89fc45223014"
3787-
integrity sha512-jgIoum0OfQfq9Whcfc2z/VhCNcmQjWbey6qBX0vqt7YICflUmBCh9E9CiQD5GSJ+Uehixm3NUwHVhqUAWRivZg==
3784+
color-string@^1.9.1:
3785+
version "1.9.1"
3786+
resolved "https://registry.yarnpkg.com/color-string/-/color-string-1.9.1.tgz#4467f9146f036f855b764dfb5bf8582bf342c7a4"
3787+
integrity sha512-shrVawQFojnZv6xM40anx4CkoDP+fZsw/ZerEMsW/pyzsRbElpsL/DBVW7q3ExxwusdNXI3lXpuhEZkzs8p5Eg==
37883788
dependencies:
37893789
color-name "^1.0.0"
37903790
simple-swizzle "^0.2.2"

0 commit comments

Comments
 (0)