aboutsummaryrefslogtreecommitdiff
path: root/mavigator-cockpit/src/main/scala/mavigator/cockpit/Instruments.scala
diff options
context:
space:
mode:
Diffstat (limited to 'mavigator-cockpit/src/main/scala/mavigator/cockpit/Instruments.scala')
-rw-r--r--mavigator-cockpit/src/main/scala/mavigator/cockpit/Instruments.scala58
1 files changed, 28 insertions, 30 deletions
diff --git a/mavigator-cockpit/src/main/scala/mavigator/cockpit/Instruments.scala b/mavigator-cockpit/src/main/scala/mavigator/cockpit/Instruments.scala
index c8715f4..f6a32db 100644
--- a/mavigator-cockpit/src/main/scala/mavigator/cockpit/Instruments.scala
+++ b/mavigator-cockpit/src/main/scala/mavigator/cockpit/Instruments.scala
@@ -97,38 +97,36 @@ trait Instruments { page: Page =>
val overlayStyle = """
- |.hud-overlay {
- | position: absolute;
- | left: 0;
- | right: 0;
- | top: 0;
- | bottom: 0;
- |
- | display: flex;
- | flex-direction: row;
- | justify-content: center;
- | align-items: center;
- |}
- |.hud-overlay > * {
- | flex: 1 1 0;
- | width: 100%;
- | height: 100%;
- | max-width: 100%;
- | max-height: 100%;
- |}""".stripMargin
-
-
- def mode(name: String, kind: String, on: Boolean = false) = {
- div(`class` := s"mode $kind ${if (!on) "off"}")(name)
+ .hud-overlay {
+ position: absolute;
+ left: 0;
+ right: 0;
+ top: 0;
+ bottom: 0;
+
+ display: flex;
+ flex-direction: row;
+ justify-content: center;
+ align-items: center;
+ }
+ .hud-overlay > * {
+ flex: 1 1 0;
+ width: 100%;
+ height: 100%;
+ max-width: 100%;
+ max-height: 100%;
+ }"""
+
+
+ def mode(name: String, level: String) = new Instrument[Boolean] {
+ override val element: html.Element = div(`class` := s"mode $level off")(name).render
+ def update(newValue: Boolean): Unit = {
+ val classes = element.classList
+ if (newValue) classes.add("off") else classes.remove("off")
+ }
}
- //TODO make these into real instruments and lazy vals
- def modes = div(style := "float: right;")(
- mode("LINK", "danger", true),
- mode("BAT", "warning", true),
- mode("GPS", "warning", true),
- mode("STABILIZED", "info", true)
- )
+ val unstable = mode("UNSTABLE", "danger")
val modeStyle = """
.mode {