Skip to content

Commit

Permalink
Show indication of process when switching between between brief and d…
Browse files Browse the repository at this point in the history
…etailed table
  • Loading branch information
v6ak committed Oct 23, 2023
1 parent 988c26b commit f4e5007
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
14 changes: 8 additions & 6 deletions client/src/main/scala/com/v6ak/zbdb/ClassSwitches.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,21 @@ import scalatags.JsDom.all.{button as buttonTag, *}
final class ClassSwitches(
initialSwitchesState: Map[String, String],
alreadySwitchedClasses: Map[String, String] = Map(),
handler: (String, String, () => Unit) => Unit = (_: String, _: String, f: () => Unit) => f(),
) {
private val switchesState = collection.mutable.Map(initialSwitchesState.toSeq: _*)

def values = switchesState.values

private def update(switchName: String, newClass: String, allValues: Set[String]) = {
private def update(switchName: String, newClass: String, allValues: Set[String]): Unit =
val oldClasses = allValues - newClass
val classList = dom.document.body.classList
classList.add(newClass)
oldClasses.foreach(classList.remove)
switchesState(switchName) = newClass
alreadySwitchedClasses.get(switchName).foreach(classList.add)
}
handler(switchName, newClass, () => {
classList.add(newClass)
oldClasses.foreach(classList.remove)
switchesState(switchName) = newClass
alreadySwitchedClasses.get(switchName).foreach(classList.add)
})

def classSelect(switchName: String)(items: (String, String)*) = select(
onchange := { (e: Event) =>
Expand Down
15 changes: 15 additions & 0 deletions client/src/main/scala/com/v6ak/zbdb/Renderer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,21 @@ final class Renderer private(
private val switches = new ClassSwitches(
Map("details" -> "without-details"),
Map("details" -> "details-switched"),
(name, cls, f) => {
document.body.style.opacity = "0.5"
window.setTimeout(
() => {
f()
window.setTimeout(
() => {
document.body.style.opacity = "1"
},
0
)
},
0
)
}
)

import participantTable.*
Expand Down

0 comments on commit f4e5007

Please sign in to comment.