From 49c757348625a0f0fef344eb809b02e5dd263e42 Mon Sep 17 00:00:00 2001 From: Anton Sviridov Date: Wed, 13 Mar 2024 08:53:04 +0000 Subject: [PATCH] More granular rate slider --- src/main/scala/example/Main.scala | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/main/scala/example/Main.scala b/src/main/scala/example/Main.scala index a70bae1..b90eb22 100644 --- a/src/main/scala/example/Main.scala +++ b/src/main/scala/example/Main.scala @@ -99,17 +99,19 @@ def app = "£" + numberFormat.format(value.floor) inline def poundValue(source: Observable[Double]) = - val nn = - source.toObservable.map(formatPound) - span(color.maroon, child.text <-- nn) + span(color.maroon, child.text <-- source.toObservable.map(formatPound)) + + import com.raquo.laminar.codecs.DoubleAsStringCodec + + val stepHtmlAttr = htmlAttr[Double]("step", DoubleAsStringCodec) val sliders = div( width := "50%", h1("Rate: ", child.text <-- rate.signal.map(y => s"$y%")), Slider( - _.min := 2, - _.max := 8.0, - _.step := 1, + _.min := 2, + _.max := 8.0, + stepHtmlAttr := 0.25, _.value <-- rate, _.showTooltip := true, _.labelInterval := 1, @@ -129,8 +131,8 @@ def app = ), h1("Deposit: ", poundValue(deposit.signal)), Slider( - _.min := 10_000, - _.max <-- housePrice, + _.min := 10_000, + _.max <-- housePrice, _.step := 10_000, _.value <-- deposit, _.showTooltip := true,