changement de logique pour le partage du lien, cela devrait marcher sur Mac 🧪

demo_bourges
Pierre Ferreira 1 year ago
parent aaa2f237b7
commit 9b05d184ce

@ -179,6 +179,18 @@ function Lobby() {
}); });
}; };
const textAreaRef = useRef<HTMLTextAreaElement>(null);
const linkToCopy = "http://localhost:3000/lobby?room="+ room
const handleCopyClick = () => {
setShow(!show)
if(textAreaRef.current != null){
textAreaRef.current.select();
document.execCommand('copy');
}
};
const [show, setShow] = useState(false); const [show, setShow] = useState(false);
const target = useRef(null); const target = useRef(null);
@ -238,34 +250,44 @@ function Lobby() {
</center> */} </center> */}
<div className='lobbyR' <div className='lobbyR'
style={{flexDirection:'column', style={{flexDirection:'column',
alignItems:'space-around'}}> alignItems:'space-around'}}>
<h3>Bienvenue dans votre lobby !</h3> <h3>Bienvenue dans votre lobby !</h3>
<p>Attendez que tous vos amis rejoignent avant de lancer la partie.</p> <p>Attendez que tous vos amis rejoignent avant de lancer la partie.</p>
{/* Bouton pour copier le lien */} {/* Bouton pour copier le lien */}
<Button variant="primary" ref={target} onClick={copyGameLink}> {/* <Button variant="primary" ref={target} onClick={copyGameLink}>
Inviter des amis Inviter des amis
</Button> </Button> */}
<Overlay target={target.current} show={show} placement="top"> <div>
{({ <textarea
placement: _placement, ref={textAreaRef}
arrowProps: _arrowProps, readOnly
show: _show, value={linkToCopy}
popper: _popper, style={{ position: 'absolute', left: '-9999px' }}
hasDoneInitialMeasure: _hasDoneInitialMeasure, />
...props <Button onClick={handleCopyClick}>Inviter des amis</Button>
}) => ( </div>
<div
{...props} <Overlay target={target.current} show={show} placement="top">
style={{ {({
position: 'absolute', placement: _placement,
backgroundColor: theme.colors.secondary, arrowProps: _arrowProps,
padding: '2px 10px', show: _show,
color: 'white', popper: _popper,
borderRadius: 3, hasDoneInitialMeasure: _hasDoneInitialMeasure,
...props.style, ...props
}} }) => (
> <div
{...props}
style={{
position: 'absolute',
backgroundColor: theme.colors.secondary,
padding: '2px 10px',
color: 'white',
borderRadius: 3,
...props.style,
}}
>
Lien copié Lien copié
</div> </div>
)} )}

Loading…
Cancel
Save