More or less working muon monitor

This commit is contained in:
Alexander Nozik 2023-12-27 17:08:24 +03:00
parent 659b9c3525
commit 3f144a5dbd
3 changed files with 16 additions and 13 deletions

View File

@ -11,9 +11,15 @@ import space.kscience.dataforge.names.length
@Composable @Composable
public fun NameCrumbs(name: Name?, link: (Name) -> Unit): Unit = Nav({ public fun NameCrumbs(name: Name?, link: (Name) -> Unit): Unit = Nav({
attr("aria-label","breadcrumb") attr("aria-label", "breadcrumb")
}) { }) {
Ol({classes("breadcrumb")}) { Ol({
classes("breadcrumb")
style {
property("--bs-breadcrumb-divider", "'.'")
property("--bs-breadcrumb-item-padding-x",".2rem")
}
}) {
Li({ Li({
classes("breadcrumb-item") classes("breadcrumb-item")
onClick { onClick {
@ -28,10 +34,9 @@ public fun NameCrumbs(name: Name?, link: (Name) -> Unit): Unit = Nav({
name.tokens.forEach { token -> name.tokens.forEach { token ->
tokens.add(token) tokens.add(token)
val fullName = Name(tokens.toList()) val fullName = Name(tokens.toList())
Text(".")
Li({ Li({
classes("breadcrumb-item") classes("breadcrumb-item")
if(tokens.size == name.length) classes("active") if (tokens.size == name.length) classes("active")
onClick { onClick {
link(fullName) link(fullName)
} }

View File

@ -22,7 +22,7 @@ public object TreeStyles : StyleSheet(VisionForgeStyles) {
cursor("pointer") cursor("pointer")
userSelect(UserSelect.none) userSelect(UserSelect.none)
/* Create the caret/arrow with a unicode, and style it */ /* Create the caret/arrow with a unicode, and style it */
before { (self + before) {
content("\u25B6") content("\u25B6")
color(Color.black) color(Color.black)
display(DisplayStyle.InlineBlock) display(DisplayStyle.InlineBlock)
@ -34,7 +34,7 @@ public object TreeStyles : StyleSheet(VisionForgeStyles) {
* Rotate the caret/arrow icon when clicked on (using JavaScript) * Rotate the caret/arrow icon when clicked on (using JavaScript)
*/ */
public val treeCaretDown: String by style { public val treeCaretDown: String by style {
before { (self + before) {
content("\u25B6") content("\u25B6")
color(Color.black) color(Color.black)
display(DisplayStyle.InlineBlock) display(DisplayStyle.InlineBlock)
@ -80,7 +80,7 @@ public object TreeStyles : StyleSheet(VisionForgeStyles) {
textAlign("center") textAlign("center")
textDecoration("none") textDecoration("none")
cursor("pointer") cursor("pointer")
disabled { (self + disabled) {
cursor("auto") cursor("auto")
border { border {
style(LineStyle.Dashed) style(LineStyle.Dashed)

View File

@ -33,8 +33,6 @@ private fun SimpleThreeView(
selected: Name?, selected: Name?,
) { ) {
val three: ThreePlugin by derivedStateOf { context.request(ThreePlugin) }
Div({ Div({
style { style {
maxWidth(100.vw) maxWidth(100.vw)
@ -43,9 +41,9 @@ private fun SimpleThreeView(
height(100.percent) height(100.percent)
} }
}) { }) {
var canvas: ThreeCanvas? = null var canvas: ThreeCanvas? by remember { mutableStateOf(null) }
DisposableEffect(options) { DisposableEffect(options) {
canvas = ThreeCanvas(three, scopeElement, options ?: Canvas3DOptions()) canvas = ThreeCanvas(context.request(ThreePlugin), scopeElement, options ?: Canvas3DOptions())
onDispose { onDispose {
scopeElement.clear() scopeElement.clear()
canvas = null canvas = null
@ -75,7 +73,7 @@ public fun ThreeView(
) { ) {
var selected: Name? by remember { mutableStateOf(initialSelected) } var selected: Name? by remember { mutableStateOf(initialSelected) }
val optionsSnapshot = remember(options) { val optionsSnapshot by derivedStateOf {
(options ?: Canvas3DOptions()).apply { (options ?: Canvas3DOptions()).apply {
this.onSelect = { this.onSelect = {
selected = it selected = it
@ -83,7 +81,7 @@ public fun ThreeView(
} }
} }
val selectedVision: Vision? = remember(solid, selected) { val selectedVision: Vision? by derivedStateOf {
selected?.let { selected?.let {
when { when {
it.isEmpty() -> solid it.isEmpty() -> solid