-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix text inside links * add changeset
- Loading branch information
Showing
5 changed files
with
56 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@react-pdf/renderer': patch | ||
--- | ||
|
||
render text inside links |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import React from 'react'; | ||
import { Document, Page, Link, Font, Text } from '..'; | ||
import renderToImage from './renderComponent'; | ||
|
||
// pdf.js does not render default fonts in node and I use Open Sans (: | ||
Font.register({ | ||
family: 'Open Sans', | ||
src: 'https://fonts.gstatic.com/s/opensans/v17/mem8YaGs126MiZpBA-UFVZ0e.ttf', | ||
}); | ||
|
||
const mount = async children => { | ||
const image = await renderToImage( | ||
<Document> | ||
<Page size={[50, 25]}>{children}</Page> | ||
</Document>, | ||
); | ||
|
||
return image; | ||
}; | ||
|
||
describe('Link', () => { | ||
test('should render text', async () => { | ||
const image = await mount( | ||
<Link | ||
href="https://github.com/wojtekmaj/react-pdf" | ||
style={{ fontFamily: 'Open Sans' }} | ||
> | ||
hello | ||
</Link>, | ||
); | ||
|
||
expect(image).toMatchImageSnapshot(); | ||
}); | ||
|
||
test('should render TEXT component', async () => { | ||
const image = await mount( | ||
<Link | ||
href="https://github.com/wojtekmaj/react-pdf" | ||
style={{ fontFamily: 'Open Sans', textDecoration: 'none' }} | ||
> | ||
he | ||
<Text style={{ textDecoration: 'underline' }}>llo</Text> | ||
</Link>, | ||
); | ||
|
||
expect(image).toMatchImageSnapshot(); | ||
}); | ||
}); |
Binary file added
BIN
+799 Bytes
packages/renderer/tests/snapshots/link-test-js-link-should-render-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
+805 Bytes
...derer/tests/snapshots/link-test-js-link-should-render-text-component-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.