From 1f44f27fbbbb0ee1b552f2b7229606bf212db8d0 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 16 Mar 2022 16:03:35 +0600 Subject: [PATCH] add container support --- CHANGELOG.md | 2 ++ .../dev/inmo/jsuikit/elements/Container.kt | 21 +++++++++++++++++++ .../inmo/jsuikit/modifiers/UIKitContainer.kt | 19 +++++++++++++++++ 3 files changed, 42 insertions(+) create mode 100644 src/jsMain/kotlin/dev/inmo/jsuikit/elements/Container.kt create mode 100644 src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitContainer.kt diff --git a/CHANGELOG.md b/CHANGELOG.md index d9c0453..500577b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## 0.0.45 +* `Add support of containers in `UIKitContainer` modifiers and `Container` function + ## 0.0.44 * `Versions`: diff --git a/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Container.kt b/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Container.kt new file mode 100644 index 0000000..7668fdd --- /dev/null +++ b/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Container.kt @@ -0,0 +1,21 @@ +package dev.inmo.jsuikit.elements + +import androidx.compose.runtime.Composable +import dev.inmo.jsuikit.modifiers.UIKitContainer +import dev.inmo.jsuikit.modifiers.include +import dev.inmo.jsuikit.utils.Attrs +import org.jetbrains.compose.web.dom.ContentBuilder +import org.jetbrains.compose.web.dom.Div +import org.w3c.dom.HTMLDivElement + +@Composable +fun Container( + attrs: Attrs = Attrs.empty(), + contentBuilder: ContentBuilder = {} +) = Div( + { + include(UIKitContainer) + attrs.builder.invoke(this) + }, + contentBuilder +) diff --git a/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitContainer.kt b/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitContainer.kt new file mode 100644 index 0000000..9bbdc5b --- /dev/null +++ b/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitContainer.kt @@ -0,0 +1,19 @@ +package dev.inmo.jsuikit.modifiers + +sealed class UIKitContainer( + override val classes: Array = emptyArray(), + override val otherAttrs: Map = emptyMap() +) : UIKitModifier { + + sealed class Size(size: String) : UIKitContainer(arrayOf("uk-container-$size")) { + object XSmall : Size("xsmall") + object Small : Size("small") + object Large : Size("large") + object XLarge : Size("xlarge") + object Expand : Size("expand") + } + + companion object : UIKitContainer( + arrayOf("uk-container") + ) +}