Skip to content

Commit e11bcea

Browse files
authored
Add color alternating for TXT records (#54)
1 parent edbd6ea commit e11bcea

2 files changed

Lines changed: 15 additions & 6 deletions

File tree

internal/display/display.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,11 @@ var (
5050
faint = ac("#8C959F", "#4E4E4E")
5151

5252
// Secondary palette tokens used across multiple files.
53-
accent = ac("#2E59A1", "#87AFFF") // nameservers, headers, DNS records
54-
muted = ac("#57606A", "#A8A8A8") // TXT records, redirect URLs, mail records
55-
border = ac("#D0D7DE", "#3A3A3A") // box and panel borders
56-
tabGray = ac("#57606A", "#A0A0A0") // inactive tab text
53+
accent = ac("#2E59A1", "#87AFFF") // nameservers, headers, DNS records
54+
muted = ac("#57606A", "#A8A8A8") // TXT records, redirect URLs, mail records
55+
mutedAlt = ac("#8C959F", "#7A7A7A") // alternate TXT shade for zebra striping
56+
border = ac("#D0D7DE", "#3A3A3A") // box and panel borders
57+
tabGray = ac("#57606A", "#A0A0A0") // inactive tab text
5758

5859
// Styles
5960
domainStyle = lipgloss.NewStyle().
@@ -85,6 +86,9 @@ var (
8586
txtStyle = lipgloss.NewStyle().
8687
Foreground(muted)
8788

89+
txtStyleAlt = lipgloss.NewStyle().
90+
Foreground(mutedAlt)
91+
8892
dimStyle = lipgloss.NewStyle().
8993
Foreground(dim)
9094

internal/display/dns.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,18 @@ func RenderDNS(records *dns.Records) string {
7777
hasRecords = true
7878
b.WriteString("\n")
7979
b.WriteString(section("TXT"))
80-
for _, txt := range records.TXT {
80+
for i, txt := range records.TXT {
8181
// Truncate long TXT records for display
8282
display := txt
8383
if len(display) > 60 {
8484
display = display[:57] + "..."
8585
}
86-
b.WriteString(row("", txtStyle.Render(display)))
86+
// Alternate shades so adjacent records are easy to tell apart.
87+
style := txtStyle
88+
if i%2 == 1 {
89+
style = txtStyleAlt
90+
}
91+
b.WriteString(row("", style.Render(display)))
8792
}
8893
}
8994

0 commit comments

Comments
 (0)