diff --git a/beam-ui/src/jsMain/kotlin/dev/d1s/beam/ui/Module.kt b/beam-ui/src/jsMain/kotlin/dev/d1s/beam/ui/Module.kt index 1dd260e1..db08bbaf 100644 --- a/beam-ui/src/jsMain/kotlin/dev/d1s/beam/ui/Module.kt +++ b/beam-ui/src/jsMain/kotlin/dev/d1s/beam/ui/Module.kt @@ -54,6 +54,7 @@ object Qualifier { val VoidContentEntityRenderer = named("void-content-entity-renderer") val TextContentEntityRenderer = named("text-content-entity-renderer") + val NormalSpaceSearchCardContent = named("normal-space-search-card-content") val NotFoundSpaceSearchCardContent = named("not-found-space-search-card-content") val EmptySpaceSearchCardContent = named("empty-space-search-card-content") } @@ -159,6 +160,10 @@ private fun Module.contentEntityRenderers() { } private fun Module.spaceSearchCardContents() { + singleOf(::NormalSpaceSearchCardContent) { + qualifier = Qualifier.NormalSpaceSearchCardContent + } + singleOf(::NotFoundSpaceSearchCardContent) { qualifier = Qualifier.NotFoundSpaceSearchCardContent } diff --git a/beam-ui/src/jsMain/kotlin/dev/d1s/beam/ui/component/BlockComponent.kt b/beam-ui/src/jsMain/kotlin/dev/d1s/beam/ui/component/BlockComponent.kt index 6a7e964d..6077f924 100644 --- a/beam-ui/src/jsMain/kotlin/dev/d1s/beam/ui/component/BlockComponent.kt +++ b/beam-ui/src/jsMain/kotlin/dev/d1s/beam/ui/component/BlockComponent.kt @@ -34,7 +34,7 @@ class BlockComponent : Component(::Config), KoinComponent block ?: error("Block isn't set") card("p-4 d-flex flex-column justify-content-start mb-4") { - width = sizeOf(block.size).px + maxWidth = sizeOf(block.size).px renderEntities(block.entities) } } diff --git a/beam-ui/src/jsMain/kotlin/dev/d1s/beam/ui/component/BlockContainerComponent.kt b/beam-ui/src/jsMain/kotlin/dev/d1s/beam/ui/component/BlockContainerComponent.kt index 050c9dd4..9586c70c 100644 --- a/beam-ui/src/jsMain/kotlin/dev/d1s/beam/ui/component/BlockContainerComponent.kt +++ b/beam-ui/src/jsMain/kotlin/dev/d1s/beam/ui/component/BlockContainerComponent.kt @@ -17,6 +17,7 @@ package dev.d1s.beam.ui.component import dev.d1s.beam.commons.Block +import dev.d1s.beam.commons.Blocks import dev.d1s.beam.ui.Qualifier import dev.d1s.beam.ui.state.CurrentSpaceContentChange import dev.d1s.beam.ui.state.Observable @@ -35,12 +36,21 @@ class BlockContainerComponent : Component(), KoinComponent { private val currentSpaceContentChangeObservable by inject>(Qualifier.CurrentSpaceContentChangeObservable) + private val spaceSearchCardComponent by inject>(Qualifier.SpaceSearchCardComponent) + override fun SimplePanel.render() { - div(className = "container-fluid d-flex justify-content-center") { - vPanel(justify = JustifyContent.START).bind( - currentSpaceContentChangeObservable.state - ) { change -> - change.blocks?.forEach { block -> + div().bind(currentSpaceContentChangeObservable.state) { change -> + change.blocks?.let { blocks -> + renderBlocks(blocks) + renderSpaceSearchCard() + } + } + } + + private fun SimplePanel.renderBlocks(blocks: Blocks) { + div(className = "container-fluid d-flex justify-content-center mb-5") { + vPanel(justify = JustifyContent.START) { + blocks.forEach { block -> renderBlock(block) } } @@ -54,4 +64,10 @@ class BlockContainerComponent : Component(), KoinComponent { this.block.setState(block) } } + + private fun SimplePanel.renderSpaceSearchCard() { + render(spaceSearchCardComponent) { + mode.value = SpaceSearchCardComponent.Mode.NORMAL + } + } } \ No newline at end of file diff --git a/beam-ui/src/jsMain/kotlin/dev/d1s/beam/ui/component/EmptySpaceSearchCardContent.kt b/beam-ui/src/jsMain/kotlin/dev/d1s/beam/ui/component/EmptySpaceSearchCardContent.kt index 0451a10b..b68ac19d 100644 --- a/beam-ui/src/jsMain/kotlin/dev/d1s/beam/ui/component/EmptySpaceSearchCardContent.kt +++ b/beam-ui/src/jsMain/kotlin/dev/d1s/beam/ui/component/EmptySpaceSearchCardContent.kt @@ -19,9 +19,7 @@ package dev.d1s.beam.ui.component import dev.d1s.beam.ui.theme.currentTheme import dev.d1s.beam.ui.util.Texts import io.kvision.html.image -import io.kvision.html.p import io.kvision.panel.SimplePanel -import io.kvision.utils.rem import org.koin.core.component.KoinComponent class EmptySpaceSearchCardContent : SpaceSearchCardContent, KoinComponent { @@ -37,8 +35,6 @@ class EmptySpaceSearchCardContent : SpaceSearchCardContent, KoinComponent { } override fun SimplePanel.text() { - p(Texts.Body.SpaceSearchCard.EmptySpaceMode.TEXT, className = "mb-3") { - fontSize = 1.6.rem - } + spaceSearchCardText(Texts.Body.SpaceSearchCard.EmptySpaceMode.TEXT) } } \ No newline at end of file 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 new file mode 100644 index 00000000..e9b77aa0 --- /dev/null +++ b/beam-ui/src/jsMain/kotlin/dev/d1s/beam/ui/component/NormalSpaceSearchCardContent.kt @@ -0,0 +1,34 @@ +/* + * Copyright 2023 Mikhail Titov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package dev.d1s.beam.ui.component + +import dev.d1s.beam.ui.util.Texts +import io.kvision.panel.SimplePanel +import org.koin.core.component.KoinComponent + +class NormalSpaceSearchCardContent : SpaceSearchCardContent, KoinComponent { + + override val mode = SpaceSearchCardComponent.Mode.NORMAL + + override fun SimplePanel.image() { + // nop + } + + override fun SimplePanel.text() { + spaceSearchCardText(Texts.Body.SpaceSearchCard.NormalMode.TEXT) + } +} \ No newline at end of file diff --git a/beam-ui/src/jsMain/kotlin/dev/d1s/beam/ui/component/NotFoundSpaceSearchCardContent.kt b/beam-ui/src/jsMain/kotlin/dev/d1s/beam/ui/component/NotFoundSpaceSearchCardContent.kt index 2261be5a..b3a1ca0d 100644 --- a/beam-ui/src/jsMain/kotlin/dev/d1s/beam/ui/component/NotFoundSpaceSearchCardContent.kt +++ b/beam-ui/src/jsMain/kotlin/dev/d1s/beam/ui/component/NotFoundSpaceSearchCardContent.kt @@ -19,9 +19,7 @@ package dev.d1s.beam.ui.component import dev.d1s.beam.ui.theme.currentTheme import dev.d1s.beam.ui.util.Texts import io.kvision.html.image -import io.kvision.html.p import io.kvision.panel.SimplePanel -import io.kvision.utils.rem import org.koin.core.component.KoinComponent class NotFoundSpaceSearchCardContent : SpaceSearchCardContent, KoinComponent { @@ -37,8 +35,6 @@ class NotFoundSpaceSearchCardContent : SpaceSearchCardContent, KoinComponent { } override fun SimplePanel.text() { - p(Texts.Body.SpaceSearchCard.NotFoundMode.TEXT, className = "mb-3") { - fontSize = 1.6.rem - } + spaceSearchCardText(Texts.Body.SpaceSearchCard.NotFoundMode.TEXT) } } \ No newline at end of file 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 e53f77cd..f5aa6d0f 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,7 +16,9 @@ package dev.d1s.beam.ui.component +import io.kvision.html.p import io.kvision.panel.SimplePanel +import io.kvision.utils.rem interface SpaceSearchCardContent { @@ -25,4 +27,10 @@ interface SpaceSearchCardContent { fun SimplePanel.image() fun SimplePanel.text() +} + +fun SimplePanel.spaceSearchCardText(text: String) { + p(text, className = "mb-3") { + fontSize = 1.6.rem + } } \ No newline at end of file diff --git a/beam-ui/src/jsMain/kotlin/dev/d1s/beam/ui/util/Texts.kt b/beam-ui/src/jsMain/kotlin/dev/d1s/beam/ui/util/Texts.kt index 215792b8..2d4616b3 100644 --- a/beam-ui/src/jsMain/kotlin/dev/d1s/beam/ui/util/Texts.kt +++ b/beam-ui/src/jsMain/kotlin/dev/d1s/beam/ui/util/Texts.kt @@ -60,6 +60,11 @@ object Texts { const val GO_BUTTON_VALUE = "Go!" + object NormalMode { + + const val TEXT = "Explore the other spaces on this instance." + } + object NotFoundMode { const val ICON_ALT = "404 image"