MCPcopy Create free account
hub / github.com/code100x/chess / ShareGame

Function ShareGame

apps/frontend/src/components/ShareGame.tsx:4–35  ·  view source on GitHub ↗
({className,gameId}:{className?:string,gameId:string})

Source from the content-addressed store, hash-verified

2import { Button } from "./Button";
3
4export const ShareGame = ({className,gameId}:{className?:string,gameId:string}) => {
5
6 const url = window.origin+"/game/"+gameId;
7 const [copied,setCopied] = useState(false);
8
9 const handleCopy = ()=>{
10 window.navigator.clipboard.writeText(url);
11 setCopied((p)=>true);
12 }
13
14 return (
15 <div className={`flex flex-col items-center gap-y-4 ${className}`}>
16
17 <h3 className="scroll-m-20 text-4xl font-semibold tracking-tight text-green-500">
18 Play with Friends
19 </h3>
20
21 <div className="flex items-center gap-x-2">
22
23 <LinkSvg/>
24
25 <div onClick={handleCopy} className="text-blue-500 cursor-pointer">
26 {url}
27 </div>
28 </div>
29
30 <Button onClick={handleCopy}>
31 {copied ? `Copied to Clipboard !!` : `Copy the link`}
32 </Button>
33 </div>
34 )
35}
36
37const LinkSvg = () => {
38 return (

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected