From cb16909e6675604aa3132e11e004ebeeb6db9b8d Mon Sep 17 00:00:00 2001
From: Salvo Miosi
Date: Sun, 6 Oct 2024 15:42:56 +0200
Subject: [PATCH] add button to toggle lobby password
---
src/Components/Button.tsx | 4 ++++
src/Scenes/WaitingArea/Style/WaitingArea.css | 24 ++++++++++----------
src/Scenes/WaitingArea/WaitingArea.tsx | 22 ++++++++++++++----
3 files changed, 33 insertions(+), 17 deletions(-)
diff --git a/src/Components/Button.tsx b/src/Components/Button.tsx
index 881dafd0..3c31e3ed 100644
--- a/src/Components/Button.tsx
+++ b/src/Components/Button.tsx
@@ -24,6 +24,10 @@ export default function Button({ className, color, type, onClick, children }: Bu
};
const fullClassName = `
+ flex
+ flex-row
+ items-center
+ justify-center
font-bold
py-1
px-4
diff --git a/src/Scenes/WaitingArea/Style/WaitingArea.css b/src/Scenes/WaitingArea/Style/WaitingArea.css
index 330a946c..e416037d 100644
--- a/src/Scenes/WaitingArea/Style/WaitingArea.css
+++ b/src/Scenes/WaitingArea/Style/WaitingArea.css
@@ -7,6 +7,18 @@
margin-right: auto;
}
+.lobby-options-visible {
+ transition: max-height 300ms ease-in-out, visibility 200ms step-end;
+ max-height: 4em;
+ overflow: hidden;
+}
+
+.lobby-options-collapsed {
+ transition: max-height 300ms ease-in-out, visibility 300ms step-end;
+ max-height: 0;
+ overflow: hidden;
+}
+
.lobby-element {
display: table-row;
}
@@ -34,18 +46,6 @@
text-align: center;
}
-.lobby-element div#lobby-button-join {
- width: 0;
-}
-
-#lobby-button-join button {
- width: 100%;
- display: flex;
- flex-direction: row;
- align-items: center;
- justify-content: center;
-}
-
.lobby-secure-icon {
margin-left: 0.5em;
width: 20px;
diff --git a/src/Scenes/WaitingArea/WaitingArea.tsx b/src/Scenes/WaitingArea/WaitingArea.tsx
index 3af06d47..ed5fc8bd 100644
--- a/src/Scenes/WaitingArea/WaitingArea.tsx
+++ b/src/Scenes/WaitingArea/WaitingArea.tsx
@@ -7,6 +7,7 @@ import { LobbyId } from "../../Model/ServerMessage";
import { BangConnection } from "../../Model/UseBangConnection";
import LobbyElement, { LobbyValue } from "./LobbyElement";
import './Style/WaitingArea.css';
+import { boolConverter, useLocalStorage } from "../../Utils/UseLocalStorage";
export interface WaitingAreaProps {
lobbies: LobbyValue[];
@@ -15,6 +16,8 @@ export interface WaitingAreaProps {
}
function WaitingArea({ lobbies, connection, settings }: WaitingAreaProps) {
+ const [expandLobbyOptions, setExpandLobbyOptions] = useLocalStorage('expand_lobby_options', boolConverter);
+
const handleCreateLobby = useCallback((event: SyntheticEvent) => {
event.preventDefault();
if (settings.lobbyName) {
@@ -47,14 +50,20 @@ function WaitingArea({ lobbies, connection, settings }: WaitingAreaProps) {
rounded-md
m-2
p-1
- w-48
+ w-44
focus:outline-none
focus:ring-2
focus:ring-blue-500
'
maxLength={MAX_LOBBY_NAME_LENGTH}
- value={settings.lobbyName} onChange={e => settings.setLobbyName(e.target.value)}>
-
+ value={settings.lobbyName} onChange={e => settings.setLobbyName(e.target.value)}>
+
+
+
settings.setLobbyPassword(e.target.value)}>
-
+
{lobbies.map((lobby) => (