style(tui): add fixed column widths to sites table
Use lipgloss StyleFunc to set per-column widths, with NAME as the flex column absorbing remaining space. History column tied to sparkWidth for consistency.
This commit is contained in:
@@ -298,6 +298,9 @@ func (m Model) viewSitesTab() string {
|
|||||||
tableWidth = 40
|
tableWidth = 40
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// column widths: #=6, name=flex, type=10, status=10, latency=8, uptime=8, history=sparkWidth+4, ssl=7, retry=9
|
||||||
|
colWidths := []int{6, 0, 10, 10, 8, 8, sparkWidth + 4, 7, 9}
|
||||||
|
|
||||||
t := table.New().
|
t := table.New().
|
||||||
Border(lipgloss.RoundedBorder()).
|
Border(lipgloss.RoundedBorder()).
|
||||||
BorderStyle(siteBorderStyle).
|
BorderStyle(siteBorderStyle).
|
||||||
@@ -305,16 +308,20 @@ func (m Model) viewSitesTab() string {
|
|||||||
Headers("#", "NAME", "TYPE", "STATUS", "LATENCY", "UPTIME", "HISTORY", "SSL", "RETRY").
|
Headers("#", "NAME", "TYPE", "STATUS", "LATENCY", "UPTIME", "HISTORY", "SSL", "RETRY").
|
||||||
Rows(rows...).
|
Rows(rows...).
|
||||||
StyleFunc(func(row, col int) lipgloss.Style {
|
StyleFunc(func(row, col int) lipgloss.Style {
|
||||||
|
var base lipgloss.Style
|
||||||
if row == table.HeaderRow {
|
if row == table.HeaderRow {
|
||||||
return siteHeaderStyle
|
base = siteHeaderStyle
|
||||||
|
} else if row == selectedVisual {
|
||||||
|
base = siteSelectedStyle
|
||||||
|
} else if isGroupRow(row) {
|
||||||
|
base = siteGroupStyle
|
||||||
|
} else {
|
||||||
|
base = siteCellStyle
|
||||||
}
|
}
|
||||||
if row == selectedVisual {
|
if col < len(colWidths) && colWidths[col] > 0 {
|
||||||
return siteSelectedStyle
|
base = base.Width(colWidths[col])
|
||||||
}
|
}
|
||||||
if isGroupRow(row) {
|
return base
|
||||||
return siteGroupStyle
|
|
||||||
}
|
|
||||||
return siteCellStyle
|
|
||||||
})
|
})
|
||||||
|
|
||||||
return "\n" + t.Render()
|
return "\n" + t.Render()
|
||||||
|
|||||||
Reference in New Issue
Block a user