Skip to content

Commit

Permalink
add rotation buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
ciur committed Aug 24, 2024
1 parent c697359 commit 8292b0f
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 3 deletions.
11 changes: 10 additions & 1 deletion ui2/src/components/Viewer/ActionButtons.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
import {useContext, useRef, useEffect} from "react"
import {Group} from "@mantine/core"
import {useViewportSize} from "@mantine/hooks"
import {useDispatch} from "react-redux"
import {useDispatch, useSelector} from "react-redux"
import ToggleSecondaryPanel from "@/components/DualPanel/ToggleSecondaryPanel"
import {updateActionPanel} from "@/slices/sizes"
import PanelContext from "@/contexts/PanelContext"
import EditTitleButton from "./EditTitleButton"

import type {PanelMode} from "@/types"
import type {RootState} from "@/app/types"
import DownloadButton from "./DownloadButton/DownloadButton"
import {selectSelectedPages} from "@/slices/dualPanel/dualPanel"
import RotateCCButton from "./RotateCCButton"
import RotateButton from "./RotateButton"

export default function ActionButtons() {
const {height, width} = useViewportSize()
const dispatch = useDispatch()
const ref = useRef<HTMLDivElement>(null)
const mode: PanelMode = useContext(PanelContext)
const selectedPages = useSelector((state: RootState) =>
selectSelectedPages(state, mode)
)

useEffect(() => {
if (ref?.current) {
Expand All @@ -34,6 +41,8 @@ export default function ActionButtons() {
<Group>
<EditTitleButton />
<DownloadButton />
{selectedPages.length > 0 && <RotateButton />}
{selectedPages.length > 0 && <RotateCCButton />}
</Group>
<Group>
<ToggleSecondaryPanel />
Expand Down
Empty file.
14 changes: 14 additions & 0 deletions ui2/src/components/Viewer/RotateButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import {Tooltip, ActionIcon} from "@mantine/core"
import {IconRotateClockwise} from "@tabler/icons-react"

export default function RotateCCButton() {
const onClick = () => {}

return (
<Tooltip label="Rotate selected pages clockwise" withArrow>
<ActionIcon size={"lg"} variant="default" onClick={onClick}>
<IconRotateClockwise stroke={1.4} />
</ActionIcon>
</Tooltip>
)
}
14 changes: 14 additions & 0 deletions ui2/src/components/Viewer/RotateCCButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import {Tooltip, ActionIcon} from "@mantine/core"
import {IconRotate} from "@tabler/icons-react"

export default function RotateCCButton() {
const onClick = () => {}

return (
<Tooltip label="Rotate selected pages counter-clockwise" withArrow>
<ActionIcon size={"lg"} variant="default" onClick={onClick}>
<IconRotate stroke={1.4} />
</ActionIcon>
</Tooltip>
)
}
3 changes: 1 addition & 2 deletions ui2/src/components/Viewer/Thumbnail/Thumbnail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ export default function Thumbnail({page}: Args) {
className={`${classes.thumbnail} ${cssClassNames.join(" ")}`}
align="center"
gap={"xs"}
onClick={onClick}
draggable
onDragStart={onDragStart}
onDragEnd={onDragEnd}
Expand All @@ -181,7 +180,7 @@ export default function Thumbnail({page}: Args) {
checked={selectedIds && selectedIds.includes(page.id)}
className={classes.checkbox}
/>
<img src={protectedImage.data || ""} />
<img onClick={onClick} src={protectedImage.data || ""} />
{page.number}
</Stack>
)
Expand Down

0 comments on commit 8292b0f

Please sign in to comment.