首页页面

This commit is contained in:
2025-03-11 14:57:23 +08:00
parent 9b36ab40f2
commit 5e3ade9aba
38 changed files with 1092 additions and 182 deletions

101
src/app/(home)/header.tsx Normal file
View File

@@ -0,0 +1,101 @@
'use client'
import {ReactNode, useEffect, useState} from 'react'
import Link from 'next/link'
import Wrap from '@/components/wrap'
export type HeaderProps = {}
export default function Header(props: HeaderProps) {
const [isScrolled, setIsScrolled] = useState(window.scrollY > 0)
const handleScroll = () => {
setIsScrolled(window.scrollY > 0)
}
useEffect(() => {
window.addEventListener('scroll', handleScroll)
return () => {
window.removeEventListener('scroll', handleScroll)
}
}, [])
return (
<header
className={[
`w-full h-24 fixed top-0 shadow-lg`,
`transition-shadow duration-200 ${isScrolled ? 'bg-white' : 'bg-transparent shadow-transparent'}`,
].join(' ')}>
<Wrap className="flex items-center justify-between">
{/* 菜单 */}
<div className="flex items-center justify-between gap-8">
{/* logo */}
<Link href="/">
<img alt={`logo`} className={`w-16 h-16 rounded-full bg-gray-100`}/>
</Link>
{/* 菜单 */}
<nav className={`flex items-center`}>
<ul className="flex items-center gap-4 text-xl">
<NavItemTop>
<Link href={`/`}></Link>
</NavItemTop>
<NavItemTop>
<button></button>
<SvgDown/>
</NavItemTop>
<NavItemTop>
<button></button>
<SvgDown/>
</NavItemTop>
<NavItemTop>
<button></button>
<SvgDown/>
</NavItemTop>
<NavItemTop>
<Link href={`#`}></Link>
</NavItemTop>
<NavItemTop>
<Link href={`#`}>广</Link>
</NavItemTop>
</ul>
</nav>
</div>
{/* 登录 */}
<div className={`flex items-center`}>
<a
href="#"
className={`w-24 h-12 flex items-center justify-center text-xl font-medium`}>
<span></span>
</a>
<a
href="#"
className={`w-24 h-12 bg-gradient-to-r from-blue-500 to-cyan-400 rounded-sm flex items-center justify-center text-xl font-medium text-white`}>
<span></span>
</a>
</div>
</Wrap>
</header>
)
}
type NavItemTopProps = {
children: ReactNode
}
function NavItemTop(props: NavItemTopProps) {
return (
<li className={`flex items-center text-xl px-2`}>
{props.children}
</li>
)
}
function SvgDown() {
return (
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path
d="M6 9L12 15L18 9" stroke="currentColor" strokeWidth="2" strokeLinecap="round"
strokeLinejoin="round"/>
</svg>
)
}