From eae8cbcbe695e93ea0b037a6381f2967655b6c23 Mon Sep 17 00:00:00 2001 From: Alvaro Date: Tue, 22 Oct 2024 18:48:13 +0200 Subject: [PATCH] Start mobile version: Intro, menu, header --- src/components/header/index.tsx | 2 +- src/components/intro/index.tsx | 16 ++++++++-------- src/components/lines/index.tsx | 5 ++++- src/components/menu-lines/index.tsx | 3 +++ src/components/menu/index.tsx | 6 +++--- src/components/section-3/index.tsx | 2 +- src/lib/hooks.ts | 17 ++++++++++++++++- 7 files changed, 36 insertions(+), 15 deletions(-) diff --git a/src/components/header/index.tsx b/src/components/header/index.tsx index 33811c4..a3ab8f5 100644 --- a/src/components/header/index.tsx +++ b/src/components/header/index.tsx @@ -33,7 +33,7 @@ export default function Header() { }) }>
- +
diff --git a/src/components/intro/index.tsx b/src/components/intro/index.tsx index 1cb8488..1831d9f 100644 --- a/src/components/intro/index.tsx +++ b/src/components/intro/index.tsx @@ -20,12 +20,12 @@ export default function Intro() {
-
-

-
Digital Twins:
-
Innovative Research for a Sustainable Future
+
+

+
Digital Twins:
+
Innovative Research for a Sustainable Future

- +
Bridging data and discovery with state-of-the-art digital twin technology
@@ -36,9 +36,9 @@ export default function Intro() { Harnessing advanced simulations to adapt to and mitigate climate impacts
-
+
- + Bridging data and discovery with state-of-the-art digital twin technology Advancing climate knowledge through digital twins Harnessing advanced simulations to adapt to and mitigate climate impacts diff --git a/src/components/lines/index.tsx b/src/components/lines/index.tsx index 7532020..2281e06 100644 --- a/src/components/lines/index.tsx +++ b/src/components/lines/index.tsx @@ -1,6 +1,7 @@ 'use client'; import { cn } from '@/lib/utils'; import { AnimatePresence, motion } from 'framer-motion'; +import { useIsMobile } from '@/lib/hooks'; type LinesProps = { sectionName: string; @@ -21,7 +22,6 @@ const Lines = ({ columnsNumber = 0, hoveredIndex, }: LinesProps) => { - const gridColumns2 = 'grid transition-all duration-500 grid-cols-[1fr_1fr_1px]'; const gridColumns3 = { 'grid transition-all duration-500': true, @@ -47,6 +47,9 @@ const Lines = ({ 5: gridColumns5 }[columnsNumber]; + const isMobile = useIsMobile(); + if (isMobile) return null; + return <> {/* Vertical lines */} diff --git a/src/components/menu-lines/index.tsx b/src/components/menu-lines/index.tsx index 409dc6c..11d23ab 100644 --- a/src/components/menu-lines/index.tsx +++ b/src/components/menu-lines/index.tsx @@ -3,6 +3,7 @@ import { cn } from '@/lib/utils'; import { AnimatePresence, motion } from 'framer-motion'; import { createPortal } from 'react-dom'; +import { useIsMobile } from '@/lib/hooks'; type MenuLinesProps = { colorClass?: string; @@ -16,6 +17,8 @@ const MenuLines = ({ }: MenuLinesProps) => { const screenWidth = window.innerWidth; const initialX = screenWidth - 470; + const isMobile = useIsMobile(); + if (isMobile) return null; return <>
diff --git a/src/components/menu/index.tsx b/src/components/menu/index.tsx index 5a5aafe..76566dc 100644 --- a/src/components/menu/index.tsx +++ b/src/components/menu/index.tsx @@ -37,14 +37,14 @@ export default function Menu() { <> {openedMenu && } -
+
-
    +
    • Home diff --git a/src/components/section-3/index.tsx b/src/components/section-3/index.tsx index 7e38937..4dd51d5 100644 --- a/src/components/section-3/index.tsx +++ b/src/components/section-3/index.tsx @@ -167,7 +167,7 @@ export default function Section3() { ))}
-
+
setHoveredIndex(0)} onMouseLeave={() => setHoveredIndex(null)}>
01
diff --git a/src/lib/hooks.ts b/src/lib/hooks.ts index 5eec018..f6b1427 100644 --- a/src/lib/hooks.ts +++ b/src/lib/hooks.ts @@ -1,4 +1,4 @@ -import { useState, useEffect, useCallback } from "react"; +import { useState, useCallback, useEffect } from "react"; export const useScreenWidthWithResize = () => { const [width, setWidth] = useState(0); @@ -18,3 +18,18 @@ export const useScreenWidthWithResize = () => { return width; }; + +export const useIsMobile = () => { + const [isMobile, setIsMobile] = useState(false); + const handleResize = useCallback(() => { + setIsMobile(window.innerWidth < 768); + }, []); + + useEffect(() => { + handleResize(); + window.addEventListener("resize", handleResize); + return () => window.removeEventListener("resize", handleResize); + }, []); + + return isMobile; +};