Skip to content

Commit

Permalink
style(confirm): Use same color for both keys (#112)
Browse files Browse the repository at this point in the history
It's a bit jarring to see the `[y/N]` with the N highlighted
in a different color.

Switch to using the same highlight for both keys.
The capitalization indicates the default.
  • Loading branch information
abhinav authored May 27, 2024
1 parent a4bc5da commit 69a5d04
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions internal/ui/confirm.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,12 @@ var DefaultConfirmKeyMap = ConfirmKeyMap{

// ConfirmStyle configures the appearance of a [Confirm] field.
type ConfirmStyle struct {
DefaultValue lipgloss.Style // Y/N
NonDefaultValue lipgloss.Style // y/n
Key lipgloss.Style // how to highlight keys
}

// DefaultConfirmStyle is the default style for a [Confirm] field.
var DefaultConfirmStyle = ConfirmStyle{
DefaultValue: lipgloss.NewStyle().Foreground(_magentaColor),
NonDefaultValue: lipgloss.NewStyle().Foreground(_plainColor),
Key: lipgloss.NewStyle().Foreground(_magentaColor),
}

// Confirm is a boolean confirmation field that takes a yes or no answer.
Expand Down Expand Up @@ -129,13 +127,13 @@ func (c *Confirm) Update(msg tea.Msg) tea.Cmd {
func (c *Confirm) Render(w Writer) {
w.WriteString("[")
if *c.value {
w.WriteString(c.Style.DefaultValue.Render("Y"))
w.WriteString(c.Style.Key.Render("Y"))
w.WriteString("/")
w.WriteString(c.Style.NonDefaultValue.Render("n"))
w.WriteString(c.Style.Key.Render("n"))
} else {
w.WriteString(c.Style.NonDefaultValue.Render("y"))
w.WriteString(c.Style.Key.Render("y"))
w.WriteString("/")
w.WriteString(c.Style.DefaultValue.Render("N"))
w.WriteString(c.Style.Key.Render("N"))
}
w.WriteString("]")
}

0 comments on commit 69a5d04

Please sign in to comment.