|
1 | | -export const PartyInviteCard = () => { |
2 | | - return <div className="card"> |
3 | | - <div className="card-body"> |
4 | | - <h5 className="card-title">Party Invite</h5> |
5 | | - <p className="card-text">Share this link with your friends to invite them to the party.</p> |
| 1 | +import { FC, useState } from "react" |
| 2 | +import { LuEye, LuEyeOff } from "react-icons/lu"; |
| 3 | +import { QRCodeSVG } from 'qrcode.react'; |
| 4 | +export const PartyInviteCard: FC<{ partyId: string }> = ({ partyId }) => { |
| 5 | + const [hidden, setHidden] = useState(true); |
| 6 | + |
| 7 | + return (<div className="card flex flex-col gap-2 max-w-sm"> |
| 8 | + <h2>Party Invite</h2> |
| 9 | + <p className="text-secondary">Share this link with your friends to invite them to the party.</p> |
| 10 | + <div className="flex justify-center gap-2 flex-col items-center"> |
| 11 | + <QRCode value={`${window.location.origin}/party/${partyId}`} hidden={hidden} /> |
| 12 | + <div className="text-secondary"> |
| 13 | + Party Code: <span className="inline-flex font-bold bg-tertiary px-2 py-1">{hidden ? '*'.repeat(partyId.length) : partyId}</span> |
| 14 | + </div> |
6 | 15 | </div> |
7 | | - </div> |
| 16 | + <div className="flex gap-2 w-full flex-wrap justify-between"> |
| 17 | + <input type={hidden ? 'password' : 'text'} className="input flex-1" value={`${window.location.origin}/party/${partyId}`} disabled /> |
| 18 | + <button className="button" onClick={() => { |
| 19 | + navigator.clipboard.writeText(`${window.location.origin}/party/${partyId}`); |
| 20 | + }}>Copy</button> |
| 21 | + </div> |
| 22 | + <button className="button flex gap-2 items-center" onClick={() => setHidden(!hidden)}> |
| 23 | + {hidden ? <><LuEye /> Show</> : <><LuEyeOff /> Hide</>} |
| 24 | + </button> |
| 25 | + </div>); |
8 | 26 | } |
| 27 | + |
| 28 | +const QRCode: FC<{ value: string, hidden: boolean }> = ({ value, hidden }) => { |
| 29 | + return <div className="bg-tertiary p-2 rounded-md"> |
| 30 | + <div className="w-full h-full bg-secondary rounded-md"> |
| 31 | + { |
| 32 | + hidden ? <div className="w-32 h-32 bg-tertiary rounded-md flex items-center justify-center gap-2"> |
| 33 | + <LuEyeOff className="text-secondary" /> |
| 34 | + <p className="text-secondary">Hidden</p> |
| 35 | + </div> : |
| 36 | + <QRCodeSVG value={value} size={128} bgColor="#2d2b29" fgColor="#F5F5F5" /> |
| 37 | + } |
| 38 | + </div> |
| 39 | + </div> |
| 40 | +}; |
0 commit comments