Skip to content

Commit 33fc7fe

Browse files
committed
feat(headerBar): add icon
1 parent 25ae4ae commit 33fc7fe

File tree

10 files changed

+113
-23
lines changed

10 files changed

+113
-23
lines changed

app/components/Home/ChanTitle.tsx

+7-3
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,19 @@ import React, { useEffect, useState } from 'react';
66
import Image from 'next/image';
77
import { Press_Start_2P } from 'next/font/google';
88
import { useDebounce } from '@/hooks/useDebounce';
9+
import { useMediaQuery } from 'react-responsive';
910

1011
const banger = Press_Start_2P({ weight: ['400'], subsets: ['latin'] });
1112
const ChanTitle: React.FC = () => {
1213
const [aniState, setAniState] = useState(false);
1314
const [hoverState, setHoverState] = useState(false); // 用来控制鼠标悬浮时显示图片3
14-
1515
const [isShow, setIsShow] = useState(false);
16+
const isXsOrSmaller = useMediaQuery({ query: '(max-width: 520px)' });
1617
const pathName = usePathname();
1718

1819
const handleMouseEnter = useDebounce(() => {
1920
setHoverState(true);
20-
console.log('ni')
21+
console.log('ni');
2122
}, 200);
2223
const handleMouseLeave = useDebounce(() => {
2324
setHoverState(false);
@@ -70,7 +71,10 @@ const ChanTitle: React.FC = () => {
7071
</animated.div>
7172
)}
7273
</span>
73-
<animated.span className={banger.className} style={propsText}>
74+
<animated.span
75+
className={banger.className}
76+
style={isXsOrSmaller ? undefined : propsText}
77+
>
7478
@CHAN
7579
</animated.span>
7680
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import React from 'react';
2+
import styles from '../headerBar.module.scss';
3+
import ChanLink from '@/components/Partial/ChanLink';
4+
import { Icon } from '@iconify/react/dist/iconify.cjs';
5+
6+
type link = {
7+
name: string;
8+
href: string;
9+
};
10+
11+
interface HeaderNavProps {
12+
links: link[];
13+
}
14+
15+
const HeaderNav: React.FC<HeaderNavProps> = ({ links }) => {
16+
return (
17+
<nav className={styles['nav-bar']}>
18+
<div className="ld:hidden">
19+
<Icon
20+
icon="line-md:close-to-menu-alt-transition"
21+
width={36}
22+
height={36}
23+
></Icon>
24+
</div>
25+
<div className='hidden ld:flex'>
26+
{links.map((link) => {
27+
return (
28+
<ChanLink to={link.href} key={link.name}>
29+
{link.name}
30+
</ChanLink>
31+
);
32+
})}
33+
</div>
34+
</nav>
35+
);
36+
};
37+
38+
export default HeaderNav;

app/components/Home/Nav/HeaderBar/Modal.tsx renamed to app/components/Home/Nav/HeaderBar/HeaderItem/Modal.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const Modal: React.FC = () => {
1111
<button>登录</button>
1212
</div>
1313
<div className="config">
14-
<Icon icon='eos-icons:rotating-gear' width={30} height={30}></Icon>
14+
<Icon icon='eos-icons:rotating-gear' width={36} height={36}></Icon>
1515
</div>
1616
</div>
1717
);

app/components/Home/Nav/HeaderBar/headerBar.module.scss

+7-1
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,19 @@
22
display: flex;
33
position: relative;
44
border: 1px solid red;
5-
5+
align-items: center;
6+
margin-left: 1%;
67
& a {
78
padding: 1rem;
89
}
10+
11+
& a{
12+
border: 1px solid black;
13+
}
914
}
1015

1116
.chan-header {
17+
height: 60px;
1218
margin-right: 0.5%;
1319
margin-left: 0.5%;
1420
border-radius: 12px;

app/components/Home/Nav/HeaderBar/index.tsx

+4-14
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
'use client';
2-
3-
import ChanLink from '@/components/Partial/ChanLink';
41
import styles from './headerBar.module.scss';
5-
import Search from './Search';
6-
import Modal from './Modal';
2+
import Search from './HeaderItem/Search';
3+
import Modal from './HeaderItem/Modal';
4+
import HeaderNav from './HeaderItem/HeaderNav';
75

86
const links = [
97
{ name: '主页', href: '/' },
@@ -18,15 +16,7 @@ const HeaderBar: React.FC = () => {
1816
id="chan-header"
1917
className={` ${styles['chan-header']} flex items-center sticky top-0 border-2 border-balck border-solid`}
2018
>
21-
<nav className={styles['nav-bar']}>
22-
{links.map((link) => {
23-
return (
24-
<ChanLink to={link.href} key={link.name}>
25-
{link.name}
26-
</ChanLink>
27-
);
28-
})}
29-
</nav>
19+
<HeaderNav links={links}></HeaderNav>
3020
<Search></Search>
3121
<Modal></Modal>
3222
</header>

app/layout.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ export default function RootLayout({
2222
<HeaderBar></HeaderBar>
2323
<div id='chan' className="flex justify-center gap-4 min-w-0">
2424
<SkipLink></SkipLink>
25-
<aside></aside>
25+
{/* <aside></aside> */}
2626
<div id="content">
2727
<main id="main-content">
2828
{children}
2929
<footer>footer</footer>
3030
</main>
31-
<aside id="r-aside"></aside>
31+
{/* <aside id="r-aside"></aside> */}
3232
</div>
3333
</div>
3434
</ThemeProvider>

package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"pusher": "^5.2.0",
2525
"pusher-js": "8.4.0-rc2",
2626
"react": "19.0.0-rc-66855b96-20241106",
27-
"react-dom": "19.0.0-rc-66855b96-20241106"
27+
"react-dom": "19.0.0-rc-66855b96-20241106",
28+
"react-responsive": "^10.0.0"
2829
},
2930
"devDependencies": {
3031
"@commitlint/cli": "^19.6.0",
@@ -33,6 +34,7 @@
3334
"@types/prop-types": "^15.7.14",
3435
"@types/react": "^18.3.14",
3536
"@types/react-dom": "^18.3.2",
37+
"@types/react-responsive": "^8.0.8",
3638
"@zinkawaii/stylelint-config": "^0.2.2",
3739
"clsx": "^2.1.1",
3840
"eslint": "8.57.0",

pnpm-lock.yaml

+49
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tailwind.config.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ export default {
1010
theme: {
1111
extend: {
1212
screens:{
13-
'xs': '480px'
13+
'xs': '520px',
14+
'ld': '900px',
1415
}
1516
},
1617
},

0 commit comments

Comments
 (0)