From 6a413fbdb2c260f721d8f04137d044e7daa60e47 Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Sat, 24 Jun 2023 12:35:42 +0800 Subject: [PATCH] mobile-gitbook --- themes/gitbook/LayoutBase.js | 6 ++- themes/gitbook/LayoutSlug.js | 2 +- themes/gitbook/components/BottomMenuBar.js | 44 +++++++++++----------- themes/gitbook/components/PageNavDrawer.js | 36 ++++++++++++++++++ themes/gitbook/components/TocDrawer.js | 4 +- 5 files changed, 67 insertions(+), 25 deletions(-) create mode 100644 themes/gitbook/components/PageNavDrawer.js diff --git a/themes/gitbook/LayoutBase.js b/themes/gitbook/LayoutBase.js index 0d169314..61a340bf 100644 --- a/themes/gitbook/LayoutBase.js +++ b/themes/gitbook/LayoutBase.js @@ -15,6 +15,7 @@ import ArticleInfo from './components/ArticleInfo' import Catalog from './components/Catalog' import { useRouter } from 'next/router' import Announcement from './components/Announcement' +import PageNavDrawer from './components/PageNavDrawer' const ThemeGlobalMedium = createContext() /** @@ -26,6 +27,7 @@ const ThemeGlobalMedium = createContext() const LayoutBase = (props) => { const { children, meta, post, allNavPages, slotLeft, slotRight, slotTop, siteInfo } = props const [tocVisible, changeTocVisible] = useState(false) + const [pageNavVisible, changePageNavVisible] = useState(false) const [filterPosts, setFilterPosts] = useState(allNavPages) const { onLoading } = useGlobal() const router = useRouter() @@ -41,7 +43,7 @@ const LayoutBase = (props) => { return ( - +
@@ -107,6 +109,8 @@ const LayoutBase = (props) => { + + {/* 移动端底部导航栏 */}
diff --git a/themes/gitbook/LayoutSlug.js b/themes/gitbook/LayoutSlug.js index ef8998ec..b33d9b61 100644 --- a/themes/gitbook/LayoutSlug.js +++ b/themes/gitbook/LayoutSlug.js @@ -25,7 +25,7 @@ export const LayoutSlug = (props) => { {/* Notion文章主体 */} {post && (
- +
)}
diff --git a/themes/gitbook/components/BottomMenuBar.js b/themes/gitbook/components/BottomMenuBar.js index 45215f50..c3348bc3 100644 --- a/themes/gitbook/components/BottomMenuBar.js +++ b/themes/gitbook/components/BottomMenuBar.js @@ -3,34 +3,36 @@ import React from 'react' import { useMediumGlobal } from '../LayoutBase' import JumpToTopButton from './JumpToTopButton' -export default function BottomMenuBar ({ post, className }) { - const { tocVisible, changeTocVisible } = useMediumGlobal() +export default function BottomMenuBar({ post, className }) { + const { tocVisible, changeTocVisible, pageNavVisible, changePageNavVisible } = useMediumGlobal() const showTocBotton = post?.toc?.length > 0 const toggleToc = () => { changeTocVisible(!tocVisible) } + const togglePageNavVisible = () => { + changePageNavVisible(!pageNavVisible) + } + return ( -
-
- -
- -
- -
- +
+
+
+ +
+
+ +
+ {showTocBotton &&
+ +
} + {!showTocBotton && +
+ +
+ } +
- {showTocBotton &&
- -
} - { !showTocBotton && -
- -
- } -
-
) } diff --git a/themes/gitbook/components/PageNavDrawer.js b/themes/gitbook/components/PageNavDrawer.js new file mode 100644 index 00000000..846428b2 --- /dev/null +++ b/themes/gitbook/components/PageNavDrawer.js @@ -0,0 +1,36 @@ +import Catalog from './Catalog' +import { useMediumGlobal } from '../LayoutBase' +import BlogPostListScroll from './BlogPostListScroll' + +/** + * 悬浮抽屉 页面内导航 + * @param toc + * @param post + * @returns {JSX.Element} + * @constructor + */ +const PageNavDrawer = ({ post, cRef }) => { + const { pageNavVisible, changePageNavVisible, filterPosts } = useMediumGlobal() + const switchVisible = () => { + changePageNavVisible(!pageNavVisible) + } + + console.log('page', pageNavVisible) + return <> +
+ {/* 侧边菜单 */} +
+
+ {/* 所有文章列表 */} + +
+
+
+ {/* 背景蒙版 */} +
+ +} +export default PageNavDrawer diff --git a/themes/gitbook/components/TocDrawer.js b/themes/gitbook/components/TocDrawer.js index 9a9270db..b58adb44 100644 --- a/themes/gitbook/components/TocDrawer.js +++ b/themes/gitbook/components/TocDrawer.js @@ -20,8 +20,8 @@ const TocDrawer = ({ post, cRef }) => { className={(tocVisible ? 'animate__slideInRight ' : ' -mr-72 animate__slideOutRight') + ' overflow-y-hidden shadow-card w-60 duration-200 fixed right-1 bottom-16 rounded py-2 bg-white dark:bg-gray-600'}> {post && <> -
- +
+
}