From 5b1109e0ec67b4ea0894513911ba46225e768cb7 Mon Sep 17 00:00:00 2001 From: Johnson Mao <86179381+JohnsonMao@users.noreply.github.com> Date: Sun, 21 Jul 2024 19:45:33 +0800 Subject: [PATCH] refactor: layout style and button (#392) * feat: add glass shadow style * refactor: layout style and buttons --- components/shared/Header.tsx | 75 +++++++++++++++++++-------------- components/shared/Sidebar.tsx | 62 +++++++++++++++------------ containers/layout/AppLayout.tsx | 2 +- hooks/useRequest.ts | 2 +- pages/index.tsx | 5 +-- tailwind.config.js | 10 +++++ 6 files changed, 91 insertions(+), 65 deletions(-) diff --git a/components/shared/Header.tsx b/components/shared/Header.tsx index a13db383..ef341948 100644 --- a/components/shared/Header.tsx +++ b/components/shared/Header.tsx @@ -1,67 +1,78 @@ import { useState } from "react"; +import type { IconNameV2 } from "@/components/shared/Icon/v2/icons"; +import Icon from "@/components/shared/Icon"; +import IconV2 from "@/components/shared/Icon/v2"; +import Button from "@/components/shared/Button"; +import Badge from "@/components/shared/Badge"; +import UserInfoModal from "@/components/lobby/UserInfoModal"; import { cn } from "@/lib/utils"; -import useAuth from "@/hooks/context/useAuth"; -import useUser from "@/hooks/useUser"; -import UserInfoModal from "../lobby/UserInfoModal"; -import Button from "./Button"; -import Badge from "./Badge"; -import Icon from "./Icon"; -import type { IconName } from "./Icon/icons"; enum HeaderActions { - HELP = "HELP", - REMIND = "REMIND", + CHAT = "CHAT", + NOTIFICATION = "NOTIFICATION", PROFILE = "PROFILE", } -export default function Header() { - const { currentUser } = useAuth(); - const { logout } = useUser(); +interface ButtonProps { + type: HeaderActions; + iconName: IconNameV2; + isActive: boolean; + onClick: () => void; +} +export default function Header() { const [openProfile, setOpenProfile] = useState(false); - const buttons = [ + const buttons: ButtonProps[] = [ + { + iconName: "chatDefault", + type: HeaderActions.CHAT, + isActive: false, + onClick: () => {}, + }, + { + iconName: "notificationDefault", + type: HeaderActions.NOTIFICATION, + isActive: false, + onClick: () => {}, + }, { - Icon: "player" as IconName, + iconName: "player", type: HeaderActions.PROFILE, - click: () => { + isActive: openProfile, + onClick: () => { setOpenProfile(true); }, - active: openProfile, }, ]; return ( -
+
+

遊戲微服務大平台

-
- {buttons.map((ButtonProps) => ( +
+ {buttons.map(({ type, iconName, isActive, onClick }) => ( ))} - {currentUser && }
{openProfile && ( + ); } diff --git a/containers/layout/AppLayout.tsx b/containers/layout/AppLayout.tsx index 3aef4a5a..af19e560 100644 --- a/containers/layout/AppLayout.tsx +++ b/containers/layout/AppLayout.tsx @@ -9,7 +9,7 @@ export default function Layout({ children }: { children: React.ReactNode }) {
-
{children}
+
{children}
diff --git a/hooks/useRequest.ts b/hooks/useRequest.ts index b6df2ba1..00adcc78 100644 --- a/hooks/useRequest.ts +++ b/hooks/useRequest.ts @@ -36,7 +36,7 @@ const useRequest = () => { toast: { show: true, options: { - position: "bottom-left", + position: "bottom-right", }, }, } diff --git a/pages/index.tsx b/pages/index.tsx index 64f83cb5..043cbfa3 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -13,10 +13,7 @@ export default function Home() { return ( <>

遊戲大廳!

-
+
{