Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/ui/progress.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (p *ProgressBar) draw(done, total int64, now time.Time) {
if total > 0 {
frac := min(float64(done)/float64(total), 1)
filled := int(frac * float64(p.width))
b.WriteString(SpinStyle.Render(strings.Repeat("█", filled)))
b.WriteString(BarStyle.Render(strings.Repeat("█", filled)))
b.WriteString(DimStyle.Render(strings.Repeat("░", p.width-filled)))
fmt.Fprintf(&b, " %3d%% %s/%s", int(frac*100), megabytes(done), megabytes(total))
} else {
Expand Down
5 changes: 5 additions & 0 deletions internal/ui/styles.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import "charm.land/lipgloss/v2"
// 82 — green for a terminal success status (see StatusStyle)
// 226 — bright yellow for a non-terminal `status` (high-visibility); terminal states use 82/203 (see StatusStyle)
// 212 — pink for the loading spinner
// 73 — rail0.xyz accent green for the download bar
// 238 — dim gray for the --pretty table separator
//
// LabelStyle.Width(22) pads every --pretty label to a fixed column so values
Expand All @@ -35,6 +36,10 @@ var (
SpinStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("212"))
HeaderStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("240")).Bold(true)
DimStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("238"))
// BarStyle fills the download bar ('rail0 update') with the rail0.xyz accent green:
// the site's dark-theme --accent #5cc0b2, as its nearest 256-colour index (73,
// #5fafaf) like every other style here, so terminals without truecolor show it too.
BarStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("73"))
)

// StatusStyle renders a resource's `status` value with a colour that mirrors the
Expand Down
8 changes: 8 additions & 0 deletions internal/ui/styles_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,11 @@ func TestStatusStyle(t *testing.T) {
})
}
}

// The download bar is filled in the rail0.xyz accent green (256-colour 73, #5fafaf,
// nearest to the site's dark-theme #5cc0b2), not the spinner's pink.
func TestBarStyleIsTheSiteGreen(t *testing.T) {
if got, want := BarStyle.GetForeground(), lipgloss.Color("73"); !reflect.DeepEqual(got, want) {
t.Errorf("BarStyle foreground = %#v, want %#v", got, want)
}
}
Loading