-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tmplimpl: Add support for ellipsed paginator #3472
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -123,32 +123,47 @@ func (t *templateHandler) embedTemplates() { | |
`) | ||
|
||
t.addInternalTemplate("", "pagination.html", `{{ $pag := $.Paginator }} | ||
{{ if gt $pag.TotalPages 1 }} | ||
<ul class="pagination"> | ||
{{ with $pag.First }} | ||
<li> | ||
<a href="{{ .URL }}" aria-label="First"><span aria-hidden="true">««</span></a> | ||
</li> | ||
{{ end }} | ||
<li | ||
{{ if not $pag.HasPrev }}class="disabled"{{ end }}> | ||
<a href="{{ if $pag.HasPrev }}{{ $pag.Prev.URL }}{{ end }}" aria-label="Previous"><span aria-hidden="true">«</span></a> | ||
</li> | ||
{{ range $pag.Pagers }} | ||
<li | ||
{{ if eq . $pag }}class="active"{{ end }}><a href="{{ .URL }}">{{ .PageNumber }}</a></li> | ||
{{ end }} | ||
<li | ||
{{ if not $pag.HasNext }}class="disabled"{{ end }}> | ||
<a href="{{ if $pag.HasNext }}{{ $pag.Next.URL }}{{ end }}" aria-label="Next"><span aria-hidden="true">»</span></a> | ||
</li> | ||
{{ with $pag.Last }} | ||
<li> | ||
<a href="{{ .URL }}" aria-label="Last"><span aria-hidden="true">»»</span></a> | ||
</li> | ||
{{ end }} | ||
</ul> | ||
{{ end }}`) | ||
{{ if gt $pag.TotalPages 1 }} | ||
<ul class="pagination"> | ||
{{ with $pag.First }} | ||
<li> | ||
<a href="{{ .URL }}" aria-label="First"><span aria-hidden="true">««</span></a> | ||
</li> | ||
{{ end }} | ||
<li | ||
{{ if not $pag.HasPrev }}class="disabled"{{ end }}> | ||
<a href="{{ if $pag.HasPrev }}{{ $pag.Prev.URL }}{{ end }}" aria-label="Previous"><span aria-hidden="true">«</span></a> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a tricky accessibility issue: do we keep "Previous" if it means including English assistive text in multilingual sites? If yes, we should likely add If this is in any way a breaking change, however, I'm not too adamant about it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hearing from the blind person in the forum, I think we overvalue the labels. I suspect that it gets noisy when doing too much. If a blind person "sees" a sequence of integer links, he/she understands that it is a paginator. And in general, your remarks are about the existing code. This PR should focus on the changes made. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I wouldn't presume to know; hence why I defer to standards built for AT. And...
LGTM 👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can look at this later ... would nice if you could post a link to those standards? (but I suspect those standards are written by people who see) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Sure:
I agree we can table these as maybe "future iterative improvements?" |
||
</li> | ||
{{ $.Scratch.Set "__paginator.ellipsed" false }} | ||
{{ range $pag.Pagers }} | ||
{{ $right := sub .TotalPages .PageNumber }} | ||
{{ $showNumber := or (le .PageNumber 3) (eq $right 0) }} | ||
{{ $showNumber := or $showNumber (and (gt .PageNumber (sub $pag.PageNumber 2)) (lt .PageNumber (add $pag.PageNumber 2))) }} | ||
{{ if $showNumber }} | ||
{{ $.Scratch.Set "__paginator.ellipsed" false }} | ||
{{ $.Scratch.Set "__paginator.shouldEllipse" false }} | ||
{{ else }} | ||
{{ $.Scratch.Set "__paginator.shouldEllipse" (not ($.Scratch.Get "__paginator.ellipsed") ) }} | ||
{{ $.Scratch.Set "__paginator.ellipsed" true }} | ||
{{ end }} | ||
{{ if $showNumber }} | ||
<li | ||
{{ if eq . $pag }}class="active"{{ end }}><a href="{{ .URL }}">{{ .PageNumber }}</a></li> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
{{ else if ($.Scratch.Get "__paginator.shouldEllipse") }} | ||
<li class="disabled"><span aria-hidden="true">…</span></li> | ||
{{ end }} | ||
{{ end }} | ||
<li | ||
{{ if not $pag.HasNext }}class="disabled"{{ end }}> | ||
<a href="{{ if $pag.HasNext }}{{ $pag.Next.URL }}{{ end }}" aria-label="Next"><span aria-hidden="true">»</span></a> | ||
</li> | ||
{{ with $pag.Last }} | ||
<li> | ||
<a href="{{ .URL }}" aria-label="Last"><span aria-hidden="true">»»</span></a> | ||
</li> | ||
{{ end }} | ||
</ul> | ||
{{ end }}`) | ||
|
||
t.addInternalTemplate("", "disqus.html", `{{ if .Site.DisqusShortname }}<div id="disqus_thread"></div> | ||
<script type="text/javascript"> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My assumption is that this would be a breaking change, but really this needs to be wrapped in
<nav role="navigation" aria-label="Pagination Navigation">
. Only mentioning this here as a note that I should add this to the new docs.