fix: use ANSI colors codes instead of RGB (#14665)

* chore: add command for showing colors

* fix: use ANSI color codes instead of RGB

* feat: add '--no-color' flag

* fix: revert colors

* chore: change colors

* fix: update golden files

* fix: replace blue with brightBlue

* fix: drop '> ' for unfocused prompts

* fix: run 'make fmt'

* chore: allow disabling color with env flags

* fix: apply fixes from feedback

* fix: run 'make gen'

* fix: refactor janky code

* fix: re-add public function

* fix: re-add init for non-color tests

* fix: move styles to 'init' that can be

* fix: stop overwriting entire DefaultStyles

* fix: make code and field obey --no-color

* fix: rip out '--no-color' due to race condition

We still support `NO_COLOR` env variable through termenv's
`EnvColorProfile`. The reason for the race condition is that
`DefaultStyles` is a global that we shouldn't mutate after `init`
is called, but we have to mutate it after `init` has ran to have
serpent collect the cli flags and env vars for us.

* fix: apply nit

* fix: simplify code && hide command

* fix: newline shouldn't be themed

* fix: appease the linter
This commit is contained in:
Danielle Maywood
2024-09-17 14:21:24 +01:00
committed by GitHub
parent 6ff9a05832
commit 14d3e300d3
3 changed files with 73 additions and 27 deletions
+5 -5
View File
@@ -256,7 +256,7 @@ func (m selectModel) View() string {
if m.cursor == start+i {
style = pretty.Style{
pretty.Wrap("> ", ""),
pretty.FgColor(Green),
DefaultStyles.Keyword,
}
}
@@ -481,13 +481,13 @@ func (m multiSelectModel) View() string {
o := option.option
if m.cursor == i {
cursor = pretty.Sprint(pretty.FgColor(Green), "> ")
chosen = pretty.Sprint(pretty.FgColor(Green), "[ ]")
o = pretty.Sprint(pretty.FgColor(Green), o)
cursor = pretty.Sprint(DefaultStyles.Keyword, "> ")
chosen = pretty.Sprint(DefaultStyles.Keyword, "[ ]")
o = pretty.Sprint(DefaultStyles.Keyword, o)
}
if option.chosen {
chosen = pretty.Sprint(pretty.FgColor(Green), "[x]")
chosen = pretty.Sprint(DefaultStyles.Keyword, "[x]")
}
_, _ = s.WriteString(fmt.Sprintf(