Skip to content

Commit d32cd05

Browse files
OE-780: Remove storybook, update readme, remove TODO comments (#145)
* remove storybook * remove unused https resources and cleanup readme * updating examples * remove isChecked from button since it was throwing react errors * remove todo comments and update unit tests * update Readme with additional context * rename props * add context to readme * adds link to NYPL's C4 diagrams public page * updates based on PR feedback
1 parent 5369a98 commit d32cd05

30 files changed

+20809
-49966
lines changed

.eslintignore

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ dist
77
.parcel-cache
88
.cache
99

10-
storybook-static
1110
.vercel
1211

1312
# env

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ coverage
99
.parcel-cache
1010
.cache
1111

12-
storybook-static
1312
.vercel
1413

1514
# env

.storybook/main.js

-25
This file was deleted.

.storybook/preview.jsx

-22
This file was deleted.

README.md

+130-189
Large diffs are not rendered by default.

build.ts

+1-19
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,6 @@ import child_process from 'child_process';
1010
const rimraf = util.promisify(origRimraf);
1111
const exec = util.promisify(child_process.exec);
1212

13-
/**
14-
* @todo
15-
*
16-
* - Figure out how to export the fonts and include them with dynamic urls in the css?
17-
* - Possibly export a CJS or IIFE version?
18-
* - Possibly add postcss or something to support namespaces?
19-
*/
20-
2113
const isWatchEnabled = process.argv[2] === '-w';
2214
// for now we bundle for production whenever we aren't in watch mode
2315
const isProduction = !isWatchEnabled;
@@ -47,16 +39,7 @@ async function buildTs(
4739
bundle: true,
4840
// what browsers we want to support, this is basically all >1% usage
4941
target: ['es2016', 'chrome89', 'firefox88', 'safari14', 'edge90'],
50-
external: [
51-
'react-dom',
52-
'react',
53-
/**
54-
* @todo - We currently ignore these fonts, but we need to figure out a better way
55-
* to include them
56-
*/
57-
'fonts/AccessibleDfA.otf',
58-
'fonts/iAWriterDuospace-Regular.ttf',
59-
],
42+
external: ['react-dom', 'react'],
6043
sourcemap: true,
6144
define: {
6245
// note these need to be double quoted if we want to define string constants
@@ -161,7 +144,6 @@ async function startWatcher() {
161144
'cypress',
162145
'coverage',
163146
'.husky',
164-
'.storybook',
165147
];
166148
const watchPaths = ['.'];
167149
console.log('👀 Watching for changes...');

example/index.tsx

+27-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ import readiumDefault from 'url:../src/HtmlReader/ReadiumCss/ReadiumCSS-default.
2828
import readiumAfter from 'url:../src/HtmlReader/ReadiumCss/ReadiumCSS-after.css';
2929
import Tests from './Tests';
3030
import { Injectable } from '../src/Readium/Injectable';
31+
import UseHtmlReader from './use-html-reader';
32+
import mobyEpub2Manifest from './static/samples/moby-epub2-exploded/manifest.json';
33+
import pdfSingleResourceManifest from './static/samples/pdf/single-resource-short.json';
34+
import { WebpubManifest } from '../src/types';
35+
import UsePdfReader from './use-pdf-reader';
3136

3237
const origin = window.location.origin;
3338

@@ -105,6 +110,14 @@ const PdfReaders = () => {
105110
pdfWorkerSrc={`${origin}/pdf-worker/pdf.worker.min.js`}
106111
/>
107112
</Route>
113+
<Route path={`/pdf/use-pdf-reader-hook`}>
114+
<UsePdfReader
115+
webpubManifestUrl="/samples/pdf/single-resource-short.json"
116+
manifest={pdfSingleResourceManifest as WebpubManifest}
117+
proxyUrl={pdfProxyUrl}
118+
pdfWorkerSrc={`${origin}/pdf-worker/pdf.worker.min.js`}
119+
/>
120+
</Route>
108121
<Route path={`/pdf/large`}>
109122
<WebReader
110123
webpubManifestUrl="/samples/pdf/single-resource-long.json"
@@ -209,7 +222,7 @@ const HtmlReaders = () => {
209222
<Text as="p">
210223
This example shows how a web reader looks embedded within a page
211224
instead of taking over the full page. It is fixed height, which
212-
means it will not grow to fit content in scrolling mode..
225+
means it will not grow to fit content in scrolling mode.
213226
</Text>
214227
<WebReader
215228
injectablesReflowable={htmlInjectablesReflowable}
@@ -250,6 +263,13 @@ const HtmlReaders = () => {
250263
webpubManifestUrl={`${origin}/samples/ReadiumCSS-docs/manifest.json`}
251264
/>
252265
</Route>
266+
<Route path={`/html/use-html-reader-hook`}>
267+
<UseHtmlReader
268+
injectablesReflowable={htmlInjectablesReflowable}
269+
webpubManifestUrl={`${origin}/samples/moby-epub2-exploded/manifest.json`}
270+
manifest={mobyEpub2Manifest as WebpubManifest}
271+
/>
272+
</Route>
253273
<Route path={`/html/url/:manifestUrl`}>
254274
<DynamicReader />
255275
</Route>
@@ -277,6 +297,9 @@ const HomePage = () => {
277297
<ListItem>
278298
<Link to="/html/moby-epub2">Moby Dick </Link>
279299
</ListItem>
300+
<ListItem>
301+
<Link to="/html/use-html-reader-hook">useHtmlReader hook</Link>
302+
</ListItem>
280303
</UnorderedList>
281304
</ListItem>
282305
<ListItem>
@@ -338,6 +361,9 @@ const HomePage = () => {
338361
<ListItem>
339362
<Link to="/pdf/single-resource-short">Single-PDF Webpub</Link>
340363
</ListItem>
364+
<ListItem>
365+
<Link to="/pdf/use-pdf-reader-hook">usePdfReader hook</Link>
366+
</ListItem>
341367
<ListItem>
342368
<Link to="/pdf/large">Single-PDF Webpub (large file)</Link>
343369
</ListItem>

example/tsconfig.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"extends": "../tsconfig.json",
33
"include": [".", "../src"],
44
"compilerOptions": {
5-
"module": "esnext"
5+
"module": "esnext",
6+
"resolveJsonModule": true
67
}
78
}

example/use-html-reader.tsx

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import React from 'react';
2+
import { useHtmlReader } from '../src';
3+
import { Injectable } from '../src/Readium/Injectable';
4+
import { WebpubManifest } from '../src/types';
5+
import Footer from '../src/ui/Footer';
6+
import Header from '../src/ui/Header';
7+
8+
type HTMLReaderProps = {
9+
injectablesReflowable: Injectable[];
10+
webpubManifestUrl: string;
11+
manifest: WebpubManifest;
12+
};
13+
14+
/**
15+
* This sample shows setting how to use the useHTMLReader hook
16+
* to render EPUBs. Use it when you know you're _not_ going to be
17+
* opening PDFs.
18+
*/
19+
const UseHtmlReader: React.FC<HTMLReaderProps> = ({
20+
injectablesReflowable,
21+
webpubManifestUrl,
22+
manifest,
23+
}) => {
24+
const reader = useHtmlReader({
25+
webpubManifestUrl,
26+
manifest,
27+
injectablesReflowable,
28+
});
29+
const containerRef = React.useRef<HTMLDivElement>(null);
30+
31+
if (!reader || !reader.type) {
32+
return null;
33+
}
34+
35+
return (
36+
<div>
37+
<Header
38+
{...reader}
39+
headerLeft={<a href="/">Back</a>}
40+
containerRef={containerRef}
41+
/>
42+
{reader.content}
43+
<Footer {...reader} />
44+
</div>
45+
);
46+
};
47+
48+
export default UseHtmlReader;

example/use-pdf-reader.tsx

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import React from 'react';
2+
import { usePdfReader } from '../src';
3+
import { WebpubManifest } from '../src/types';
4+
import Footer from '../src/ui/Footer';
5+
import Header from '../src/ui/Header';
6+
7+
type PDFReaderProps = {
8+
webpubManifestUrl: string;
9+
manifest: WebpubManifest;
10+
proxyUrl: string | undefined;
11+
pdfWorkerSrc: string;
12+
};
13+
14+
/**
15+
* This sample shows setting how to use the usePdfReader hook
16+
* to render PDFs. Use it when you know you're _not_ going to be
17+
* opening EPUBs.
18+
*/
19+
const UsePdfReader: React.FC<PDFReaderProps> = ({
20+
webpubManifestUrl,
21+
manifest,
22+
proxyUrl,
23+
pdfWorkerSrc,
24+
}) => {
25+
const reader = usePdfReader({
26+
webpubManifestUrl,
27+
manifest,
28+
proxyUrl,
29+
pdfWorkerSrc,
30+
});
31+
const containerRef = React.useRef<HTMLDivElement>(null);
32+
33+
if (!reader || !reader.type) {
34+
return null;
35+
}
36+
37+
return (
38+
<div>
39+
<Header
40+
{...reader}
41+
headerLeft={<a href="/">Back</a>}
42+
containerRef={containerRef}
43+
/>
44+
{reader.content}
45+
<Footer {...reader} />
46+
</div>
47+
);
48+
};
49+
50+
export default UsePdfReader;

localhost-key.pem

-28
This file was deleted.

localhost.pem

-24
This file was deleted.

0 commit comments

Comments
 (0)