Skip to content
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

Update Pagination styling #1828

Merged
merged 6 commits into from
Dec 11, 2024
Merged

Update Pagination styling #1828

merged 6 commits into from
Dec 11, 2024

Conversation

robertknight
Copy link
Member

@robertknight robertknight commented Dec 9, 2024

Update the styling of the Pagination control as follows:

  • Remove the background color from non-active items. This is a vestige from when this component was first created for use in the client's Notebook UI.
  • Use Unicode ellipsis for elided pages and page the elided-page markers approximately the same width as a (small) page number
  • Prevent text of pagination controls from being selected
  • Fix an issue where the Prev/Next button would have incorrect vertical alignment if the font size did not match that used in the client
  • Disable and hide prev/next controls rather than removing them when unavailable. This keeps the position of other controls consistent when moving from page to page, without needing to place these controls in a container with a hard-coded size

Before:

pagination-before

After:

pagination-after

This is a vestige from when this component was first created for use in the
client's Notebook UI. The background color for non-active pages matched the
client's background color.
Copy link

codecov bot commented Dec 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (f59c680) to head (b802d7a).
Report is 12 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #1828   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           70        70           
  Lines         1273      1272    -1     
  Branches       478       477    -1     
=========================================
- Hits          1273      1272    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

onClick: (e: MouseEvent) => void;
pressed?: boolean;
title?: string;
};
Copy link
Member Author

@robertknight robertknight Dec 9, 2024

Choose a reason for hiding this comment

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

I changed to explicitly listing all the used props here rather than using forwarding. This makes it easier to understand and constrain the variations in how this component is used. In general I am not a huge fan of using prop forwarding heavily except for components which are primarily intended to be styled wrappers around basic DOM components.

 - Use Unicode ellipsis instead of ASCII "..."
 - Make the elided pages indicator approximately the same width as a small page
   number. Together with some future changes to how pagination items are
   generated, this will reduce the amount of variation in width of the
   Pagination component as the current page is advanced.
This fixes an issue where repeatedly pressing the prev/next page buttons would
sometimes cause the text to be selected.
This fixes an issue where the Prev button was not vertically aligned with the
page numbers if the font size was larger than the one used in the client, where
this component originates.
This avoids the need to specify a fixed width for the container of the Prev/Next
page buttons in order to keep other controls in a consistent position as the
user navigates between pages, and the Prev/Next page buttons are shown/hidden.
@robertknight robertknight force-pushed the remove-pagination-background branch from 27ecc51 to b802d7a Compare December 9, 2024 12:15
@robertknight robertknight requested a review from acelaya December 10, 2024 11:30
// rather than removed so that the overall width of the component and
// positions of child controls doesn't change too much when navigating
// between pages.
invisible && 'invisible',
Copy link
Contributor

Choose a reason for hiding this comment

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

I reckon this should be equivalent to { invisible }

Suggested change
invisible && 'invisible',
{ invisible },

Copy link
Member Author

Choose a reason for hiding this comment

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

You are right. I find the current version slightly more obvious in its meaning. It also avoids a hazard of silently breaking things if the prop is renamed.

Comment on lines +32 to +35
// Disabled navigation buttons are rendered as invisible and disabled
// rather than removed so that the overall width of the component and
// positions of child controls doesn't change too much when navigating
// between pages.
Copy link
Contributor

Choose a reason for hiding this comment

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

I would even consider keeping them visible but disabled, but this should work for now without introducing design changes.

@robertknight robertknight merged commit 5c82a76 into main Dec 11, 2024
4 checks passed
@robertknight robertknight deleted the remove-pagination-background branch December 11, 2024 10:15
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.

2 participants