Problem/Motivation

#3023242: Pagination/Pager style update implemented the full pager according to the design system. However, for example, views allow using mini pager as an alternative to the full pager. This is how the mini pager looks currently in Claro:

Proposed resolution

Remaining tasks

  • Design
  • Development Implementation

Note: The Figma file contains the full layout with specs. Screen shot attached in comment #3 for reference.

Link to Figma file: https://www.figma.com/file/OqWgzAluHtsOd5uwm1lubFeH/Drupal-Design-system...

Release notes snippet

Issue fork claro-3049321

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

  • 3049321-mini-pager Comparecompare

Comments

lauriii created an issue. See original summary.

L2G2’s picture

Status: Active » Needs review
StatusFileSize
new45.51 KB

Utilizing the new pagination styles here:
https://www.drupal.org/project/claro/issues/3023242

I have implemented a few options for the mini pager.
Can be found in the Figma file here:
https://www.figma.com/file/OqWgzAluHtsOd5uwm1lubFeH/Drupal-Design-system?node-id=10266%3A18279

Outline of Options:
The first option keeps the existing styles of "current item" being fully enclosed in a blue circle. The second iteration could be to remove the circle when we are only showing one number, but the typography would still retain the current state blue color.

Then each one has an option for "first, previous, next, last" or just "previous and next"

Screenshot preview also attached.
Note the bounding box around the items is just to show they are variants, I'm not recommending it actually live in a box. :)

L2G2’s picture

Component: Needs design » Code
Issue summary: View changes
StatusFileSize
new109.28 KB

The Mini Pager is finalized and ready for implementation.

bnjmnm’s picture

Assigned: Unassigned » bnjmnm
Status: Needs review » Needs work
bnjmnm’s picture

Assigned: bnjmnm » Unassigned
Status: Needs work » Needs review
StatusFileSize
new5.37 KB

Here's an implementation of the mini pager. Because views does not supply first/last links, I added some logic to the preprocessor to create those.

During manual testing, noticed that the views mini pager has an option for a "more" link, which is not accounted for in these designs. I'm not sure if this is necessarily something that would fall in the scope of this issue, but mentioning it just in case.

lauriii’s picture

StatusFileSize
new3.18 KB

The buttons are now implemented as a square. This is how I would interpret the design system as well. It would be good to confirm this with the design team since this is inconsistent with the full pager.

lauriii’s picture

Another question; should we keep the current page as a link? It doesn't seem useful since it would always link to the current page.

ckrina’s picture

I wouldn't keep the link to the current page neither.

ckrina’s picture

I wouldn't keep the link to the current page neither.

lauriii’s picture

  1. +++ b/claro.theme
    @@ -763,3 +763,40 @@ function claro_preprocess_views_ui_display_tab_bucket(&$variables) {
    +  if($variables['items']['current'] > 1) {
    ...
    +  if($variables['quantity'] - $variables['items']['current'] > 0) {
    

    Nit: Space between if and opening parenthesis

  2. +++ b/claro.theme
    @@ -763,3 +763,40 @@ function claro_preprocess_views_ui_display_tab_bucket(&$variables) {
    +      $query['page'] = $variables['current'];
    

    I'm getting following error if I access /admin/content/media:

    Notice: Undefined index: current in claro_preprocess_views_mini_pager() (line 852 of themes/claro/claro.theme).
    claro_preprocess_views_mini_pager(Array, 'views_mini_pager', Array) (Line: 287)
    Drupal\Core\Theme\ThemeManager->render('views_mini_pager', Array) (Line: 430)

ckrina’s picture

StatusFileSize
new11.33 KB

All link areas in the pager should be circles unless they have text (prev, next...). So the hover should keep the circle appearance too. Here's an screenshot of the current specs, but we'll add states for all of them to avoid future confusions.

ckrina’s picture

Issue summary: View changes
StatusFileSize
new9.51 KB

Adding another screenshot for the target area:

lauriii’s picture

Status: Needs review » Needs work
junaidmasoodi’s picture

Assigned: Unassigned » junaidmasoodi
antonellasev’s picture

Issue tags: +beta blocker
ant1’s picture

Assigned: junaidmasoodi » Unassigned
Status: Needs work » Needs review
StatusFileSize
new5.89 KB
new3.07 KB
  • #7: I removed the link to current page and replaced it with a <span>.
  • #10.1: Fixed.
  • #10.2: This error didn't occur with me.
  • #11: Done.
lauriii’s picture

Status: Needs review » Needs work
  1. +++ b/claro.theme
    @@ -843,3 +843,40 @@ function claro_preprocess_views_ui_display_tab_bucket(&$variables) {
    +  // If there are additional pages, create an item that advances to the last
    +  // page. In some instances, it will also be necessary to create an item that
    +  // advances to the next page.
    +  if ($variables['quantity'] - $variables['items']['current'] > 0) {
    +    $query['page'] = $variables['quantity'] - 1;
    +    $current_url->setOption('query', $query);
    +    $variables['items']['last']['href'] = $current_url->toString();
    

    It doesn't seem like this is working. I get a link to the last page even on the last page.

  2. +++ b/claro.theme
    @@ -843,3 +843,40 @@ function claro_preprocess_views_ui_display_tab_bucket(&$variables) {
    +    // The Content view (and perhaps others?) do not provide a "next" item to
    +    // the mini pager, even when there is definitely a next page. In those
    +    // instances, one can be generated here.
    +    if (!isset($variables['items']['next'])) {
    +      $query['page'] = $variables['current'];
    +      $current_url->setOption('query', $query);
    +      $variables['items']['next']['href'] = $current_url->toString();
    +    }
    

    What are the steps to reproduce the problem this is trying to solve? I still get the notification that I mentioned in #10.2 on lists that only contain one page and I'm wondering if we could remove this.

  3. +++ b/css/src/components/pager.css
    @@ -118,6 +118,31 @@
    +.pager--mini span.pager__link.is-active:hover {
    

    We shouldn't assume the element type. Let's remove span from the selector.

ant1’s picture

Assigned: Unassigned » ant1
ant1’s picture

Assigned: ant1 » Unassigned
Status: Needs work » Needs review
StatusFileSize
new5.9 KB
new1.72 KB
  • #17.1: This should be fixed.
  • #17.2: I believe I fixed the code, but after testing it I still commented it out. I do not know which steps to undertake to recreate the problem this is trying to solve. This snippet also creates the link to next page even when it shouldn't (when there is only one page available). I would say to remove this snippet and when confronted with this issue, to create a follow-up issue.
  • #17.3: The span has been removed.
ant1’s picture

StatusFileSize
new5.9 KB

Forgot to add the comments (addressed in #19->#17.2).

Edit: or so I thought. You can ignore this patch.

lauriii’s picture

Status: Needs review » Needs work
  1. +++ b/claro.theme
    @@ -843,3 +843,39 @@ function claro_preprocess_views_ui_display_tab_bucket(&$variables) {
    +    /*if (!isset($variables['items']['next'])) {
    +      $query['page'] = $variables['items']['current'];
    +      $current_url->setOption('query', $query);
    +      $variables['items']['next']['href'] = $current_url->toString();
    +    }*/
    

    Instead of commenting these lines, we should remove these. Other than that, I think we're close to getting this finished 🥳

  2. I still see the last item page link on the last page. For some reason, the last page link is linking to page 8, even though I only have only 4 pages. 🤷‍♂️
ant1’s picture

Looking at the code, I strongly believe it's actually not possible to create a link to last page in the mini pager. The template_preprocess_views_mini_pager does not provide the needed information for making this possible (e.g. the amount of pages). Unless someone does know a proper solution, I think we should consider skipping the first/last links.

lauriii’s picture

Status: Needs work » Needs review
StatusFileSize
new3.26 KB
new5.83 KB

@AntoineH is right, it's not possible to implement the last page link. We also shouldn't add those since it's one of the reasons mini pager exists - it's supposed to bring better performance to views with lots of pages.

We could generate the first-page link since it's always the same, but it feels like we shouldn't have the first-page link without the last-page link. Here's a version that has both of them removed.

ant1’s picture

StatusFileSize
new609 bytes
new3.25 KB

Adjusted the comment on removing the margins, as there are no first and last links anymore.
Apart from that, I believe this patch covers everything for this issue. Tested it and it looks good to me.

ckrina’s picture

huzooka’s picture

Reviewing this.

huzooka’s picture

Assigned: Unassigned » huzooka
huzooka’s picture

Status: Needs review » Needs work
huzooka’s picture

Assigned: huzooka » Unassigned
Status: Needs work » Needs review

Additional changes since #24:

  1. Standardized pager and mini pager markup and CSS: instead of using SMACSS for handling mini-pager related differences, we do those with BEM.
  2. I simplified the icon margin issue: the provided patch adds the margin to the visible label instead of the icon's pseudo element.
  3. Fixed the wrong aria-labelledby attribute, see #3059232: Views mini pager Twig template has broken "aria-labelledby" reference

No visual difference (hopefully 🙂).

huzooka’s picture

Assigned: Unassigned » huzooka
Status: Needs review » Needs work

Forgot to add the patch.

huzooka’s picture

StatusFileSize
new9.22 KB
new10.23 KB
huzooka’s picture

Assigned: huzooka » Unassigned
Status: Needs work » Needs review
huzooka’s picture

Assigned: Unassigned » huzooka
Status: Needs review » Needs work
huzooka’s picture

Assigned: huzooka » Unassigned
Status: Needs work » Needs review
StatusFileSize
new8.91 KB
new3.47 KB
new9.99 KB

  • lauriii committed 39d6279 on 8.x-1.x
    Issue #3049321 by AntoineH, huzooka, lauriii, bnjmnm, ckrina, L2G2,...
lauriii’s picture

Status: Needs review » Fixed
StatusFileSize
new471 bytes

Tested both, mini pager and full pager manually to ensure that there are no regressions. Everything looked as expected.

Made a minor documentation improvement. Interdiff attached.

Thanks everyone!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

lauriii’s picture

alejandro.pinero made their first commit to this issue’s fork.