Skip to content
Draft
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
39 changes: 5 additions & 34 deletions pkg/gui/controllers/branches_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/jesseduffield/lazygit/pkg/commands/models"
"github.com/jesseduffield/lazygit/pkg/gui/context"
"github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers"
"github.com/jesseduffield/lazygit/pkg/gui/presentation"
"github.com/jesseduffield/lazygit/pkg/gui/presentation/icons"
"github.com/jesseduffield/lazygit/pkg/gui/style"
"github.com/jesseduffield/lazygit/pkg/gui/types"
Expand Down Expand Up @@ -251,42 +252,12 @@ func stateText(state string) string {
func coloredStateText(state string) string {
if icons.IsIconEnabled() {
return fmt.Sprintf("%s%s%s",
withPrFgColor(state, ""),
withPrBgColor(state, style.FgWhite.Sprint(stateText(state))),
withPrFgColor(state, ""))
presentation.WithPrColor(state, "", false),
presentation.WithPrColor(state, color.RGB(0xFF, 0xFF, 0xFF, false).Sprint(stateText(state)), true),
presentation.WithPrColor(state, "", false))
}

return withPrFgColor(state, stateText(state))
}

func withPrFgColor(state string, text string) string {
switch state {
case "OPEN":
return style.FgGreen.Sprint(text)
case "CLOSED":
return style.FgRed.Sprint(text)
case "MERGED":
return style.FgMagenta.Sprint(text)
case "DRAFT":
return color.RGB(0x66, 0x66, 0x66, false).Sprint(text)
default:
return style.FgDefault.Sprint(text)
}
}

func withPrBgColor(state string, text string) string {
switch state {
case "OPEN":
return style.BgGreen.Sprint(text)
case "CLOSED":
return style.BgRed.Sprint(text)
case "MERGED":
return style.BgMagenta.Sprint(text)
case "DRAFT":
return color.RGB(0x66, 0x66, 0x66, true).Sprint(text)
default:
return style.BgDefault.Sprint(text)
}
return presentation.WithPrColor(state, stateText(state), false)
}

func (self *BranchesController) viewUpstreamOptions(selectedBranch *models.Branch) error {
Expand Down
15 changes: 8 additions & 7 deletions pkg/gui/presentation/branches.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"strings"
"time"

"github.com/gookit/color"
"github.com/jesseduffield/lazygit/pkg/commands/git_commands"
"github.com/jesseduffield/lazygit/pkg/commands/models"
"github.com/jesseduffield/lazygit/pkg/config"
Expand Down Expand Up @@ -148,7 +149,7 @@ func getBranchDisplayStrings(
} else {
prIcon = "●"
}
coloredPrIcon = prColor(pr.State).Sprint(prIcon)
coloredPrIcon = WithPrColor(pr.State, prIcon, false)
}
res = append(res, coloredPrIcon)

Expand Down Expand Up @@ -271,17 +272,17 @@ func SetCustomBranches(customBranchColors map[string]string, isRegex bool) {
}
}

func prColor(state string) style.TextStyle {
func WithPrColor(state string, text string, isBg bool) string {
switch state {
case "OPEN":
return style.FgGreen
return color.RGB(0x43, 0x84, 0x40, isBg).Sprint(text)
case "CLOSED":
return style.FgRed
return color.RGB(0xC9, 0x45, 0x3C, isBg).Sprint(text)
case "MERGED":
return style.FgMagenta
return color.RGB(0x82, 0x59, 0xDD, isBg).Sprint(text)
case "DRAFT":
return style.FgBlackLighter
return color.RGB(0x67, 0x6C, 0x75, isBg).Sprint(text)
default:
return style.FgDefault
return lo.Ternary(isBg, style.BgDefault, style.FgDefault).Sprint(text)
}
}
Loading