Skip to content

Commit

Permalink
feat: add copy button (#1)
Browse files Browse the repository at this point in the history
Co-authored-by: Your Name <you@example.com>
  • Loading branch information
LoliE1ON and Your Name authored Oct 21, 2023
1 parent 14f001a commit a138a88
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/components/FileViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ export function FileViewer(props: FileViewerProps) {
event.key === "ArrowRight" && props.onNext?.();
};

const handleCopy = async () => {
await navigator.clipboard.writeText(props.file.url);
};

onMount(() => window.addEventListener("keydown", listener));
onCleanup(() => window.removeEventListener("keydown", listener));

Expand Down Expand Up @@ -144,6 +148,8 @@ export function FileViewer(props: FileViewerProps) {
<ButtonGroup colorScheme="accent" size="xs">
<Button onClick={props.onPrev}>prev</Button>
<Button onClick={props.onNext}>next</Button>

<Button onClick={() => handleCopy()}>copy</Button>
</ButtonGroup>
</Box>
</Box>
Expand Down

0 comments on commit a138a88

Please sign in to comment.