From 68bf97efd6a46f68486c8540f53493862a720828 Mon Sep 17 00:00:00 2001 From: Hadi <112569860+anotherhadi@users.noreply.github.com> Date: Mon, 24 Aug 2026 18:57:08 +0200 Subject: [PATCH] add basic app components Signed-off-by: Hadi <112569860+anotherhadi@users.noreply.github.com> --- app/components.go | 39 +++++++++++++++++++++++++++++++++++++++ app/{app.go => msg.go} | 0 2 files changed, 39 insertions(+) create mode 100644 app/components.go rename app/{app.go => msg.go} (100%) diff --git a/app/components.go b/app/components.go new file mode 100644 index 0000000..e702cb1 --- /dev/null +++ b/app/components.go @@ -0,0 +1,39 @@ +package app + +import ( + "image/color" + + "charm.land/lipgloss/v2" + "github.com/anotherhadi/ilovetui/style" +) + +func RenderToggle(on bool) string { + if !style.S.NerdFonts { + if on { + return lipgloss.NewStyle(). + Foreground(style.S.Success). + Bold(true). + Render("on") + } + return lipgloss.NewStyle(). + Foreground(style.S.Subtle). + Bold(true). + Render("off") + } + + if on { + return RenderBadge(" ●", style.S.Success) + } + return RenderBadge("● ", style.S.Subtle) +} + +func RenderBadge(label string, fill color.Color) string { + body := lipgloss.NewStyle(). + Background(fill). + Foreground(style.S.Background). + Bold(true). + Render(label) + + cap := lipgloss.NewStyle().Foreground(fill).Background(style.S.Background) + return cap.Render("") + body + cap.Render("") +} diff --git a/app/app.go b/app/msg.go similarity index 100% rename from app/app.go rename to app/msg.go