-
Notifications
You must be signed in to change notification settings - Fork 249
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: background-clip:text should compatible with transform and mask (#…
…639)
- Loading branch information
1 parent
618d565
commit 11575c9
Showing
5 changed files
with
110 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+1.58 KB
...und-clip-test-tsx-background-clip-should-render-background-clip-text-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.18 KB
...kground-clip-should-render-background-clip-text-compatible-with-mask-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.57 KB
...nd-clip-should-render-background-clip-text-compatible-with-transform-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
import { it, describe, expect } from 'vitest' | ||
|
||
import { initFonts, toImage } from './utils.js' | ||
import satori from '../src/index.js' | ||
|
||
describe('backgroundClip', () => { | ||
let fonts | ||
initFonts((f) => (fonts = f)) | ||
|
||
it('should render background-clip:text', async () => { | ||
const svg = await satori( | ||
<div | ||
style={{ | ||
display: 'flex', | ||
fontSize: 30, | ||
flexDirection: 'column', | ||
background: '#ffffff', | ||
}} | ||
> | ||
<div | ||
style={{ | ||
backgroundImage: 'linear-gradient(to right, red, green)', | ||
WebkitBackgroundClip: 'text', | ||
backgroundClip: 'text', | ||
color: 'transparent', | ||
}} | ||
> | ||
lynn | ||
</div> | ||
</div>, | ||
{ | ||
width: 100, | ||
height: 100, | ||
fonts, | ||
} | ||
) | ||
|
||
expect(toImage(svg)).toMatchImageSnapshot() | ||
}) | ||
|
||
it('should render background-clip:text compatible with transform', async () => { | ||
const svg = await satori( | ||
<div | ||
style={{ | ||
display: 'flex', | ||
fontSize: 30, | ||
flexDirection: 'column', | ||
background: '#ffffff', | ||
}} | ||
> | ||
<div | ||
style={{ | ||
transform: 'translateX(25px)', | ||
backgroundImage: 'linear-gradient(to right, red, green)', | ||
WebkitBackgroundClip: 'text', | ||
backgroundClip: 'text', | ||
color: 'transparent', | ||
}} | ||
> | ||
lynn | ||
</div> | ||
</div>, | ||
{ | ||
width: 100, | ||
height: 100, | ||
fonts, | ||
} | ||
) | ||
|
||
expect(toImage(svg)).toMatchImageSnapshot() | ||
}) | ||
|
||
it('should render background-clip:text compatible with mask', async () => { | ||
const svg = await satori( | ||
<div | ||
style={{ | ||
display: 'flex', | ||
fontSize: 30, | ||
flexDirection: 'column', | ||
background: '#ffffff', | ||
}} | ||
> | ||
<div | ||
style={{ | ||
transform: 'translateX(25px)', | ||
backgroundImage: 'linear-gradient(to right, red, green)', | ||
WebkitBackgroundClip: 'text', | ||
backgroundClip: 'text', | ||
maskImage: 'linear-gradient(to right, blue, transparent)', | ||
color: 'transparent', | ||
}} | ||
> | ||
lynn | ||
</div> | ||
</div>, | ||
{ | ||
width: 100, | ||
height: 100, | ||
fonts, | ||
} | ||
) | ||
|
||
expect(toImage(svg)).toMatchImageSnapshot() | ||
}) | ||
}) |