From 7aad2ecf6a43404b92f644733f63311833bc0969 Mon Sep 17 00:00:00 2001 From: William Moore Date: Fri, 10 Feb 2023 14:57:11 +0000 Subject: [PATCH] Add Copy button --- public/copy_icon.png | Bin 0 -> 599 bytes src/App.css | 5 +++- src/CopyButton.jsx | 53 +++++++++++++++++++++++++++++++++++++++++++ src/ImageItem.jsx | 2 ++ src/OpenWith.jsx | 16 ++++++------- 5 files changed, 66 insertions(+), 10 deletions(-) create mode 100644 public/copy_icon.png create mode 100644 src/CopyButton.jsx diff --git a/public/copy_icon.png b/public/copy_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..6cfdbd545c254a6ed036792e9ccd0e3faf52d6db GIT binary patch literal 599 zcmV-d0;v6oP)@z0nc@~D|2Sq&DFLdv6TY>17LjbtLp zC{~mtyIIbHQt~ckVHUC=b{;i0ghXP>v!obPQ)F3_x^idQ&* z{c%78m9g67r8tW9M^X^D$g?UX42q!C?S*NbwLG(St6vy#c*s~7I6w35su2U;BfK!+&%wiV$qMoJI1TB+F za0Vkac_-9)j!V(+NZpXygWf2uurp`)?@N@L!EWJPH1QQjC$xL9Lbx`rml6zRzE5PN z)_#fKcwcu+1saUf3iqN^Ov6|%L8tudRWXK7QSTBiLqetPz%zWyB{(cxzfF9>rl|K| zL)6EGlfJFqVHNHcf~M%hp(cl_Oy6LU!m+Q>j;+X&d002ovPDHLkV1h { + // reset after 1 second + setShaking(false); + }, 1000); + } else { + console.log("Copying failed"); + } + } + + let buttonStyle = { + background: "transparent", + border: "none", + padding: "0 2px" + }; + if (shaking) { + // NB: seesaw is defined in global App.css + buttonStyle["animation"] = "0.1s linear 0s infinite alternate seesaw"; + } + + return ( + + ); +} diff --git a/src/ImageItem.jsx b/src/ImageItem.jsx index 9d6e127..e62c87c 100644 --- a/src/ImageItem.jsx +++ b/src/ImageItem.jsx @@ -2,6 +2,7 @@ import React from "react"; import Viewer from "./Viewer"; import OpenWith from "./OpenWith"; +import CopyButton from "./CopyButton"; import { loadOmeroMultiscales, open, getNgffAxes } from "./util"; // DeckGL react component @@ -103,6 +104,7 @@ export default function ImageItem({ source }) { {imgInfo.version} {source} + {sizes} diff --git a/src/OpenWith.jsx b/src/OpenWith.jsx index c6afbdf..54a3829 100644 --- a/src/OpenWith.jsx +++ b/src/OpenWith.jsx @@ -3,17 +3,15 @@ import React from "react"; import openwithJson from "../public/openwith.json"; export default function OpenWith({ source }) { - let viewers = openwithJson.viewers; - - return (
- { - viewers.map(viewer => ( + return ( + + {viewers.map((viewer) => ( - + - )) - } -
); + ))} + + ); }