mirror of
https://github.com/TheRealOwenRees/echecsfrance.git
synced 2026-07-23 04:26:57 +00:00
Improve mobile burger menu
This commit is contained in:
Vendored
+1
@@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"cSpell.words": [
|
"cSpell.words": [
|
||||||
"approximative",
|
"approximative",
|
||||||
|
"Armes",
|
||||||
"colour",
|
"colour",
|
||||||
"colours",
|
"colours",
|
||||||
"contactez",
|
"contactez",
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import HamburgerMenu from "./HamburgerMenu";
|
|
||||||
import { useRef, useState } from "react";
|
import { useRef, useState } from "react";
|
||||||
|
import { twMerge } from "tailwind-merge";
|
||||||
|
|
||||||
|
import HamburgerMenu from "./HamburgerMenu";
|
||||||
|
|
||||||
const Hamburger = () => {
|
const Hamburger = () => {
|
||||||
const [menuVisible, setMenuVisible] = useState(false);
|
const [menuVisible, setMenuVisible] = useState(false);
|
||||||
@@ -15,19 +17,23 @@ const Hamburger = () => {
|
|||||||
onClick={() => setMenuVisible(!menuVisible)}
|
onClick={() => setMenuVisible(!menuVisible)}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
className={`h-0.5 w-8 bg-gray-600 transition-transform duration-300 ease-in-out dark:bg-white ${
|
className={twMerge(
|
||||||
menuVisible ? "translate-x-[1px] translate-y-2.5 rotate-45" : ""
|
"h-0.5 w-8 bg-gray-600 transition-all duration-300 ease-in-out dark:bg-white",
|
||||||
}`}
|
menuVisible &&
|
||||||
|
"translate-x-[1px] translate-y-2.5 rotate-45 bg-white",
|
||||||
|
)}
|
||||||
></div>
|
></div>
|
||||||
<div
|
<div
|
||||||
className={`h-0.5 w-8 bg-gray-600 transition-transform duration-300 ease-linear dark:bg-white ${
|
className={twMerge(
|
||||||
menuVisible ? "rotate-0 scale-0 opacity-0" : ""
|
"h-0.5 w-8 bg-gray-600 transition-transform duration-300 ease-linear dark:bg-white",
|
||||||
}`}
|
menuVisible && "scale-0 bg-white opacity-0",
|
||||||
|
)}
|
||||||
></div>
|
></div>
|
||||||
<div
|
<div
|
||||||
className={`h-0.5 w-8 bg-gray-600 transition-transform duration-300 ease-in-out dark:bg-white ${
|
className={twMerge(
|
||||||
menuVisible ? "-translate-y-2.5 -rotate-45" : ""
|
"h-0.5 w-8 bg-gray-600 transition-transform duration-300 ease-in-out dark:bg-white",
|
||||||
}`}
|
menuVisible && "-translate-y-2.5 -rotate-45 bg-white",
|
||||||
|
)}
|
||||||
></div>
|
></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ interface HamburgerMenuState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
import { Dispatch, RefObject, SetStateAction, useRef, useState } from "react";
|
import { Dispatch, RefObject, SetStateAction, useRef, useState } from "react";
|
||||||
|
import { twMerge } from "tailwind-merge";
|
||||||
import Link from "next-intl/link";
|
import Link from "next-intl/link";
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
|
|
||||||
@@ -51,14 +52,16 @@ const HamburgerMenu = ({
|
|||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
ref={menuRef}
|
ref={menuRef}
|
||||||
className={`fixed right-0 top-0 ${
|
className={twMerge(
|
||||||
menuVisible ? "" : "translate-x-full"
|
"fixed right-0 top-0 z-[9999] h-[calc(100svh-5rem)] w-full",
|
||||||
} z-[9999] flex bg-primary-600 transition-transform duration-200 ease-linear dark:bg-gray-600 md:hidden`}
|
"flex items-center justify-center bg-primary-600 transition-transform duration-200 ease-linear dark:bg-gray-600 md:hidden",
|
||||||
|
!menuVisible && "translate-x-full",
|
||||||
|
)}
|
||||||
onMouseEnter={handleMouseEnterMenu}
|
onMouseEnter={handleMouseEnterMenu}
|
||||||
onMouseLeave={handleMouseLeaveMenu}
|
onMouseLeave={handleMouseLeaveMenu}
|
||||||
>
|
>
|
||||||
<ul className="list-reset mt-16 p-5 text-white">
|
<ul className="list-reset text-white">
|
||||||
<li className="py-5">
|
<li className="py-5 text-center text-xl">
|
||||||
<Link
|
<Link
|
||||||
href="/tournois"
|
href="/tournois"
|
||||||
className="border-b-2 border-transparent transition-all duration-300 ease-in-out hover:border-white"
|
className="border-b-2 border-transparent transition-all duration-300 ease-in-out hover:border-white"
|
||||||
@@ -66,7 +69,7 @@ const HamburgerMenu = ({
|
|||||||
{t("tournaments")}
|
{t("tournaments")}
|
||||||
</Link>
|
</Link>
|
||||||
</li>
|
</li>
|
||||||
<li className="py-5">
|
<li className="py-5 text-center text-xl">
|
||||||
<Link
|
<Link
|
||||||
href="/qui-sommes-nous"
|
href="/qui-sommes-nous"
|
||||||
className="border-b-2 border-transparent transition-all duration-300 ease-in-out hover:border-white"
|
className="border-b-2 border-transparent transition-all duration-300 ease-in-out hover:border-white"
|
||||||
@@ -74,7 +77,7 @@ const HamburgerMenu = ({
|
|||||||
{t("about")}
|
{t("about")}
|
||||||
</Link>
|
</Link>
|
||||||
</li>
|
</li>
|
||||||
<li className="py-5">
|
<li className="py-5 text-center text-xl">
|
||||||
<Link
|
<Link
|
||||||
href="/contactez-nous"
|
href="/contactez-nous"
|
||||||
className="border-b-2 border-transparent transition-all duration-300 ease-in-out hover:border-white"
|
className="border-b-2 border-transparent transition-all duration-300 ease-in-out hover:border-white"
|
||||||
|
|||||||
@@ -17,18 +17,17 @@ export default function Navbar() {
|
|||||||
className="relative mt-0 h-16 w-full overflow-x-clip border-b-[1px] bg-white px-5 dark:border-gray-700 dark:bg-gray-800"
|
className="relative mt-0 h-16 w-full overflow-x-clip border-b-[1px] bg-white px-5 dark:border-gray-700 dark:bg-gray-800"
|
||||||
data-test="navbar"
|
data-test="navbar"
|
||||||
>
|
>
|
||||||
<div className="container mx-auto flex h-full items-center">
|
<div className="container mx-auto flex h-full items-center justify-between">
|
||||||
<div className="flex w-full justify-center font-extrabold md:w-1/2 md:justify-start">
|
<Link
|
||||||
<Link
|
className="font-extrabold text-gray-900 no-underline hover:no-underline dark:text-white"
|
||||||
className="text-gray-900 no-underline hover:no-underline dark:text-white"
|
href="/"
|
||||||
href="/"
|
>
|
||||||
>
|
<span className="font-title text-2xl text-gray-800 dark:text-white">
|
||||||
<span className="font-title text-2xl text-gray-800 dark:text-white">
|
{t("title")}
|
||||||
{t("title")}
|
</span>
|
||||||
</span>
|
</Link>
|
||||||
</Link>
|
|
||||||
</div>
|
<div className="md:hidden" data-test="mobile-menu">
|
||||||
<div className="pb-2 md:hidden" data-test="mobile-menu">
|
|
||||||
<Hamburger />
|
<Hamburger />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -36,9 +35,9 @@ export default function Navbar() {
|
|||||||
className="hidden h-full justify-center md:flex md:w-1/2 md:justify-end"
|
className="hidden h-full justify-center md:flex md:w-1/2 md:justify-end"
|
||||||
data-test="desktop-menu"
|
data-test="desktop-menu"
|
||||||
>
|
>
|
||||||
<ul className="list-reset flex h-full flex-1 items-center justify-around text-gray-900 no-underline dark:text-white md:flex-none">
|
<ul className="list-reset flex h-full flex-1 items-center gap-14 text-gray-900 no-underline dark:text-white md:flex-none">
|
||||||
{links.map(({ title, route }) => (
|
{links.map(({ title, route }) => (
|
||||||
<li key={route} className="mr-10 h-full">
|
<li key={route} className="h-full">
|
||||||
<Link
|
<Link
|
||||||
className="inline-flex h-full items-center border-b-4 border-t-4 border-transparent transition-all duration-300 ease-in-out hover:border-b-primary-600"
|
className="inline-flex h-full items-center border-b-4 border-t-4 border-transparent transition-all duration-300 ease-in-out hover:border-b-primary-600"
|
||||||
href={route}
|
href={route}
|
||||||
|
|||||||
Reference in New Issue
Block a user