From ac610a1867f3ff184d08a256ae6c52a8f9692b77 Mon Sep 17 00:00:00 2001 From: d1snin Date: Fri, 11 Aug 2023 02:11:09 +0300 Subject: [PATCH] fix: make normal space search card smaller --- .../beam/ui/component/NormalSpaceSearchCardContent.kt | 10 +++++++++- .../d1s/beam/ui/component/SpaceSearchCardComponent.kt | 10 +++++++++- .../d1s/beam/ui/component/SpaceSearchCardContent.kt | 9 +++++++-- .../ui/state/CurrentSpaceContentChangeObservable.kt | 4 +++- 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/beam-ui/src/jsMain/kotlin/dev/d1s/beam/ui/component/NormalSpaceSearchCardContent.kt b/beam-ui/src/jsMain/kotlin/dev/d1s/beam/ui/component/NormalSpaceSearchCardContent.kt index 32928b6e..4d639308 100644 --- a/beam-ui/src/jsMain/kotlin/dev/d1s/beam/ui/component/NormalSpaceSearchCardContent.kt +++ b/beam-ui/src/jsMain/kotlin/dev/d1s/beam/ui/component/NormalSpaceSearchCardContent.kt @@ -17,16 +17,24 @@ package dev.d1s.beam.ui.component import dev.d1s.beam.ui.theme.currentTheme +import dev.d1s.beam.ui.util.Size import dev.d1s.beam.ui.util.Texts import io.kvision.html.image import io.kvision.panel.SimplePanel import io.kvision.utils.perc +import io.kvision.utils.px +import io.kvision.utils.rem import org.koin.core.component.KoinComponent class NormalSpaceSearchCardContent : SpaceSearchCardContent, KoinComponent { override val mode = SpaceSearchCardComponent.Mode.NORMAL + override fun SimplePanel.configureContainer() { + maxWidth = Size.Md.px + fontSize = 0.8.rem + } + override fun SimplePanel.image() { image( currentTheme.normalSpaceIcon, @@ -38,6 +46,6 @@ class NormalSpaceSearchCardContent : SpaceSearchCardContent, KoinComponent { } override fun SimplePanel.text() { - spaceSearchCardText(Texts.Body.SpaceSearchCard.NormalMode.TEXT) + spaceSearchCardText(Texts.Body.SpaceSearchCard.NormalMode.TEXT, fontSize = 1.1.rem) } } \ No newline at end of file diff --git a/beam-ui/src/jsMain/kotlin/dev/d1s/beam/ui/component/SpaceSearchCardComponent.kt b/beam-ui/src/jsMain/kotlin/dev/d1s/beam/ui/component/SpaceSearchCardComponent.kt index fd9acbd4..bfced668 100644 --- a/beam-ui/src/jsMain/kotlin/dev/d1s/beam/ui/component/SpaceSearchCardComponent.kt +++ b/beam-ui/src/jsMain/kotlin/dev/d1s/beam/ui/component/SpaceSearchCardComponent.kt @@ -64,7 +64,9 @@ class SpaceSearchCardComponent : Component(::Co override fun SimplePanel.render() { div(className = "container d-flex justify-content-center") { - maxWidth = Size.LgBreakpoint.px + maxWidth = Size.Lg.px + + configureContainer() card(className = "d-flex flex-column justify-content-center w-100 p-5") { image() @@ -74,6 +76,12 @@ class SpaceSearchCardComponent : Component(::Co } } + private fun SimplePanel.configureContainer() { + with(content) { + configureContainer() + } + } + private fun SimplePanel.image() { with(content) { image() diff --git a/beam-ui/src/jsMain/kotlin/dev/d1s/beam/ui/component/SpaceSearchCardContent.kt b/beam-ui/src/jsMain/kotlin/dev/d1s/beam/ui/component/SpaceSearchCardContent.kt index f5aa6d0f..8eb343a8 100644 --- a/beam-ui/src/jsMain/kotlin/dev/d1s/beam/ui/component/SpaceSearchCardContent.kt +++ b/beam-ui/src/jsMain/kotlin/dev/d1s/beam/ui/component/SpaceSearchCardContent.kt @@ -16,6 +16,7 @@ package dev.d1s.beam.ui.component +import io.kvision.core.CssSize import io.kvision.html.p import io.kvision.panel.SimplePanel import io.kvision.utils.rem @@ -24,13 +25,17 @@ interface SpaceSearchCardContent { val mode: SpaceSearchCardComponent.Mode + fun SimplePanel.configureContainer() { + // nop + } + fun SimplePanel.image() fun SimplePanel.text() } -fun SimplePanel.spaceSearchCardText(text: String) { +fun SimplePanel.spaceSearchCardText(text: String, fontSize: CssSize = 1.6.rem) { p(text, className = "mb-3") { - fontSize = 1.6.rem + this.fontSize = fontSize } } \ No newline at end of file diff --git a/beam-ui/src/jsMain/kotlin/dev/d1s/beam/ui/state/CurrentSpaceContentChangeObservable.kt b/beam-ui/src/jsMain/kotlin/dev/d1s/beam/ui/state/CurrentSpaceContentChangeObservable.kt index 14eb4fc9..c13afaa4 100644 --- a/beam-ui/src/jsMain/kotlin/dev/d1s/beam/ui/state/CurrentSpaceContentChangeObservable.kt +++ b/beam-ui/src/jsMain/kotlin/dev/d1s/beam/ui/state/CurrentSpaceContentChangeObservable.kt @@ -183,7 +183,9 @@ class CurrentSpaceContentChangeObservable : Observable. () -> Unit): Blocks = this?.let { - this.toMutableList().apply(modification) + this.toMutableList().apply(modification).sortedBy { + it.index + } } ?: listOf() private fun setCurrentSpaceContentChange(change: CurrentSpaceContentChange) {