Skip to content

Commit 798745f

Browse files
committed
Show Next/Prev when disabled and CSS improvements
1 parent 32cdfdb commit 798745f

File tree

3 files changed

+41
-43
lines changed

3 files changed

+41
-43
lines changed

datafiles/static/browse.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -248,13 +248,16 @@ const createPageLink = (num) => {
248248
return a;
249249
};
250250

251-
const createPrevNext = (prevNextNum, txt) => {
251+
const createPrevNext = (prevNextNum, hasLink, txt) => {
252252
const el = d.createElement("a");
253-
el.setAttribute("href", "#");
254-
el.addEventListener('click', (evt) => {
255-
evt.preventDefault();
256-
changePage(prevNextNum);
257-
});
253+
254+
if(hasLink) {
255+
el.setAttribute("href", "#");
256+
el.addEventListener('click', (evt) => {
257+
evt.preventDefault();
258+
changePage(prevNextNum);
259+
});
260+
}
258261

259262
el.appendChild(d.createTextNode(txt));
260263
return el;
@@ -271,7 +274,7 @@ const createPaginator = () => {
271274

272275
const pag = d.createElement("div");
273276
pag.classList.add("paginator");
274-
if (state.page !== 0) pag.appendChild(createPrevNext(state.page - 1, "Previous"));
277+
pag.appendChild(createPrevNext(state.page - 1, state.page !== 0, "Previous"));
275278
// note that page is zero-indexed
276279
if (maxPage <= 4) {
277280
// No ellipsis
@@ -304,7 +307,7 @@ const createPaginator = () => {
304307
}
305308
const isNowOnLastPage = state.page === maxPage;
306309

307-
if(!isNowOnLastPage) pag.appendChild(createPrevNext(state.page + 1, "Next"));
310+
pag.appendChild(createPrevNext(state.page + 1, !isNowOnLastPage, "Next"));
308311

309312
return pag;
310313
};

datafiles/static/hackage.css

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,50 +1046,49 @@ a.deprecated[href]:visited {
10461046
display: flex;
10471047
align-items: center;
10481048
flex-wrap: wrap;
1049+
justify-content: space-between;
1050+
}
1051+
1052+
#paginatorContainer > div {
1053+
padding: 1em 0;
10491054
}
10501055

10511056
.paginator {
1052-
margin-left: auto;
1057+
display: flex;
1058+
flex-wrap: wrap;
10531059
}
10541060

1061+
/* Styles Next/Prev when they have no href */
10551062
.paginator a {
1056-
box-sizing: border-box;
1057-
display: inline-block;
1058-
min-width: 1.5em;
1063+
color: #666;
1064+
cursor: default;
1065+
background: none;
1066+
border: none;
10591067
padding: 0.5em 1em;
1060-
margin-left: 2px;
1061-
text-align: center;
10621068
text-decoration: none;
1063-
color: #333;
1064-
border: 1px solid transparent;
1065-
border-radius: 2px;
10661069
}
10671070

1068-
/* Targeting of href for a tags higher up makes it more cumbersome to override */
1069-
.paginator a[href]:link, .paginator a[href]:visited {
1071+
.paginator span {
10701072
color: #333;
1071-
text-decoration: none;
1073+
padding: 0.5em 1em;
10721074
}
10731075

1074-
.paginator .current,
1075-
.paginator .current:hover {
1076+
.paginator a:link, .paginator a:visited {
10761077
color: #333;
1077-
border: 1px solid #979797;
1078-
background: linear-gradient(to bottom, #fff 0%, #dcdcdc 100%);
1078+
border: 1px solid transparent;
1079+
border-radius: 2px;
10791080
}
10801081

1081-
.paginator a[href]:hover {
1082+
.paginator a:link:hover, .paginator a:visited:hover {
10821083
color: white;
10831084
border: 1px solid #111;
10841085
background: linear-gradient(to bottom, #585858 0%, #111 100%);
1086+
text-decoration: none;
10851087
}
10861088

1087-
.paginator a[href][disabled] {
1088-
color: #666;
1089-
cursor: default;
1089+
.paginator .current,
1090+
.paginator .current:hover {
1091+
color: #333;
1092+
border: 1px solid #979797;
1093+
background: linear-gradient(to bottom, #fff 0%, #dcdcdc 100%);
10901094
}
1091-
1092-
.paginator a[href][disabled]:hover {
1093-
background: none;
1094-
border: none;
1095-
}

src/Distribution/Server/Pages/Recent.hs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,9 @@ paginator pc@PaginatedConfiguration{currPage,totalAmount} baseUrl =
7373
infoText = "Showing " ++ show start ++ " to " ++ show end ++ " of " ++ show totalAmount ++ " entries"
7474
info = XHtml.thediv << infoText
7575

76-
next = if hasNext pc
77-
then XHtml.anchor ! [XHtml.href (fromMaybe "" (nextURL baseUrl pc))] << "Next"
78-
else XHtml.noHtml
79-
prev = if hasPrev pc
80-
then XHtml.anchor ! [XHtml.href (fromMaybe "" (prevURL baseUrl pc)) ] << "Previous"
81-
else XHtml.noHtml
76+
next = XHtml.anchor ! [XHtml.href (fromMaybe "" (nextURL baseUrl pc)) | hasNext pc] << "Next"
77+
prev = XHtml.anchor ! [XHtml.href (fromMaybe "" (prevURL baseUrl pc)) | hasPrev pc] << "Previous"
78+
8279

8380
pagedURLS = zip [1..] (allPagedURLs baseUrl pc)
8481
pagedLinks = (\(x,y) -> XHtml.anchor ! [XHtml.href y,
@@ -90,7 +87,6 @@ paginator pc@PaginatedConfiguration{currPage,totalAmount} baseUrl =
9087

9188
in XHtml.thediv ! [XHtml.identifier "paginatorContainer"] << mconcat [info, wrapper]
9289

93-
-- | Results in a empty attr, kinda hackish but surprisingly XHtml.HtmlAttr has no concept of a mempty
9490
noAttr :: XHtml.HtmlAttr
9591
noAttr = XHtml.theclass ""
9692

@@ -205,7 +201,7 @@ recentFeed conf users hostURI now pkgs = RSS
205201
(map (releaseItem users hostURI) pkgList)
206202
where
207203
(start,end) = pageIndexRange conf
208-
desc = "Showing" ++ show start ++ " - " ++ show end ++ " most recent additions to Hackage, the Haskell package database."
204+
desc = "Showing " ++ show start ++ " - " ++ show end ++ " most recent additions to Hackage, the Haskell package database."
209205
pkgList = paginate conf pkgs
210206
updated = maybe now (fst . pkgOriginalUploadInfo) (listToMaybe pkgList)
211207

@@ -218,12 +214,12 @@ recentRevisionsFeed conf users hostURI now pkgs = RSS
218214
(map (revisionItem users hostURI) pkgList)
219215
where
220216
(start, end) = pageIndexRange conf
221-
desc = "Showing" ++ show start ++ " - " ++ show end ++ " most recent revisions to cabal metadata in Hackage, the Haskell package database."
217+
desc = "Showing " ++ show start ++ " - " ++ show end ++ " most recent revisions to cabal metadata in Hackage, the Haskell package database."
222218
pkgList = paginate conf pkgs
223219
updated = maybe now (fst . pkgOriginalUploadInfo) (listToMaybe pkgList)
224220

225221
channel :: UTCTime -> [RSS.ChannelElem]
226-
channel updated =
222+
channel updated =
227223
[ RSS.Language "en"
228224
, RSS.ManagingEditor email
229225
, RSS.WebMaster email

0 commit comments

Comments
 (0)