From 175a42f58ce03ef67b87b39309e2562251bef958 Mon Sep 17 00:00:00 2001 From: James Tombleson Date: Sat, 13 Jul 2024 10:38:40 -0700 Subject: [PATCH] Adding a table view for articles --- internal/views/articles/table.templ | 32 +++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 internal/views/articles/table.templ diff --git a/internal/views/articles/table.templ b/internal/views/articles/table.templ new file mode 100644 index 0000000..08aeabf --- /dev/null +++ b/internal/views/articles/table.templ @@ -0,0 +1,32 @@ +package articles + +import ( + "git.jamestombleson.com/jtom38/newsbot-portal/components/bulma" + "git.jamestombleson.com/jtom38/newsbot-portal/internal/models" + "git.jamestombleson.com/jtom38/newsbot-portal/internal/views/layout" +) + +templ ListArticlesTable(model models.ListArticlesViewModel) { + @layout.WithTemplate() { + @bulma.Table() { + @bulma.TableHeader() { + @bulma.TableRow() { + @bulma.TableHeaderData("Title") + @bulma.TableHeaderData("Source") + @bulma.TableHeaderData("View") + } + } + for _, item := range model.Items { + @bulma.TableRow() { + @bulma.TableData(item.Article.Title) + @bulma.TableData(item.Source.DisplayName) + @bulma.TableDataChildren() { + @bulma.Button() { + @bulma.ANewTab(item.Article.Url, "View") + } + } + } + } + } + } +}