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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user