add user profile page
This commit is contained in:
37
client/src/components/user/CopyLink.tsx
Normal file
37
client/src/components/user/CopyLink.tsx
Normal file
@@ -0,0 +1,37 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import { IconCopy } from "@tabler/icons-react";
|
||||
|
||||
export default function CopyLink({ name }: { name: string }) {
|
||||
const [copiedLink, setCopiedLink] = useState(false);
|
||||
|
||||
function copyLink() {
|
||||
const text = `https://ches.su/user/${name}`;
|
||||
|
||||
if ("clipboard" in navigator) {
|
||||
navigator.clipboard.writeText(text);
|
||||
} else {
|
||||
document.execCommand("copy", true, text);
|
||||
}
|
||||
setCopiedLink(true);
|
||||
setTimeout(() => {
|
||||
setCopiedLink(false);
|
||||
}, 5000);
|
||||
}
|
||||
return (
|
||||
<div className={"dropdown dropdown-top dropdown-end" + (copiedLink ? " dropdown-open" : "")}>
|
||||
<label
|
||||
tabIndex={0}
|
||||
className="badge badge-md bg-base-300 text-base-content h-8 gap-1 font-mono text-xs sm:h-5 sm:text-sm"
|
||||
onClick={copyLink}
|
||||
>
|
||||
<IconCopy size={16} />
|
||||
ches.su/user/{name}
|
||||
</label>
|
||||
<div tabIndex={0} className="dropdown-content badge badge-neutral text-xs shadow">
|
||||
copied to clipboard
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user