-
Notifications
You must be signed in to change notification settings - Fork 242
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
### Description 1. Default to the current color when `textDecorationColor` is unset. 2. Resolve incorrect positioning of decoration line. 3. Address inaccurate line-through positioning. <img width="1438" alt="image" src="https://github.com/vercel/satori/assets/22126563/71e401e1-f03d-45e4-a5ad-c202487ad605"> <img width="912" alt="image" src="https://github.com/vercel/satori/assets/22126563/fe010957-ce7c-401d-bf02-e59e1a03a2a9"> Closes: #530
- Loading branch information
Showing
8 changed files
with
181 additions
and
26 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
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
+7.27 KB
...oration-should-work-correctly-when-text-decoration-line-line-through-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
+8.74 KB
...orrectly-when-text-decoration-line-line-through-and-text-align-right-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
+8.57 KB
...k-correctly-when-text-decoration-line-underline-and-text-align-right-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
+7.75 KB
...t-decoration-should-work-correctly-when-text-decoration-style-dashed-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
+7.36 KB
...t-decoration-should-work-correctly-when-text-decoration-style-dotted-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,155 @@ | ||
import { it, describe, expect } from 'vitest' | ||
|
||
import { initFonts, loadDynamicAsset, toImage } from './utils.js' | ||
import satori from '../src/index.js' | ||
|
||
describe('Text Decoration', () => { | ||
let fonts | ||
initFonts((f) => (fonts = f)) | ||
|
||
it('Should work correctly when `text-decoration-line: line-through` and `text-align: right`', async () => { | ||
const svg = await satori( | ||
<div | ||
style={{ | ||
height: '100%', | ||
width: '100%', | ||
display: 'flex', | ||
flexDirection: 'column', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
backgroundColor: '#fff', | ||
fontSize: 20, | ||
fontWeight: 600, | ||
}} | ||
> | ||
<div | ||
style={{ | ||
maxWidth: '190px', | ||
backgroundColor: '#91a8d0', | ||
textDecorationLine: 'line-through', | ||
color: 'white', | ||
textAlign: 'center', | ||
}} | ||
> | ||
你好! It doesn’t 안녕! exist, it never has. I’m nostalgic for a place | ||
that never existed. | ||
</div> | ||
</div>, | ||
{ | ||
width: 200, | ||
height: 200, | ||
fonts, | ||
loadAdditionalAsset: (languageCode: string, segment: string) => { | ||
return loadDynamicAsset(languageCode, segment) as any | ||
}, | ||
} | ||
) | ||
expect(toImage(svg, 200)).toMatchImageSnapshot() | ||
}) | ||
|
||
it('Should work correctly when `text-decoration-line: underline` and `text-align: right`', async () => { | ||
const svg = await satori( | ||
<div | ||
style={{ | ||
height: '100%', | ||
width: '100%', | ||
display: 'flex', | ||
flexDirection: 'column', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
backgroundColor: '#fff', | ||
fontSize: 20, | ||
fontWeight: 600, | ||
}} | ||
> | ||
<div | ||
style={{ | ||
maxWidth: '190px', | ||
backgroundColor: '#91a8d0', | ||
textDecorationLine: 'underline', | ||
color: 'white', | ||
textAlign: 'right', | ||
}} | ||
> | ||
你好! It doesn’t 안녕! exist, it never has. I’m nostalgic for a place | ||
that never existed. | ||
</div> | ||
</div>, | ||
{ | ||
width: 200, | ||
height: 200, | ||
fonts, | ||
loadAdditionalAsset: (languageCode: string, segment: string) => { | ||
return loadDynamicAsset(languageCode, segment) as any | ||
}, | ||
} | ||
) | ||
expect(toImage(svg, 200)).toMatchImageSnapshot() | ||
}) | ||
|
||
it('Should work correctly when `text-decoration-style: dotted`', async () => { | ||
const svg = await satori( | ||
<div | ||
style={{ | ||
height: '100%', | ||
width: '100%', | ||
display: 'flex', | ||
flexDirection: 'column', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
backgroundColor: '#fff', | ||
fontSize: 20, | ||
fontWeight: 600, | ||
}} | ||
> | ||
<div | ||
style={{ | ||
maxWidth: '190px', | ||
backgroundColor: '#91a8d0', | ||
textDecorationLine: 'underline', | ||
textDecorationStyle: 'dotted', | ||
color: 'white', | ||
}} | ||
> | ||
It doesn’t exist, it never has. I’m nostalgic for a place that never | ||
existed. | ||
</div> | ||
</div>, | ||
{ width: 200, height: 200, fonts } | ||
) | ||
expect(toImage(svg, 200)).toMatchImageSnapshot() | ||
}) | ||
|
||
it('Should work correctly when `text-decoration-style: dashed`', async () => { | ||
const svg = await satori( | ||
<div | ||
style={{ | ||
height: '100%', | ||
width: '100%', | ||
display: 'flex', | ||
flexDirection: 'column', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
backgroundColor: '#fff', | ||
fontSize: 20, | ||
fontWeight: 600, | ||
}} | ||
> | ||
<div | ||
style={{ | ||
maxWidth: '190px', | ||
backgroundColor: '#91a8d0', | ||
textDecorationLine: 'underline', | ||
textDecorationStyle: 'dashed', | ||
color: 'white', | ||
}} | ||
> | ||
It doesn’t exist, it never has. I’m nostalgic for a place that never | ||
existed. | ||
</div> | ||
</div>, | ||
{ width: 200, height: 200, fonts } | ||
) | ||
expect(toImage(svg, 200)).toMatchImageSnapshot() | ||
}) | ||
}) |
c47e1a9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
satori-playground – ./
satori-playground.vercel.app
satori-playground.vercel.sh
og-playground.vercel.sh
og-playground.vercel.app
satori-playground-git-main.vercel.sh