Skip to content

Commit 3262159

Browse files
authored
fix: zero value should make sense (vercel#696)
1 parent 691f01d commit 3262159

File tree

5 files changed

+27
-7
lines changed

5 files changed

+27
-7
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103
"@shuding/opentype.js": "1.4.0-beta.0",
104104
"css-background-parser": "^0.1.0",
105105
"css-box-shadow": "1.0.0-3",
106-
"css-gradient-parser": "^0.0.16",
106+
"css-gradient-parser": "^0.0.17",
107107
"css-to-react-native": "^3.0.0",
108108
"emoji-regex-xs": "^2.0.1",
109109
"escape-html": "^1.0.3",

pnpm-lock.yaml

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/builder/gradient/radial.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ function calcRadialGradient(
153153
xDelta,
154154
style,
155155
true
156-
) || xDelta / 2
156+
) ?? xDelta / 2
157157
}
158158

159159
if (cy.type === 'keyword') {
@@ -169,7 +169,7 @@ function calcRadialGradient(
169169
yDelta,
170170
style,
171171
true
172-
) || yDelta / 2
172+
) ?? yDelta / 2
173173
}
174174

175175
return pos
3.71 KB
Loading

test/gradient.test.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,26 @@ describe('Gradient', () => {
172172
expect(toImage(svg, 100)).toMatchImageSnapshot()
173173
})
174174

175+
it('should make sense if x of y is zero', async () => {
176+
const svg = await satori(
177+
<div
178+
style={{
179+
backgroundColor: 'white',
180+
backgroundImage: 'radial-gradient(circle at 0px 0%, blue, red)',
181+
backgroundSize: '100px 100px',
182+
height: '100%',
183+
width: '100%',
184+
}}
185+
></div>,
186+
{
187+
width: 100,
188+
height: 100,
189+
fonts,
190+
}
191+
)
192+
expect(toImage(svg, 100)).toMatchImageSnapshot()
193+
})
194+
175195
it('should support radial-gradient with unspecified <ending-shape>', async () => {
176196
const svg = await satori(
177197
<div

0 commit comments

Comments
 (0)