From 3796b0f64ae959a77496f21d9e35249a625c400e Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Tue, 14 Dec 2021 17:48:00 +0800 Subject: [PATCH] =?UTF-8?q?feature:=20=E6=A0=B7=E5=BC=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- blog.config.js | 2 +- components/BlogPostListScroll.js | 2 +- components/DarkModeButton.js | 2 +- components/JumpToTopButton.js | 10 ++++++---- components/Progress.js | 7 +++---- components/StickyBar.js | 2 +- components/TocDrawer.js | 2 +- components/TocDrawerButton.js | 26 +++++++++++++++++++++----- components/TopNav.js | 4 ++-- layouts/BaseLayout.js | 21 +++------------------ package.json | 13 ++++++------- pages/_app.js | 4 ++-- pages/article/[slug].js | 6 +++--- styles/globals.css | 20 +++++++++++++++++++- styles/notion.css | 2 +- 15 files changed, 71 insertions(+), 52 deletions(-) diff --git a/blog.config.js b/blog.config.js index dd007a5b..45f9a626 100644 --- a/blog.config.js +++ b/blog.config.js @@ -9,7 +9,7 @@ const BLOG = { notionAccessToken: process.env.NOTION_ACCESS_TOKEN || '', // Useful if you prefer not to make your database public defaultImgCover: 'https://avatars.githubusercontent.com/u/15920488', // default image cover appearance: 'auto', // ['light', 'dark', 'auto'], - font: 'font-serif tracking-wider subpixel-antialiased', // 文章字体 ['font-sans', 'font-serif', 'font-mono'] @see https://www.tailwindcss.cn/docs/font-family + font: 'font-sans tracking-wider subpixel-antialiased', // 文章字体 ['font-sans', 'font-serif', 'font-mono'] @see https://www.tailwindcss.cn/docs/font-family lightBackground: '#ffffff', // use hex value, don't forget '#' e.g #fffefc darkBackground: '#111827', // use hex value, don't forget '#' path: '', // leave this empty unless you want to deploy in a folder diff --git a/components/BlogPostListScroll.js b/components/BlogPostListScroll.js index 7b027d42..e5f7920b 100644 --- a/components/BlogPostListScroll.js +++ b/components/BlogPostListScroll.js @@ -64,7 +64,7 @@ const BlogPostListScroll = ({ posts = [], tags, currentSearch, currentCategory,
{ handleGetMore() }} - className='w-full my-4 py-4 bg-gray-300 text-center cursor-pointer dark:bg-gray-700 dark:text-gray-200' + className='w-full my-4 py-4 bg-gray-200 text-center cursor-pointer dark:bg-gray-700 dark:text-gray-200' > {hasMore ? '继续加载' : '加载完了😰'}
diff --git a/components/DarkModeButton.js b/components/DarkModeButton.js index c5297176..1bb7d086 100644 --- a/components/DarkModeButton.js +++ b/components/DarkModeButton.js @@ -11,7 +11,7 @@ const DarkModeButton = () => { saveTheme(newTheme) changeTheme(newTheme) } - return
+ return
diff --git a/components/JumpToTopButton.js b/components/JumpToTopButton.js index 96f6c548..5bec69fc 100644 --- a/components/JumpToTopButton.js +++ b/components/JumpToTopButton.js @@ -2,6 +2,7 @@ import React, { useEffect, useState } from 'react' import { useGlobal } from '@/lib/global' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { faArrowUp } from '@fortawesome/free-solid-svg-icons' +let windowTop = 0 /** * 跳转到网页顶部 @@ -22,7 +23,8 @@ const JumpToTopButton = ({ targetRef, showPercent = true }) => { const fullHeight = clientHeight - window.outerHeight let per = parseFloat(((scrollY / fullHeight * 100)).toFixed(0)) if (per > 100) per = 100 - const shouldShow = scrollY > 100 && per > 0 + const shouldShow = scrollY > 100 && per > 0 && scrollY < windowTop + windowTop = scrollY if (shouldShow !== show) { switchShow(shouldShow) @@ -34,11 +36,11 @@ const JumpToTopButton = ({ targetRef, showPercent = true }) => { return () => document.removeEventListener('scroll', scrollListener) }, [show]) - return (
+ return (
window.scrollTo({ top: 0, behavior: 'smooth' })} - className={(show ? 'animate__fadeInRight' : 'animate__fadeOutRight') + ' shadow-card bg-white dark:bg-gray-700 px-1 py-1 cursor-pointer animate__animated animate__faster shadow-2xl'}> + className={(show ? '' : 'hidden') + ' animate__fadeInRight rounded-full glassmorphism p-2 cursor-pointer animate__animated animate__faster shadow-card'}>
-
+
{showPercent && (
{percent}
)} diff --git a/components/Progress.js b/components/Progress.js index 0914ef5c..1ce7083a 100644 --- a/components/Progress.js +++ b/components/Progress.js @@ -1,5 +1,4 @@ -import React, { useCallback, useEffect, useState } from 'react' -import throttle from 'lodash.throttle' +import React, { useEffect, useState } from 'react' /** * 顶部页面阅读进度条 @@ -24,8 +23,8 @@ const Progress = ({ targetRef }) => { return () => document.removeEventListener('scroll', scrollListener) }, [percent]) - return (
-
+ return (
+
) } diff --git a/components/StickyBar.js b/components/StickyBar.js index dce840ff..dfc23181 100644 --- a/components/StickyBar.js +++ b/components/StickyBar.js @@ -8,7 +8,7 @@ const StickyBar = ({ children }) => { if (!children) return <> return ( -