Skip to content

Commit

Permalink
feat: add current page highlighting on the pagination component durin…
Browse files Browse the repository at this point in the history
…g navigation

- add Handlebars helper function for conditional class addition
- ensure the current page is visually distinct in the pagination component
  • Loading branch information
sikatikenmogne committed Aug 18, 2024
1 parent 8f757d4 commit 7c63a61
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/helpers/handlebars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,7 @@ export const repoName = (v1: string): string => {
const part: Array<string> = v1.split('/');
return `${part[3]}/${part[4]}`;
};

export const addClassIfEqual = (v1: number, v2: number, extra: number, v3: string): string => {
return v1 === (v2+extra) ? v3 : '';
};
4 changes: 2 additions & 2 deletions src/views/partials/pagination.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
<li class="disabled page-item"><a class="page-link">...</a></li>
{{/if}}
{{#each (displayPagesNumber interval current pages)}}
{{#if (ifEqual . current 0)}}
{{#if (ifEqual . @root.current 0)}}
<li class="active page-item"><a class="page-link">{{ . }}</a></li>
{{else}}
{{#if @root.hasParams}}
{{#if (contains @root.fullUrl "page")}}
<li class="page-item"><a href="{{{constructUrl @root.fullUrl .}}}" class="page-link">{{ . }}</a></li>
<li class="page-item {{{addClassIfEqual . @root.current 0 'active'}}}"><a href="{{{constructUrl @root.fullUrl .}}}" class="page-link">{{ . }}</a></li>
{{else}}
<li class="page-item"><a href="{{@root.fullUrl}}&page={{.}}" class="page-link">{{ . }}</a></li>
{{/if}}
Expand Down

0 comments on commit 7c63a61

Please sign in to comment.