Skip to content

Commit

Permalink
More granular rate slider
Browse files Browse the repository at this point in the history
  • Loading branch information
keynmol committed Mar 13, 2024
1 parent ea5b456 commit 49c7573
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/main/scala/example/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit 49c7573

Please sign in to comment.