feat(tui): bordered modals, welcome state, and dynamic name width

- Delete confirmation wrapped in rounded border box with danger color
- Empty sites view shows styled welcome box with onboarding hint
- NAME column width scales with terminal width (13-40 chars)
This commit is contained in:
2026-05-16 12:56:09 -04:00
parent 3bc8e31b89
commit f2ea0dc758
2 changed files with 30 additions and 5 deletions
+24 -4
View File
@@ -195,11 +195,31 @@ func fmtStatus(status string, paused bool) string {
}
}
func (m Model) nameWidth() int {
w := m.termWidth - 105
if w < 13 {
w = 13
}
if w > 40 {
w = 40
}
return w
}
func (m Model) viewSitesTab() string {
const sparkWidth = 20
if len(m.sites) == 0 {
return "\n No sites configured. Press [n] to add one."
welcome := lipgloss.NewStyle().
Border(lipgloss.RoundedBorder()).
BorderForeground(lipgloss.Color("#7D56F4")).
Padding(1, 3).
Render(
titleStyle.Render("Go-Upkeep") + "\n\n" +
"No monitors configured yet.\n\n" +
subtleStyle.Render("[n] Add your first monitor"),
)
return "\n" + welcome
}
colWidths := []int{6, 0, 10, 10, 8, 8, sparkWidth + 4, 7, 9}
@@ -222,7 +242,7 @@ func (m Model) viewSitesTab() string {
}
rows = append(rows, []string{
strconv.Itoa(i + 1),
m.zones.Mark(fmt.Sprintf("site-%d", i), arrow+" "+limitStr(site.Name, 11)),
m.zones.Mark(fmt.Sprintf("site-%d", i), arrow+" "+limitStr(site.Name, m.nameWidth()-2)),
"group",
fmtStatus(site.Status, site.Paused),
subtleStyle.Render("—"),
@@ -240,9 +260,9 @@ func (m Model) viewSitesTab() string {
if i+1 >= len(m.sites) || m.sites[i+1].ParentID != site.ParentID {
prefix = "└"
}
name = prefix + " " + limitStr(name, 11)
name = prefix + " " + limitStr(name, m.nameWidth()-2)
} else {
name = limitStr(name, 13)
name = limitStr(name, m.nameWidth())
}
hist, _ := m.engine.GetHistory(site.ID)
+6 -1
View File
@@ -551,7 +551,12 @@ func (m Model) View() string {
}
msg := dangerStyle.Render(fmt.Sprintf("Delete %s \"%s\"?", kind, m.deleteName))
hint := subtleStyle.Render("[y] Confirm [n] Cancel")
return lipgloss.NewStyle().Padding(2, 4).Render(msg + "\n\n" + hint)
box := lipgloss.NewStyle().
Border(lipgloss.RoundedBorder()).
BorderForeground(lipgloss.Color("#F25D94")).
Padding(1, 3).
Render(msg + "\n\n" + hint)
return lipgloss.NewStyle().Padding(2, 4).Render(box)
case stateFormSite, stateFormAlert, stateFormUser:
if m.huhForm != nil {
title := ""