mirror of
https://github.com/runkids/skillshare.git
synced 2026-11-19 02:17:09 +00:00
refactor(tui): unify color palette via shared tc struct and configureDelegate
Consolidate 30+ scattered lipgloss.NewStyle() calls across 6 TUI files into a single tc (TUI colors) struct in tui_colors.go. Add configureDelegate() helper to replace repetitive ~8-line delegate setup blocks with one call. - ac/lc structs now reference tc base colors (Title, Dim, Green, Yellow, Red) - list_tui detail panel: tracked repo and source URL now use tc.Cyan - skillItem.Title(): inline color for name (bright white) and badge (green/gray) - search_tui: enable description row (source + tags visible in list) - Remove unused lipgloss imports from 4 files
This commit is contained in:
+62
-130
@@ -7,7 +7,6 @@ import (
|
||||
"time"
|
||||
|
||||
"skillshare/internal/audit"
|
||||
"skillshare/internal/ui"
|
||||
|
||||
"github.com/charmbracelet/bubbles/list"
|
||||
"github.com/charmbracelet/bubbles/textinput"
|
||||
@@ -15,80 +14,21 @@ import (
|
||||
"github.com/charmbracelet/lipgloss"
|
||||
)
|
||||
|
||||
// auditTUIColors centralizes all color styles for the audit TUI.
|
||||
// Single source of truth — change colors here, not scattered across methods.
|
||||
// ac holds audit-specific styles that don't belong in the shared tc palette.
|
||||
var ac = struct {
|
||||
// Semantic
|
||||
Title lipgloss.Style // section headings (skill name, "Findings")
|
||||
Dim lipgloss.Style // secondary info, separators
|
||||
Green lipgloss.Style // passed, clean
|
||||
Yellow lipgloss.Style // warning, has findings
|
||||
Red lipgloss.Style // blocked, failed
|
||||
White lipgloss.Style // primary values
|
||||
File lipgloss.Style // file:line locations
|
||||
Snippet lipgloss.Style // code snippets
|
||||
|
||||
// Severity (from ui.SeverityID* constants)
|
||||
Critical lipgloss.Style
|
||||
High lipgloss.Style
|
||||
Medium lipgloss.Style
|
||||
Low lipgloss.Style
|
||||
Info lipgloss.Style
|
||||
|
||||
// Detail panel
|
||||
Label lipgloss.Style // row labels ("Risk:", "Status:", etc.)
|
||||
|
||||
// List item symbols
|
||||
SymbolGreen lipgloss.Style
|
||||
SymbolYellow lipgloss.Style
|
||||
SymbolRed lipgloss.Style
|
||||
ItemName lipgloss.Style
|
||||
File lipgloss.Style // file:line locations — cyan
|
||||
Snippet lipgloss.Style // code snippet highlight
|
||||
ItemName lipgloss.Style // list item name — light gray
|
||||
}{
|
||||
Title: lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("6")),
|
||||
Dim: lipgloss.NewStyle().Foreground(lipgloss.Color("8")),
|
||||
Green: lipgloss.NewStyle().Foreground(lipgloss.Color("2")),
|
||||
Yellow: lipgloss.NewStyle().Foreground(lipgloss.Color("3")),
|
||||
Red: lipgloss.NewStyle().Foreground(lipgloss.Color("1")),
|
||||
White: lipgloss.NewStyle().Foreground(lipgloss.Color("15")),
|
||||
File: lipgloss.NewStyle().Foreground(lipgloss.Color("6")),
|
||||
Snippet: lipgloss.NewStyle().Foreground(lipgloss.Color("179")),
|
||||
|
||||
Critical: lipgloss.NewStyle().Foreground(lipgloss.Color(ui.SeverityIDCritical)).Bold(true),
|
||||
High: lipgloss.NewStyle().Foreground(lipgloss.Color(ui.SeverityIDHigh)),
|
||||
Medium: lipgloss.NewStyle().Foreground(lipgloss.Color(ui.SeverityIDMedium)),
|
||||
Low: lipgloss.NewStyle().Foreground(lipgloss.Color(ui.SeverityIDLow)),
|
||||
Info: lipgloss.NewStyle().Foreground(lipgloss.Color(ui.SeverityIDInfo)),
|
||||
|
||||
Label: lipgloss.NewStyle().Foreground(lipgloss.Color("8")).Width(14),
|
||||
|
||||
SymbolGreen: lipgloss.NewStyle().Foreground(lipgloss.Color("2")),
|
||||
SymbolYellow: lipgloss.NewStyle().Foreground(lipgloss.Color("3")),
|
||||
SymbolRed: lipgloss.NewStyle().Foreground(lipgloss.Color("1")),
|
||||
ItemName: lipgloss.NewStyle().Foreground(lipgloss.Color("252")),
|
||||
}
|
||||
|
||||
// acSevStyle returns the severity lipgloss style from the centralized config.
|
||||
func acSevStyle(severity string) lipgloss.Style {
|
||||
switch strings.ToUpper(severity) {
|
||||
case "CRITICAL":
|
||||
return ac.Critical
|
||||
case "HIGH":
|
||||
return ac.High
|
||||
case "MEDIUM":
|
||||
return ac.Medium
|
||||
case "LOW":
|
||||
return ac.Low
|
||||
case "INFO":
|
||||
return ac.Info
|
||||
default:
|
||||
return ac.Dim
|
||||
}
|
||||
File: lipgloss.NewStyle().Foreground(lipgloss.Color("6")),
|
||||
Snippet: lipgloss.NewStyle().Foreground(lipgloss.Color("179")),
|
||||
ItemName: lipgloss.NewStyle().Foreground(lipgloss.Color("252")),
|
||||
}
|
||||
|
||||
// acSevCount returns severity color for non-zero counts, dim for zero.
|
||||
func acSevCount(count int, style lipgloss.Style) lipgloss.Style {
|
||||
if count == 0 {
|
||||
return ac.Dim
|
||||
return tc.Dim
|
||||
}
|
||||
return style
|
||||
}
|
||||
@@ -102,12 +42,12 @@ type auditItem struct {
|
||||
func (i auditItem) Title() string {
|
||||
name := i.result.SkillName
|
||||
if len(i.result.Findings) == 0 {
|
||||
return ac.SymbolGreen.Render("✓") + " " + ac.ItemName.Render(name)
|
||||
return tc.Green.Render("✓") + " " + ac.ItemName.Render(name)
|
||||
}
|
||||
if i.result.IsBlocked {
|
||||
return ac.SymbolRed.Render("✗") + " " + ac.ItemName.Render(name)
|
||||
return tc.Red.Render("✗") + " " + ac.ItemName.Render(name)
|
||||
}
|
||||
return ac.SymbolYellow.Render("!") + " " + ac.ItemName.Render(name)
|
||||
return tc.Yellow.Render("!") + " " + ac.ItemName.Render(name)
|
||||
}
|
||||
|
||||
func (i auditItem) Description() string { return "" }
|
||||
@@ -177,18 +117,11 @@ func newAuditTUIModel(results []*audit.Result, scanOutputs []audit.ScanOutput, s
|
||||
}
|
||||
|
||||
delegate := list.NewDefaultDelegate()
|
||||
delegate.ShowDescription = false
|
||||
delegate.SetHeight(1)
|
||||
delegate.SetSpacing(0)
|
||||
delegate.Styles.NormalTitle = lipgloss.NewStyle().PaddingLeft(2)
|
||||
delegate.Styles.SelectedTitle = lipgloss.NewStyle().Bold(true).
|
||||
Foreground(tuiBrandYellow).
|
||||
Border(lipgloss.NormalBorder(), false, false, false, true).
|
||||
BorderForeground(tuiBrandYellow).PaddingLeft(1)
|
||||
configureDelegate(&delegate, false)
|
||||
|
||||
l := list.New(listItems, delegate, 0, 0)
|
||||
l.Title = fmt.Sprintf("Audit results (%d scanned)", summary.Scanned)
|
||||
l.Styles.Title = lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("6"))
|
||||
l.Styles.Title = tc.ListTitle
|
||||
l.SetShowStatusBar(false)
|
||||
l.SetFilteringEnabled(false)
|
||||
l.SetShowHelp(false)
|
||||
@@ -196,8 +129,8 @@ func newAuditTUIModel(results []*audit.Result, scanOutputs []audit.ScanOutput, s
|
||||
|
||||
fi := textinput.New()
|
||||
fi.Prompt = "/ "
|
||||
fi.PromptStyle = tuiFilterStyle
|
||||
fi.Cursor.Style = tuiFilterStyle
|
||||
fi.PromptStyle = tc.Filter
|
||||
fi.Cursor.Style = tc.Filter
|
||||
|
||||
return auditTUIModel{
|
||||
list: l,
|
||||
@@ -357,8 +290,7 @@ func (m auditTUIModel) View() string {
|
||||
Render(m.list.View())
|
||||
|
||||
// Border column
|
||||
borderStyle := lipgloss.NewStyle().
|
||||
Foreground(lipgloss.Color("8")).
|
||||
borderStyle := tc.Border.
|
||||
Height(panelHeight).MaxHeight(panelHeight)
|
||||
borderCol := strings.Repeat("│\n", panelHeight)
|
||||
borderPanel := borderStyle.Render(strings.TrimRight(borderCol, "\n"))
|
||||
@@ -383,7 +315,7 @@ func (m auditTUIModel) View() string {
|
||||
b.WriteString(m.renderSummaryFooter())
|
||||
|
||||
// Help line
|
||||
b.WriteString(tuiHelpStyle.Render("↑↓ navigate ←→ page / filter Ctrl+d/u scroll detail q quit"))
|
||||
b.WriteString(tc.Help.Render("↑↓ navigate ←→ page / filter Ctrl+d/u scroll detail q quit"))
|
||||
b.WriteString("\n")
|
||||
|
||||
return b.String()
|
||||
@@ -406,7 +338,7 @@ func (m auditTUIModel) viewVertical() string {
|
||||
|
||||
b.WriteString(m.renderSummaryFooter())
|
||||
|
||||
b.WriteString(tuiHelpStyle.Render("↑↓ navigate ←→ page / filter Ctrl+d/u scroll q quit"))
|
||||
b.WriteString(tc.Help.Render("↑↓ navigate ←→ page / filter Ctrl+d/u scroll q quit"))
|
||||
b.WriteString("\n")
|
||||
|
||||
return b.String()
|
||||
@@ -429,31 +361,31 @@ func (m auditTUIModel) renderSummaryFooter() string {
|
||||
s := m.summary
|
||||
|
||||
parts := []string{
|
||||
ac.Dim.Render(fmt.Sprintf("Scanned: %s", formatNumber(s.Scanned))),
|
||||
ac.Green.Render(fmt.Sprintf("Passed: %s", formatNumber(s.Passed))),
|
||||
tc.Dim.Render(fmt.Sprintf("Scanned: %s", formatNumber(s.Scanned))),
|
||||
tc.Green.Render(fmt.Sprintf("Passed: %s", formatNumber(s.Passed))),
|
||||
}
|
||||
if s.Warning > 0 {
|
||||
parts = append(parts, ac.Yellow.Render(fmt.Sprintf("Warning: %s", formatNumber(s.Warning))))
|
||||
parts = append(parts, tc.Yellow.Render(fmt.Sprintf("Warning: %s", formatNumber(s.Warning))))
|
||||
} else {
|
||||
parts = append(parts, ac.Dim.Render(fmt.Sprintf("Warning: %s", formatNumber(s.Warning))))
|
||||
parts = append(parts, tc.Dim.Render(fmt.Sprintf("Warning: %s", formatNumber(s.Warning))))
|
||||
}
|
||||
if s.Failed > 0 {
|
||||
parts = append(parts, ac.Red.Render(fmt.Sprintf("Failed: %s", formatNumber(s.Failed))))
|
||||
parts = append(parts, tc.Red.Render(fmt.Sprintf("Failed: %s", formatNumber(s.Failed))))
|
||||
} else {
|
||||
parts = append(parts, ac.Dim.Render(fmt.Sprintf("Failed: %s", formatNumber(s.Failed))))
|
||||
parts = append(parts, tc.Dim.Render(fmt.Sprintf("Failed: %s", formatNumber(s.Failed))))
|
||||
}
|
||||
|
||||
sevParts := []string{
|
||||
acSevCount(s.Critical, ac.Critical).Render(fmt.Sprintf("%d", s.Critical)),
|
||||
acSevCount(s.High, ac.High).Render(fmt.Sprintf("%d", s.High)),
|
||||
acSevCount(s.Medium, ac.Medium).Render(fmt.Sprintf("%d", s.Medium)),
|
||||
acSevCount(s.Low, ac.Low).Render(fmt.Sprintf("%d", s.Low)),
|
||||
acSevCount(s.Info, ac.Info).Render(fmt.Sprintf("%d", s.Info)),
|
||||
acSevCount(s.Critical, tc.Critical).Render(fmt.Sprintf("%d", s.Critical)),
|
||||
acSevCount(s.High, tc.High).Render(fmt.Sprintf("%d", s.High)),
|
||||
acSevCount(s.Medium, tc.Medium).Render(fmt.Sprintf("%d", s.Medium)),
|
||||
acSevCount(s.Low, tc.Low).Render(fmt.Sprintf("%d", s.Low)),
|
||||
acSevCount(s.Info, tc.Info).Render(fmt.Sprintf("%d", s.Info)),
|
||||
}
|
||||
sep := ac.Dim.Render("/")
|
||||
parts = append(parts, ac.Dim.Render("c/h/m/l/i = ")+strings.Join(sevParts, sep))
|
||||
sep := tc.Dim.Render("/")
|
||||
parts = append(parts, tc.Dim.Render("c/h/m/l/i = ")+strings.Join(sevParts, sep))
|
||||
|
||||
return " " + strings.Join(parts, ac.Dim.Render(" | ")) + "\n"
|
||||
return " " + strings.Join(parts, tc.Dim.Render(" | ")) + "\n"
|
||||
}
|
||||
|
||||
// renderDetailContent renders the full detail panel for the selected audit item.
|
||||
@@ -464,24 +396,24 @@ func (m auditTUIModel) renderDetailContent(item auditItem) string {
|
||||
r := item.result
|
||||
|
||||
row := func(label, value string) {
|
||||
b.WriteString(ac.Label.Render(label))
|
||||
b.WriteString(tc.Label.Render(label))
|
||||
b.WriteString(value)
|
||||
b.WriteString("\n")
|
||||
}
|
||||
|
||||
// ── Header ──
|
||||
b.WriteString(ac.Title.Render(r.SkillName))
|
||||
b.WriteString(tc.Title.Render(r.SkillName))
|
||||
b.WriteString("\n")
|
||||
b.WriteString(ac.Dim.Render(strings.Repeat("─", 40)))
|
||||
b.WriteString(tc.Dim.Render(strings.Repeat("─", 40)))
|
||||
b.WriteString("\n\n")
|
||||
|
||||
// ── Summary section ──
|
||||
|
||||
// Risk — colorized by severity
|
||||
riskText := fmt.Sprintf("%s (%d/100)", strings.ToUpper(r.RiskLabel), r.RiskScore)
|
||||
riskStyle := acSevStyle(r.RiskLabel)
|
||||
riskStyle := tcSevStyle(r.RiskLabel)
|
||||
if r.RiskLabel == "clean" {
|
||||
riskStyle = ac.Green
|
||||
riskStyle = tc.Green
|
||||
}
|
||||
row("Risk:", riskStyle.Render(riskText))
|
||||
|
||||
@@ -490,29 +422,29 @@ func (m auditTUIModel) renderDetailContent(item auditItem) string {
|
||||
if maxSev == "" {
|
||||
maxSev = "NONE"
|
||||
}
|
||||
maxSevStyle := acSevStyle(maxSev)
|
||||
maxSevStyle := tcSevStyle(maxSev)
|
||||
if strings.ToUpper(maxSev) == "NONE" {
|
||||
maxSevStyle = ac.Green
|
||||
maxSevStyle = tc.Green
|
||||
}
|
||||
row("Max sev:", maxSevStyle.Render(maxSev))
|
||||
|
||||
// Block status
|
||||
if r.IsBlocked {
|
||||
row("Status:", ac.Red.Render("✗ BLOCKED"))
|
||||
row("Status:", tc.Red.Render("✗ BLOCKED"))
|
||||
} else if len(r.Findings) == 0 {
|
||||
row("Status:", ac.Green.Render("✓ Clean"))
|
||||
row("Status:", tc.Green.Render("✓ Clean"))
|
||||
} else {
|
||||
row("Status:", ac.Yellow.Render("! Has findings (not blocked)"))
|
||||
row("Status:", tc.Yellow.Render("! Has findings (not blocked)"))
|
||||
}
|
||||
|
||||
// Threshold
|
||||
if r.Threshold != "" {
|
||||
row("Threshold:", ac.Dim.Render("severity >= ")+ac.White.Render(strings.ToUpper(r.Threshold)))
|
||||
row("Threshold:", tc.Dim.Render("severity >= ")+tc.Emphasis.Render(strings.ToUpper(r.Threshold)))
|
||||
}
|
||||
|
||||
// Scan time
|
||||
if item.elapsed > 0 {
|
||||
row("Scan time:", ac.Dim.Render(fmt.Sprintf("%.1fs", item.elapsed.Seconds())))
|
||||
row("Scan time:", tc.Dim.Render(fmt.Sprintf("%.1fs", item.elapsed.Seconds())))
|
||||
}
|
||||
|
||||
// Severity breakdown — only non-zero counts are colorized; zeros are dim
|
||||
@@ -521,23 +453,23 @@ func (m auditTUIModel) renderDetailContent(item auditItem) string {
|
||||
for _, f := range r.Findings {
|
||||
counts[f.Severity]++
|
||||
}
|
||||
sep := ac.Dim.Render("/")
|
||||
sevLine := acSevCount(counts["CRITICAL"], ac.Critical).Render(fmt.Sprintf("%d", counts["CRITICAL"])) + sep +
|
||||
acSevCount(counts["HIGH"], ac.High).Render(fmt.Sprintf("%d", counts["HIGH"])) + sep +
|
||||
acSevCount(counts["MEDIUM"], ac.Medium).Render(fmt.Sprintf("%d", counts["MEDIUM"])) + sep +
|
||||
acSevCount(counts["LOW"], ac.Low).Render(fmt.Sprintf("%d", counts["LOW"])) + sep +
|
||||
acSevCount(counts["INFO"], ac.Info).Render(fmt.Sprintf("%d", counts["INFO"]))
|
||||
row("Severity:", ac.Dim.Render("c/h/m/l/i = ")+sevLine)
|
||||
row("Total:", ac.White.Render(fmt.Sprintf("%d", len(r.Findings)))+ac.Dim.Render(" finding(s)"))
|
||||
sep := tc.Dim.Render("/")
|
||||
sevLine := acSevCount(counts["CRITICAL"], tc.Critical).Render(fmt.Sprintf("%d", counts["CRITICAL"])) + sep +
|
||||
acSevCount(counts["HIGH"], tc.High).Render(fmt.Sprintf("%d", counts["HIGH"])) + sep +
|
||||
acSevCount(counts["MEDIUM"], tc.Medium).Render(fmt.Sprintf("%d", counts["MEDIUM"])) + sep +
|
||||
acSevCount(counts["LOW"], tc.Low).Render(fmt.Sprintf("%d", counts["LOW"])) + sep +
|
||||
acSevCount(counts["INFO"], tc.Info).Render(fmt.Sprintf("%d", counts["INFO"]))
|
||||
row("Severity:", tc.Dim.Render("c/h/m/l/i = ")+sevLine)
|
||||
row("Total:", tc.Emphasis.Render(fmt.Sprintf("%d", len(r.Findings)))+tc.Dim.Render(" finding(s)"))
|
||||
}
|
||||
|
||||
b.WriteString("\n")
|
||||
|
||||
// ── Findings detail ──
|
||||
if len(r.Findings) > 0 {
|
||||
b.WriteString(ac.Title.Render("Findings"))
|
||||
b.WriteString(tc.Title.Render("Findings"))
|
||||
b.WriteString("\n")
|
||||
b.WriteString(ac.Dim.Render(strings.Repeat("─", 40)))
|
||||
b.WriteString(tc.Dim.Render(strings.Repeat("─", 40)))
|
||||
b.WriteString("\n\n")
|
||||
|
||||
sorted := make([]audit.Finding, len(r.Findings))
|
||||
@@ -548,25 +480,25 @@ func (m auditTUIModel) renderDetailContent(item auditItem) string {
|
||||
|
||||
for idx, f := range sorted {
|
||||
// [N] SEVERITY pattern
|
||||
sevBadge := acSevStyle(f.Severity).Render(strings.ToUpper(f.Severity))
|
||||
header := ac.Dim.Render(fmt.Sprintf("[%d] ", idx+1))
|
||||
patternText := ac.White.Bold(true).Render(f.Pattern)
|
||||
sevBadge := tcSevStyle(f.Severity).Render(strings.ToUpper(f.Severity))
|
||||
header := tc.Dim.Render(fmt.Sprintf("[%d] ", idx+1))
|
||||
patternText := tc.Emphasis.Bold(true).Render(f.Pattern)
|
||||
b.WriteString(header + sevBadge + " " + patternText + "\n")
|
||||
|
||||
// Message
|
||||
b.WriteString(ac.Dim.Render(" "))
|
||||
b.WriteString(ac.Dim.Render(f.Message))
|
||||
b.WriteString(tc.Dim.Render(" "))
|
||||
b.WriteString(tc.Dim.Render(f.Message))
|
||||
b.WriteString("\n")
|
||||
|
||||
// Location: file:line
|
||||
loc := fmt.Sprintf("%s:%d", f.File, f.Line)
|
||||
b.WriteString(ac.Dim.Render(" "))
|
||||
b.WriteString(tc.Dim.Render(" "))
|
||||
b.WriteString(ac.File.Render(loc))
|
||||
b.WriteString("\n")
|
||||
|
||||
// Snippet — with │ gutter
|
||||
if f.Snippet != "" {
|
||||
gutter := ac.Dim.Render(" │ ")
|
||||
gutter := tc.Dim.Render(" │ ")
|
||||
b.WriteString(gutter)
|
||||
b.WriteString(ac.Snippet.Render(f.Snippet))
|
||||
b.WriteString("\n")
|
||||
@@ -614,7 +546,7 @@ func (m auditTUIModel) applyDetailScroll(content string, viewHeight int) string
|
||||
// Scroll indicator
|
||||
if offset > 0 || offset < maxScroll {
|
||||
indicator := fmt.Sprintf("── Ctrl+d/u scroll (%d/%d) ──", offset+1, maxScroll+1)
|
||||
b.WriteString(ac.Dim.Render(indicator))
|
||||
b.WriteString(tc.Dim.Render(indicator))
|
||||
b.WriteString("\n")
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ import (
|
||||
|
||||
"github.com/charmbracelet/bubbles/list"
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
"github.com/charmbracelet/lipgloss"
|
||||
)
|
||||
|
||||
// checklistItemData holds the input data for a single checklist item.
|
||||
@@ -94,29 +93,10 @@ func newChecklistModel(cfg checklistConfig) checklistModel {
|
||||
listItems := makeChecklistItems(cfg.items, sel, cfg.singleSelect)
|
||||
|
||||
delegate := list.NewDefaultDelegate()
|
||||
delegate.ShowDescription = hasDesc
|
||||
if hasDesc {
|
||||
delegate.SetSpacing(0)
|
||||
} else {
|
||||
delegate.SetHeight(1)
|
||||
delegate.SetSpacing(0)
|
||||
}
|
||||
delegate.Styles.NormalTitle = lipgloss.NewStyle().
|
||||
Foreground(lipgloss.Color("15")).PaddingLeft(2)
|
||||
delegate.Styles.NormalDesc = lipgloss.NewStyle().
|
||||
Foreground(lipgloss.Color("8")).PaddingLeft(2)
|
||||
delegate.Styles.SelectedTitle = lipgloss.NewStyle().Bold(true).
|
||||
Foreground(tuiBrandYellow).
|
||||
Border(lipgloss.NormalBorder(), false, false, false, true).
|
||||
BorderForeground(tuiBrandYellow).PaddingLeft(1)
|
||||
delegate.Styles.SelectedDesc = lipgloss.NewStyle().
|
||||
Foreground(lipgloss.Color("8")).
|
||||
Border(lipgloss.NormalBorder(), false, false, false, true).
|
||||
BorderForeground(tuiBrandYellow).PaddingLeft(1)
|
||||
configureDelegate(&delegate, hasDesc)
|
||||
|
||||
l := list.New(listItems, delegate, 0, 0)
|
||||
l.Styles.Title = lipgloss.NewStyle().
|
||||
Bold(true).Foreground(lipgloss.Color("6"))
|
||||
l.Styles.Title = tc.ListTitle
|
||||
l.SetShowStatusBar(true)
|
||||
l.SetFilteringEnabled(true)
|
||||
l.SetShowHelp(false)
|
||||
@@ -284,7 +264,7 @@ func (m checklistModel) View() string {
|
||||
} else {
|
||||
help = "↑↓ navigate space toggle a all enter confirm / filter esc cancel"
|
||||
}
|
||||
b.WriteString(tuiHelpStyle.Render(help))
|
||||
b.WriteString(tc.Help.Render(help))
|
||||
b.WriteString("\n")
|
||||
|
||||
return b.String()
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"github.com/charmbracelet/bubbles/list"
|
||||
"github.com/charmbracelet/bubbles/textinput"
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
"github.com/charmbracelet/lipgloss"
|
||||
|
||||
"skillshare/internal/install"
|
||||
)
|
||||
@@ -86,25 +85,11 @@ func newDirPickerModel(skills []install.SkillInfo) dirPickerModel {
|
||||
items := m.buildItems(skills, "")
|
||||
|
||||
delegate := list.NewDefaultDelegate()
|
||||
delegate.ShowDescription = true
|
||||
delegate.SetSpacing(0)
|
||||
delegate.Styles.NormalTitle = lipgloss.NewStyle().
|
||||
Foreground(lipgloss.Color("15")).PaddingLeft(2) // bright white
|
||||
delegate.Styles.NormalDesc = lipgloss.NewStyle().
|
||||
Foreground(lipgloss.Color("8")).PaddingLeft(2)
|
||||
delegate.Styles.SelectedTitle = lipgloss.NewStyle().
|
||||
Foreground(tuiBrandYellow).Bold(true).
|
||||
Border(lipgloss.NormalBorder(), false, false, false, true).
|
||||
BorderForeground(tuiBrandYellow).PaddingLeft(1)
|
||||
delegate.Styles.SelectedDesc = lipgloss.NewStyle().
|
||||
Foreground(lipgloss.Color("8")).
|
||||
Border(lipgloss.NormalBorder(), false, false, false, true).
|
||||
BorderForeground(tuiBrandYellow).PaddingLeft(1)
|
||||
configureDelegate(&delegate, true)
|
||||
|
||||
l := list.New(items, delegate, 0, 0)
|
||||
l.Title = "Select directory"
|
||||
l.Styles.Title = lipgloss.NewStyle().
|
||||
Bold(true).Foreground(lipgloss.Color("6"))
|
||||
l.Styles.Title = tc.ListTitle
|
||||
l.SetShowStatusBar(false)
|
||||
l.SetFilteringEnabled(false)
|
||||
l.SetShowHelp(false)
|
||||
@@ -113,8 +98,8 @@ func newDirPickerModel(skills []install.SkillInfo) dirPickerModel {
|
||||
// Filter text input
|
||||
fi := textinput.New()
|
||||
fi.Prompt = "/ "
|
||||
fi.PromptStyle = tuiFilterStyle
|
||||
fi.Cursor.Style = tuiFilterStyle
|
||||
fi.PromptStyle = tc.Filter
|
||||
fi.Cursor.Style = tc.Filter
|
||||
|
||||
m.list = l
|
||||
m.allItems = items
|
||||
@@ -324,7 +309,7 @@ func (m dirPickerModel) View() string {
|
||||
} else {
|
||||
help = "↑↓ navigate enter select / filter q quit"
|
||||
}
|
||||
b.WriteString(tuiHelpStyle.Render(help))
|
||||
b.WriteString(tc.Help.Render(help))
|
||||
b.WriteString("\n")
|
||||
|
||||
return b.String()
|
||||
@@ -421,15 +406,7 @@ func newSkillSelectModel(skills []install.SkillInfo) skillSelectModel {
|
||||
items := makeSkillSelectItems(sorted, locs, sel)
|
||||
|
||||
delegate := list.NewDefaultDelegate()
|
||||
delegate.ShowDescription = false
|
||||
delegate.SetHeight(1)
|
||||
delegate.SetSpacing(0)
|
||||
delegate.Styles.NormalTitle = lipgloss.NewStyle().
|
||||
Foreground(lipgloss.Color("15")).PaddingLeft(2) // bright white
|
||||
delegate.Styles.SelectedTitle = lipgloss.NewStyle().Bold(true).
|
||||
Foreground(tuiBrandYellow).
|
||||
Border(lipgloss.NormalBorder(), false, false, false, true).
|
||||
BorderForeground(tuiBrandYellow).PaddingLeft(1)
|
||||
configureDelegate(&delegate, false)
|
||||
|
||||
// Keep typed allItems for filter
|
||||
allItems := make([]skillSelectItem, len(items))
|
||||
@@ -439,8 +416,7 @@ func newSkillSelectModel(skills []install.SkillInfo) skillSelectModel {
|
||||
|
||||
l := list.New(items, delegate, 0, 0)
|
||||
l.Title = skillSelectTitle(0, len(sorted))
|
||||
l.Styles.Title = lipgloss.NewStyle().
|
||||
Bold(true).Foreground(lipgloss.Color("6"))
|
||||
l.Styles.Title = tc.ListTitle
|
||||
l.SetShowStatusBar(false)
|
||||
l.SetFilteringEnabled(false)
|
||||
l.SetShowHelp(false)
|
||||
@@ -449,8 +425,8 @@ func newSkillSelectModel(skills []install.SkillInfo) skillSelectModel {
|
||||
// Filter text input
|
||||
fi := textinput.New()
|
||||
fi.Prompt = "/ "
|
||||
fi.PromptStyle = tuiFilterStyle
|
||||
fi.Cursor.Style = tuiFilterStyle
|
||||
fi.PromptStyle = tc.Filter
|
||||
fi.Cursor.Style = tc.Filter
|
||||
|
||||
return skillSelectModel{
|
||||
list: l,
|
||||
@@ -638,7 +614,7 @@ func (m skillSelectModel) View() string {
|
||||
))
|
||||
|
||||
help := "↑↓ navigate space toggle a all enter confirm / filter esc cancel"
|
||||
b.WriteString(tuiHelpStyle.Render(help))
|
||||
b.WriteString(tc.Help.Render(help))
|
||||
b.WriteString("\n")
|
||||
|
||||
return b.String()
|
||||
|
||||
+20
-61
@@ -15,36 +15,6 @@ import (
|
||||
"github.com/charmbracelet/bubbles/spinner"
|
||||
"github.com/charmbracelet/bubbles/textinput"
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
"github.com/charmbracelet/lipgloss"
|
||||
)
|
||||
|
||||
// tuiBrandYellow is the logo yellow used for active/selected item borders across all TUIs.
|
||||
const tuiBrandYellow = lipgloss.Color("#D4D93C")
|
||||
|
||||
// Styles for the TUI list view.
|
||||
// Colors match existing CLI output: Cyan (\033[36m) = "6", Gray (\033[90m) = "8".
|
||||
var (
|
||||
tuiDetailLabelStyle = lipgloss.NewStyle().
|
||||
Foreground(lipgloss.Color("8")). // gray — matches ui.Gray
|
||||
Width(14)
|
||||
|
||||
tuiDetailValueStyle = lipgloss.NewStyle() // default foreground — matches ui.Reset
|
||||
|
||||
tuiHelpStyle = lipgloss.NewStyle().
|
||||
MarginLeft(2).
|
||||
Foreground(lipgloss.Color("8")) // gray
|
||||
|
||||
tuiSeparatorStyle = lipgloss.NewStyle().
|
||||
Foreground(lipgloss.Color("8"))
|
||||
|
||||
tuiFileStyle = lipgloss.NewStyle().
|
||||
Foreground(lipgloss.Color("8"))
|
||||
|
||||
tuiTargetStyle = lipgloss.NewStyle().
|
||||
Foreground(lipgloss.Color("6")) // cyan
|
||||
|
||||
tuiFilterStyle = lipgloss.NewStyle().
|
||||
Foreground(lipgloss.Color("6")) // cyan — shared by list and log TUI
|
||||
)
|
||||
|
||||
// maxListItems is the maximum number of items passed to bubbles/list.
|
||||
@@ -53,9 +23,9 @@ const maxListItems = 1000
|
||||
|
||||
// applyTUIFilterStyle sets filter prompt, cursor, and input cursor to the shared style.
|
||||
func applyTUIFilterStyle(l *list.Model) {
|
||||
l.Styles.FilterPrompt = tuiFilterStyle
|
||||
l.Styles.FilterCursor = tuiFilterStyle
|
||||
l.FilterInput.Cursor.Style = tuiFilterStyle
|
||||
l.Styles.FilterPrompt = tc.Filter
|
||||
l.Styles.FilterCursor = tc.Filter
|
||||
l.FilterInput.Cursor.Style = tc.Filter
|
||||
}
|
||||
|
||||
// listLoadResult holds the result of async skill loading inside the TUI.
|
||||
@@ -128,18 +98,8 @@ type listTUIModel struct {
|
||||
// When loadFn is non-nil, skills are loaded asynchronously inside the TUI (spinner shown).
|
||||
// When loadFn is nil, skills/totalCount are used directly (pre-loaded).
|
||||
func newListTUIModel(loadFn listLoadFn, skills []skillItem, totalCount int, modeLabel, sourcePath string, targets map[string]config.TargetConfig) listTUIModel {
|
||||
// Create delegate — NormalTitle/SelectedTitle have NO Foreground
|
||||
// so that Title()'s inline lipgloss colors (white name + colored badge) take effect.
|
||||
delegate := list.NewDefaultDelegate()
|
||||
delegate.ShowDescription = false
|
||||
delegate.SetHeight(1)
|
||||
delegate.SetSpacing(0)
|
||||
delegate.Styles.NormalTitle = lipgloss.NewStyle().
|
||||
Foreground(lipgloss.Color("15")).PaddingLeft(2) // bright white
|
||||
delegate.Styles.SelectedTitle = lipgloss.NewStyle().Bold(true).
|
||||
Foreground(tuiBrandYellow).
|
||||
Border(lipgloss.NormalBorder(), false, false, false, true).
|
||||
BorderForeground(tuiBrandYellow).PaddingLeft(1)
|
||||
configureDelegate(&delegate, false)
|
||||
|
||||
// Build initial item set (empty if async loading)
|
||||
var items []list.Item
|
||||
@@ -155,8 +115,7 @@ func newListTUIModel(loadFn listLoadFn, skills []skillItem, totalCount int, mode
|
||||
// Create list model — built-in filter DISABLED; we manage our own.
|
||||
l := list.New(items, delegate, 0, 0)
|
||||
l.Title = fmt.Sprintf("Installed skills (%s)", modeLabel)
|
||||
l.Styles.Title = lipgloss.NewStyle().
|
||||
Bold(true).Foreground(lipgloss.Color("6")) // cyan
|
||||
l.Styles.Title = tc.ListTitle
|
||||
l.SetShowStatusBar(false) // we render our own status with real total count
|
||||
l.SetFilteringEnabled(false) // application-level filter replaces built-in
|
||||
l.SetShowHelp(false) // we render our own help
|
||||
@@ -165,13 +124,13 @@ func newListTUIModel(loadFn listLoadFn, skills []skillItem, totalCount int, mode
|
||||
// Loading spinner
|
||||
sp := spinner.New()
|
||||
sp.Spinner = spinner.Dot
|
||||
sp.Style = lipgloss.NewStyle().Foreground(lipgloss.Color("6")) // cyan
|
||||
sp.Style = tc.SpinnerStyle
|
||||
|
||||
// Filter text input
|
||||
fi := textinput.New()
|
||||
fi.Prompt = "/ "
|
||||
fi.PromptStyle = tuiFilterStyle
|
||||
fi.Cursor.Style = tuiFilterStyle
|
||||
fi.PromptStyle = tc.Filter
|
||||
fi.Cursor.Style = tc.Filter
|
||||
|
||||
return listTUIModel{
|
||||
list: l,
|
||||
@@ -378,7 +337,7 @@ func (m listTUIModel) View() string {
|
||||
|
||||
// Help line
|
||||
help := "↑↓ navigate ←→ page / filter Enter view A audit U update X uninstall q quit"
|
||||
b.WriteString(tuiHelpStyle.Render(help))
|
||||
b.WriteString(tc.Help.Render(help))
|
||||
b.WriteString("\n")
|
||||
|
||||
return b.String()
|
||||
@@ -399,14 +358,14 @@ func renderTUIFilterBar(inputView string, filtering bool, filterText string, mat
|
||||
if filtering {
|
||||
if filterText == "" {
|
||||
status := fmt.Sprintf(" %s %s%s", formatNumber(totalCount), noun, pageInfo)
|
||||
return " " + inputView + tuiHelpStyle.Render(status) + "\n"
|
||||
return " " + inputView + tc.Help.Render(status) + "\n"
|
||||
}
|
||||
status := fmt.Sprintf(" %s/%s %s", formatNumber(matchCount), formatNumber(totalCount), noun)
|
||||
if maxShown > 0 && matchCount > maxShown {
|
||||
status += fmt.Sprintf(" (first %s shown)", formatNumber(maxShown))
|
||||
}
|
||||
status += pageInfo
|
||||
return " " + inputView + tuiHelpStyle.Render(status) + "\n"
|
||||
return " " + inputView + tc.Help.Render(status) + "\n"
|
||||
}
|
||||
if filterText != "" {
|
||||
status := fmt.Sprintf("filter: %s — %s/%s %s", filterText, formatNumber(matchCount), formatNumber(totalCount), noun)
|
||||
@@ -414,9 +373,9 @@ func renderTUIFilterBar(inputView string, filtering bool, filterText string, mat
|
||||
status += fmt.Sprintf(" (first %s shown)", formatNumber(maxShown))
|
||||
}
|
||||
status += pageInfo
|
||||
return tuiHelpStyle.Render(status) + "\n"
|
||||
return tc.Help.Render(status) + "\n"
|
||||
}
|
||||
return tuiHelpStyle.Render(fmt.Sprintf("%s %s%s", formatNumber(totalCount), noun, pageInfo)) + "\n"
|
||||
return tc.Help.Render(fmt.Sprintf("%s %s%s", formatNumber(totalCount), noun, pageInfo)) + "\n"
|
||||
}
|
||||
|
||||
// renderPageInfo returns page indicator like " · Page 2 of 4,729" or "" if single page.
|
||||
@@ -482,13 +441,13 @@ func (m listTUIModel) getDetailData(e skillEntry) *detailData {
|
||||
// renderDetailPanel renders the detail section for the selected skill.
|
||||
func (m listTUIModel) renderDetailPanel(e skillEntry) string {
|
||||
var b strings.Builder
|
||||
b.WriteString(tuiSeparatorStyle.Render(" ─────────────────────────────────────────"))
|
||||
b.WriteString(tc.Separator.Render(" ─────────────────────────────────────────"))
|
||||
b.WriteString("\n")
|
||||
|
||||
row := func(label, value string) {
|
||||
b.WriteString(" ")
|
||||
b.WriteString(tuiDetailLabelStyle.Render(label))
|
||||
b.WriteString(tuiDetailValueStyle.Render(value))
|
||||
b.WriteString(tc.Label.Render(label))
|
||||
b.WriteString(tc.Value.Render(value))
|
||||
b.WriteString("\n")
|
||||
}
|
||||
|
||||
@@ -513,7 +472,7 @@ func (m listTUIModel) renderDetailPanel(e skillEntry) string {
|
||||
indent := strings.Repeat(" ", labelOffset)
|
||||
for _, line := range lines[1:] {
|
||||
b.WriteString(indent)
|
||||
b.WriteString(tuiDetailValueStyle.Render(line))
|
||||
b.WriteString(tc.Value.Render(line))
|
||||
b.WriteString("\n")
|
||||
}
|
||||
b.WriteString("\n") // blank line after multi-line description
|
||||
@@ -529,10 +488,10 @@ func (m listTUIModel) renderDetailPanel(e skillEntry) string {
|
||||
|
||||
// Source info
|
||||
if e.RepoName != "" {
|
||||
row("Tracked:", e.RepoName)
|
||||
row("Tracked:", tc.Cyan.Render(e.RepoName))
|
||||
}
|
||||
if e.Source != "" {
|
||||
row("Source:", e.Source)
|
||||
row("Source:", tc.Cyan.Render(e.Source))
|
||||
} else {
|
||||
row("Source:", "(local)")
|
||||
}
|
||||
@@ -547,7 +506,7 @@ func (m listTUIModel) renderDetailPanel(e skillEntry) string {
|
||||
|
||||
// Synced targets
|
||||
if len(d.SyncedTargets) > 0 {
|
||||
row("Synced to:", tuiTargetStyle.Render(strings.Join(d.SyncedTargets, ", ")))
|
||||
row("Synced to:", tc.Target.Render(strings.Join(d.SyncedTargets, ", ")))
|
||||
}
|
||||
|
||||
return b.String()
|
||||
|
||||
@@ -350,8 +350,8 @@ func sidebarWidth(termWidth int) int {
|
||||
func renderContentOverlay(m listTUIModel) string {
|
||||
var b strings.Builder
|
||||
|
||||
titleStyle := lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("6"))
|
||||
dimStyle := lipgloss.NewStyle().Foreground(lipgloss.Color("8"))
|
||||
titleStyle := tc.Title
|
||||
dimStyle := tc.Dim
|
||||
|
||||
skillName := filepath.Base(m.contentSkillKey)
|
||||
fileName := ""
|
||||
@@ -382,8 +382,7 @@ func renderContentOverlay(m listTUIModel) string {
|
||||
PaddingLeft(1).
|
||||
Render(sidebarStr)
|
||||
|
||||
borderStyle := lipgloss.NewStyle().
|
||||
Foreground(lipgloss.Color("8")).
|
||||
borderStyle := tc.Border.
|
||||
Height(contentHeight).MaxHeight(contentHeight)
|
||||
borderCol := strings.Repeat("│\n", contentHeight)
|
||||
borderPanel := borderStyle.Render(strings.TrimRight(borderCol, "\n"))
|
||||
@@ -402,7 +401,7 @@ func renderContentOverlay(m listTUIModel) string {
|
||||
if scrollInfo != "" {
|
||||
help += " " + scrollInfo
|
||||
}
|
||||
b.WriteString(tuiHelpStyle.Render(help))
|
||||
b.WriteString(tc.Help.Render(help))
|
||||
b.WriteString("\n")
|
||||
|
||||
return b.String()
|
||||
@@ -414,10 +413,10 @@ func renderSidebarStr(m listTUIModel, width, height int) string {
|
||||
return "(no files)"
|
||||
}
|
||||
|
||||
selectedStyle := lipgloss.NewStyle().Bold(true).Foreground(tuiBrandYellow)
|
||||
dirStyle := lipgloss.NewStyle().Foreground(lipgloss.Color("6"))
|
||||
selectedStyle := lipgloss.NewStyle().Bold(true).Foreground(tc.BrandYellow)
|
||||
dirStyle := tc.Cyan
|
||||
fileStyle := lipgloss.NewStyle()
|
||||
dimStyle := lipgloss.NewStyle().Foreground(lipgloss.Color("8"))
|
||||
dimStyle := tc.Dim
|
||||
|
||||
total := len(m.treeNodes)
|
||||
start := m.treeScroll
|
||||
|
||||
@@ -24,18 +24,18 @@ func (i skillItem) FilterValue() string {
|
||||
}
|
||||
|
||||
// Title returns the skill name with a type badge for the list delegate.
|
||||
// Name is bright white; badge: tracked → green, local → gray.
|
||||
// Inline colors: name → bright white, badge: tracked → green, local → gray.
|
||||
func (i skillItem) Title() string {
|
||||
name := i.entry.Name
|
||||
nameStr := i.entry.Name
|
||||
if i.entry.RelPath != "" && i.entry.RelPath != i.entry.Name {
|
||||
name = i.entry.RelPath
|
||||
nameStr = i.entry.RelPath
|
||||
}
|
||||
title := name
|
||||
title := tc.Emphasis.Render(nameStr)
|
||||
|
||||
if i.entry.RepoName != "" {
|
||||
title += " [tracked]"
|
||||
title += " " + tc.Green.Render("[tracked]")
|
||||
} else if i.entry.Source == "" {
|
||||
title += " [local]"
|
||||
title += " " + tc.Dim.Render("[local]")
|
||||
}
|
||||
return title
|
||||
}
|
||||
|
||||
+62
-114
@@ -16,43 +16,13 @@ import (
|
||||
"skillshare/internal/ui"
|
||||
)
|
||||
|
||||
// lc centralizes all color styles for the log TUI.
|
||||
// Single source of truth — change colors here, not scattered across methods.
|
||||
// lc holds log-specific styles that don't belong in the shared tc palette.
|
||||
var lc = struct {
|
||||
// Semantic
|
||||
Title lipgloss.Style // section headings, command names
|
||||
Dim lipgloss.Style // secondary info, labels, separators
|
||||
Cyan lipgloss.Style // command names, emphasis
|
||||
Green lipgloss.Style // ok status, passed
|
||||
Red lipgloss.Style // error, blocked, failed
|
||||
Yellow lipgloss.Style // warning, partial
|
||||
Bold lipgloss.Style // counts, totals
|
||||
|
||||
// Severity (shared from ui.SeverityID* constants)
|
||||
Critical lipgloss.Style
|
||||
High lipgloss.Style
|
||||
Medium lipgloss.Style
|
||||
Low lipgloss.Style
|
||||
Info lipgloss.Style
|
||||
|
||||
// Detail panel
|
||||
Label lipgloss.Style // row labels (wider for log keys)
|
||||
Bold lipgloss.Style // counts, totals — bold without color
|
||||
Label lipgloss.Style // row labels — wider (22) than tc.Label (14)
|
||||
}{
|
||||
Title: lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("6")),
|
||||
Dim: lipgloss.NewStyle().Foreground(lipgloss.Color("8")),
|
||||
Cyan: lipgloss.NewStyle().Foreground(lipgloss.Color("6")),
|
||||
Green: lipgloss.NewStyle().Foreground(lipgloss.Color("2")),
|
||||
Red: lipgloss.NewStyle().Foreground(lipgloss.Color("1")),
|
||||
Yellow: lipgloss.NewStyle().Foreground(lipgloss.Color("3")),
|
||||
Bold: lipgloss.NewStyle().Bold(true),
|
||||
|
||||
Critical: lipgloss.NewStyle().Foreground(lipgloss.Color(ui.SeverityIDCritical)).Bold(true),
|
||||
High: lipgloss.NewStyle().Foreground(lipgloss.Color(ui.SeverityIDHigh)),
|
||||
Medium: lipgloss.NewStyle().Foreground(lipgloss.Color(ui.SeverityIDMedium)),
|
||||
Low: lipgloss.NewStyle().Foreground(lipgloss.Color(ui.SeverityIDLow)),
|
||||
Info: lipgloss.NewStyle().Foreground(lipgloss.Color(ui.SeverityIDInfo)),
|
||||
|
||||
Label: lipgloss.NewStyle().Foreground(lipgloss.Color("8")).Width(22),
|
||||
Bold: lipgloss.NewStyle().Bold(true),
|
||||
Label: lipgloss.NewStyle().Foreground(lipgloss.Color("245")).Width(22),
|
||||
}
|
||||
|
||||
// logLoadFn is a function that loads log items (runs in a goroutine inside the TUI).
|
||||
@@ -123,19 +93,11 @@ func newLogTUIModel(loadFn logLoadFn, items []logItem, logLabel, modeLabel, conf
|
||||
}
|
||||
|
||||
delegate := list.NewDefaultDelegate()
|
||||
delegate.ShowDescription = false
|
||||
delegate.SetHeight(1)
|
||||
delegate.SetSpacing(0)
|
||||
delegate.Styles.NormalTitle = lipgloss.NewStyle().PaddingLeft(2)
|
||||
delegate.Styles.SelectedTitle = lipgloss.NewStyle().
|
||||
Bold(true).Foreground(tuiBrandYellow).
|
||||
Border(lipgloss.NormalBorder(), false, false, false, true).
|
||||
BorderForeground(tuiBrandYellow).PaddingLeft(1)
|
||||
configureDelegate(&delegate, false)
|
||||
|
||||
l := list.New(listItems, delegate, 0, 0)
|
||||
l.Title = fmt.Sprintf("Log: %s (%s)", logLabel, modeLabel)
|
||||
l.Styles.Title = lipgloss.NewStyle().
|
||||
Bold(true).Foreground(lipgloss.Color("6"))
|
||||
l.Styles.Title = tc.ListTitle
|
||||
l.SetShowStatusBar(false) // custom status line
|
||||
l.SetFilteringEnabled(false) // application-level filter
|
||||
l.SetShowHelp(false)
|
||||
@@ -144,13 +106,13 @@ func newLogTUIModel(loadFn logLoadFn, items []logItem, logLabel, modeLabel, conf
|
||||
// Loading spinner
|
||||
sp := spinner.New()
|
||||
sp.Spinner = spinner.Dot
|
||||
sp.Style = lipgloss.NewStyle().Foreground(lipgloss.Color("6"))
|
||||
sp.Style = tc.SpinnerStyle
|
||||
|
||||
// Filter text input
|
||||
fi := textinput.New()
|
||||
fi.Prompt = "/ "
|
||||
fi.PromptStyle = tuiFilterStyle
|
||||
fi.Cursor.Style = tuiFilterStyle
|
||||
fi.PromptStyle = tc.Filter
|
||||
fi.Cursor.Style = tc.Filter
|
||||
|
||||
return logTUIModel{
|
||||
list: l,
|
||||
@@ -569,7 +531,7 @@ func (m logTUIModel) View() string {
|
||||
b.WriteString("\n")
|
||||
|
||||
help := "s back to list q quit"
|
||||
b.WriteString(tuiHelpStyle.Render(help))
|
||||
b.WriteString(tc.Help.Render(help))
|
||||
b.WriteString("\n")
|
||||
return b.String()
|
||||
}
|
||||
@@ -599,8 +561,7 @@ func (m logTUIModel) View() string {
|
||||
Render(m.list.View())
|
||||
|
||||
// Border column
|
||||
borderStyle := lipgloss.NewStyle().
|
||||
Foreground(lipgloss.Color("8")).
|
||||
borderStyle := tc.Border.
|
||||
Height(panelHeight).MaxHeight(panelHeight)
|
||||
borderCol := strings.Repeat("│\n", panelHeight)
|
||||
borderPanel := borderStyle.Render(strings.TrimRight(borderCol, "\n"))
|
||||
@@ -624,7 +585,7 @@ func (m logTUIModel) View() string {
|
||||
// Stats footer
|
||||
b.WriteString(m.renderStatsFooter())
|
||||
|
||||
b.WriteString(tuiHelpStyle.Render(m.logHelpBar()))
|
||||
b.WriteString(tc.Help.Render(m.logHelpBar()))
|
||||
b.WriteString("\n")
|
||||
|
||||
return b.String()
|
||||
@@ -648,7 +609,7 @@ func (m logTUIModel) viewVertical() string {
|
||||
|
||||
b.WriteString(m.renderStatsFooter())
|
||||
|
||||
b.WriteString(tuiHelpStyle.Render(m.logHelpBar()))
|
||||
b.WriteString(tc.Help.Render(m.logHelpBar()))
|
||||
b.WriteString("\n")
|
||||
|
||||
return b.String()
|
||||
@@ -674,7 +635,7 @@ func (m logTUIModel) logHelpBar() string {
|
||||
help := strings.Join(parts, " ")
|
||||
|
||||
if m.lastDeletedMsg != "" {
|
||||
help = lc.Green.Render(m.lastDeletedMsg) + " " + help
|
||||
help = tc.Green.Render(m.lastDeletedMsg) + " " + help
|
||||
}
|
||||
|
||||
return help
|
||||
@@ -748,7 +709,7 @@ func (m logTUIModel) applyDetailScroll(content string, viewHeight int) string {
|
||||
// Scroll indicator
|
||||
if offset > 0 || offset < maxScroll {
|
||||
indicator := fmt.Sprintf(" ── Ctrl+d/u scroll (%d/%d) ──", offset+1, maxScroll+1)
|
||||
b.WriteString(lc.Dim.Render(indicator))
|
||||
b.WriteString(tc.Dim.Render(indicator))
|
||||
b.WriteString("\n")
|
||||
}
|
||||
|
||||
@@ -761,7 +722,7 @@ func renderLogDetailPanel(item logItem) string {
|
||||
|
||||
row := func(label, value string) {
|
||||
b.WriteString(lc.Label.Render(label))
|
||||
b.WriteString(tuiDetailValueStyle.Render(value))
|
||||
b.WriteString(tc.Value.Render(value))
|
||||
b.WriteString("\n")
|
||||
}
|
||||
|
||||
@@ -771,17 +732,17 @@ func renderLogDetailPanel(item logItem) string {
|
||||
row("Timestamp:", e.Timestamp)
|
||||
|
||||
// Command — cyan to match CLI palette
|
||||
row("Command:", lc.Cyan.Render(strings.ToUpper(e.Command)))
|
||||
row("Command:", tc.Cyan.Render(strings.ToUpper(e.Command)))
|
||||
|
||||
// Status with color
|
||||
statusDisplay := e.Status
|
||||
switch e.Status {
|
||||
case "ok":
|
||||
statusDisplay = lc.Green.Render(e.Status)
|
||||
statusDisplay = tc.Green.Render(e.Status)
|
||||
case "error", "blocked":
|
||||
statusDisplay = lc.Red.Render(e.Status)
|
||||
statusDisplay = tc.Red.Render(e.Status)
|
||||
case "partial":
|
||||
statusDisplay = lc.Yellow.Render(e.Status)
|
||||
statusDisplay = tc.Yellow.Render(e.Status)
|
||||
}
|
||||
row("Status:", statusDisplay)
|
||||
|
||||
@@ -816,11 +777,11 @@ func renderLogDetailPanel(item logItem) string {
|
||||
show = show[:maxBulletItems]
|
||||
}
|
||||
for _, v := range show {
|
||||
b.WriteString(" - " + tuiDetailValueStyle.Render(v) + "\n")
|
||||
b.WriteString(" - " + tc.Value.Render(v) + "\n")
|
||||
}
|
||||
if remaining > 0 {
|
||||
summary := fmt.Sprintf(" ... and %d more", remaining)
|
||||
b.WriteString(lc.Dim.Render(summary) + "\n")
|
||||
b.WriteString(tc.Dim.Render(summary) + "\n")
|
||||
}
|
||||
continue
|
||||
}
|
||||
@@ -833,9 +794,9 @@ func renderLogDetailPanel(item logItem) string {
|
||||
// Colorize only severity/status fields to avoid visual noise
|
||||
switch {
|
||||
case strings.Contains(p.key, "failed") || strings.Contains(p.key, "scan-errors"):
|
||||
value = lc.Red.Render(value)
|
||||
value = tc.Red.Render(value)
|
||||
case strings.Contains(p.key, "warning"):
|
||||
value = lc.Yellow.Render(value)
|
||||
value = tc.Yellow.Render(value)
|
||||
case p.key == "risk":
|
||||
value = colorizeRiskValue(value)
|
||||
case p.key == "threshold":
|
||||
@@ -850,10 +811,9 @@ func renderLogDetailPanel(item logItem) string {
|
||||
return b.String()
|
||||
}
|
||||
|
||||
// severityStyles maps the 5 severity levels (c/h/m/l/i) to lipgloss styles
|
||||
// using the centralized lc color config.
|
||||
// severityStyles maps the 5 severity levels (c/h/m/l/i) to lipgloss styles.
|
||||
var severityStyles = []lipgloss.Style{
|
||||
lc.Critical, lc.High, lc.Medium, lc.Low, lc.Info,
|
||||
tc.Critical, tc.High, tc.Medium, tc.Low, tc.Info,
|
||||
}
|
||||
|
||||
// colorizeSeverityBreakdown colors each number in "0/0/1/0/0" to match audit summary.
|
||||
@@ -865,39 +825,27 @@ func colorizeSeverityBreakdown(value string) string {
|
||||
for i, p := range parts {
|
||||
parts[i] = severityStyles[i].Render(p)
|
||||
}
|
||||
sep := lc.Dim.Render("/")
|
||||
sep := tc.Dim.Render("/")
|
||||
return strings.Join(parts, sep)
|
||||
}
|
||||
|
||||
// severityLipglossStyle returns a lipgloss style for the given severity string.
|
||||
func severityLipglossStyle(severity string) lipgloss.Style {
|
||||
id := ui.SeverityColorID(severity)
|
||||
if id == "" {
|
||||
return lipgloss.NewStyle()
|
||||
}
|
||||
return lipgloss.NewStyle().Foreground(lipgloss.Color(id))
|
||||
}
|
||||
|
||||
// colorizeThreshold applies color based on audit threshold level.
|
||||
func colorizeThreshold(value string) string {
|
||||
style := severityLipglossStyle(value)
|
||||
if ui.SeverityColorID(value) == "" {
|
||||
return lc.Green.Render(value)
|
||||
return tc.Green.Render(value)
|
||||
}
|
||||
return style.Render(value)
|
||||
return tcSevStyle(value).Render(value)
|
||||
}
|
||||
|
||||
// colorizeRiskValue applies color based on the risk label embedded in the value string.
|
||||
// e.g. "CRITICAL (85/100)" → red, "LOW (15/100)" → green
|
||||
func colorizeRiskValue(value string) string {
|
||||
// Extract the severity word (first token before space or paren)
|
||||
sev := strings.SplitN(strings.ToUpper(value), " ", 2)[0]
|
||||
sev = strings.TrimRight(sev, "(")
|
||||
style := severityLipglossStyle(sev)
|
||||
if ui.SeverityColorID(sev) == "" {
|
||||
return lc.Green.Render(value)
|
||||
return tc.Green.Render(value)
|
||||
}
|
||||
return style.Render(value)
|
||||
return tcSevStyle(sev).Render(value)
|
||||
}
|
||||
|
||||
// computeLogStatsFromItems converts logItems to oplog entries and computes stats.
|
||||
@@ -918,21 +866,21 @@ func (m logTUIModel) renderStatsFooter() string {
|
||||
rateStyle := statsSuccessRateColor(m.stats.SuccessRate)
|
||||
|
||||
parts := []string{
|
||||
lc.Dim.Render(fmt.Sprintf("%d ops", m.stats.Total)),
|
||||
tc.Dim.Render(fmt.Sprintf("%d ops", m.stats.Total)),
|
||||
rateStyle.Render(fmt.Sprintf("✓ %.1f%%", m.stats.SuccessRate*100)),
|
||||
}
|
||||
|
||||
if m.stats.LastOperation != nil {
|
||||
ts, err := time.Parse(time.RFC3339, m.stats.LastOperation.Timestamp)
|
||||
if err == nil {
|
||||
lastPart := lc.Dim.Render("last: ") +
|
||||
lc.Cyan.Render(m.stats.LastOperation.Command) +
|
||||
lc.Dim.Render(fmt.Sprintf(" %s ago", formatRelativeTime(time.Since(ts))))
|
||||
lastPart := tc.Dim.Render("last: ") +
|
||||
tc.Cyan.Render(m.stats.LastOperation.Command) +
|
||||
tc.Dim.Render(fmt.Sprintf(" %s ago", formatRelativeTime(time.Since(ts))))
|
||||
parts = append(parts, lastPart)
|
||||
}
|
||||
}
|
||||
|
||||
sep := lc.Dim.Render(" | ")
|
||||
sep := tc.Dim.Render(" | ")
|
||||
return " " + strings.Join(parts, sep) + "\n"
|
||||
}
|
||||
|
||||
@@ -940,13 +888,13 @@ func (m logTUIModel) renderStatsFooter() string {
|
||||
func (m logTUIModel) renderStatsPanel() string {
|
||||
var b strings.Builder
|
||||
|
||||
b.WriteString(lc.Title.Render(" Operation Log Summary"))
|
||||
b.WriteString(tc.Title.Render(" Operation Log Summary"))
|
||||
b.WriteString("\n")
|
||||
b.WriteString(lc.Dim.Render(" " + strings.Repeat("─", 50)))
|
||||
b.WriteString(tc.Dim.Render(" " + strings.Repeat("─", 50)))
|
||||
b.WriteString("\n\n")
|
||||
|
||||
if m.stats.Total == 0 {
|
||||
b.WriteString(lc.Dim.Render(" No entries"))
|
||||
b.WriteString(tc.Dim.Render(" No entries"))
|
||||
b.WriteString("\n")
|
||||
return b.String()
|
||||
}
|
||||
@@ -958,20 +906,20 @@ func (m logTUIModel) renderStatsPanel() string {
|
||||
}
|
||||
rateColor := statsSuccessRateColor(m.stats.SuccessRate)
|
||||
b.WriteString(fmt.Sprintf(" %s %s\n\n",
|
||||
lc.Dim.Render("Total:"),
|
||||
tc.Dim.Render("Total:"),
|
||||
lc.Bold.Render(fmt.Sprintf("%d", m.stats.Total)),
|
||||
))
|
||||
b.WriteString(fmt.Sprintf(" %s %s %s\n\n",
|
||||
lc.Dim.Render("OK:"),
|
||||
tc.Dim.Render("OK:"),
|
||||
rateColor.Render(fmt.Sprintf("%d/%d", okTotal, m.stats.Total)),
|
||||
lc.Dim.Render(fmt.Sprintf("(%.1f%%)", m.stats.SuccessRate*100)),
|
||||
tc.Dim.Render(fmt.Sprintf("(%.1f%%)", m.stats.SuccessRate*100)),
|
||||
))
|
||||
|
||||
// ── Command breakdown with horizontal bars ──
|
||||
header := fmt.Sprintf(" %-12s %-20s %s", "Command", "", "OK")
|
||||
b.WriteString(lc.Dim.Render(header))
|
||||
b.WriteString(tc.Dim.Render(header))
|
||||
b.WriteString("\n")
|
||||
b.WriteString(lc.Dim.Render(" " + strings.Repeat("─", 42)))
|
||||
b.WriteString(tc.Dim.Render(" " + strings.Repeat("─", 42)))
|
||||
b.WriteString("\n")
|
||||
|
||||
type cmdEntry struct {
|
||||
@@ -1007,21 +955,21 @@ func (m logTUIModel) renderStatsPanel() string {
|
||||
}
|
||||
errBarLen := barLen - okBarLen
|
||||
|
||||
cmdBar := lc.Green.Render(strings.Repeat("▓", okBarLen))
|
||||
cmdBar := tc.Green.Render(strings.Repeat("▓", okBarLen))
|
||||
if errBarLen > 0 {
|
||||
cmdBar += lc.Red.Render(strings.Repeat("▓", errBarLen))
|
||||
cmdBar += tc.Red.Render(strings.Repeat("▓", errBarLen))
|
||||
}
|
||||
padding := strings.Repeat(" ", cmdBarWidth-barLen)
|
||||
|
||||
// "✓6/9" format — ok out of total, self-explanatory
|
||||
okRatio := fmt.Sprintf("✓%d/%d", cmd.cs.OK, cmd.cs.Total)
|
||||
ratioColor := lc.Green
|
||||
ratioColor := tc.Green
|
||||
if cmd.cs.OK < cmd.cs.Total {
|
||||
ratioColor = lc.Red
|
||||
ratioColor = tc.Red
|
||||
}
|
||||
|
||||
b.WriteString(fmt.Sprintf(" %s %s%s %s\n",
|
||||
lc.Dim.Render(fmt.Sprintf("%-12s", cmd.name)),
|
||||
tc.Dim.Render(fmt.Sprintf("%-12s", cmd.name)),
|
||||
cmdBar, padding, ratioColor.Render(okRatio)))
|
||||
}
|
||||
|
||||
@@ -1036,19 +984,19 @@ func (m logTUIModel) renderStatsPanel() string {
|
||||
blockedTotal += cs.Blocked
|
||||
}
|
||||
|
||||
b.WriteString(lc.Dim.Render(" " + strings.Repeat("─", 50)))
|
||||
b.WriteString(tc.Dim.Render(" " + strings.Repeat("─", 50)))
|
||||
b.WriteString("\n")
|
||||
b.WriteString(fmt.Sprintf(" %s %s",
|
||||
lc.Dim.Render("Status:"),
|
||||
lc.Green.Render(fmt.Sprintf("✓ %d ok", okTotal))))
|
||||
tc.Dim.Render("Status:"),
|
||||
tc.Green.Render(fmt.Sprintf("✓ %d ok", okTotal))))
|
||||
if errTotal > 0 {
|
||||
b.WriteString(fmt.Sprintf(" %s", lc.Red.Render(fmt.Sprintf("✗ %d error", errTotal))))
|
||||
b.WriteString(fmt.Sprintf(" %s", tc.Red.Render(fmt.Sprintf("✗ %d error", errTotal))))
|
||||
}
|
||||
if partialTotal > 0 {
|
||||
b.WriteString(fmt.Sprintf(" %s", lc.Yellow.Render(fmt.Sprintf("◐ %d partial", partialTotal))))
|
||||
b.WriteString(fmt.Sprintf(" %s", tc.Yellow.Render(fmt.Sprintf("◐ %d partial", partialTotal))))
|
||||
}
|
||||
if blockedTotal > 0 {
|
||||
b.WriteString(fmt.Sprintf(" %s", lc.Red.Render(fmt.Sprintf("⊘ %d blocked", blockedTotal))))
|
||||
b.WriteString(fmt.Sprintf(" %s", tc.Red.Render(fmt.Sprintf("⊘ %d blocked", blockedTotal))))
|
||||
}
|
||||
b.WriteString("\n")
|
||||
|
||||
@@ -1058,9 +1006,9 @@ func (m logTUIModel) renderStatsPanel() string {
|
||||
if err == nil {
|
||||
ago := formatRelativeTime(time.Since(ts))
|
||||
b.WriteString(fmt.Sprintf(" %s %s %s\n",
|
||||
lc.Dim.Render("Last op:"),
|
||||
lc.Cyan.Render(m.stats.LastOperation.Command),
|
||||
lc.Dim.Render(fmt.Sprintf("(%s ago)", ago))))
|
||||
tc.Dim.Render("Last op:"),
|
||||
tc.Cyan.Render(m.stats.LastOperation.Command),
|
||||
tc.Dim.Render(fmt.Sprintf("(%s ago)", ago))))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1071,11 +1019,11 @@ func (m logTUIModel) renderStatsPanel() string {
|
||||
func statsSuccessRateColor(rate float64) lipgloss.Style {
|
||||
switch {
|
||||
case rate >= 0.9:
|
||||
return lipgloss.NewStyle().Foreground(lipgloss.Color("2")).Bold(true) // green
|
||||
return tc.Green.Bold(true)
|
||||
case rate >= 0.7:
|
||||
return lipgloss.NewStyle().Foreground(lipgloss.Color("3")).Bold(true) // yellow
|
||||
return tc.Yellow.Bold(true)
|
||||
default:
|
||||
return lipgloss.NewStyle().Foreground(lipgloss.Color("1")).Bold(true) // red
|
||||
return tc.Red.Bold(true)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ import (
|
||||
"github.com/charmbracelet/bubbles/list"
|
||||
"github.com/charmbracelet/bubbles/textinput"
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
"github.com/charmbracelet/lipgloss"
|
||||
|
||||
"skillshare/internal/search"
|
||||
)
|
||||
@@ -113,26 +112,11 @@ func newSearchSelectModel(results []search.SearchResult, isHub bool) searchSelec
|
||||
}
|
||||
|
||||
delegate := list.NewDefaultDelegate()
|
||||
delegate.ShowDescription = false
|
||||
delegate.SetHeight(1)
|
||||
delegate.SetSpacing(0)
|
||||
delegate.Styles.NormalTitle = lipgloss.NewStyle().
|
||||
Foreground(lipgloss.Color("15")).PaddingLeft(2)
|
||||
delegate.Styles.NormalDesc = lipgloss.NewStyle().
|
||||
Foreground(lipgloss.Color("8")).PaddingLeft(2)
|
||||
delegate.Styles.SelectedTitle = lipgloss.NewStyle().Bold(true).
|
||||
Foreground(tuiBrandYellow).
|
||||
Border(lipgloss.NormalBorder(), false, false, false, true).
|
||||
BorderForeground(tuiBrandYellow).PaddingLeft(1)
|
||||
delegate.Styles.SelectedDesc = lipgloss.NewStyle().
|
||||
Foreground(lipgloss.Color("8")).
|
||||
Border(lipgloss.NormalBorder(), false, false, false, true).
|
||||
BorderForeground(tuiBrandYellow).PaddingLeft(1)
|
||||
configureDelegate(&delegate, true)
|
||||
|
||||
l := list.New(items, delegate, 0, 0)
|
||||
l.Title = searchSelectTitle(0, len(results))
|
||||
l.Styles.Title = lipgloss.NewStyle().
|
||||
Bold(true).Foreground(lipgloss.Color("6"))
|
||||
l.Styles.Title = tc.ListTitle
|
||||
l.SetShowStatusBar(false) // custom status line
|
||||
l.SetFilteringEnabled(false) // application-level filter
|
||||
l.SetShowHelp(false)
|
||||
@@ -141,8 +125,8 @@ func newSearchSelectModel(results []search.SearchResult, isHub bool) searchSelec
|
||||
// Filter text input
|
||||
fi := textinput.New()
|
||||
fi.Prompt = "/ "
|
||||
fi.PromptStyle = tuiFilterStyle
|
||||
fi.Cursor.Style = tuiFilterStyle
|
||||
fi.PromptStyle = tc.Filter
|
||||
fi.Cursor.Style = tc.Filter
|
||||
|
||||
return searchSelectModel{
|
||||
list: l,
|
||||
@@ -335,7 +319,7 @@ func (m searchSelectModel) View() string {
|
||||
}
|
||||
|
||||
help := "↑↓ navigate ←→ page space toggle a all enter install s search again / filter esc cancel"
|
||||
b.WriteString(tuiHelpStyle.Render(help))
|
||||
b.WriteString(tc.Help.Render(help))
|
||||
b.WriteString("\n")
|
||||
|
||||
return b.String()
|
||||
@@ -353,13 +337,13 @@ func (m searchSelectModel) renderSearchFilterBar() string {
|
||||
// renderSearchDetailPanel renders the detail section for the selected search result.
|
||||
func (m searchSelectModel) renderSearchDetailPanel(r search.SearchResult) string {
|
||||
var b strings.Builder
|
||||
b.WriteString(tuiSeparatorStyle.Render(" ─────────────────────────────────────────"))
|
||||
b.WriteString(tc.Separator.Render(" ─────────────────────────────────────────"))
|
||||
b.WriteString("\n")
|
||||
|
||||
row := func(label, value string) {
|
||||
b.WriteString(" ")
|
||||
b.WriteString(tuiDetailLabelStyle.Render(label))
|
||||
b.WriteString(tuiDetailValueStyle.Render(value))
|
||||
b.WriteString(tc.Label.Render(label))
|
||||
b.WriteString(tc.Value.Render(value))
|
||||
b.WriteString("\n")
|
||||
}
|
||||
|
||||
@@ -381,7 +365,7 @@ func (m searchSelectModel) renderSearchDetailPanel(r search.SearchResult) string
|
||||
indent := strings.Repeat(" ", labelOffset)
|
||||
for _, line := range lines[1:] {
|
||||
b.WriteString(indent)
|
||||
b.WriteString(tuiDetailValueStyle.Render(line))
|
||||
b.WriteString(tc.Value.Render(line))
|
||||
b.WriteString("\n")
|
||||
}
|
||||
b.WriteString("\n")
|
||||
@@ -406,7 +390,7 @@ func (m searchSelectModel) renderSearchDetailPanel(r search.SearchResult) string
|
||||
for i, tag := range r.Tags {
|
||||
tags[i] = "#" + tag
|
||||
}
|
||||
row("Tags:", tuiTargetStyle.Render(strings.Join(tags, " ")))
|
||||
row("Tags:", tc.Target.Render(strings.Join(tags, " ")))
|
||||
}
|
||||
|
||||
return b.String()
|
||||
|
||||
@@ -0,0 +1,131 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"skillshare/internal/ui"
|
||||
|
||||
"github.com/charmbracelet/bubbles/list"
|
||||
"github.com/charmbracelet/lipgloss"
|
||||
)
|
||||
|
||||
// tuiBrandYellow is the logo yellow used for active/selected item borders across all TUIs.
|
||||
const tuiBrandYellow = lipgloss.Color("#D4D93C")
|
||||
|
||||
// tc centralizes shared color styles used across all TUI views.
|
||||
// Domain-specific structs (ac, lc) reference tc for base colors.
|
||||
var tc = struct {
|
||||
BrandYellow lipgloss.Color
|
||||
|
||||
// Semantic
|
||||
Title lipgloss.Style // section headings — bold cyan
|
||||
Emphasis lipgloss.Style // primary values, bright text — bright white (15)
|
||||
Dim lipgloss.Style // secondary info, labels, descriptions — gray
|
||||
Faint lipgloss.Style // decorative chrome, borders, help — darker gray
|
||||
Cyan lipgloss.Style // emphasis, targets — cyan
|
||||
Green lipgloss.Style // ok, passed
|
||||
Yellow lipgloss.Style // warning
|
||||
Red lipgloss.Style // error, blocked
|
||||
|
||||
// Detail panel
|
||||
Label lipgloss.Style // row labels (width 14)
|
||||
Value lipgloss.Style // default foreground
|
||||
File lipgloss.Style // file names — dim gray
|
||||
Target lipgloss.Style // target names — cyan
|
||||
Separator lipgloss.Style // horizontal rules — faint
|
||||
Border lipgloss.Style // panel borders — faint
|
||||
|
||||
// Filter & help
|
||||
Filter lipgloss.Style // filter prompt/cursor — cyan
|
||||
Help lipgloss.Style // help bar — faint, left margin
|
||||
|
||||
// Delegate styles — shared by all list TUIs
|
||||
NormalTitle lipgloss.Style
|
||||
NormalDesc lipgloss.Style
|
||||
SelectedTitle lipgloss.Style
|
||||
SelectedDesc lipgloss.Style
|
||||
|
||||
// Severity — shared across all TUIs (audit, log, etc.)
|
||||
Critical lipgloss.Style // red, bold
|
||||
High lipgloss.Style // orange
|
||||
Medium lipgloss.Style // yellow
|
||||
Low lipgloss.Style // bright blue
|
||||
Info lipgloss.Style // medium gray
|
||||
|
||||
// List chrome
|
||||
ListTitle lipgloss.Style // list title — bold cyan
|
||||
SpinnerStyle lipgloss.Style // loading spinner — cyan
|
||||
}{
|
||||
BrandYellow: lipgloss.Color("#D4D93C"),
|
||||
|
||||
Title: lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("6")),
|
||||
Emphasis: lipgloss.NewStyle().Foreground(lipgloss.Color("15")),
|
||||
Dim: lipgloss.NewStyle().Foreground(lipgloss.Color("245")),
|
||||
Faint: lipgloss.NewStyle().Foreground(lipgloss.Color("239")),
|
||||
Cyan: lipgloss.NewStyle().Foreground(lipgloss.Color("6")),
|
||||
Green: lipgloss.NewStyle().Foreground(lipgloss.Color("2")),
|
||||
Yellow: lipgloss.NewStyle().Foreground(lipgloss.Color("3")),
|
||||
Red: lipgloss.NewStyle().Foreground(lipgloss.Color("1")),
|
||||
|
||||
Label: lipgloss.NewStyle().Foreground(lipgloss.Color("245")).Width(14),
|
||||
Value: lipgloss.NewStyle(),
|
||||
File: lipgloss.NewStyle().Foreground(lipgloss.Color("245")),
|
||||
Target: lipgloss.NewStyle().Foreground(lipgloss.Color("6")),
|
||||
Separator: lipgloss.NewStyle().Foreground(lipgloss.Color("239")),
|
||||
Border: lipgloss.NewStyle().Foreground(lipgloss.Color("239")),
|
||||
|
||||
Filter: lipgloss.NewStyle().Foreground(lipgloss.Color("6")),
|
||||
Help: lipgloss.NewStyle().MarginLeft(2).Foreground(lipgloss.Color("239")),
|
||||
|
||||
NormalTitle: lipgloss.NewStyle().PaddingLeft(2),
|
||||
NormalDesc: lipgloss.NewStyle().Foreground(lipgloss.Color("245")).PaddingLeft(2),
|
||||
SelectedTitle: lipgloss.NewStyle().Bold(true).
|
||||
Foreground(lipgloss.Color("#D4D93C")).
|
||||
Border(lipgloss.NormalBorder(), false, false, false, true).
|
||||
BorderForeground(lipgloss.Color("#D4D93C")).PaddingLeft(1),
|
||||
SelectedDesc: lipgloss.NewStyle().Foreground(lipgloss.Color("245")).
|
||||
Border(lipgloss.NormalBorder(), false, false, false, true).
|
||||
BorderForeground(lipgloss.Color("#D4D93C")).PaddingLeft(1),
|
||||
|
||||
Critical: lipgloss.NewStyle().Foreground(lipgloss.Color(ui.SeverityIDCritical)).Bold(true),
|
||||
High: lipgloss.NewStyle().Foreground(lipgloss.Color(ui.SeverityIDHigh)),
|
||||
Medium: lipgloss.NewStyle().Foreground(lipgloss.Color(ui.SeverityIDMedium)),
|
||||
Low: lipgloss.NewStyle().Foreground(lipgloss.Color(ui.SeverityIDLow)),
|
||||
Info: lipgloss.NewStyle().Foreground(lipgloss.Color(ui.SeverityIDInfo)),
|
||||
|
||||
ListTitle: lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("6")),
|
||||
SpinnerStyle: lipgloss.NewStyle().Foreground(lipgloss.Color("6")),
|
||||
}
|
||||
|
||||
// tcSevStyle returns the severity lipgloss style from the centralized tc config.
|
||||
func tcSevStyle(severity string) lipgloss.Style {
|
||||
switch strings.ToUpper(severity) {
|
||||
case "CRITICAL":
|
||||
return tc.Critical
|
||||
case "HIGH":
|
||||
return tc.High
|
||||
case "MEDIUM":
|
||||
return tc.Medium
|
||||
case "LOW":
|
||||
return tc.Low
|
||||
case "INFO":
|
||||
return tc.Info
|
||||
default:
|
||||
return tc.Dim
|
||||
}
|
||||
}
|
||||
|
||||
// configureDelegate applies shared delegate styles to a list.DefaultDelegate.
|
||||
// showDesc toggles description row (2-line items when true, 1-line when false).
|
||||
func configureDelegate(d *list.DefaultDelegate, showDesc bool) {
|
||||
d.ShowDescription = showDesc
|
||||
d.SetSpacing(0)
|
||||
d.Styles.NormalTitle = tc.NormalTitle
|
||||
d.Styles.SelectedTitle = tc.SelectedTitle
|
||||
if showDesc {
|
||||
d.Styles.NormalDesc = tc.NormalDesc
|
||||
d.Styles.SelectedDesc = tc.SelectedDesc
|
||||
} else {
|
||||
d.SetHeight(1)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user