Skip to content

Commit

Permalink
Refactor previous and next page anchors
Browse files Browse the repository at this point in the history
  • Loading branch information
pikinier20 committed Mar 15, 2022
1 parent 491c6e9 commit a0f612f
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 22 deletions.
6 changes: 4 additions & 2 deletions docs/_layouts/static-site-main.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@
{{ content }}
<nav class="arrows-wrapper" aria-label="Page navigation">
{% if page.previous %}
<a rel="prev" href="{{ page.previous }}" class="arrows previous" aria-keyshortcuts="Left">
<a rel="prev" href="{{ page.previous.url }}" class="arrows previous" aria-keyshortcuts="Left">
<span>{{ page.previous.title }}</span>
<i class="fa fa-angle-left"></i>
</a>
{% endif %}
{% if page.next %}
<a rel="next" href="{{ page.next }}" class="arrows next" aria-keyshortcuts="Right">
<a rel="next" href="{{ page.next.url }}" class="arrows next" aria-keyshortcuts="Right">
<span>{{ page.previous.title }}</span>
<i class="fa fa-angle-right"></i>
</a>
{% endif %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,14 @@
{{ content }}
<nav class="arrows-wrapper" aria-label="Page navigation">
{% if page.previous %}
<a rel="prev" href="{{ page.previous }}" class="arrows previous" aria-keyshortcuts="Left">
<a rel="prev" href="{{ page.previous.url }}" class="arrows previous" aria-keyshortcuts="Left">
<span>{{ page.previous.title }}</span>
<i class="fa fa-angle-left"></i>
</a>
{% endif %}
{% if page.next %}
<a rel="next" href="{{ page.next }}" class="arrows next" aria-keyshortcuts="Right">
<a rel="next" href="{{ page.next.url }}" class="arrows next" aria-keyshortcuts="Right">
<span>{{ page.next.title }}</span>
<i class="fa fa-angle-right"></i>
</a>
{% endif %}
Expand Down
40 changes: 23 additions & 17 deletions scaladoc/resources/dotty_res/styles/scalastyle.css
Original file line number Diff line number Diff line change
Expand Up @@ -1118,23 +1118,32 @@ footer .socials {

/* Nav Icons */

.arrows-wrapper {
display: flex;
justify-content: space-between;
padding-top: 10px;
}

.arrows {
font-size: 3em;
color: var(--link-fg);
font-size: 1em;
text-align: center;

position: fixed;
top: 0;
bottom: 0;
margin: 0;
max-width: 150px;
min-width: 90px;

display: flex;
justify-content: center;
flex-direction: column;
align-items: center;

transition: color 0.5s, background-color 0.5s;
z-index: 3;
}

.arrows span {
max-width: 10vw;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}

.arrows i {
margin: 8px;
}

.arrows.previous, .arrows.next {
Expand All @@ -1143,19 +1152,16 @@ footer .socials {

.arrows:hover {
text-decoration: none;
color: var(--grey300);
background-color: var(--grey900);
color: var(--link-hover-fg);
transition: background-color 0.15s, color 0.15s;
}

.previous {
left: var(--side-width);
float: left;
flex-direction: row-reverse;
}

.next {
right: 0;
float: right;
flex-direction: row;
}

@media screen and (max-width: 1000px) {
Expand Down
21 changes: 20 additions & 1 deletion scaladoc/src/dotty/tools/scaladoc/renderers/Renderer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,26 @@ abstract class Renderer(rootPackage: Member, val members: Map[DRI, Member], prot
val realSiblingPath = realPath(n.file.toPath)
realMidPath.relativize(realSiblingPath).toString.stripPrefix("../")
}
List(link(prev).map("previous" -> _), link(next).map("next" -> _)).flatten.toMap
List(
for {
link <- link(prev)
p <- prev
} yield (
"previous" -> Map(
"title" -> p.templateFile.title.name,
"url" -> link
)
),
for {
link <- link(next)
n <- next
} yield (
"next" -> Map(
"title" -> n.templateFile.title.name,
"url" -> link
)
),
).flatten.toMap
}.toList

def updateSettings(templates: Seq[LoadedTemplate], additionalSettings: ListBuffer[Map[String, Object]]): List[LoadedTemplate] =
Expand Down

0 comments on commit a0f612f

Please sign in to comment.