From e1b65a49db360199d6b18b96cc37ff78d3ff1240 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Eduardo=20Jer=C3=A9z=20Gir=C3=B3n?= Date: Sun, 1 Sep 2024 22:49:25 -0600 Subject: [PATCH] Add EmptyResults component to handle display for empty states in the UI with customizable title and subtitle parameters --- internal/view/web/component/empty_results.go | 44 ++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 internal/view/web/component/empty_results.go diff --git a/internal/view/web/component/empty_results.go b/internal/view/web/component/empty_results.go new file mode 100644 index 0000000..4e1419d --- /dev/null +++ b/internal/view/web/component/empty_results.go @@ -0,0 +1,44 @@ +package component + +import ( + lucide "github.com/eduardolat/gomponents-lucide" + "github.com/maragudk/gomponents" + "github.com/maragudk/gomponents/components" + "github.com/maragudk/gomponents/html" +) + +type EmptyResultsParams struct { + IsLarge bool + Title string + Subtitle string +} + +func EmptyResults(params EmptyResultsParams) gomponents.Node { + return html.Div( + html.Class("flex flex-col justify-center items-center space-x-1"), + lucide.FileSearch(components.Classes{ + "size-6": !params.IsLarge, + "size-12": params.IsLarge, + }), + gomponents.If( + params.Title != "", + html.Span( + components.Classes{ + "text-lg": !params.IsLarge, + "text-2xl": params.IsLarge, + }, + gomponents.Text(params.Title), + ), + ), + gomponents.If( + params.Subtitle != "", + html.Span( + components.Classes{ + "text-sm": !params.IsLarge, + "text-lg": params.IsLarge, + }, + gomponents.Text(params.Subtitle), + ), + ), + ) +}