2024-05-07 17:32:35 +03:30
|
|
|
import React, { useState } from "react";
|
2024-05-06 13:46:11 +03:30
|
|
|
import "./websiteTextField.css";
|
2024-05-07 17:32:35 +03:30
|
|
|
import HelpOutlineIcon from "@mui/icons-material/HelpOutline";
|
|
|
|
|
import ContentCopyIcon from "@mui/icons-material/ContentCopy";
|
2024-05-06 13:46:11 +03:30
|
|
|
|
2024-05-07 17:32:35 +03:30
|
|
|
function WebsiteTextField({
|
|
|
|
|
showHelp = true,
|
|
|
|
|
hasCopyButton = false,
|
|
|
|
|
hintText,
|
|
|
|
|
}) {
|
|
|
|
|
const [copied, setCopied] = useState(false);
|
|
|
|
|
|
|
|
|
|
const handleCopy = () => {
|
|
|
|
|
setCopied(true);
|
|
|
|
|
setTimeout(() => setCopied(false), 1000);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<>
|
2024-05-07 20:40:01 +03:30
|
|
|
<div className="website-textfield-title">Website</div>
|
2024-05-07 17:32:35 +03:30
|
|
|
<div className="website-textfield">
|
|
|
|
|
<label className="website-label" htmlFor="website">
|
|
|
|
|
http://
|
|
|
|
|
</label>
|
|
|
|
|
<input
|
|
|
|
|
type="url"
|
|
|
|
|
name="website-url"
|
|
|
|
|
id="website-url"
|
|
|
|
|
className="website-url"
|
|
|
|
|
/>
|
|
|
|
|
{showHelp && (
|
|
|
|
|
<div
|
|
|
|
|
className={
|
|
|
|
|
`website-icon-holder ` + !hasCopyButton
|
|
|
|
|
? "with-no-copy-button"
|
|
|
|
|
: ""
|
|
|
|
|
}
|
|
|
|
|
>
|
|
|
|
|
<HelpOutlineIcon style={{ fill: "var(--icon-color)" }} />
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
{hasCopyButton && (
|
|
|
|
|
<div className="copy-to-clipboard-button" onClick={handleCopy}>
|
|
|
|
|
<ContentCopyIcon className="copy-icon" />
|
|
|
|
|
<span>{copied ? " Copied " : " Copy "}</span>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
<label className="website-textfield-hint">{hintText}</label>
|
|
|
|
|
</>
|
|
|
|
|
);
|
2024-05-06 13:46:11 +03:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default WebsiteTextField;
|