({className,gameId}:{className?:string,gameId:string})
| 2 | import { Button } from "./Button"; |
| 3 | |
| 4 | export 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 | |
| 37 | const LinkSvg = () => { |
| 38 | return ( |
nothing calls this directly
no outgoing calls
no test coverage detected