-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Ensure table datetime columns have thematic, customizable muted text #10709
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
Changes from all commits
346fab2
d2cd14b
3c38ced
de86cc6
1bf1ad2
e36d795
b3c8c70
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -181,7 +181,7 @@ func listRun(opts *ListOptions) error { | |
| totalMatchCount := len(listResult.Repositories) | ||
| for _, repo := range listResult.Repositories { | ||
| info := repoInfo(repo) | ||
| infoColor := cs.Gray | ||
| infoColor := cs.Muted | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thought: this changes the |
||
|
|
||
| if repo.IsPrivate { | ||
| infoColor = cs.Yellow | ||
|
|
@@ -195,7 +195,7 @@ func listRun(opts *ListOptions) error { | |
| tp.AddField(repo.NameWithOwner, tableprinter.WithColor(cs.Bold)) | ||
| tp.AddField(text.RemoveExcessiveWhitespace(repo.Description)) | ||
| tp.AddField(info, tableprinter.WithColor(infoColor)) | ||
| tp.AddTimeField(opts.Now(), *t, cs.Gray) | ||
| tp.AddTimeField(opts.Now(), *t, cs.Muted) | ||
| tp.EndRow() | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,32 +30,36 @@ var ( | |
| greenBold = ansi.ColorFunc("green+b") | ||
| highlightStart = ansi.ColorCode(highlightStyle) | ||
| highlight = ansi.ColorFunc(highlightStyle) | ||
| darkThemeMuted = ansi.ColorFunc("white+d") | ||
| darkThemeTableHeader = ansi.ColorFunc("white+du") | ||
| lightThemeMuted = ansi.ColorFunc("black+h") | ||
| lightThemeTableHeader = ansi.ColorFunc("black+hu") | ||
| noThemeTableHeader = ansi.ColorFunc("default+u") | ||
|
|
||
| gray256 = func(t string) string { | ||
| return fmt.Sprintf("\x1b[%d;5;%dm%s\x1b[m", 38, 242, t) | ||
| return fmt.Sprintf("\x1b[%d;5;%dm%s\x1b[0m", 38, 242, t) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. note: |
||
| } | ||
| ) | ||
|
|
||
| // NewColorScheme initializes color logic based on provided terminal capabilities. | ||
| // Logic dealing with terminal theme detected, such as whether color is enabled, 8-bit color supported, true color supported, | ||
| // and terminal theme detected. | ||
| func NewColorScheme(enabled, is256enabled, trueColor bool, theme string) *ColorScheme { | ||
| func NewColorScheme(enabled, is256enabled, trueColor, accessibleColors bool, theme string) *ColorScheme { | ||
| return &ColorScheme{ | ||
| enabled: enabled, | ||
| is256enabled: is256enabled, | ||
| hasTrueColor: trueColor, | ||
| theme: theme, | ||
| enabled: enabled, | ||
| is256enabled: is256enabled, | ||
| hasTrueColor: trueColor, | ||
| accessibleColors: accessibleColors, | ||
| theme: theme, | ||
| } | ||
| } | ||
|
|
||
| type ColorScheme struct { | ||
| enabled bool | ||
| is256enabled bool | ||
| hasTrueColor bool | ||
| theme string | ||
| enabled bool | ||
| is256enabled bool | ||
| hasTrueColor bool | ||
| accessibleColors bool | ||
| theme string | ||
| } | ||
|
|
||
| func (c *ColorScheme) Enabled() bool { | ||
|
|
@@ -73,6 +77,31 @@ func (c *ColorScheme) Boldf(t string, args ...interface{}) string { | |
| return c.Bold(fmt.Sprintf(t, args...)) | ||
| } | ||
|
|
||
| func (c *ColorScheme) Muted(t string) string { | ||
| // Fallback to previous logic if accessible colors preview is disabled. | ||
| if !c.accessibleColors { | ||
| return c.Gray(t) | ||
| } | ||
|
|
||
| // Muted text is only stylized if color is enabled. | ||
| if !c.enabled { | ||
| return t | ||
| } | ||
|
|
||
| switch c.theme { | ||
| case LightTheme: | ||
| return lightThemeMuted(t) | ||
| case DarkTheme: | ||
| return darkThemeMuted(t) | ||
| default: | ||
| return t | ||
| } | ||
| } | ||
|
|
||
| func (c *ColorScheme) Mutedf(t string, args ...interface{}) string { | ||
| return c.Muted(fmt.Sprintf(t, args...)) | ||
| } | ||
|
|
||
| func (c *ColorScheme) Red(t string) string { | ||
| if !c.enabled { | ||
| return t | ||
|
|
@@ -113,6 +142,7 @@ func (c *ColorScheme) GreenBold(t string) string { | |
| return greenBold(t) | ||
| } | ||
|
|
||
| // Use Muted instead for thematically contrasting color. | ||
| func (c *ColorScheme) Gray(t string) string { | ||
| if !c.enabled { | ||
| return t | ||
|
|
@@ -123,6 +153,7 @@ func (c *ColorScheme) Gray(t string) string { | |
| return gray(t) | ||
| } | ||
|
|
||
| // Use Mutedf instead for thematically contrasting color. | ||
| func (c *ColorScheme) Grayf(t string, args ...interface{}) string { | ||
| return c.Gray(fmt.Sprintf(t, args...)) | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: this change is due to a minor enhancement to 8-bit gray color logic to make this easier to standardize testing with our dependency which use the
ESC[0mescape sequence.