Skip to content

Commit 0a44f4b

Browse files
Revise pagination styling
1 parent 3f51875 commit 0a44f4b

3 files changed

Lines changed: 29 additions & 7 deletions

File tree

src/uproot/_static/admin.css

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,31 @@ footer a {
204204
Pagination Styles
205205
============================================================================ */
206206

207+
208+
.pagination {
209+
dflex-wrap: wrap;
210+
}
211+
212+
.pagination > .page-item {
213+
max-width: 3.1em;
214+
min-width: 2em;
215+
width: 12.5%;
216+
}
217+
218+
.pagination > li:first-child,
219+
.pagination > li:last-child {
220+
flex-shrink: 0;
221+
min-width: 1.75em;
222+
width: 1.75em;
223+
}
224+
207225
.pagination .page-item .page-link {
208226
align-items: center;
209227
color: var(--bs-uproot);
210228
display: flex;
211229
height: 100%;
212-
text-align: center;
230+
justify-content: center;
231+
padding-inline: 0;
213232
}
214233
.pagination .page-item.disabled .page-link {
215234
background-color: unset;

src/uproot/_static/admin.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ function createElement(tag, className, attrs = {}) {
4747
return el;
4848
}
4949

50+
function getPaginationLabel(name) {
51+
const [first = "", second = ""] = Array.from(name.trim());
52+
return first.toLocaleUpperCase() + second.toLocaleLowerCase();
53+
}
54+
5055
/**
5156
* Creates a table row with label and value for d-table layout.
5257
*/
@@ -121,7 +126,7 @@ function renderRooms(rooms, containerId) {
121126

122127
sortedRooms.forEach(room => {
123128
const col = createElement("div", "mb-4 uproot-pagination-item");
124-
col.dataset.paginationLabel = Array.from(room.name.trim())[0]?.toLocaleUpperCase() || "";
129+
col.dataset.paginationLabel = getPaginationLabel(room.name);
125130
const card = createElement("div", "border-uproot callout card");
126131

127132
// Card header
@@ -433,7 +438,7 @@ function renderConfigsAppsCards(data, containerId, groupKey) {
433438
"align-items-start border-start callout d-flex justify-content-between px-3 py-2 mb-3 uproot-pagination-item " +
434439
cardBodyClass
435440
);
436-
item.dataset.paginationLabel = Array.from(displayKey.trim())[0]?.toLocaleUpperCase() || "";
441+
item.dataset.paginationLabel = getPaginationLabel(displayKey);
437442

438443
const content = createElement("div", "flex-grow-1 overflow-x-auto");
439444

src/uproot/_static/uproot.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -991,7 +991,7 @@ window.uproot = {
991991

992992
paginateBlocks() {
993993
document.querySelectorAll(".uproot-pagination").forEach((wrapper) => {
994-
const itemsPerPage = parseInt(wrapper.dataset.itemsPerPage) || 15;
994+
const itemsPerPage = parseInt(wrapper.dataset.itemsPerPage) || 10;
995995
const items = Array.from(wrapper.querySelectorAll(":scope > .uproot-pagination-item"));
996996

997997
if (items.length <= itemsPerPage) return;
@@ -1074,9 +1074,7 @@ window.uproot = {
10741074
const a = document.createElement("a");
10751075
a.className = "page-link";
10761076
a.href = "#";
1077-
const firstLabel = items[(p - 1) * itemsPerPage].dataset.paginationLabel;
1078-
const lastLabel = items[Math.min(p * itemsPerPage, items.length) - 1].dataset.paginationLabel;
1079-
a.textContent = firstLabel && lastLabel ? `${firstLabel}\u200B\u200A–\u200A\u200B${lastLabel}` : p;
1077+
a.textContent = items[(p - 1) * itemsPerPage].dataset.paginationLabel || p;
10801078
if (isActive) a.setAttribute("aria-current", "page");
10811079
a.addEventListener("click", (e) => {
10821080
e.preventDefault();

0 commit comments

Comments
 (0)