Skip to content

Commit

Permalink
fix: main menu click area
Browse files Browse the repository at this point in the history
  • Loading branch information
shiftpsh committed Jul 16, 2024
1 parent 994b1fc commit f72f476
Show file tree
Hide file tree
Showing 7 changed files with 322 additions and 195 deletions.
194 changes: 0 additions & 194 deletions src/components/Menu.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion src/components/layouts/DefaultLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { PropsWithChildren } from "react";
import Menu from "../Menu";
import Menu from "../menu/Menu";
import TitleLogo from "../TitleLogo";
import { Global, css } from "@emotion/react";
import mahjongBackground from "/mahjong-background.jpg";
Expand Down
95 changes: 95 additions & 0 deletions src/components/menu/Menu.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import styled from "@emotion/styled";
import { useAuth } from "../../contexts/AuthContext";
import MenuIcon from "./MenuIcon";
import MenuIconMainAction from "./MenuIconMainAction";
import { MENU_ITEMS } from "./MenuItem";

const MenuContainer = styled.div`
position: fixed;
top: 0;
right: 0;
padding: 32px;
pointer-events: none;
z-index: 100;
@media screen and (max-width: 720px) {
top: unset;
bottom: 0;
height: 72px;
padding: 0;
width: 100%;
}
`;

const Icons = styled.div`
display: flex;
flex-direction: column;
align-items: flex-end;
justify-content: flex-start;
gap: 16px;
pointer-events: all;
@media screen and (max-width: 720px) {
padding: 0;
gap: 0;
height: 100%;
flex-direction: row;
}
`;

const MainIconsContainer = styled.div`
position: fixed;
bottom: 0;
right: 0;
padding: 32px;
pointer-events: none;
z-index: 100;
@media screen and (max-width: 720px) {
bottom: 72px;
padding: 16px;
}
`;

const Menu = () => {
const { user } = useAuth();

return (
<>
<MenuContainer>
<Icons>
{MENU_ITEMS.filter(({ authState, mainAction }) => {
if (mainAction) return false;
if (authState === "logged-in") {
return !!user;
}
if (authState === "logged-out") {
return !user;
}
return true;
}).map((item, index) => (
<MenuIcon item={item} key={index} />
))}
</Icons>
</MenuContainer>
<MainIconsContainer>
<Icons>
{MENU_ITEMS.filter(({ authState, mainAction }) => {
if (!mainAction) return false;
if (authState === "logged-in") {
return !!user;
}
if (authState === "logged-out") {
return !user;
}
return true;
}).map((item, index) => (
<MenuIconMainAction item={item} key={index} />
))}
</Icons>
</MainIconsContainer>
</>
);
};

export default Menu;
Loading

0 comments on commit f72f476

Please sign in to comment.