style: fixed top navigation bar

This commit is contained in:
Evan Buss
2024-07-06 14:52:20 -04:00
parent a39936fbaa
commit 8e42b71dc7
3 changed files with 92 additions and 37 deletions

View File

@@ -1,29 +1,52 @@
{{define "title"}}{{.Title}}{{end}} {{define "title"}}{{.Title}}{{end}} {{define "content"}}
{{define "content"}}
<ul>
{{if .Search }}
<li><a href="{{.Search}}">Search</a></li>
{{end}}
<nav class="navigation">
{{if .Search }}
<div class="search">
<a href="{{.Search}}" tabindex="-1">
<svg
width="30"
height="30"
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
class="size-6"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="m21 21-5.197-5.197m0 0A7.5 7.5 0 1 0 5.196 5.196a7.5 7.5 0 0 0 10.607 10.607Z"
/>
</svg>
</a>
</div>
{{end}}
<div class="nav-controls">
{{range .Navigation}} {{range .Navigation}}
<li><a href="{{.Href}}">{{.Label}}</a></li> <a tabindex="-1" href="{{.Href}}">{{.Label}}</a>
{{end}}
</div>
</nav>
<ul>
{{range .Links}}
<li class="link">
{{if .ImageURL}}
<img src="/acquisition{{.ImageURL}}" alt="{{.Title}}" height="40" />
{{end}} {{end}}
{{range .Links}} <div class="info">
<li class="link"> {{if .IsDownload}}
{{if .ImageURL}} <a href="/acquisition{{.Href}}" download>{{.Title}}</a>
<img src="/acquisition{{.ImageURL}}" alt="{{.Title}}" height="40"> {{else}}
{{end}} <a href="{{.Href}}">{{.Title}}</a>
{{end}}
<div class="info"> <p>{{.Author}}</p>
{{if .IsDownload}} </div>
<a href="/acquisition{{.Href}}" download>{{.Title}}</a> </li>
{{else}} {{end}}
<a href="{{.Href}}">{{.Title}}</a>
{{end}}
<p>{{.Author}}</p>
</div>
</li>
{{end}}
</ul> </ul>
{{end}} {{end}}

View File

@@ -82,11 +82,13 @@ func constructLink(entry opds.Entry) LinkViewModel {
for _, author := range entry.Author { for _, author := range entry.Author {
authors = append(authors, author.Name) authors = append(authors, author.Name)
} }
vm.Author = strings.Join(authors, ", ") vm.Author = strings.Join(authors, " & ")
for _, link := range entry.Links { for _, link := range entry.Links {
vm.IsDownload = link.IsDownload()
if link.IsNavigation() || link.IsDownload() { if link.IsNavigation() || link.IsDownload() {
vm.Href = link.Href vm.Href = link.Href
} }
// Prefer the first "thumbnail" image we find // Prefer the first "thumbnail" image we find

View File

@@ -8,20 +8,13 @@
font-size: 1.25rem; font-size: 1.25rem;
} }
body {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
}
#container { #container {
padding: 2rem; padding: 1rem;
border: 1px solid rgba(0, 0, 0, 0.5);
width: 100%; width: 100%;
} }
#container > ul { #container > ul {
margin-top: 75px;
list-style-type: none; list-style-type: none;
} }
@@ -45,17 +38,54 @@ body {
font-size: 1rem; font-size: 1rem;
} }
#container > ul > li a { a {
display: inline-block; display: inline-block;
text-decoration: none; text-decoration: none;
color: black; color: black;
vertical-align: top;
} }
#container > ul > li a:active { #container > ul > li a {
background-color: black; vertical-align: top;
} }
#container > ul > li:not(:last-child) { #container > ul > li:not(:last-child) {
border-bottom: 1px solid rgba(0, 0, 0, 0.5); border-bottom: 1px solid rgba(0, 0, 0, 0.5);
} }
.navigation {
background-color: white;
position: fixed;
top: 0;
left: 0;
right: 0;
display: block;
border-bottom: 1px solid rgba(0, 0, 0, 0.5);
}
.search {
width: 100px;
display: inline-block;
}
.search:focus {
outline: none;
box-shadow: none;
}
.search > a {
padding-top: 1rem;
padding-left: 1rem;
display: block;
margin: auto;
}
.nav-controls {
float: right;
}
.nav-controls > a {
padding: 1rem;
}