-
Notifications
You must be signed in to change notification settings - Fork 36
/
CustomizeZoomButtonsExample.tsx
91 lines (86 loc) · 3.33 KB
/
CustomizeZoomButtonsExample.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import * as React from 'react';
import { Viewer } from '@react-pdf-viewer/core';
import { RenderCurrentScaleProps, RenderZoomInProps, RenderZoomOutProps, zoomPlugin } from '@react-pdf-viewer/zoom';
import '@react-pdf-viewer/core/lib/styles/index.css';
import '@react-pdf-viewer/zoom/lib/styles/index.css';
interface CustomizeZoomButtonsExampleProps {
fileUrl: string;
}
const CustomizeZoomButtonsExample: React.FC<CustomizeZoomButtonsExampleProps> = ({ fileUrl }) => {
const zoomPluginInstance = zoomPlugin();
const { CurrentScale, ZoomIn, ZoomOut } = zoomPluginInstance;
return (
<div
style={{
border: '1px solid rgba(0, 0, 0, 0.3)',
display: 'flex',
flexDirection: 'column',
height: '100%',
}}
>
<div
style={{
alignItems: 'center',
backgroundColor: '#eeeeee',
borderBottom: '1px solid rgba(0, 0, 0, 0.1)',
display: 'flex',
justifyContent: 'center',
padding: '4px',
}}
>
<div style={{ padding: '0px 2px' }}>
<ZoomOut>
{(props: RenderZoomOutProps) => (
<button
style={{
backgroundColor: '#357edd',
border: 'none',
borderRadius: '4px',
color: '#ffffff',
cursor: 'pointer',
padding: '8px',
}}
onClick={props.onClick}
>
Zoom out
</button>
)}
</ZoomOut>
</div>
<div style={{ padding: '0px 2px' }}>
<CurrentScale>
{(props: RenderCurrentScaleProps) => <>{`${Math.round(props.scale * 100)}%`}</>}
</CurrentScale>
</div>
<div style={{ padding: '0px 2px' }}>
<ZoomIn>
{(props: RenderZoomInProps) => (
<button
style={{
backgroundColor: '#357edd',
border: 'none',
borderRadius: '4px',
color: '#ffffff',
cursor: 'pointer',
padding: '8px',
}}
onClick={props.onClick}
>
Zoom in
</button>
)}
</ZoomIn>
</div>
</div>
<div
style={{
flex: 1,
overflow: 'hidden',
}}
>
<Viewer fileUrl={fileUrl} plugins={[zoomPluginInstance]} />
</div>
</div>
);
};
export default CustomizeZoomButtonsExample;