forked from naman79820/circuitverse-leaderboard
-
Notifications
You must be signed in to change notification settings - Fork 49
Feat : Enable click-to-copy for email address and adding slack icon in footer #190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
66f9c71
Feat : Enable click-to-copy for email address in footer
Yana-do-code 054d192
Update components/copy-email-button.tsx
Yana-do-code 3b1991c
Update components/copy-email-button.tsx
Yana-do-code 8179878
Fixed coderabbit issues
Yana-do-code 54b24c8
feat : added slack icon to the footer
Yana-do-code File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| "use client"; | ||
|
|
||
| import Image from "next/image"; | ||
| import { useState, useRef, useEffect } from "react"; | ||
| import Hint from "./hint"; | ||
|
|
||
| const EMAIL = "support@circuitverse.org"; | ||
|
|
||
| export default function CopyEmailButton() { | ||
| const [copied, setCopied] = useState(false); | ||
| const timeoutRef = useRef<NodeJS.Timeout | null>(null); | ||
|
|
||
| useEffect(() => { | ||
| return () => { | ||
| if (timeoutRef.current) { | ||
| clearTimeout(timeoutRef.current); | ||
| } | ||
| }; | ||
| }, []); | ||
|
|
||
| const handleCopy = async () => { | ||
| if (!navigator.clipboard) { | ||
| console.error("Clipboard API not available"); | ||
| return; | ||
| } | ||
|
|
||
| try { | ||
| await navigator.clipboard.writeText(EMAIL); | ||
| setCopied(true); | ||
|
|
||
| if (timeoutRef.current) { | ||
| clearTimeout(timeoutRef.current); | ||
| } | ||
|
|
||
| timeoutRef.current = setTimeout(() => { | ||
| setCopied(false); | ||
| timeoutRef.current = null; | ||
| }, 1500); | ||
| } catch (error) { | ||
| console.error("Failed to copy email:", error); | ||
| } | ||
| }; | ||
|
|
||
| return ( | ||
| <div className="relative"> | ||
| <Hint label="Email"> | ||
| <button | ||
| type="button" | ||
| onClick={handleCopy} | ||
| aria-label="Email" | ||
| className="text-zinc-400 hover:bg-zinc-100 dark:hover:bg-zinc-800 p-2 rounded-full transition-all duration-200" | ||
| > | ||
| <Image | ||
| src="/gmail.svg" | ||
| alt="Email" | ||
| width={20} | ||
| height={20} | ||
| className="w-5 h-5" | ||
| /> | ||
| </button> | ||
| </Hint> | ||
|
Yana-do-code marked this conversation as resolved.
Yana-do-code marked this conversation as resolved.
|
||
|
|
||
| {copied && ( | ||
| <div className="absolute -top-9 left-1/2 -translate-x-1/2 z-50"> | ||
| <div className="relative"> | ||
| <div className="rounded-md bg-zinc-900 px-2 py-1 text-xs text-white | ||
| dark:bg-zinc-100 dark:text-zinc-900 shadow-md"> | ||
| Email Copied! | ||
| </div> | ||
| <span | ||
| className="absolute left-1/2 top-full -translate-x-1/2 | ||
| h-2 w-2 rotate-45 | ||
| bg-zinc-900 dark:bg-zinc-100" | ||
| /> | ||
| </div> | ||
| </div> | ||
| )} | ||
|
Yana-do-code marked this conversation as resolved.
|
||
| </div> | ||
| ); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.