Add indicator when url is copied (#4) #12

merged
opened by openwheel.racing targeting main

Add an indicator when the URL is copied, per issue #4. I had a hell of a time trying to get this to run on my computer for some reason (my computer seemingly can't find bun run build:raichu in the repo), so it was easier to just MVP'd it in using a vite react app with basic-ui locally and it worked well, just to test this page. It just changes the text "Copy API Key" to "Copied!" and it then resets back after 1500 ms.

Changed files
+14 -2
apps
web
src
layouts
Navbar
+14 -2
apps/web/src/layouts/Navbar/Navbar.tsx
···
return "";
}, [data]);
+
const [tooltipContent, setTooltipContent] = useState("Copy API Key");
+
+
const handleCopyClick = () => {
+
copy(webscrobblerWebhook);
+
+
setTooltipContent("Copied!");
+
+
setTimeout(() => {
+
setTooltipContent("Copy API Key");
+
}, 1500);
+
}
+
useEffect(() => {
if (profile?.spotifyConnected && !!localStorage.getItem("spotify")) {
localStorage.removeItem("spotify");
···
extension settings as a custom API URL:
</LabelMedium>
<Code className="mt-[15px]">{webscrobblerWebhook}</Code>
-
<StatefulTooltip content="Copy API Key">
+
<StatefulTooltip content={tooltipContent}>
<Copy
-
onClick={() => copy(webscrobblerWebhook)}
+
onClick={handleCopyClick}
size={18}
color="var(--color-text)"
className="ml-[5px] cursor-pointer"