From 7b526ec6e1498e0fce360852082233696fa79359 Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Fri, 14 Jul 2023 16:44:19 +0800 Subject: [PATCH] banner hover --- components/HeroIcons.js | 6 +++++ themes/heo/components/Hero.js | 46 ++++++++++++++++++++++++----------- 2 files changed, 38 insertions(+), 14 deletions(-) diff --git a/components/HeroIcons.js b/components/HeroIcons.js index f40fdfc3..d9bf4ff8 100644 --- a/components/HeroIcons.js +++ b/components/HeroIcons.js @@ -80,3 +80,9 @@ export const PlusSmall = ({ className }) => { } + +export const ArrowSmallRight = ({ className }) => { + return + + +} diff --git a/themes/heo/components/Hero.js b/themes/heo/components/Hero.js index 442f1c39..59e7c278 100644 --- a/themes/heo/components/Hero.js +++ b/themes/heo/components/Hero.js @@ -1,7 +1,7 @@ // import Image from 'next/image' import BLOG from '@/blog.config' -import { PlusSmall } from '@/components/HeroIcons' +import { ArrowSmallRight, PlusSmall } from '@/components/HeroIcons' import Link from 'next/link' import { useRouter } from 'next/router' import { useImperativeHandle, useRef, useState } from 'react' @@ -19,7 +19,7 @@ const Hero = props => {
{/* 左侧banner组 */} - + {/* 右侧置顶文章组 */} @@ -32,12 +32,12 @@ const Hero = props => { * 英雄区左侧banner组 * @returns */ -function BannerGroup() { +function BannerGroup(props) { return ( // 左侧英雄区
{/* 动图 */} - + {/* 导航分类 */}
@@ -48,8 +48,17 @@ function BannerGroup() { * 英雄区左上角banner动图 * @returns */ -function Banner() { - return
+function Banner(props) { + const router = useRouter() + const { latestPosts } = props + // 跳转到任意文章 + function handleClickBanner() { + const randomIndex = Math.floor(Math.random() * latestPosts.length) + const randomPost = latestPosts[randomIndex] + router.push(randomPost.slug) + } + + return
} @@ -158,8 +176,8 @@ function TodayCard({ cRef }) { const [isCoverUp, setIsCoverUp] = useState(true) /** - * 外部可以调用此方法 - */ + * 外部可以调用此方法 + */ useImperativeHandle(cRef, () => { return { coverUp: () => { @@ -169,18 +187,18 @@ function TodayCard({ cRef }) { }) /** - * 点击更多 - * @param {*} e - */ + * 点击更多 + * @param {*} e + */ function handleClickMore(e) { e.stopPropagation() setIsCoverUp(false) } /** - * 点击卡片跳转的链接 - * @param {*} e - */ + * 点击卡片跳转的链接 + * @param {*} e + */ function handleCardClick(e) { router.push('https://tangly1024.com') }