From dc43a8438ec60a6602b48249956a816195a81f47 Mon Sep 17 00:00:00 2001 From: plebeius Date: Tue, 24 Feb 2026 19:34:55 +0800 Subject: [PATCH] feat(board-pagination): redirect /boardIdentifier/1 to not-found, refine [All] button, hide pagelist when infinite scroll enabled --- src/app.tsx | 10 +- .../board-pagination.module.css | 35 ++++-- .../board-pagination/board-pagination.tsx | 113 +++++++++++------- 3 files changed, 103 insertions(+), 55 deletions(-) diff --git a/src/app.tsx b/src/app.tsx index 16ed0608..c8078553 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -180,6 +180,14 @@ const CatalogFeedRoute = () => { return ; }; +const PageOneGuard = () => { + const { pageNumber } = useParams(); + if (pageNumber === '1') { + return ; + } + return null; +}; + const ModQueueRoute = () => { const { boardIdentifier } = useParams(); const account = useAccount(); @@ -261,7 +269,7 @@ const App = () => { } /> } /> - + } /> diff --git a/src/components/board-pagination/board-pagination.module.css b/src/components/board-pagination/board-pagination.module.css index 703356f5..c1b35e10 100644 --- a/src/components/board-pagination/board-pagination.module.css +++ b/src/components/board-pagination/board-pagination.module.css @@ -25,7 +25,8 @@ } .paginationButton:disabled, -.paginationButton.disabled { +.paginationButton.disabled, +.disabled { opacity: 0.5; cursor: not-allowed; } @@ -39,6 +40,7 @@ display: flex; align-items: center; flex-wrap: wrap; + gap: 0 0.25em; margin: 0; padding: 3px 7px !important; overflow: hidden; @@ -46,6 +48,20 @@ background-color: var(--pagelist-background-color); } +.footerPageItem { + display: inline-flex; + align-items: center; +} + +.footerPageBracket { + color: var(--boardsbar-separator-color); +} + +/* Restore native button appearance (footer.module.css applies all: unset to .footerRow button) */ +.pagelist button.pagelistNavButton { + all: revert; +} + .footerNavPlain { font: inherit; margin: 0; @@ -76,12 +92,12 @@ .footerPageCurrent { font-size: 13px; margin: 0; - padding: 3px 2px; + padding: 0; border: none; background: transparent; list-style: none; overflow: hidden; - color: var(--pagelist-item-text-color, #89a); + color: var(--boardsbar-desktop-link-text-color); } .footerPageLink { @@ -89,21 +105,22 @@ display: inline-block; font-size: 13px; margin: 0; - padding: 3px 2px; + padding: 0; border: none; background: transparent; - color: var(--pagelist-item-text-color, #89a); + color: var(--boardsbar-desktop-link-text-color); text-transform: capitalize; cursor: pointer; - text-decoration: var(--button-text-decoration); + text-decoration: var(--boardsbar-desktop-link-text-decoration); } .footerPageLink:hover { - color: var(--pagelist-item-text-color-hover, #d00); - text-decoration: var(--button-text-decoration); + color: var(--boardsbar-desktop-link-text-color-hover); + text-decoration: var(--boardsbar-desktop-link-text-decoration-hover); } .footerPageCurrent { font-weight: bold; - color: var(--pagelist-item-text-color-current, #000); + color: var(--boardsbar-desktop-link-text-color-hover); + text-decoration: var(--boardsbar-desktop-link-text-decoration); } diff --git a/src/components/board-pagination/board-pagination.tsx b/src/components/board-pagination/board-pagination.tsx index 29b2ce92..565bcf0d 100644 --- a/src/components/board-pagination/board-pagination.tsx +++ b/src/components/board-pagination/board-pagination.tsx @@ -1,5 +1,6 @@ -import { Link } from 'react-router-dom'; +import { Link, useNavigate } from 'react-router-dom'; import { useTranslation } from 'react-i18next'; +import useFeedViewSettingsStore from '../../stores/use-feed-view-settings-store'; import StyleSelector from '../style-selector/style-selector'; import footerStyles from '../footer/footer.module.css'; import styles from './board-pagination.module.css'; @@ -14,10 +15,11 @@ export interface BoardPaginationProps { const BoardPagination = ({ basePath, currentPage, totalPages, footerStyle = false }: BoardPaginationProps) => { const { t } = useTranslation(); + const navigate = useNavigate(); + const enableInfiniteScroll = useFeedViewSettingsStore((state) => state.enableInfiniteScroll); + const setEnableInfiniteScroll = useFeedViewSettingsStore((state) => state.setEnableInfiniteScroll); const pageHref = (page: number) => (page === 1 ? basePath : `${basePath}/${page}`); - const prevHref = currentPage > 1 ? pageHref(currentPage - 1) : undefined; - const nextHref = currentPage < totalPages ? pageHref(currentPage + 1) : undefined; const catalogHref = `${basePath}/catalog`; if (totalPages <= 1 && !footerStyle) { @@ -30,40 +32,65 @@ const BoardPagination = ({ basePath, currentPage, totalPages, footerStyle = fals return (
-
- {currentPage > 1 && ( - - {t('previous')} - - )} - - [{t('all')}] - - {pageNumbers.map((page) => - page === currentPage ? ( - - [{page}] + {!enableInfiniteScroll && ( +
+ {currentPage > 1 && ( + + )} + {currentPage === 1 && ( + + [ + setEnableInfiniteScroll(true)} + onKeyDown={(e) => { + if (e.key === 'Enter' || e.key === ' ') { + e.preventDefault(); + setEnableInfiniteScroll(true); + } + }} + > + {t('all')} + + ] + )} + {pageNumbers.map((page) => + page === currentPage ? ( + + [ + {page} + ] + + ) : ( + + [ + + {page} + + ] + + ), + )} + {currentPage < totalPages ? ( + ) : ( - - [{page}] - - ), - )} - {currentPage < totalPages ? ( - - {t('next')} + {t('next')} + )} + + {t('catalog')} - ) : ( - {t('next')} - )} - - {t('catalog')} - - - {t('archive')} - -
+ + {t('archive')} + +
+ )}
{t('style')}: @@ -76,14 +103,10 @@ const BoardPagination = ({ basePath, currentPage, totalPages, footerStyle = fals return (
- {prevHref ? ( - + {currentPage > 1 && ( + )} {pageNumbers.map((page) => { const href = pageHref(page); @@ -98,12 +121,12 @@ const BoardPagination = ({ basePath, currentPage, totalPages, footerStyle = fals ); })} - {nextHref ? ( - + {currentPage < totalPages ? ( + ) : ( - + {t('next')} )}