mirror of
https://github.com/NohamR/lanyard-profile-readme.git
synced 2026-05-26 13:41:32 +00:00
Feat: Copy button!
This commit is contained in:
@@ -4,8 +4,13 @@ import { useState } from "react";
|
|||||||
|
|
||||||
export default function Home() {
|
export default function Home() {
|
||||||
const [userId, setUserId] = useState(":id");
|
const [userId, setUserId] = useState(":id");
|
||||||
|
const [copyState, setCopyState] = useState("Copy");
|
||||||
const copy = () => {
|
const copy = () => {
|
||||||
return;
|
navigator.clipboard.writeText(`[](https://discord.com/users/${userId})`);
|
||||||
|
setCopyState("Copied!");
|
||||||
|
|
||||||
|
setTimeout(() => setCopyState("Copy"), 1500);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -43,7 +48,7 @@ export default function Home() {
|
|||||||
[](https://discord.com/users/{userId})
|
)](https://discord.com/users/{userId})
|
||||||
</Link>
|
</Link>
|
||||||
<StupidBtn onClick={copy}>Copy</StupidBtn>
|
<StupidBtn onClick={copy}>{copyState}</StupidBtn>
|
||||||
</LinkContainer>
|
</LinkContainer>
|
||||||
<span style={{ fontSize: "1rem", fontStyle: "italic", marginTop: "1rem" }}>
|
<span style={{ fontSize: "1rem", fontStyle: "italic", marginTop: "1rem" }}>
|
||||||
For further customization, check out the{" "}
|
For further customization, check out the{" "}
|
||||||
@@ -139,7 +144,8 @@ const Link = styled.div`
|
|||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
background-color: #222;
|
background-color: #222;
|
||||||
|
overflow: hidden;
|
||||||
|
overflow-wrap: break-word;
|
||||||
scrollbar-width: thin;
|
scrollbar-width: thin;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
@@ -157,6 +163,7 @@ const Example = styled.img`
|
|||||||
|
|
||||||
const LinkContainer = styled.div`
|
const LinkContainer = styled.div`
|
||||||
position: relative;
|
position: relative;
|
||||||
|
margin-bottom: 18px;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const StupidBtn = styled.button`
|
const StupidBtn = styled.button`
|
||||||
@@ -166,6 +173,11 @@ const StupidBtn = styled.button`
|
|||||||
padding: 5px 18px;
|
padding: 5px 18px;
|
||||||
border: none;
|
border: none;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
border: #fff solid 1px;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
|
|
||||||
|
&:active {
|
||||||
|
opacity: 0.5;
|
||||||
|
}
|
||||||
`;
|
`;
|
||||||
|
|||||||
Reference in New Issue
Block a user