Skip to content

Commit 0aade6f

Browse files
committed
PR review adjustements: visual cue when clicking CopyButton & typo fix
1 parent 24e147e commit 0aade6f

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

mithril-explorer/__tests__/InOutRegistrations/compareRegistrations.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ describe("Compare registrations", () => {
2626
expect(result).toEqual({ in: [], out: [reg("party1", 10)] });
2727
});
2828

29-
it("'In', 'out', and 'still there' altogether", () => {
29+
it("'In', 'out', and 'still there' all together", () => {
3030
const result = compareRegistrations(
3131
[reg("party1", 10), reg("party3", 12), reg("party4", 13)],
3232
[reg("party1", 10), reg("party2", 11), reg("party3", 12)],

mithril-explorer/src/components/CopyButton.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,32 @@
1-
import React from "react";
1+
import React, { useState, useEffect } from "react";
22
import { Button, OverlayTrigger, Tooltip } from "react-bootstrap";
33

44
export default function CopyButton({ textToCopy, variant = "link", text = "" }) {
5+
const [isCopying, setIsCopying] = useState(false);
6+
const [icon, setIcon] = useState("copy");
7+
8+
useEffect(() => {
9+
setIcon(isCopying ? "check-circle" : "copy");
10+
}, [isCopying]);
11+
512
function copyToClipboard() {
613
if (window.isSecureContext && textToCopy) {
7-
navigator.clipboard.writeText(textToCopy).then(() => {});
14+
setIsCopying(true);
15+
navigator.clipboard
16+
.writeText(textToCopy)
17+
.finally(() => setTimeout(() => setIsCopying(false), 400));
818
}
919
}
1020

1121
return (
1222
<OverlayTrigger overlay={<Tooltip>Copy</Tooltip>}>
1323
{variant === "link" ? (
1424
<Button variant="link" onClick={copyToClipboard} size="md" className="p-0">
15-
{text} <i className="bi bi-copy" style={{ color: "black" }}></i>
25+
{text} <i className={`text-black bi bi-${icon}`}></i>
1626
</Button>
1727
) : (
1828
<Button variant={variant} onClick={copyToClipboard} size="md">
19-
{text} <i className="bi bi-copy"></i>
29+
{text} <i className={`bi bi-${icon}`}></i>
2030
</Button>
2131
)}
2232
</OverlayTrigger>

mithril-explorer/src/components/RegistrationMarkdownFormatModal.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import React, { useEffect, useState } from "react";
2-
import { Card, Modal, Stack } from "react-bootstrap";
3-
import CopyButton from "#/CopyButton";
2+
import { Card, Modal } from "react-bootstrap";
43
import { useSelector } from "react-redux";
54
import { getSelectedAggregatorPools } from "@/store/poolsSlice";
5+
import CopyButton from "#/CopyButton";
66

77
/**
88
* Modal to show a list of registrations in a markdown formatted code block

0 commit comments

Comments
 (0)