|
1 | 1 | import { FC, useMemo, useState } from "react"; |
2 | 2 | import { useSuspenseAPIQuery } from "../../../api/api"; |
3 | 3 | import { MetadataResult } from "../../../api/responseTypes/metadata"; |
4 | | -import { ActionIcon, Group, Stack, Table, TextInput } from "@mantine/core"; |
| 4 | +import { ActionIcon, CopyButton, Group, Stack, Table, TextInput } from "@mantine/core"; |
5 | 5 | import React from "react"; |
6 | 6 | import { Fuzzy } from "@nexucis/fuzzy"; |
7 | 7 | import sanitizeHTML from "sanitize-html"; |
8 | | -import { IconCodePlus, IconCopy, IconZoomCode } from "@tabler/icons-react"; |
| 8 | +import { IconCheck, IconCodePlus, IconCopy, IconZoomCode } from "@tabler/icons-react"; |
9 | 9 | import LabelsExplorer from "./LabelsExplorer"; |
10 | 10 | import { useDebouncedValue } from "@mantine/hooks"; |
11 | 11 | import classes from "./MetricsExplorer.module.css"; |
@@ -139,20 +139,29 @@ const MetricsExplorer: FC<MetricsExplorerProps> = ({ |
139 | 139 | stroke={1.5} |
140 | 140 | /> |
141 | 141 | </ActionIcon> |
142 | | - <ActionIcon |
143 | | - size="sm" |
144 | | - color="gray" |
145 | | - variant="light" |
146 | | - title="Copy to clipboard" |
147 | | - onClick={() => { |
148 | | - navigator.clipboard.writeText(m.original); |
149 | | - }} |
150 | | - > |
151 | | - <IconCopy |
152 | | - style={{ width: "70%", height: "70%" }} |
153 | | - stroke={1.5} |
154 | | - /> |
155 | | - </ActionIcon> |
| 142 | + <CopyButton value={m.original}> |
| 143 | + {({ copied, copy }) => ( |
| 144 | + <ActionIcon |
| 145 | + size="sm" |
| 146 | + color="gray" |
| 147 | + variant="light" |
| 148 | + title="Copy to clipboard" |
| 149 | + onClick={copy} |
| 150 | + > |
| 151 | + {copied ? ( |
| 152 | + <IconCheck |
| 153 | + style={{ width: "70%", height: "70%" }} |
| 154 | + stroke={1.5} |
| 155 | + /> |
| 156 | + ) : ( |
| 157 | + <IconCopy |
| 158 | + style={{ width: "70%", height: "70%" }} |
| 159 | + stroke={1.5} |
| 160 | + /> |
| 161 | + )} |
| 162 | + </ActionIcon> |
| 163 | + )} |
| 164 | + </CopyButton> |
156 | 165 | </Group> |
157 | 166 | </Group> |
158 | 167 | </Table.Td> |
|
0 commit comments