Skip to content

Commit

Permalink
fix: warning settings (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
nrwiersma authored Jul 12, 2024
1 parent 29ede42 commit 8e9dfd8
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
6 changes: 3 additions & 3 deletions assets/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
stroke: rgb(87, 148, 242);
}

#heat.geyser.warm {
#heat.geyser.warning {
stroke: rgb(255, 152, 48);
}

#heat.geyser.hot {
#heat.geyser.low {
stroke: rgb(242, 73, 92);
}

Expand All @@ -36,7 +36,7 @@
stroke: rgb(55 199 255);
}

#water.tank.medium {
#water.tank.warning {
stroke: rgb(255, 152, 48);
}

Expand Down
24 changes: 24 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,20 @@ func (m *Module) updateState(id, state string) {
}
perStr := strconv.FormatFloat(per, 'f', 0, 64)

var class string
if per <= float64(m.cfg.Geyser.Low) {
class = "low"
} else if per <= float64(m.cfg.Geyser.Warning) {
class = "warning"
}

if elem := m.mod.Element().QuerySelector("#heat"); elem != nil {
elem.SetAttribute("style", percentageVar+perStr)
elem.Class().Remove("low")
elem.Class().Remove("warning")
if class != "" {
elem.Class().Add(class)
}
}
if elem := m.mod.Element().QuerySelector("#geyserText .super"); elem != nil {
elem.SetTextContent(strconv.Itoa(int(per)))
Expand All @@ -179,8 +191,20 @@ func (m *Module) updateState(id, state string) {
}
perStr := strconv.FormatFloat(per, 'f', 2, 64)

var class string
if per <= float64(m.cfg.Tank.Low) {
class = "low"
} else if per <= float64(m.cfg.Tank.Warning) {
class = "warning"
}

if elem := m.mod.Element().QuerySelector("#water"); elem != nil {
elem.SetAttribute("style", percentageVar+perStr)
elem.Class().Remove("low")
elem.Class().Remove("warning")
if class != "" {
elem.Class().Add(class)
}
}
}
}

0 comments on commit 8e9dfd8

Please sign in to comment.