feat: Add jump-to-page dialog and improve pagination logic and styling (#1303)

* feat: add jump-to-page dialog on pagination ellipsis

- Replace pagination windowing algorithm with a tighter 5-item window
  (curr-1 / curr / curr+1, clamped at edges) and hide-on-mobile for
  pages more than 1 step away from the current page
- Ellipsis spans now carry the pagination-jump-trigger class and open
  a native <dialog> on click instead of being static decorations
- Add <dialog id="pagination-jump-dialog"> with number input, Go button,
  and Enter-key hint; data-total / data-first-url / data-format-url
  attributes on <nav> give the JS all it needs to build the target URL
- Add assets/ts/pagination.ts: setupPaginationJump() with Fisher-Yates
  backdrop-click and ESC handling, animated open/close via .closing class
- Wire setupPaginationJump() into Stack.init() in main.ts
- Extend pagination.scss with .hide-on-mobile, .pagination-jump-trigger
  hover style, and the full #pagination-jump-dialog styling + keyframe
  scale-up/scale-down animations
- Add [pagination] i18n keys (jumpToPage / jump / pressEnter) to
  en / zh / zh-hant-tw / zh-hant-hk / ja

* style: align pagination code with upstream conventions

- pagination.html: collapse multi-line span/class/aria attrs to single
  lines; use HTML5 void element syntax; fix hint div indentation
- pagination.scss: 2-space indent → 4-space indent
- pagination.ts: tab indent → 4-space indent; export const arrow fn →
  export function declaration

* chore: update layouts/_partials/pagination.html

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* chore: add aria-labelledby attrributes for better accesibility

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* fix: use { once: true } for the listener and guard against re-entry when .closing is already set.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* style: replace hardcoded values with design tokens and improve dialog UX

- Replace all hardcoded px spacing in .page-link with --spacing-* tokens
- Use @include card-style in #pagination-jump-dialog; override with --shadow-l2
- Replace padding: 24px with var(--card-padding) for responsive dialog padding
- Align header title/subtitle to space-between for cleaner layout
- Replace hardcoded gaps/padding in form with spacing tokens
- Fix input/button border-radius from 8px to 6px (better proportion for 44px height)
- Fix focus ring: use color-mix(accent-color 20%) so it's visible in dark mode
- Add :focus-visible + outline:none to fully suppress native browser outline
- Remove translateY from button hover for more restrained interaction
- Scope transition to specific properties (border-color, box-shadow, background-color)

* chore: add pagination test articles for easier debugging

* style: enhance backdrop animations for pagination jump dialog

* style: replace pagination ellipsis spans with buttons for improved accessibility

* fix: check if browser supports dialog API before continue with pagination jump setup

* fix: retain focus on last active element when closing pagination jump dialog

* fix: style for page-link button (pagination-jump)

* style: adjust width of pagination jump dialog, add container padding

* style: simplify

* refactor: simplify pagination link logic

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Jimmy Cai <jimmy@cai.im>
This commit is contained in:
powerfullz
2026-04-26 12:41:31 +02:00
committed by GitHub
co-authored by Copilot Jimmy Cai
parent 8e3687431f
commit 37f6a77a1a
22 changed files with 646 additions and 67 deletions
+1 -1
View File
@@ -12,7 +12,7 @@ hasCJKLanguage = false
path = "github.com/CaiJimmy/hugo-theme-stack/v3"
[pagination]
pagerSize = 5
pagerSize = 3
[permalinks]
post = "/p/:slug/"
+14
View File
@@ -0,0 +1,14 @@
---
title: Pagination Test 01
date: 2000-01-01
description: Test post 01 for pagination behavior.
slug: pagination-test-01
tags:
- pagination
- test
categories:
- Testing
draft: false
---
This is pagination test post **01**.
+14
View File
@@ -0,0 +1,14 @@
---
title: Pagination Test 02
date: 2000-01-02
description: Test post 02 for pagination behavior.
slug: pagination-test-02
tags:
- pagination
- test
categories:
- Testing
draft: false
---
This is pagination test post **02**.
+14
View File
@@ -0,0 +1,14 @@
---
title: Pagination Test 03
date: 2000-01-03
description: Test post 03 for pagination behavior.
slug: pagination-test-03
tags:
- pagination
- test
categories:
- Testing
draft: false
---
This is pagination test post **03**.
+14
View File
@@ -0,0 +1,14 @@
---
title: Pagination Test 04
date: 2000-01-04
description: Test post 04 for pagination behavior.
slug: pagination-test-04
tags:
- pagination
- test
categories:
- Testing
draft: false
---
This is pagination test post **04**.
+14
View File
@@ -0,0 +1,14 @@
---
title: Pagination Test 05
date: 2000-01-05
description: Test post 05 for pagination behavior.
slug: pagination-test-05
tags:
- pagination
- test
categories:
- Testing
draft: false
---
This is pagination test post **05**.
+14
View File
@@ -0,0 +1,14 @@
---
title: Pagination Test 06
date: 2000-01-06
description: Test post 06 for pagination behavior.
slug: pagination-test-06
tags:
- pagination
- test
categories:
- Testing
draft: false
---
This is pagination test post **06**.
+14
View File
@@ -0,0 +1,14 @@
---
title: Pagination Test 07
date: 2000-01-07
description: Test post 07 for pagination behavior.
slug: pagination-test-07
tags:
- pagination
- test
categories:
- Testing
draft: false
---
This is pagination test post **07**.
+14
View File
@@ -0,0 +1,14 @@
---
title: Pagination Test 08
date: 2000-01-08
description: Test post 08 for pagination behavior.
slug: pagination-test-08
tags:
- pagination
- test
categories:
- Testing
draft: false
---
This is pagination test post **08**.
+14
View File
@@ -0,0 +1,14 @@
---
title: Pagination Test 09
date: 2000-01-09
description: Test post 09 for pagination behavior.
slug: pagination-test-09
tags:
- pagination
- test
categories:
- Testing
draft: false
---
This is pagination test post **09**.
+14
View File
@@ -0,0 +1,14 @@
---
title: Pagination Test 10
date: 2000-01-10
description: Test post 10 for pagination behavior.
slug: pagination-test-10
tags:
- pagination
- test
categories:
- Testing
draft: false
---
This is pagination test post **10**.
+14
View File
@@ -0,0 +1,14 @@
---
title: Pagination Test 11
date: 2000-01-11
description: Test post 11 for pagination behavior.
slug: pagination-test-11
tags:
- pagination
- test
categories:
- Testing
draft: false
---
This is pagination test post **11**.
+14
View File
@@ -0,0 +1,14 @@
---
title: Pagination Test 12
date: 2000-01-12
description: Test post 12 for pagination behavior.
slug: pagination-test-12
tags:
- pagination
- test
categories:
- Testing
draft: false
---
This is pagination test post **12**.