Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion postcss.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ const purgecss = require("@fullhuman/postcss-purgecss")({

// pp google form
// /^pp-gf/, "fl-button", "pp-button",

// sdb
"jt-active",
],
Expand Down
80 changes: 80 additions & 0 deletions themes/beaver/assets/css/pagination.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
pagination
*/

.pagination {
display: flex;
padding-left: 0;
list-style: none;
margin-top: 5rem;
}

.page-link {
position: relative;
display: block;
padding: 0.5rem 1rem; /* --bs-pagination-padding-y and --bs-pagination-padding-x */
font-size: 1.25rem; /* --bs-pagination-font-size */
color: #0d6efd; /* --bs-link-color */
text-decoration: none;
background-color: #fff; /* --bs-body-bg */
border: 1px solid #dee2e6; /* --bs-border-color */
transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

@media (prefers-reduced-motion: reduce) {
.page-link {
transition: none;
}
}


.page-link:hover {
text-decoration: none;

z-index: 2;
color: #0a58ca; /* --bs-link-hover-color */
background-color: #f8f9fa; /* --bs-tertiary-bg */
border-color: #dee2e6; /* --bs-border-color */
}

.page-link:focus {
text-decoration: none;

z-index: 3;
color: #0a58ca; /* --bs-link-hover-color */

background-color: #e9ecef; /* --bs-secondary-bg */
outline: 0;
box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25); /* --bs-pagination-focus-box-shadow */
}
Comment on lines +31 to +49

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Accessibility Issue: Missing Focus Indicators on Pagination Links

The .page-link:focus selector in pagination.css lacks visible focus styles such as outline or box-shadow. This omission can impair keyboard navigation by not providing clear visual feedback for focused elements, negatively impacting accessibility.

Recommendations:

  • Add Focus Styles: Implement outline or box-shadow properties in the .page-link:focus selector to ensure focused pagination links are clearly visible.

    Example:

    .page-link:focus {
        outline: 2px solid #0a58ca; /* Adds a visible outline */
        box-shadow: 0 0 0 3px rgba(10, 88, 202, 0.5); /* Adds a subtle shadow */
    }
  • Test Keyboard Navigation: After adding focus styles, verify that users can navigate through pagination links using the keyboard and that the focus indicators are prominent and consistent.

🔗 Analysis chain

LGTM! Consider testing keyboard navigation.

The hover and focus states for .page-link are well-defined, providing good visual feedback to users. The z-index adjustments and box-shadow on focus enhance usability and accessibility.

To ensure a great user experience for keyboard users, please verify that the focus styles work well with keyboard navigation. You can test this by tabbing through the pagination links and checking if the focus indicator is clearly visible and functional.


To ensure that keyboard navigation provides clear visual feedback, please run the following script to verify the focus styles in pagination.css:


It appears there was a syntax error in the previous shell script due to incorrect escaping of the { character. Please use the corrected script below to verify that .page-link:focus has appropriate visual indicator styles:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any JavaScript files that might handle keyboard navigation for pagination.

# Test: Search for JavaScript files that mention both 'keyboard' and 'pagination'
rg --type js -e 'keyboard' -e 'pagination' | grep -E '(keyboard.*pagination)|(pagination.*keyboard)'

Length of output: 125493


Script:

#!/bin/bash
# Description: Verify that .page-link:focus has appropriate visual indicator styles

# Search for .page-link:focus selectors and check for outline or box-shadow properties
grep -A 5 "\.page-link:focus\s*\{" themes/beaver/assets/css/pagination.css | grep -E "outline|box-shadow" || echo "No visible focus styles found for .page-link:focus"

Length of output: 237


Script:

#!/bin/bash
# Description: Verify that .page-link:focus has appropriate visual indicator styles

# Corrected grep pattern with proper escaping or single quotes
grep -A 5 '\.page-link:focus\s*\{' themes/beaver/assets/css/pagination.css | grep -E 'outline|box-shadow' || echo "No visible focus styles found for .page-link:focus"

Length of output: 237


.page-link.active, .active > .page-link {
z-index: 3;
color: #fff; /* --bs-pagination-active-color */
background-color: #0d6efd; /* --bs-pagination-active-bg */
border-color: #0d6efd; /* --bs-pagination-active-border-color */
}

.page-link.disabled, .disabled > .page-link {
color: rgba(33, 37, 41, 0.75); /* --bs-secondary-color */
pointer-events: none;
background-color: #e9ecef; /* --bs-secondary-bg */
border-color: #dee2e6; /* --bs-border-color */
}

.page-item:not(:first-child) .page-link {
margin-left: calc(1px * -1);
}

.page-item:first-child .page-link {
border-top-left-radius: 0.5rem;
border-bottom-left-radius: 0.5rem;
}

.page-item:last-child .page-link {
border-top-right-radius: 0.5rem;
border-bottom-right-radius: 0.5rem;
}
.justify-content-between {
justify-content: space-between !important;
}
43 changes: 0 additions & 43 deletions themes/beaver/assets/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -128,50 +128,7 @@ Appearance > Theme Settings > Code or create a child theme.
text-decoration: none;
}

/*Pagination*/
.pagination {
list-style: none;
padding: 100px 0 30px;
margin: 0;
text-align: center;
font-size: 0;
line-height: 0;
}

.pagination .page-item {
display: inline-block;
vertical-align: middle;
}

.pagination .page-link {
display: block;
font-size: 16px;
line-height: 20px;
padding: 10px 16px;
text-decoration: none;
color: rgb(55, 65, 81);
border-color: rgb(209, 213, 219);
border-style: solid;
border-width: 1px 1px 1px 0;
}

.pagination .page-link:hover {
background-color: rgb(243 244 246);
}

.pagination .page-item:first-child .page-link {
border-width: 1px;
border-radius: 8px 0 0 8px;
}

.pagination .page-item:last-child .page-link {
border-radius: 0 8px 8px 0;
}

.pagination .page-item.active .page-link {
color: rgb(28, 100, 242);
background-color: rgb(235, 245, 255);
}

input[type=submit]:disabled {
opacity: 0.25
Expand Down
3 changes: 2 additions & 1 deletion themes/beaver/layouts/_default/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
| resources.Concat "css/blog.css" | postCSS | minify | fingerprint | resources.PostProcess}}

<link rel="stylesheet" href="{{ $CSS.RelPermalink }}" media='all' />

{{ $paginationCss := resources.Get "css/pagination.css" | minify | fingerprint }}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can add for sure to use: postCSS | minify | fingerprint | resources.PostProcess

<link rel="stylesheet" href="{{ $paginationCss.RelPermalink }}">


{{ if eq .Type "tags" }}
Expand Down
3 changes: 2 additions & 1 deletion themes/beaver/layouts/blog/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@

<link rel="stylesheet" href="{{ $CSS.RelPermalink }}" media='all' />


{{ $paginationCss := resources.Get "css/pagination.css" | minify | fingerprint }}
<link rel="stylesheet" href="{{ $paginationCss.RelPermalink }}">

{{ if eq .Type "tags" }}
{{ $blogIndex := .Site.GetPage "blog" }} <!-- Get the blog index page -->
Expand Down
203 changes: 134 additions & 69 deletions themes/beaver/layouts/partials/pagination.html
Original file line number Diff line number Diff line change
@@ -1,69 +1,134 @@
{{ $paginator := $.Paginator }}
<!-- Number of links either side of the current page. -->
{{ $adjacent_links := 1 }}
<!-- $max_links = ($adjacent_links * 2) + 1 -->
{{ $max_links := (add (mul $adjacent_links 2) 1) }}
<!-- $lower_limit = $adjacent_links + 1 -->
{{ $lower_limit := (add $adjacent_links 1) }}
<!-- $upper_limit = $paginator.TotalPages - $adjacent_links -->
{{ $upper_limit := (sub $paginator.TotalPages $adjacent_links) }}

{{ if gt $paginator.TotalPages 1 }}
<nav aria-label="Page navigation" class="w-100">
<ul class="pagination justify-content-center pagination-lg">
<!-- First page. -->
{{ if ne $paginator.PageNumber 1 }}
<li class="page-item">
<a class="page-link" href="{{ $paginator.First.URL }}"> First </a>
</li>
{{ end }}
<!-- Page numbers. -->
{{ range $paginator.Pagers }}
{{ $.Scratch.Set "page_number_flag" false }}
<!-- Advanced page numbers. -->
{{ if gt $paginator.TotalPages $max_links }}
<!-- Lower limit pages. -->
<!-- If the user is on a page which is in the lower limit. -->
{{ if le $paginator.PageNumber $lower_limit }}
<!-- If the current loop page is less than max_links. -->
{{ if le .PageNumber $max_links }}
{{ $.Scratch.Set "page_number_flag" true }}
{{ end }}
<!-- Upper limit pages. -->
<!-- If the user is on a page which is in the upper limit. -->
{{ else if ge $paginator.PageNumber $upper_limit }}
<!-- If the current loop page is greater than total pages minus $max_links -->
{{ if gt .PageNumber (sub $paginator.TotalPages $max_links) }}
{{ $.Scratch.Set "page_number_flag" true }}
{{ end }}
<!-- Middle pages. -->
{{ else }}
{{ if and ( ge .PageNumber (sub $paginator.PageNumber $adjacent_links) ) ( le .PageNumber (add
$paginator.PageNumber $adjacent_links) )
}}
{{ $.Scratch.Set "page_number_flag" true }}
{{ end }}
{{ end }}
<!-- Simple page numbers. -->
{{ else }}
{{ $.Scratch.Set "page_number_flag" true }}
{{ end }}
<!-- Output page numbers. -->
{{ if eq ($.Scratch.Get "page_number_flag") true }}
<li class="page-item{{ if eq . $paginator }}active{{ end }}">
<a class="page-link" href="{{ .URL }}">
{{ .PageNumber }}
</a>
</li>
{{ end }}
{{ end }}
<!-- Last page. -->
{{ if ne $paginator.PageNumber $paginator.TotalPages }}
<li class="page-item">
<a class="page-link" href="{{ $paginator.Last.URL }}"> Last </a>
</li>
{{ end }}
</ul>
<!-- </nav> -->
</nav>
{{ end }}
{{- $validFormats := slice "default" "terse" }}

{{- $msg1 := "When passing a map to the internal pagination template, one of the elements must be named 'page', and it must be set to the context of the current page." }}
{{- $msg2 := "The 'format' specified in the map passed to the internal pagination template is invalid. Valid choices are: %s." }}

{{- $page := . }}
{{- $format := "default" }}

{{- if reflect.IsMap . }}
{{- with .page }}
{{- $page = . }}
{{- else }}
{{- errorf $msg1 }}
{{- end }}
{{- with .format }}
{{- $format = lower . }}
{{- end }}
{{- end }}

{{- if in $validFormats $format }}
{{- if gt $page.Paginator.TotalPages 1 }}
<ul class="pagination pagination-{{ $format }} justify-content-between">
{{- partial (printf "partials/inline/pagination/%s" $format) $page }}
</ul>
{{- end }}
{{- else }}
{{- errorf $msg2 (delimit $validFormats ", ") }}
{{- end -}}

{{/* Format: default
{{/* --------------------------------------------------------------------- */}}
{{- define "partials/inline/pagination/default" }}
{{- with .Paginator }}
{{- $currentPageNumber := .PageNumber }}

{{- with .First }}
{{- if ne $currentPageNumber .PageNumber }}
{{- else }}
{{- end }}
{{- end }}

{{- with .Prev }}
<li class="page-item">
<a href="{{ .URL }}" aria-label="Previous" class="page-link" role="button">← Prev</a>
</li>
{{- else }}
<li class="page-item disabled">
<a aria-disabled="true" aria-label="Previous" class="page-link" role="button" tabindex="-1">← Prev</a>
</li>
{{- end }}

{{- $slots := 3 }}
{{- $start := math.Max 1 (sub .PageNumber (math.Floor (div $slots 2))) }}
{{- $end := math.Min .TotalPages (sub (add $start $slots) 1) }}
{{- if lt (add (sub $end $start) 1) $slots }}
{{- $start = math.Max 1 (add (sub $end $slots) 1) }}
{{- end }}

{{- range $k := seq $start $end }}
{{- if eq $.Paginator.PageNumber $k }}

{{- else }}

{{- end }}
{{- end }}

{{- with .Next }}
<li class="page-item">
<a href="{{ .URL }}" aria-label="Next" class="page-link" role="button">Next →</a>
</li>
{{- else }}
<li class="page-item disabled">
<a aria-disabled="true" aria-label="Next" class="page-link" role="button" tabindex="-1">Next →</a>
</li>
{{- end }}

{{- with .Last }}
{{- if ne $currentPageNumber .PageNumber }}
{{- else }}
{{- end }}
{{- end }}
{{- end }}
{{- end -}}

{{/* Format: terse
{{/* --------------------------------------------------------------------- */}}
{{- define "partials/inline/pagination/terse" }}
{{- with .Paginator }}
{{- $currentPageNumber := .PageNumber }}

{{- with .First }}
{{- if ne $currentPageNumber .PageNumber }}
{{- end }}
{{- end }}

{{- with .Prev }}
<li class="page-item">
<a href="{{ .URL }}" aria-label="Previous" class="page-link" role="button">← Prev</a>
</li>
{{- else }}
<li class="page-item disabled">
<a aria-disabled="true" aria-label="Previous" class="page-link" role="button" tabindex="-1">← Prev</a>
</li>
{{- end }}

{{- $slots := 3 }}
{{- $start := math.Max 1 (sub .PageNumber (math.Floor (div $slots 2))) }}
{{- $end := math.Min .TotalPages (sub (add $start $slots) 1) }}
{{- if lt (add (sub $end $start) 1) $slots }}
{{- $start = math.Max 1 (add (sub $end $slots) 1) }}
{{- end }}

{{- range $k := seq $start $end }}
{{- if eq $.Paginator.PageNumber $k }}
{{- else }}
{{- end }}
{{- end }}

{{- with .Next }}
<li class="page-item">
<a href="{{ .URL }}" aria-label="Next" class="page-link" role="button">Next →</a>
</li>
{{- else }}
<li class="page-item disabled">
<a aria-disabled="true" aria-label="Next" class="page-link" role="button" tabindex="-1">Next →</a>
</li>
{{- end }}

{{- with .Last }}
{{- if ne $currentPageNumber .PageNumber }}
{{- end }}
{{- end }}
{{- end }}
{{- end -}}