Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: error color missing crashes the app and help height #477

Merged
merged 2 commits into from
Nov 9, 2024
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
11 changes: 9 additions & 2 deletions config/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,13 @@ type Pager struct {
type HexColor string

type ColorThemeText struct {
Primary HexColor `yaml:"primary" validate:"hexcolor"`
Primary HexColor `yaml:"primary" validate:"omitempty,hexcolor"`
Secondary HexColor `yaml:"secondary" validate:"hexcolor"`
Inverted HexColor `yaml:"inverted" validate:"hexcolor"`
Faint HexColor `yaml:"faint" validate:"hexcolor"`
Warning HexColor `yaml:"warning" validate:"hexcolor"`
Success HexColor `yaml:"success" validate:"hexcolor"`
Error HexColor `yaml:"error" validate:"hexcolor"`
Error HexColor `yaml:"error" validate:"omitempty,hexcolor"`
}

type ColorThemeBorder struct {
Expand Down Expand Up @@ -296,6 +296,13 @@ func (parser ConfigParser) getDefaultConfig() Config {
},
RepoPaths: map[string]string{},
Theme: &ThemeConfig{
Colors: &ColorThemeConfig{
Inline: ColorTheme{
Text: ColorThemeText{
Error: "#F7768E",
},
},
},
Ui: UIThemeConfig{
SectionsShowCount: true,
Table: TableUIThemeConfig{
Expand Down
6 changes: 3 additions & 3 deletions ui/common/styles.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
var (
SearchHeight = 3
FooterHeight = 1
ExpandedHelpHeight = 13
ExpandedHelpHeight = 14
InputBoxHeight = 8
SingleRuneWidth = 4
MainContentPadding = 1
Expand Down Expand Up @@ -41,14 +41,14 @@ func BuildStyles(theme theme.Theme) CommonStyles {
Height(FooterHeight)

s.ErrorStyle = s.FooterStyle.
Foreground(theme.WarningText).
Foreground(theme.ErrorText).
MaxHeight(FooterHeight)

s.WaitingGlyph = lipgloss.NewStyle().
Foreground(theme.FaintText).
Render(constants.WaitingIcon)
s.FailureGlyph = lipgloss.NewStyle().
Foreground(theme.WarningText).
Foreground(theme.ErrorText).
Render(constants.FailureIcon)
s.SuccessGlyph = lipgloss.NewStyle().
Foreground(theme.SuccessText).
Expand Down
6 changes: 3 additions & 3 deletions ui/components/branch/branch.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (b *Branch) renderReviewStatus() string {

if b.PR.ReviewDecision == "CHANGES_REQUESTED" {
reviewCellStyle = reviewCellStyle.Foreground(
b.Ctx.Theme.WarningText,
b.Ctx.Theme.ErrorText,
)
return reviewCellStyle.Render("󰌑")
}
Expand Down Expand Up @@ -125,7 +125,7 @@ func (b *Branch) renderCiStatus() string {
return ciCellStyle.Render(b.Ctx.Styles.Common.WaitingGlyph)
}

ciCellStyle = ciCellStyle.Foreground(b.Ctx.Theme.WarningText)
ciCellStyle = ciCellStyle.Foreground(b.Ctx.Theme.ErrorText)
return ciCellStyle.Render(constants.FailureIcon)
}

Expand All @@ -140,7 +140,7 @@ func (b *Branch) renderLines(isSelected bool) string {

var additionsFg, deletionsFg lipgloss.AdaptiveColor
additionsFg = b.Ctx.Theme.SuccessText
deletionsFg = b.Ctx.Theme.WarningText
deletionsFg = b.Ctx.Theme.ErrorText

baseStyle := lipgloss.NewStyle()
if isSelected {
Expand Down
4 changes: 2 additions & 2 deletions ui/components/pr/pr.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (pr *PullRequest) renderReviewStatus() string {

if pr.Data.ReviewDecision == "CHANGES_REQUESTED" {
reviewCellStyle = reviewCellStyle.Foreground(
pr.Ctx.Theme.WarningText,
pr.Ctx.Theme.ErrorText,
)
return reviewCellStyle.Render("󰌑")
}
Expand Down Expand Up @@ -125,7 +125,7 @@ func (pr *PullRequest) renderCiStatus() string {
return ciCellStyle.Render(pr.Ctx.Styles.Common.WaitingGlyph)
}

ciCellStyle = ciCellStyle.Foreground(pr.Ctx.Theme.WarningText)
ciCellStyle = ciCellStyle.Foreground(pr.Ctx.Theme.ErrorText)
return ciCellStyle.Render(constants.FailureIcon)
}

Expand Down
2 changes: 1 addition & 1 deletion ui/components/prsidebar/prsidebar.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ func (m *Model) renderMergeablePill() string {
status := m.pr.Data.Mergeable
if status == "CONFLICTING" {
return m.ctx.Styles.PrSidebar.PillStyle.
Background(m.ctx.Theme.WarningText).
Background(m.ctx.Theme.ErrorText).
Render("󰅖 Merge Conflicts")
} else if status == "MERGEABLE" {
return m.ctx.Styles.PrSidebar.PillStyle.
Expand Down
2 changes: 1 addition & 1 deletion ui/components/reposection/reposection.go
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ func (m *Model) GetPagerContent() string {
s := lipgloss.NewStyle().Background(m.Ctx.Styles.ListViewPort.PagerStyle.GetBackground())
mod := s.Foreground(lipgloss.Color("#e0af68")).Render(fmt.Sprintf(" %d", len(m.repo.Status.Modified)))
plus := s.Foreground(m.Ctx.Theme.SuccessText).Render(fmt.Sprintf(" %d", len(m.repo.Status.Added)))
minus := s.Foreground(m.Ctx.Theme.WarningText).Render(fmt.Sprintf(" %d", len(m.repo.Status.Removed)))
minus := s.Foreground(m.Ctx.Theme.ErrorText).Render(fmt.Sprintf(" %d", len(m.repo.Status.Removed)))
spacer := s.Render(" ")
return m.Ctx.Styles.ListViewPort.PagerStyle.Render(lipgloss.JoinHorizontal(lipgloss.Top, plus, spacer, minus, spacer, mod))
}
4 changes: 2 additions & 2 deletions ui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ func (m Model) View() string {
Render(fmt.Sprintf("%s %s",
m.ctx.Styles.Common.FailureGlyph,
lipgloss.NewStyle().
Foreground(m.ctx.Theme.WarningText).
Foreground(m.ctx.Theme.ErrorText).
Render(m.ctx.Error.Error()),
)),
)
Expand Down Expand Up @@ -898,7 +898,7 @@ func (m *Model) renderRunningTask() string {
))
case context.TaskError:
currTaskStatus = lipgloss.NewStyle().
Foreground(m.ctx.Theme.WarningText).
Foreground(m.ctx.Theme.ErrorText).
Background(m.ctx.Theme.SelectedBackground).
Render(fmt.Sprintf("%s %s", constants.FailureIcon, task.Error.Error()))
case context.TaskFinished:
Expand Down