Skip to content

Commit

Permalink
Change spelling
Browse files Browse the repository at this point in the history
  • Loading branch information
danvim committed Nov 26, 2023
1 parent 8aa2a31 commit e7b8353
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 12 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# React PDF Make Reconciler
# React pdfmake Reconciler

This package lets you create PDFs using PDF Make and React.
This package lets you create PDFs using pdfmake and React.

[![npm version](https://img.shields.io/npm/v/react-pdfmake-reconciler.svg?logo=npm)](https://www.npmjs.com/package/react-pdfmake-reconciler)

Expand All @@ -14,15 +14,15 @@ npm i react-pdfmake-reconciler

## Features

- Write complex PDF in JSX. Render JSX into PDF Make content structure.
- Write complex PDF in JSX. Render JSX into pdfmake content structure.
- Utilize React features like:
- Context. Note that outside React contexts do not penetrate into PDF renderer.
- Components
- Hooks
- Working React update loop, (although it is unlikely to trigger user events inside PDF.), e.g.
- async setState calls
- useEffect call
- TypeScript typing for PDF Make Components (`<pdf-*>` components)
- TypeScript typing for pdfmake Components (`<pdf-*>` components)
- React Developer Tools support

![React Developer Tools Demo](./screenshots/react-devtools-demo.png)
Expand Down Expand Up @@ -73,7 +73,7 @@ const document = PdfRenderer.renderOnce(<pdf-text bold>Hello World!</pdf-text>);

### PDF elements

Newly defined intrinsic elements by this package have the `pdf-` prefix. Roughly speaking, each type of PDF Make content object corresponds to one element type, where the property specifying the `Content` is mapped to the `children` prop. For example:
Newly defined intrinsic elements by this package have the `pdf-` prefix. Roughly speaking, each type of pdfmake content object corresponds to one element type, where the property specifying the `Content` is mapped to the `children` prop. For example:

```tsx
const pdfMakeContent = {
Expand Down Expand Up @@ -118,7 +118,7 @@ const pdfNode = (

### PdfPreview

`<PdfPreview>` provides an easy way to render your React PDF Make Reconciler JSX in the browser. You can also debug your PDF JSX using the [React Developer Tools](https://chromewebstore.google.com/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi) browser extension.
`<PdfPreview>` provides an easy way to render your React pdfmake Reconciler JSX in the browser. You can also debug your PDF JSX using the [React Developer Tools](https://chromewebstore.google.com/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi) browser extension.

```tsx
import { FC, StrictMode } from "react";
Expand Down
3 changes: 1 addition & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>React PDF Make Reconciler Demo</title>
<title>React pdfmake Reconciler Demo</title>
</head>
<body>
<div id="root"></div>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"type": "module",
"license": "MIT",
"author": "Daniel Cheung",
"description": "Writing PDF Make with React JSX using React Reconciler.",
"description": "Writing pdfmake with React JSX using React Reconciler.",
"keywords": [
"react",
"pdfmake",
Expand Down
17 changes: 15 additions & 2 deletions src/__tests__/PdfRenderer.test.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { describe, expect, test } from "vitest";
import { PdfRenderer } from "../PdfRenderer.tsx";
import { FC, useEffect, useState } from "react";
import { FC, Fragment, useEffect, useState } from "react";
import { PdfFooter, PdfHeader } from "../components";
import { DynamicPdfNode } from "../types/DynamicPdfNode.tsx";

describe("PdfRenderer", () => {
describe("PDF Make Content", () => {
describe("pdfmake Content", () => {
test("string", () => {
expect(PdfRenderer.renderOnce("Hello World!").content).toEqual(
"Hello World!",
Expand Down Expand Up @@ -260,6 +260,19 @@ describe("PdfRenderer", () => {
PdfRenderer.renderOnce(<pdf-array>Hello World!</pdf-array>).content,
).toEqual(["Hello World!"]);
});

test("fragment", () => {
expect(
PdfRenderer.renderOnce(
<pdf-stack>
{["Hello", <Fragment key={1}>World!</Fragment>]}
</pdf-stack>,
).content,
).toEqual({
$__reactPdfMakeType: "pdf-stack",
stack: ["Hello", "World!"],
});
});
});

describe("renderOnce", () => {
Expand Down
2 changes: 1 addition & 1 deletion src/demo/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function App() {

return (
<>
<h1>React PDF Make Reconciler</h1>
<h1>React pdfmake Reconciler</h1>
<p>
<a href="https://www.npmjs.com/package/react-pdfmake-reconciler">
NPM Package
Expand Down

0 comments on commit e7b8353

Please sign in to comment.