-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: layout style and button (#392)
* feat: add glass shadow style * refactor: layout style and buttons
- Loading branch information
1 parent
a35a9b6
commit 5b1109e
Showing
6 changed files
with
91 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,65 @@ | ||
import Link from "next/link"; | ||
import { useRouter } from "next/router"; | ||
import { cn } from "@/lib/utils"; | ||
|
||
import Button from "./Button"; | ||
import Icon from "@/components/shared/Icon"; | ||
import type { IconName } from "./Icon/icons"; | ||
import type { IconNameV2 } from "@/components/shared/Icon/v2/icons"; | ||
import Icon from "@/components/shared/Icon/v2"; | ||
import Button from "@/components/shared/Button"; | ||
import useAuth from "@/hooks/context/useAuth"; | ||
import useUser from "@/hooks/useUser"; | ||
import { cn } from "@/lib/utils"; | ||
|
||
enum SidebarRoutes { | ||
HOME = "/", | ||
ROOMS = "/rooms", | ||
} | ||
|
||
interface ButtonProps { | ||
text: string; | ||
iconName: IconNameV2; | ||
route: SidebarRoutes; | ||
} | ||
|
||
export default function Sidebar() { | ||
const router = useRouter(); | ||
const { pathname } = router; | ||
const { pathname } = useRouter(); | ||
const { currentUser } = useAuth(); | ||
const { logout } = useUser(); | ||
|
||
const buttons: { | ||
text: string; | ||
iconName: IconName; | ||
route: SidebarRoutes; | ||
}[] = [ | ||
const buttons: ButtonProps[] = [ | ||
{ text: "遊戲大廳", iconName: "home", route: SidebarRoutes.HOME }, | ||
{ text: "遊戲房間", iconName: "arcade", route: SidebarRoutes.ROOMS }, | ||
]; | ||
|
||
return ( | ||
<nav className="flex flex-col shrink-0 justify-start bg-dark29 rounded-[10px] w-[71px] gap-5"> | ||
<nav className="flex flex-col shrink-0 justify-start bg-white/8 glass-shadow my-6 ms-1.5 py-6 rounded-2xl w-18 gap-5"> | ||
{buttons.map((ButtonProps) => ( | ||
<Link | ||
href={ButtonProps.route} | ||
key={ButtonProps.text} | ||
className="flex justify-center items-center" | ||
> | ||
<Button | ||
className={cn( | ||
"bg-transparent px-0 justify-center opacity-[0.3] hover:shadow-none hover:opacity-100", | ||
{ | ||
"opacity-1": pathname === ButtonProps.route, | ||
} | ||
)} | ||
className={cn("bg-transparent p-3 rounded-full hover:shadow-none", { | ||
"bg-primary-200/20": pathname === ButtonProps.route, | ||
})} | ||
> | ||
<div className="w-full flex flex-col items-center gap-1"> | ||
<Icon | ||
name={ButtonProps.iconName} | ||
className={{ | ||
"[&_*]:stroke-[#2F88FF]": pathname === ButtonProps.route, | ||
}} | ||
/> | ||
<span className={cn("text-xs")}>{ButtonProps.text}</span> | ||
</div> | ||
<Icon | ||
name={ButtonProps.iconName} | ||
className={cn("w-6 h-6 stroke-primary-400", { | ||
"stroke-primary-200": pathname === ButtonProps.route, | ||
})} | ||
/> | ||
</Button> | ||
</Link> | ||
))} | ||
{currentUser && ( | ||
<Button | ||
className="mt-auto bg-transparent px-0 justify-center opacity-[0.3] hover:shadow-none hover:opacity-100" | ||
onClick={logout} | ||
> | ||
<Icon className="stroke-primary-400" name="logOut" /> | ||
<span className="text-xs">登出</span> | ||
</Button> | ||
)} | ||
</nav> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters