Skip to content

Commit cb343b8

Browse files
committed
feat: add zoom btns, replace btn text with icons
1 parent 8a413cb commit cb343b8

File tree

1 file changed

+24
-7
lines changed

1 file changed

+24
-7
lines changed

components/pdf-container/toolbar.tsx

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1+
import { useExportCapability } from "@embedpdf/plugin-export/react"
2+
import { useZoom } from "@embedpdf/plugin-zoom/react"
3+
import { Download, Highlighter, Trash2, Underline, ZoomIn, ZoomOut } from "lucide-react"
14
import { useEffect, useState } from "react"
25
import { useAnnotationCapability } from "./plugin-annotation-2"
3-
import { useExportCapability } from "@embedpdf/plugin-export/react"
46

57
export const Toolbar = () => {
68
const { provides: annotationApi } = useAnnotationCapability()
79
const { provides: exportApi } = useExportCapability()
10+
const { provides: zoom } = useZoom()
811
const [activeTool, setActiveTool] = useState<string | null>(null)
912
const [canDelete, setCanDelete] = useState(false)
1013

@@ -32,9 +35,8 @@ export const Toolbar = () => {
3235
}
3336

3437
const tools = [
35-
{ id: "highlight", active: activeTool === "highlight" },
36-
{ id: "underline", active: activeTool === "underline" },
37-
{ id: "squiggly", active: activeTool === "squiggly" },
38+
{ id: "highlight", active: activeTool === "highlight", icon: Highlighter },
39+
{ id: "underline", active: activeTool === "underline", icon: Underline },
3840
]
3941

4042
return (
@@ -47,10 +49,25 @@ export const Toolbar = () => {
4749
tool.active ? "bg-blue-500 text-white" : "bg-gray-100 hover:bg-gray-200"
4850
}`}
4951
>
50-
{tool.id}
52+
{tool.icon ? <tool.icon size={18} /> : tool.id}
5153
</button>
5254
))}
5355
<div className="h-6 w-px bg-gray-200"></div>
56+
<button
57+
onClick={() => zoom?.zoomOut()}
58+
disabled={!zoom}
59+
className="rounded-md bg-gray-500 px-3 py-1 text-sm font-medium text-white transition-colors hover:bg-gray-600 disabled:cursor-not-allowed disabled:bg-gray-300"
60+
>
61+
<ZoomOut size={18} />
62+
</button>
63+
<button
64+
onClick={() => zoom?.zoomIn()}
65+
disabled={!zoom}
66+
className="rounded-md bg-gray-500 px-3 py-1 text-sm font-medium text-white transition-colors hover:bg-gray-600 disabled:cursor-not-allowed disabled:bg-gray-300"
67+
>
68+
<ZoomIn size={18} />
69+
</button>
70+
<div className="h-6 w-px bg-gray-200"></div>
5471
<button
5572
onClick={() => annotationApi?.exportAnnotationsToJSON()}
5673
className="rounded-md bg-blue-500 px-3 py-1 text-sm font-medium text-white transition-colors hover:bg-blue-600"
@@ -62,14 +79,14 @@ export const Toolbar = () => {
6279
disabled={!exportApi}
6380
className="rounded-md bg-green-500 px-3 py-1 text-sm font-medium text-white transition-colors hover:bg-green-600 disabled:cursor-not-allowed disabled:bg-green-300"
6481
>
65-
Download PDF
82+
<Download size={18} />
6683
</button>
6784
<button
6885
onClick={handleDelete}
6986
disabled={!canDelete}
7087
className="rounded-md bg-red-500 px-3 py-1 text-sm font-medium text-white transition-colors hover:bg-red-600 disabled:cursor-not-allowed disabled:bg-red-300"
7188
>
72-
Delete Selected
89+
<Trash2 size={18} />
7390
</button>
7491
</div>
7592
)

0 commit comments

Comments
 (0)