Skip to content

Commit

Permalink
add ability to share lobby with a preloaded deck
Browse files Browse the repository at this point in the history
  • Loading branch information
JollyGrin committed Mar 26, 2024
1 parent 3f9c982 commit 74595c9
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions components/Connect/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export const ConnectPage = () => {
const nameRef = useRef<HTMLInputElement>(null);
const gidRef = useRef<HTMLInputElement>(null);

const [lobby, setLobby] = useState(gidRef?.current?.value ?? "");
const [sharedDeckId, setSharedDeckId] = useState<string | undefined>();

// uses router props to load new decks
Expand Down Expand Up @@ -84,6 +85,10 @@ export const ConnectPage = () => {
<Input
ref={gidRef}
defaultValue={router.query.lobby as string | undefined}
onChange={(e) => {
setLobby(e.target.value);
if (e.target.value === "") setSharedDeckId(undefined);
}}
placeholder="lobby name"
bg="white"
/>
Expand All @@ -108,10 +113,16 @@ export const ConnectPage = () => {
</VStack>
{sharedDeckId === undefined && (
<PlusSquareIcon
opacity={lobby !== "" ? 1 : 0}
transition="all 0.25s ease-in-out"
onClick={() => setSharedDeckId("")}
fontSize="2rem"
alignSelf="center"
justifySelf="center"
cursor="pointer"
_hover={{
transform: "scale(1.2)",
}}
/>
)}

Expand Down

0 comments on commit 74595c9

Please sign in to comment.