mirror of
https://github.com/openziti/zrok.git
synced 2025-06-14 13:56:57 +02:00
clipboard improvements
This commit is contained in:
parent
7fdd6a4a86
commit
9f8b3c8e9f
@ -1,4 +1,5 @@
|
|||||||
import ContentCopyIcon from '@mui/icons-material/ContentCopy';
|
import ContentCopyIcon from '@mui/icons-material/ContentCopy';
|
||||||
|
import CheckMarkIcon from "@mui/icons-material/Check";
|
||||||
import {useEffect, useState} from "react";
|
import {useEffect, useState} from "react";
|
||||||
import {Button, Popover, Typography} from "@mui/material";
|
import {Button, Popover, Typography} from "@mui/material";
|
||||||
|
|
||||||
@ -8,13 +9,13 @@ interface ClipboardTextProps {
|
|||||||
|
|
||||||
const ClipboardText = ({ text }: ClipboardTextProps) => {
|
const ClipboardText = ({ text }: ClipboardTextProps) => {
|
||||||
const [copied, setCopied] = useState<boolean>(false);
|
const [copied, setCopied] = useState<boolean>(false);
|
||||||
const [color, setColor] = useState<string>("black");
|
const [control, setControl] = useState<React.JSX.Element>(<ContentCopyIcon />);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if(copied) {
|
if(copied) {
|
||||||
setColor("red");
|
setControl(<CheckMarkIcon />);
|
||||||
} else {
|
} else {
|
||||||
setColor("black");
|
setControl(<ContentCopyIcon />);
|
||||||
}
|
}
|
||||||
}, [copied]);
|
}, [copied]);
|
||||||
|
|
||||||
@ -26,7 +27,7 @@ const ClipboardText = ({ text }: ClipboardTextProps) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Button onClick={copy} sx={{ minWidth: "30px" }} style={{ color: color }} ><ContentCopyIcon /></Button>
|
<Button onClick={copy} sx={{ minWidth: "30px" }} style={{ color: "black" }}>{control}</Button>
|
||||||
<Popover anchorOrigin={{ vertical: "top", horizontal: "right" }} open={copied}><Typography sx={{ p: 2 }}>Copied!</Typography></Popover>
|
<Popover anchorOrigin={{ vertical: "top", horizontal: "right" }} open={copied}><Typography sx={{ p: 2 }}>Copied!</Typography></Popover>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user