add SignalBars

Signed-off-by: Hadi <[email protected]>
This commit is contained in:
Hadi
2026-08-24 21:54:12 +02:00
parent 68bf97efd6
commit df7bd3df0a
+16
View File
@@ -2,6 +2,7 @@ package app
import ( import (
"image/color" "image/color"
"strings"
"charm.land/lipgloss/v2" "charm.land/lipgloss/v2"
"github.com/anotherhadi/ilovetui/style" "github.com/anotherhadi/ilovetui/style"
@@ -37,3 +38,18 @@ func RenderBadge(label string, fill color.Color) string {
cap := lipgloss.NewStyle().Foreground(fill).Background(style.S.Background) cap := lipgloss.NewStyle().Foreground(fill).Background(style.S.Background)
return cap.Render("") + body + cap.Render("") return cap.Render("") + body + cap.Render("")
} }
func SignalBars(signal int) string {
bars := []rune("▁▃▅▇")
level := signal * len(bars) / 100
var b strings.Builder
for i, ch := range bars {
s := lipgloss.NewStyle().Foreground(style.S.Subtle)
if i < level {
s = lipgloss.NewStyle().Foreground(style.S.Text)
}
b.WriteString(s.Render(string(ch)))
}
return b.String()
}