Skip to content

Commit 4b03ec2

Browse files
committed
HEO 关闭移动端动画
1 parent e16142f commit 4b03ec2

File tree

4 files changed

+153
-97
lines changed

4 files changed

+153
-97
lines changed

themes/heo/components/InfoCard.js

+60-40
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { siteConfig } from '@/lib/config'
21
import { ArrowRightCircle, GlobeAlt } from '@/components/HeroIcons'
32
import LazyImage from '@/components/LazyImage'
3+
import { siteConfig } from '@/lib/config'
44
import Link from 'next/link'
55
import { useRouter } from 'next/router'
66
import { useState } from 'react'
@@ -19,41 +19,48 @@ export function InfoCard(props) {
1919
// 在文章详情页特殊处理
2020
const isSlugPage = router.pathname.indexOf('/[prefix]') === 0
2121
return (
22-
<Card className='bg-[#4f65f0] dark:bg-yellow-600 text-white flex flex-col w-72 overflow-hidden relative'>
23-
{/* 信息卡牌第一行 */}
24-
<div className='flex justify-between'>
25-
{/* 问候语 */}
26-
<GreetingsWords />
27-
<div className={`${isSlugPage ? 'absolute right-0 -mt-8 -mr-6 hover:opacity-0 hover:scale-150 blur' : 'cursor-pointer'} justify-center items-center flex dark:text-gray-100 transform transitaion-all duration-200`}>
28-
<LazyImage src={siteInfo?.icon} className='rounded-full' width={isSlugPage ? 100 : 28} alt={siteConfig('AUTHOR')} />
29-
</div>
30-
</div>
22+
<Card className='bg-[#4f65f0] dark:bg-yellow-600 text-white flex flex-col w-72 overflow-hidden relative'>
23+
{/* 信息卡牌第一行 */}
24+
<div className='flex justify-between'>
25+
{/* 问候语 */}
26+
<GreetingsWords />
27+
<div
28+
className={`${isSlugPage ? 'absolute right-0 -mt-8 -mr-6 hover:opacity-0 hover:scale-150 blur' : 'cursor-pointer'} justify-center items-center flex dark:text-gray-100 transform transitaion-all duration-200`}>
29+
<LazyImage
30+
src={siteInfo?.icon}
31+
className='rounded-full'
32+
width={isSlugPage ? 100 : 28}
33+
alt={siteConfig('AUTHOR')}
34+
/>
35+
</div>
36+
</div>
3137

32-
<h2 className='text-3xl font-extrabold mt-3'>
33-
{siteConfig('AUTHOR')}
34-
</h2>
38+
<h2 className='text-3xl font-extrabold mt-3'>{siteConfig('AUTHOR')}</h2>
3539

36-
{/* 公告栏 */}
37-
<div>
38-
<Announcement post={notice} style={{ color: 'white !important' }} />
39-
</div>
40+
{/* 公告栏 */}
41+
<div>
42+
<Announcement post={notice} style={{ color: 'white !important' }} />
43+
</div>
4044

41-
<div className='flex justify-between'>
42-
<div className='flex space-x-3 hover:text-black dark:hover:text-white'>
43-
{/* 两个社交按钮 */}
44-
<div className='bg-indigo-400 p-2 rounded-full transition-colors duration-200 dark:bg-yellow-500 dark:hover:bg-black hover:bg-white'>
45-
<Link href='/about'><GlobeAlt className={'w-6 h-6'} /></Link>
46-
</div>
47-
<div className='bg-indigo-400 p-2 rounded-full w-10 items-center flex justify-center transition-colors duration-200 dark:bg-yellow-500 dark:hover:bg-black hover:bg-white'>
48-
{siteConfig('HEO_INFO_CARD_URL', null, CONFIG) && <Link href={siteConfig('HEO_INFO_CARD_URL', null, CONFIG)}>
49-
<i className='fab fa-github text-xl' />
50-
</Link>
51-
}
52-
</div>
53-
</div>
54-
<MoreButton />
55-
</div>
56-
</Card>
45+
<div className='flex justify-between'>
46+
<div className='flex space-x-3 hover:text-black dark:hover:text-white'>
47+
{/* 两个社交按钮 */}
48+
<div className='bg-indigo-400 p-2 rounded-full transition-colors duration-200 dark:bg-yellow-500 dark:hover:bg-black hover:bg-white'>
49+
<Link href='/about'>
50+
<GlobeAlt className={'w-6 h-6'} />
51+
</Link>
52+
</div>
53+
<div className='bg-indigo-400 p-2 rounded-full w-10 items-center flex justify-center transition-colors duration-200 dark:bg-yellow-500 dark:hover:bg-black hover:bg-white'>
54+
{siteConfig('HEO_INFO_CARD_URL', null, CONFIG) && (
55+
<Link href={siteConfig('HEO_INFO_CARD_URL', null, CONFIG)}>
56+
<i className='fab fa-github text-xl' />
57+
</Link>
58+
)}
59+
</div>
60+
</div>
61+
<MoreButton />
62+
</div>
63+
</Card>
5764
)
5865
}
5966

@@ -69,20 +76,33 @@ function GreetingsWords() {
6976
setGreeting(greetings[randomIndex])
7077
}
7178

72-
return <div onClick={handleChangeGreeting} className=' select-none cursor-pointer py-1 px-2 bg-indigo-400 hover:bg-indigo-50 hover:text-indigo-950 dark:bg-yellow-500 dark:hover:text-white dark:hover:bg-black text-sm rounded-lg duration-200 transition-colors'>
73-
{greeting}
79+
return (
80+
<div
81+
onClick={handleChangeGreeting}
82+
className=' select-none cursor-pointer py-1 px-2 bg-indigo-400 hover:bg-indigo-50 hover:text-indigo-950 dark:bg-yellow-500 dark:hover:text-white dark:hover:bg-black text-sm rounded-lg duration-200 transition-colors'>
83+
{greeting}
7484
</div>
85+
)
7586
}
7687

7788
/**
7889
* 了解更多按鈕
7990
* @returns
8091
*/
8192
function MoreButton() {
82-
return <Link href='/about'>
83-
<div className={'group bg-indigo-400 dark:bg-yellow-500 hover:bg-white dark:hover:bg-black hover:text-black dark:hover:text-white flex items-center transition-colors duration-200 py-2 px-3 rounded-full space-x-1'}>
84-
<ArrowRightCircle className={'group-hover:stroke-black dark:group-hover:stroke-white w-6 h-6 transition-all duration-100'} />
85-
<div className='font-bold'>了解更多</div>
86-
</div>
93+
return (
94+
<Link href='/about'>
95+
<div
96+
className={
97+
'group bg-indigo-400 dark:bg-yellow-500 hover:bg-white dark:hover:bg-black hover:text-black dark:hover:text-white flex items-center transition-colors duration-200 py-2 px-3 rounded-full space-x-1'
98+
}>
99+
<ArrowRightCircle
100+
className={
101+
'group-hover:stroke-black dark:group-hover:stroke-white w-6 h-6 transition-all duration-100'
102+
}
103+
/>
104+
<div className='font-bold'>了解更多</div>
105+
</div>
87106
</Link>
107+
)
88108
}

themes/heo/components/PostHeader.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export default function PostHeader({ post, siteInfo, isDarkMode }) {
2222
return (
2323
<div
2424
id='post-bg'
25-
className='w-full h-[30rem] relative md:flex-shrink-0 overflow-hidden bg-cover bg-center bg-no-repeat z-10 mb-5'>
25+
className='md:mb-0 -mb-5 w-full h-[30rem] relative md:flex-shrink-0 overflow-hidden bg-cover bg-center bg-no-repeat z-10'>
2626
<style jsx>{`
2727
.coverdiv:after {
2828
position: absolute;
@@ -38,18 +38,17 @@ export default function PostHeader({ post, siteInfo, isDarkMode }) {
3838
`}</style>
3939

4040
<div
41-
style={{ backdropFilter: 'blur(15px)' }}
4241
className={`${isDarkMode ? 'bg-[#CA8A04]' : 'bg-[#0060e0]'} absolute top-0 w-full h-full py-10 flex justify-center items-center`}>
4342
{/* 文章背景图 */}
4443
<div
4544
id='post-cover-wrapper'
4645
style={{
4746
filter: 'blur(15px)'
4847
}}
49-
className='coverdiv lg:translate-x-96 opacity-50 lg:rotate-12'>
48+
className='coverdiv lg:opacity-50 lg:translate-x-96 lg:rotate-12'>
5049
<LazyImage
5150
id='post-cover'
52-
className='w-full h-full object-cover opacity-80 max-h-[50rem] min-w-[50vw] min-h-[20rem]'
51+
className='w-full h-full object-cover max-h-[50rem] min-w-[50vw] min-h-[20rem]'
5352
src={headerImage}
5453
/>
5554
</div>

themes/heo/components/WavesArea.js

+89-52
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,102 @@
11
import { useGlobal } from '@/lib/global'
2+
import { useEffect, useState } from 'react'
23

34
/**
45
* 文章波浪动画
56
*/
67
export default function WavesArea() {
78
const { isDarkMode } = useGlobal()
89
const color = isDarkMode ? '#18171d' : '#f7f9fe'
10+
const [showWave, setShowWave] = useState(true)
11+
12+
useEffect(() => {
13+
const handleResize = () => {
14+
if (window.innerWidth < 800) {
15+
setShowWave(false)
16+
} else {
17+
setShowWave(true)
18+
}
19+
}
20+
21+
// Initial check
22+
handleResize()
23+
24+
// Add event listener for window resize
25+
window.addEventListener('resize', handleResize)
26+
27+
// Cleanup event listener on component unmount
28+
return () => {
29+
window.removeEventListener('resize', handleResize)
30+
}
31+
}, [])
32+
33+
if (!showWave) {
34+
return null
35+
}
936

1037
return (
11-
<section className="main-hero-waves-area waves-area w-full absolute left-0 z-10 bottom-0">
12-
<svg className="waves-svg w-full h-[60px]" xmlns="http://www.w3.org/2000/svg" xlink="http://www.w3.org/1999/xlink" viewBox="0 24 150 28" preserveAspectRatio="none" shapeRendering="auto">
13-
<defs>
14-
<path id="gentle-wave" d="M -160 44 c 30 0 58 -18 88 -18 s 58 18 88 18 s 58 -18 88 -18 s 58 18 88 18 v 44 h -352 Z"></path>
15-
</defs>
16-
<g className="parallax">
17-
<use href="#gentle-wave" x="48" y="0"></use>
18-
<use href="#gentle-wave" x="48" y="3"></use>
19-
<use href="#gentle-wave" x="48" y="5"></use>
20-
<use href="#gentle-wave" x="48" y="7"></use>
21-
</g>
22-
</svg>
23-
<style jsx global>{`
24-
/* Animation */
38+
<section className='main-hero-waves-area waves-area w-full absolute left-0 z-10 bottom-0'>
39+
<svg
40+
className='waves-svg w-full h-[60px]'
41+
xmlns='http://www.w3.org/2000/svg'
42+
xlink='http://www.w3.org/1999/xlink'
43+
viewBox='0 24 150 28'
44+
preserveAspectRatio='none'
45+
shapeRendering='auto'>
46+
<defs>
47+
<path
48+
id='gentle-wave'
49+
d='M -160 44 c 30 0 58 -18 88 -18 s 58 18 88 18 s 58 -18 88 -18 s 58 18 88 18 v 44 h -352 Z'></path>
50+
</defs>
51+
<g className='parallax'>
52+
<use href='#gentle-wave' x='48' y='0'></use>
53+
<use href='#gentle-wave' x='48' y='3'></use>
54+
<use href='#gentle-wave' x='48' y='5'></use>
55+
<use href='#gentle-wave' x='48' y='7'></use>
56+
</g>
57+
</svg>
58+
<style jsx global>
59+
{`
60+
/* Animation */
61+
62+
.parallax > use {
63+
animation: move-forever 30s cubic-bezier(0.55, 0.5, 0.45, 0.5)
64+
infinite;
65+
}
66+
.parallax > use:nth-child(1) {
67+
animation-delay: -2s;
68+
animation-duration: 7s;
69+
fill: ${color};
70+
opacity: 0.5;
71+
}
72+
.parallax > use:nth-child(2) {
73+
animation-delay: -3s;
74+
animation-duration: 10s;
75+
fill: ${color};
76+
opacity: 0.6;
77+
}
78+
.parallax > use:nth-child(3) {
79+
animation-delay: -4s;
80+
animation-duration: 13s;
81+
fill: ${color};
82+
opacity: 0.7;
83+
}
84+
.parallax > use:nth-child(4) {
85+
animation-delay: -5s;
86+
animation-duration: 20s;
87+
fill: ${color};
88+
}
2589
26-
.parallax > use {
27-
animation: move-forever 30s cubic-bezier(0.55, 0.5, 0.45, 0.5) infinite;
28-
}
29-
.parallax > use:nth-child(1) {
30-
animation-delay: -2s;
31-
animation-duration: 7s;
32-
fill: ${color};
33-
opacity: 0.5;
34-
}
35-
.parallax > use:nth-child(2) {
36-
animation-delay: -3s;
37-
animation-duration: 10s;
38-
fill: ${color};
39-
opacity: 0.6;
40-
}
41-
.parallax > use:nth-child(3) {
42-
animation-delay: -4s;
43-
animation-duration: 13s;
44-
fill: ${color};
45-
opacity: 0.7;
46-
}
47-
.parallax > use:nth-child(4) {
48-
animation-delay: -5s;
49-
animation-duration: 20s;
50-
fill: ${color};
51-
}
52-
53-
@keyframes move-forever {
54-
0% {
55-
transform: translate3d(-90px, 0, 0);
56-
}
57-
100% {
58-
transform: translate3d(85px, 0, 0);
59-
}
60-
}
61-
`}
62-
</style>
63-
</section>
90+
@keyframes move-forever {
91+
0% {
92+
transform: translate3d(-90px, 0, 0);
93+
}
94+
100% {
95+
transform: translate3d(85px, 0, 0);
96+
}
97+
}
98+
`}
99+
</style>
100+
</section>
64101
)
65102
}

themes/heo/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ const LayoutSlug = props => {
297297
data-wow-delay='.2s'
298298
className='wow fadeInUp'>
299299
{/* Notion文章主体 */}
300-
<section className='px-5 justify-center mx-auto'>
300+
<section className='px-5 py-5 justify-center mx-auto'>
301301
<WWAds orientation='horizontal' className='w-full' />
302302
{post && <NotionPage post={post} />}
303303
<WWAds orientation='horizontal' className='w-full' />

0 commit comments

Comments
 (0)