From 736578dae39ea5e287054d1dd4dbb0be89596f87 Mon Sep 17 00:00:00 2001 From: philipcheung Date: Sun, 2 Nov 2025 19:32:26 +0800 Subject: [PATCH] header updated --- src/components/header.tsx | 44 +++++++++++++++------------- src/components/new_ui/advantages.tsx | 1 + src/components/new_ui/info.tsx | 2 +- src/components/new_ui/truth.tsx | 3 +- 4 files changed, 27 insertions(+), 23 deletions(-) diff --git a/src/components/header.tsx b/src/components/header.tsx index c44f994..31ae080 100644 --- a/src/components/header.tsx +++ b/src/components/header.tsx @@ -1,4 +1,4 @@ -import { Box, Flex, Image, VStack, Text, Link } from '@chakra-ui/react'; +import { Box, Flex, Image, VStack, Text } from '@chakra-ui/react'; import { GiHamburgerMenu } from "react-icons/gi"; import { IoCloseSharp } from "react-icons/io5"; import { colors } from '../colors'; @@ -69,11 +69,19 @@ function Header({ showMenu = false }: HeaderProps) { }; }, []); + const scrollToSection = (sectionId: string) => { + const element = document.getElementById(sectionId.replace('#', '')); + if (element) { + element.scrollIntoView({ behavior: 'smooth' }); + } + setIsDrawerOpen(false); + }; + const menuItems = [ - { label: '40+常見健康問題', href: '#info' }, - { label: '營萃護心油四大優勢', href: '#advantages' }, - { label: '護心食譜', href: '#recipes' }, - { label: '更多食用油健康真相', href: '#truth' }, + { label: '40+常見健康問題', id: 'info' }, + { label: '營萃護心油四大優勢', id: 'advantages' }, + { label: '護心食譜', id: 'recipes' }, + { label: '更多食用油健康真相', id: 'truth' }, ]; return ( @@ -143,24 +151,18 @@ function Header({ showMenu = false }: HeaderProps) { > {menuItems.map((item, index) => ( - setIsDrawerOpen(false)} - textDecoration="none" - _hover={{ textDecoration: 'none' }} + onClick={() => scrollToSection(item.id)} + p={3} + borderRadius="md" + _hover={{ bg: 'gray.100' }} + cursor="pointer" > - - - {item.label} - - - + + {item.label} + + ))} diff --git a/src/components/new_ui/advantages.tsx b/src/components/new_ui/advantages.tsx index d98618a..108df76 100644 --- a/src/components/new_ui/advantages.tsx +++ b/src/components/new_ui/advantages.tsx @@ -122,6 +122,7 @@ function Advantages() { const isMainInView = useInView(mainRef, { once: true }); return ( setSelectedInfo(info.id)} bg={selectedInfo === info.id ? '#3D6741' : '#BCBCBC'} - border={selectedInfo === info.id ? "4px solid #99BF35" : "none"} + border={selectedInfo === info.id ? { base: "1px solid #99BF35", sm: "1px solid #99BF35", md: "4px solid #99BF35", lg: "4px solid #99BF35", xl: "4px solid #99BF35" } : "none"} borderRadius={{ base: '15px', sm: '15px', md: '18px', lg: '20px', xl: '20px' }} display="flex" alignItems="center" diff --git a/src/components/new_ui/truth.tsx b/src/components/new_ui/truth.tsx index bc6c608..f08da83 100644 --- a/src/components/new_ui/truth.tsx +++ b/src/components/new_ui/truth.tsx @@ -108,6 +108,7 @@ function Truth() { return (