Skip to content

Build your personal knowledge base with Trilium Notes

ui/pager: improve layout

Adorian Doran782cd59407c5
diff --git a/apps/client/src/widgets/collections/Pagination.css b/apps/client/src/widgets/collections/Pagination.css
index fcb5ef6391..d2acef6453 100644
--- a/apps/client/src/widgets/collections/Pagination.css
+++ b/apps/client/src/widgets/collections/Pagination.css
@@ -19,9 +19,12 @@
display: flex;
align-items: baseline;
justify-content: space-around;
- /* Prevent the prev/next buttons from shifting when ellipses appear or disappear */
- min-width: calc(var(--note-list-pager-page-button-count) * var(--note-list-pager-page-button-width)
- + (var(--note-list-pager-ellipsis-width) * 2));
+
+ &.note-list-pager-ellipsis-present {
+ /* Prevent the prev/next buttons from shifting when ellipses appear or disappear */
+ min-width: calc(var(--note-list-pager-page-button-count) * var(--note-list-pager-page-button-width)
+ + (var(--note-list-pager-ellipsis-width) * 2));
+ }
.note-list-pager-page-button {
min-width: var(--note-list-pager-page-button-width);
diff --git a/apps/client/src/widgets/collections/Pagination.tsx b/apps/client/src/widgets/collections/Pagination.tsx
index 99e5ae5d81..8096ab2a36 100644
--- a/apps/client/src/widgets/collections/Pagination.tsx
+++ b/apps/client/src/widgets/collections/Pagination.tsx
@@ -76,8 +76,12 @@ function PageButtons(props: PageButtonsProps) {
const rightStart = props.pageCount - rightLength + 1;
middleStart = Math.min(middleStart, rightStart - middleLength);
- return <div class="note-list-pager-page-button-container"
- style={{"--note-list-pager-page-button-count": leftLength + middleLength + rightLength}}>
+ const totalButtonCount = leftLength + middleLength + rightLength;
+
+ return <div className={clsx("note-list-pager-page-button-container", {
+ "note-list-pager-ellipsis-present": (totalButtonCount === maxButtonCount)
+ })}
+ style={{"--note-list-pager-page-button-count": totalButtonCount}}>
{[
...createSegment(leftStart, leftLength, props.page, props.setPage, false),
...createSegment(middleStart, middleLength, props.page, props.setPage, (middleStart - leftLength > 1)),