Skip to content

Story 2377: Webpage Integration: Implement Pagination to Posts Feed Page#2392

Open
herzog0 wants to merge 5 commits intodevelopfrom
teo/2377-posts-feed-pagination
Open

Story 2377: Webpage Integration: Implement Pagination to Posts Feed Page#2392
herzog0 wants to merge 5 commits intodevelopfrom
teo/2377-posts-feed-pagination

Conversation

@herzog0
Copy link
Copy Markdown
Collaborator

@herzog0 herzog0 commented May 4, 2026

Issue: #2377

Summary & Context

This PR introduces a new V3 pagination component, including custom template tags for dynamic page range calculation and URL generation. It integrates this new component into the posts feed (news list) and provides comprehensive demo examples for various pagination states, ensuring a consistent user experience.

  • Figma link:
  • Link to components/page: localhost:8000/v3/components/#pagination, localhost:8000/news/

Changes

  • Adds new Django template tags (resolve_pagination, pagination_range, page_url) for handling pagination logic, contextual data resolution, and URL construction with query parameters and anchor links.
  • Implements the V3 pagination UI with a new CSS stylesheet (pagination.css) and a dedicated HTML include (_pagination.html), featuring page numbers, ellipses, and chevron navigation.
  • Integrates the new pagination component into the EntryListView (posts feed) by enabling paginate_by and including the pagination template.
  • Expands the V3ComponentDemoView to include a new section demonstrating various pagination scenarios, with parameters for current page, total pages, and anchor scrolling, allowing for easy testing of different pagination states.
  • Ensures the pagination component always renders correctly, even when only a single page of content is available.

‼️ Risks & Considerations ‼️

  • There're no Figma definitions for how the styles should behave depending on the amount of pages and the selected page. The implementation is based on my opinion and some feedback from the refinement meeting;
  • There's no Figma for dark mode, tablet and mobile variants. I'm basing myself off of the foundations mappings;

Screenshots

image

Mobile:
image

Desktop:
image

Dark mode:
image

Self-review Checklist

  • Tag at least one team member from each team to review this PR
  • Link this PR to the related GitHub Project ticket

Frontend

  • UI implementation matches Figma design
  • Tested in light and dark mode
  • Responsive / mobile verified
  • Accessibility checked (keyboard navigation, etc.)
  • Ensure design tokens are used for colors, spacing, typography, etc. – No hardcoded values
  • Test without JavaScript (if applicable)
  • No console errors or warnings

herzog0 added 5 commits May 4, 2026 16:34
- `core/templatetags/pagination_tags.py`: new `pagination_range` tag
  (computes window ±2 with leading/trailing ellipsis) and `page_url`
  tag (builds URL preserving all existing query params)
- `static/css/v3/pagination.css`: component styles using design tokens;
  active page uses --color-surface-weak, inactive --color-text-secondary,
  ellipsis --color-text-tertiary, border-radius --border-radius-xl (12px)
- `templates/v3/includes/_pagination.html`: reusable partial; works in
  standard ListView context (page_obj/paginator) or in isolation via
  pagination_current/pagination_total/pagination_page_param params
- `news/views.py`: enable pagination (paginate_by=10) on EntryListView
- `templates/v3/posts_list.html`: include pagination partial below posts
- `templates/v3/examples/_v3_example_section.html`: 7 clickable demo
  examples (24-page and small-page sets) driven by URL query params
- `core/views.py`: add demo_pagination context data to V3ComponentDemoView
…o context

Django evaluates filter arguments eagerly, so `|default:page_obj.number`
raises VariableDoesNotExist when page_obj is not in context (e.g. demo page).

Replace the broken `{% with current=...|default:page_obj.number %}` pattern
with a new `resolve_pagination` template tag that reads page_obj/paginator
from context safely via Python's dict.get().
Each demo example div gets a unique id (pag-pg24a, etc.) plus
scroll-margin-top so the browser snaps to the right position.
Every page link in the partial now appends #anchor when pagination_anchor
is set, keeping the user in the right section after a page change.

The posts feed does not pass pagination_anchor so its links are unchanged.
pagination_range now returns [1] for num_pages=1 instead of hiding.
The partial guard changed from total > 1 to total >= 1 so the nav
always renders (both chevrons disabled, single page number shown).
@herzog0 herzog0 requested review from jlchilders11 and julhoang May 4, 2026 20:04
@herzog0 herzog0 linked an issue May 4, 2026 that may be closed by this pull request
@herzog0 herzog0 changed the title Adds V3 pagination component and posts feed integration Story 2377: Webpage Integration: Implement Pagination to Posts Feed Page May 4, 2026
@herzog0 herzog0 marked this pull request as ready for review May 4, 2026 22:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Webpage Integration: Implement Pagination to Posts Feed Page

1 participant