@pdfslick/solid 1.1.3 → 1.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +41 -70
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  <br><br>
6
6
  <div align="center">
7
- View and Interact with PDFs in React and SolidJS apps
7
+ View and Interact with PDF documents in SolidJS apps
8
8
  <br><br>
9
9
 
10
10
  [Getting Started](https://pdfslick.dev/docs) | [Examples](https://pdfslick.dev/examples)
@@ -15,69 +15,12 @@ View and Interact with PDFs in React and SolidJS apps
15
15
  ---
16
16
  <br>
17
17
 
18
- PDFSlick is a library that enables viewing of and interaction with PDF documents in React and SolidJS apps.
18
+ PDFSlick for Solid is a library which enables viewing of and interaction with PDF documents in SolidJS apps.
19
19
  It's build on top of Mozilla's [PDF.js](https://github.com/mozilla/pdf.js), and utilises [Zustand](https://github.com/pmndrs/zustand) to provide a reactive store for the loaded documents.
20
20
 
21
- ## Motivation
21
+ ## Getting started with PDFSlick for SolidJS
22
22
 
23
- [PDF.js](https://github.com/mozilla/pdf.js) is an amazing piece of software. It is also a very stable and mature one — it powers the PDF viewer in Mozilla Firefox and it's been around since 2011. However, it's all Vanilla JavaScript, and when it comes to using it with libraries like React and SolidJS (although possible) it's a litte bit hard in terms of integrating it in these Component- and reactive-like environments. PDFSlick attempts to wrap all of that fascinating functionality into one that is easier to fit in React and SolidJS worlds — as components and a reactive store.
24
-
25
- ## Core Concepts
26
-
27
- The core of PDFSlick is within the `@pdfslick/core` package. It wraps `PDF.js`'s functionality and links it to the store. This `@pdfslick/core` package is the basis for the React and SolidJS packages, which additionally transform the store and make it suitable for the adequate library, as well as providing components for the PDF viewer and thumbnails.
28
-
29
- Depending on your needs, at this you might find it useful to continue with learning more about using PDFSlick with React and SolidJS respsectivelly. However, if really interested you can learn more about using PDFSlick's `@pdfslick/core` package with Vanilla JS apps and with libraries other than React and SolidJS in the sections below.
30
-
31
- ## Getting Started with React
32
-
33
- To get started with React run:
34
- ```shell
35
- npm install @pdfslick/react
36
- # yarn add @pdfslick/react
37
- # pnpm add @pdfslick/react
38
- ```
39
-
40
- You can start using PDFSlick with the `usePDFSlick()` hook, like with the following basic example:
41
- ```jsx
42
- import { usePDFSlick } from "@pdfslick/react";
43
- import PDFNavigation from "./PDFNavigation";
44
-
45
- import "@pdfslick/react/dist/pdf_viewer.css";
46
-
47
- type PDFViewerAppProps = {
48
- pdfFilePath: string;
49
- };
50
-
51
- const SimplePDFViewer = ({ pdfFilePath }: PDFViewerAppProps) => {
52
- const { viewerRef, usePDFSlickStore, PDFSlickViewer } = usePDFSlick(pdfFilePath, {
53
- singlePageViewer: true,
54
- scaleValue: "page-fit"
55
- });
56
-
57
- return (
58
- <div className="absolute inset-0 bg-slate-200/70 pdfSlick">
59
- <div className="flex-1 relative h-full">
60
- <PDFSlickViewer {...{ viewerRef, usePDFSlickStore }} />
61
- <PDFNavigation {...{ usePDFSlickStore }} />
62
- </div>
63
- </div>
64
- );
65
- };
66
-
67
- export default SimplePDFViewer;
68
- ```
69
-
70
- Provided with the PDF Document path and options object, the `usePDFSlick()` hook returns an object consisting (among the other things) of:
71
- - `PDFSlickViewer` — the PDF Viewer component used for viewing the PDF document
72
- - `viewerRef` — a `RefCallback` that is provided as a prop to the `<PDFSlickViewer />` component
73
- - `usePDFSlickStore` — a hook to the PDFSlick store
74
-
75
- <br><br>
76
- [Read more about using PDFSlick with React](https://pdfslick.dev/docs/react) | [Checkout the React Examples](./apps/web/examples)
77
-
78
- ## SolidJS
79
-
80
- To get started with PDFSlick for SolidJS React run:
23
+ To get started with PDFSlick for SolidJS run:
81
24
  ```shell
82
25
  npm install @pdfslick/solid
83
26
  # yarn add @pdfslick/solid
@@ -88,32 +31,60 @@ You can start using PDFSlick with the `usePDFSlick()` hook, like with the follow
88
31
  ```jsx
89
32
  import { Component, createSignal } from "solid-js";
90
33
  import { usePDFSlick } from "@pdfslick/solid";
34
+ import PDFNavigation from "./yourcomponents/PDFNavigation";
35
+
36
+ //
37
+ // It is required to include PDFSlick's CSS styles once
38
+ // you can do it in your main `App.tsx` for example
39
+ //
40
+ import "@pdfslick/solid/dist/pdf_viewer.css";
91
41
 
92
- type PDFViewerAppProps = {
42
+ type PDFViewerComponentProps = {
93
43
  pdfFilePath: string;
94
44
  };
95
45
 
96
- const PDFViewerApp: Component<PDFViewerAppProps> = ({ pdfFilePath }) => {
46
+ const PDFViewerComponent: Component<PDFViewerComponentProps> = ({ pdfFilePath }) => {
97
47
  const { viewerRef, pdfSlickStore: store, PDFSlickViewer } =
98
48
  usePDFSlick(pdfFilePath);
99
49
 
100
50
  return (
101
- <div class="absolute inset-0 bg-slate-200/70 flex flex-col pdfSlick">
51
+ <div class="absolute inset-0 flex flex-col pdfSlick">
102
52
  <div class="flex-1 relative h-full">
103
53
  <PDFSlickViewer {...{ store, viewerRef }} />
54
+
55
+ {/*
56
+ Pass PDFSlick's store to your custom components (like the `<PDFNavigation />` below) —
57
+ Toolbars, Sidebars, components which render thumbnails etc.
58
+ and use it as here to get and react on
59
+ PDF document and viewer properties and changes
60
+ */}
61
+ <PDFNavigation {...{ store }} />
62
+
63
+ {/*
64
+ PDFSlick's store values automatically update
65
+ */}
66
+ <div className="absolute w-full top-0 left-0">
67
+ <p>Current scale: {store.scale}</p>
68
+ <p>Current page number: {store.pageNumber}</p>
69
+ <p>Total number of pages: {store.numPages}</p>
70
+ </div>
104
71
  </div>
105
72
  </div>
106
73
  );
107
74
  };
108
75
 
109
- export default PDFViewerApp;
76
+ export default PDFViewerComponent;
110
77
  ```
111
78
 
112
79
  Provided with the PDF Document path and options object, the `usePDFSlick()` hook returns an object consisting (among the other things) of:
113
- - `PDFSlickViewer` the PDF Viewer component used for viewing the PDF document
114
- - `viewerRef` a `RefCallback` that is provided as a prop to the `<PDFSlickViewer />` component
115
- - `pdfSlickStore` the PDFSlick store
80
+ - `PDFSlickViewer` is the PDF Viewer component used for viewing the PDF document
81
+ - `viewerRef` is the `ref` callback that is provided as a prop to the `<PDFSlickViewer />` component
82
+ - `pdfSlickStore` is the PDFSlick store
116
83
 
117
- <br><br>
118
- [Read more about using PDFSlick with SolidJS](https://pdfslick.dev/docs/solid) | [Checkout the SolidJS Examples](./apps/solidweb/src/examples)
84
+ <br>
85
+
86
+ [More on using PDFSlick with Solid](https://pdfslick.dev/docs/solid) | [Checkout the SolidJS Examples](./apps/solidweb/src/examples)
119
87
 
88
+ ## Thanks
89
+ - [Vane Kosturanov](https://kosturanov.com/portfolio/logo-branding-design) for designing the logo
90
+ - [VS Code Icons](https://github.com/microsoft/vscode-codicons) for the icons used throughout the examples
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pdfslick/solid",
3
- "version": "1.1.3",
3
+ "version": "1.1.5",
4
4
  "source": "./index.tsx",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",