Fix book grid layout with long titles
- static/styles.css: use CSS grid instead of inline-block for .book-list so rows align consistently regardless of card content height; add overflow-wrap/word-break to titles/authors - views/pages.templ: truncate long titles/authors server-side (truncateTitle helper) instead of relying on CSS line-clamp, which behaved inconsistently across browsers (esp. Firefox with flex); full title kept in title attribute and on the book detail page - views/pages_templ.go regenerated via templ generate Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
+13
-2
@@ -114,8 +114,8 @@ templ IndexPage(books []library.Book, canUpload bool) {
|
||||
@BookCover(b, false)
|
||||
</div>
|
||||
<div class="book-card-body">
|
||||
<strong class="book-title">{ b.Title }</strong>
|
||||
<span class="book-author">{ b.Author }</span>
|
||||
<strong class="book-title" title={ b.Title }>{ truncateTitle(b.Title, 60) }</strong>
|
||||
<span class="book-author">{ truncateTitle(b.Author, 40) }</span>
|
||||
<span class="format">{ b.Format }</span>
|
||||
</div>
|
||||
</a>
|
||||
@@ -164,3 +164,14 @@ func placeholderClass(detail bool) string {
|
||||
}
|
||||
return "book-cover-placeholder"
|
||||
}
|
||||
|
||||
// truncateTitle kürzt lange Titel für die Kartenansicht, damit lange,
|
||||
// nicht umbrechbare Titel das Grid-Layout nicht sprengen. Der volle Titel
|
||||
// bleibt im Detail-Seiten-Titel und im alt-Text des Covers erhalten.
|
||||
func truncateTitle(title string, maxLen int) string {
|
||||
r := []rune(title)
|
||||
if len(r) <= maxLen {
|
||||
return title
|
||||
}
|
||||
return string(r[:maxLen]) + "…"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user