-
Notifications
You must be signed in to change notification settings - Fork 587
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use Deep Links for Copying Multiplayer Join Code, Update Host Lobby A…
…ppearance (#9153) This updates the host lobby appearance to match the latest designs more closely, and it will copy a deep link rather than the code itself when the copy button is pressed (on both the host lobby and the game page). Also sneaking in a fix to make the sim use the full screen width when on a smaller screen.
- Loading branch information
Showing
5 changed files
with
109 additions
and
85 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
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,53 @@ | ||
import { faCopy } from "@fortawesome/free-regular-svg-icons"; | ||
import { faCheck } from "@fortawesome/free-solid-svg-icons"; | ||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; | ||
import { useContext, useEffect, useState } from "react"; | ||
import { AppStateContext } from "../state/AppStateContext"; | ||
|
||
export default function Render(props: { | ||
copyValue: string; | ||
title: string; | ||
eventName?: string; | ||
}) { | ||
const { state } = useContext(AppStateContext); | ||
const [copySuccessful, setCopySuccessful] = useState(false); | ||
const copyTimeoutMs = 2500; | ||
|
||
const copyValue = async () => { | ||
if (props.eventName) pxt.tickEvent(props.eventName); | ||
if (state.gameState?.joinCode) { | ||
navigator.clipboard.writeText(props.copyValue); | ||
setCopySuccessful(true); | ||
} | ||
}; | ||
|
||
useEffect(() => { | ||
if (copySuccessful) { | ||
let resetCopyTimer = setTimeout(() => { | ||
setCopySuccessful(false); | ||
}, copyTimeoutMs); | ||
return () => { | ||
clearTimeout(resetCopyTimer); | ||
}; | ||
} | ||
}, [copySuccessful]); | ||
|
||
return ( | ||
<button onClick={copyValue} title={props.title}> | ||
<div> | ||
{!copySuccessful && ( | ||
<FontAwesomeIcon | ||
icon={faCopy} | ||
className="hover:tw-scale-110 tw-ease-linear tw-duration-[50ms]" | ||
/> | ||
)} | ||
{copySuccessful && ( | ||
<FontAwesomeIcon | ||
icon={faCheck} | ||
className="tw-text-green-600" | ||
/> | ||
)} | ||
</div> | ||
</button> | ||
); | ||
} |
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