-
Notifications
You must be signed in to change notification settings - Fork 135
/
Basic.tsx
38 lines (36 loc) · 1.13 KB
/
Basic.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { useState, useRef, useEffect } from 'react'
import { ReactReader } from '../../lib/index'
import type { Contents, Rendition } from 'epubjs'
import { DEMO_URL, DEMO_NAME } from '../components/config'
import { Example } from '../components/Example'
export const Basic = () => {
const [largeText, setLargeText] = useState(false)
const rendition = useRef<Rendition | undefined>(undefined)
const [location, setLocation] = useState<string | number>(0)
useEffect(() => {
rendition.current?.themes.fontSize(largeText ? '140%' : '100%')
}, [largeText])
return (
<Example
title="Basic example"
actions={
<>
<button onClick={() => setLargeText(!largeText)} className="btn">
Toggle font-size
</button>
</>
}
>
<ReactReader
url={DEMO_URL}
title={DEMO_NAME}
location={location}
locationChanged={(loc: string) => setLocation(loc)}
getRendition={(_rendition: Rendition) => {
rendition.current = _rendition
rendition.current.themes.fontSize(largeText ? '140%' : '100%')
}}
/>
</Example>
)
}