Skip to content

Commit

Permalink
Fix resizing and chat menu
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack-Papel committed Dec 1, 2024
1 parent 5f82f4f commit 09a72dc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 63 deletions.
82 changes: 20 additions & 62 deletions client/src/menu/game/GameScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ export enum ContentMenu {
GraveyardMenu = "GraveyardMenu",
WikiMenu = "WikiMenu",
}

const MENU_ELEMENTS = {
[ContentMenu.ChatMenu]: ChatMenu,
[ContentMenu.PlayerListMenu]: PlayerListMenu,
[ContentMenu.RoleSpecificMenu]: RoleSpecificMenu,
[ContentMenu.WillMenu]: WillMenu,
[ContentMenu.GraveyardMenu]: GraveyardMenu,
[ContentMenu.WikiMenu]: WikiMenu
}

const ALL_CONTENT_MENUS = Object.values(ContentMenu);

export interface MenuController {
Expand Down Expand Up @@ -203,75 +213,23 @@ export default function GameScreen(): ReactElement {
})

const allMenusClosed = menuController.menusOpen().length === 0;
const minSize = 5;
const minSize = 10;

return <MenuControllerContext.Provider value={menuController}>
<div className="game-screen">
<div className="header">
<HeaderMenu chatMenuNotification={chatMenuNotification}/>
</div>
<PanelGroup direction="horizontal" className="content">
{menuController.menuOpen(ContentMenu.ChatMenu) &&
<Panel minSize={minSize}>
<ChatMenu/>
</Panel>
}
{
menuController.menuOpen(ContentMenu.ChatMenu) && (
menuController.menuOpen(ContentMenu.PlayerListMenu) ||
menuController.menuOpen(ContentMenu.WillMenu) ||
menuController.menuOpen(ContentMenu.RoleSpecificMenu) ||
menuController.menuOpen(ContentMenu.GraveyardMenu) ||
menuController.menuOpen(ContentMenu.WikiMenu)
) && <PanelResizeHandle/>
}
{menuController.menuOpen(ContentMenu.PlayerListMenu) &&
<Panel minSize={minSize}>
<PlayerListMenu/>
</Panel>
}
{
menuController.menuOpen(ContentMenu.PlayerListMenu) &&
(menuController.menuOpen(ContentMenu.WillMenu) ||
menuController.menuOpen(ContentMenu.RoleSpecificMenu) ||
menuController.menuOpen(ContentMenu.GraveyardMenu) ||
menuController.menuOpen(ContentMenu.WikiMenu)) && <PanelResizeHandle/>
}
{menuController.menuOpen(ContentMenu.WillMenu) &&
<Panel minSize={minSize}>
<WillMenu/>
</Panel>
}
{
menuController.menuOpen(ContentMenu.WillMenu) &&
(menuController.menuOpen(ContentMenu.RoleSpecificMenu) ||
menuController.menuOpen(ContentMenu.GraveyardMenu) ||
menuController.menuOpen(ContentMenu.WikiMenu)) && <PanelResizeHandle/>
}
{menuController.menuOpen(ContentMenu.RoleSpecificMenu) &&
<Panel minSize={minSize}>
<RoleSpecificMenu/>
</Panel>
}
{
menuController.menuOpen(ContentMenu.RoleSpecificMenu) &&
(menuController.menuOpen(ContentMenu.GraveyardMenu) ||
menuController.menuOpen(ContentMenu.WikiMenu)) && <PanelResizeHandle/>
}
{menuController.menuOpen(ContentMenu.GraveyardMenu) &&
<Panel minSize={minSize}>
<GraveyardMenu/>
</Panel>
}
{
menuController.menuOpen(ContentMenu.GraveyardMenu) &&
menuController.menuOpen(ContentMenu.WikiMenu) && <PanelResizeHandle/>
}
{menuController.menuOpen(ContentMenu.WikiMenu) &&
<Panel minSize={minSize}>
<WikiMenu/>
</Panel>
}
{menuController.menusOpen().map((menu, index, menusOpen) => {
const MenuElement = MENU_ELEMENTS[menu];
return <>
<Panel minSize={minSize}>
<MenuElement />
</Panel>
{menusOpen.some((_, i) => i > index) && <PanelResizeHandle />}
</>
})}
{allMenusClosed && <Panel><div className="no-content">
{translate("menu.gameScreen.noContent")}
</div></Panel>}
Expand Down
2 changes: 1 addition & 1 deletion client/src/menu/game/gameScreenContent/chatMenu.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

.game-screen .content > .chat-menu {
.game-screen .content .chat-menu {
display: flex;
flex-direction: column;
}
Expand Down

0 comments on commit 09a72dc

Please sign in to comment.