From 804d765988b75442e3f8dc8ca615335b154fdfc3 Mon Sep 17 00:00:00 2001 From: John O'Keefe Date: Fri, 27 Mar 2026 15:52:02 -0400 Subject: [PATCH] refactor(templates): simplify BooksGrid component Remove wrapper div and pagination from BooksGrid component. The component now only renders book cards, making it more reusable. Changes: - Remove books-grid wrapper div from BooksGrid - Remove pagination controls from BooksGrid - Component now only renders book card grid This allows the parent template to control the wrapper div placement and pagination location, which is needed for proper HTMX targeting on the bookshelf page. Related: Issue with pagination displaying inside grid instead of below --- templates/books_grid.templ | 31 -------------------- templates/books_grid_templ.go | 53 +---------------------------------- 2 files changed, 1 insertion(+), 83 deletions(-) diff --git a/templates/books_grid.templ b/templates/books_grid.templ index 94cc371..b6ca5ca 100644 --- a/templates/books_grid.templ +++ b/templates/books_grid.templ @@ -3,7 +3,6 @@ package templates import "bookhoard/internal/handlers" templ BooksGrid(books []handlers.BookInfo, limit int, offset int, count int, currentLibraryID string) { -
if len(books) > 0 { for _, book := range books { @BookCard(book) @@ -15,34 +14,4 @@ templ BooksGrid(books []handlers.BookInfo, limit int, offset int, count int, cur

Try adjusting your filters or add some books to your library.

} - - - } diff --git a/templates/books_grid_templ.go b/templates/books_grid_templ.go index cd61086..99606d6 100644 --- a/templates/books_grid_templ.go +++ b/templates/books_grid_templ.go @@ -31,10 +31,6 @@ func BooksGrid(books []handlers.BookInfo, limit int, offset int, count int, curr templ_7745c5c3_Var1 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "
") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } if len(books) > 0 { for _, book := range books { templ_7745c5c3_Err = BookCard(book).Render(ctx, templ_7745c5c3_Buffer) @@ -43,58 +39,11 @@ func BooksGrid(books []handlers.BookInfo, limit int, offset int, count int, curr } } } else { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "

📚 No books found

Try adjusting your filters or add some books to your library.

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "

📚 No books found

Try adjusting your filters or add some books to your library.

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "
") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - if count > 0 { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, " Page ") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - var templ_7745c5c3_Var2 string - templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(offset/limit + 1) - if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/books_grid.templ`, Line: 34, Col: 29} - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2)) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, " ") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 10, "
") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } return nil }) }