Skip to content

Commit

Permalink
add common status colors to global theme
Browse files Browse the repository at this point in the history
  • Loading branch information
bcicen committed Aug 27, 2017
1 parent a1ebf3f commit add44c0
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
3 changes: 3 additions & 0 deletions colors.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ var ColorMap = map[string]ui.Attribute{
"par.text.hi": ui.ColorBlack,
"sparkline.line.fg": ui.ColorGreen,
"sparkline.title.fg": ui.ColorWhite,
"status.ok": ui.ColorGreen,
"status.warn": ui.ColorYellow,
"status.danger": ui.ColorRed,
}

func InvertColorMap() {
Expand Down
6 changes: 3 additions & 3 deletions cwidgets/compact/gauge.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ func (w *GaugeCol) Reset() {

func colorScale(n int) ui.Attribute {
if n > 70 {
return ui.ColorRed
return ui.ThemeAttr("status.danger")
}
if n > 30 {
return ui.ColorYellow
return ui.ThemeAttr("status.warn")
}
return ui.ColorGreen
return ui.ThemeAttr("status.ok")
}
4 changes: 2 additions & 2 deletions cwidgets/compact/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ func (s *Status) Set(val string) {

switch val {
case "running":
color = ui.ColorGreen
color = ui.ThemeAttr("status.ok")
case "exited":
color = ui.ColorRed
color = ui.ThemeAttr("status.danger")
case "paused":
text = fmt.Sprintf("%s%s", vBar, vBar)
}
Expand Down
14 changes: 7 additions & 7 deletions cwidgets/compact/text.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ func NewTextCol(s string) *TextCol {
}

func (w *TextCol) Highlight() {
if w.TextFgColor ==ui.ThemeAttr("par.text.fg"){
if w.TextFgColor == ui.ThemeAttr("par.text.fg") {
w.TextFgColor = ui.ThemeAttr("par.text.hi")
}
w.TextBgColor = ui.ThemeAttr("par.text.fg")
w.isHighlight = true
}

func (w *TextCol) UnHighlight() {
if w.TextFgColor == ui.ThemeAttr("par.text.hi"){
if w.TextFgColor == ui.ThemeAttr("par.text.hi") {
w.TextFgColor = ui.ThemeAttr("par.text.fg")
}
w.TextBgColor = ui.ThemeAttr("par.text.bg")
Expand All @@ -41,18 +41,18 @@ func (w *TextCol) Set(s string) {
w.Text = s
}

func (w *TextCol) Color(s string){
func (w *TextCol) Color(s string) {
color := ui.ThemeAttr("par.text.fg")
if w.isHighlight{
if w.isHighlight {
color = ui.ThemeAttr("par.text.hi")
}
switch s {
case "healthy":
color = ui.ColorGreen
color = ui.ThemeAttr("status.ok")
case "unhealthy":
color = ui.ColorMagenta
color = ui.ThemeAttr("status.danger")
case "starting":
color = ui.ColorYellow
color = ui.ThemeAttr("status.warn")
}
w.TextFgColor = color
}

0 comments on commit add44c0

Please sign in to comment.