forked from code100x/chess
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request code100x#296 from VK-RED/feature-share-game-link
Feature: Share the game link with Opponent
- Loading branch information
Showing
4 changed files
with
77 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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,43 @@ | ||
import { useState } from "react" | ||
import { Button } from "./Button"; | ||
|
||
export const ShareGame = ({className,gameId}:{className?:string,gameId:string}) => { | ||
|
||
const url = window.origin+"/game/"+gameId; | ||
const [copied,setCopied] = useState(false); | ||
|
||
const handleCopy = ()=>{ | ||
window.navigator.clipboard.writeText(url); | ||
setCopied((p)=>true); | ||
} | ||
|
||
return ( | ||
<div className={`flex flex-col items-center gap-y-4 ${className}`}> | ||
|
||
<h3 className="scroll-m-20 text-4xl font-semibold tracking-tight text-green-500"> | ||
Play with Friends | ||
</h3> | ||
|
||
<div className="flex items-center gap-x-2"> | ||
|
||
<LinkSvg/> | ||
|
||
<div onClick={handleCopy} className="text-blue-500 cursor-pointer"> | ||
{url} | ||
</div> | ||
</div> | ||
|
||
<Button onClick={handleCopy}> | ||
{copied ? `Copied to Clipboard !!` : `Copy the link`} | ||
</Button> | ||
</div> | ||
) | ||
} | ||
|
||
const LinkSvg = () => { | ||
return ( | ||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" className="lucide lucide-link text-white"> | ||
<path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/> | ||
</svg> | ||
) | ||
} |
This file contains 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
This file contains 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
This file contains 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