From 3ddb22341c9583623aa9f682128c23da36bc9865 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sat, 12 Mar 2022 00:06:47 +0600 Subject: [PATCH] additions in UIKitScreenSizeModifier and support of Tile --- CHANGELOG.md | 3 +++ .../kotlin/dev/inmo/jsuikit/elements/Tile.kt | 21 +++++++++++++++++++ .../modifiers/UIKitScreenSizeModifier.kt | 9 ++++++++ .../dev/inmo/jsuikit/modifiers/UIKitTile.kt | 15 +++++++++++++ 4 files changed, 48 insertions(+) create mode 100644 src/jsMain/kotlin/dev/inmo/jsuikit/elements/Tile.kt create mode 100644 src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitTile.kt diff --git a/CHANGELOG.md b/CHANGELOG.md index d9d5fd5..c886dff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## 0.0.43 +* Several new extensions for `UIKitModifier` like `UIKitModifier#onSmallScreen` +* Support of `Tile` + ## 0.0.42 * Migration to compose 1.1.0 diff --git a/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Tile.kt b/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Tile.kt new file mode 100644 index 0000000..5a533c3 --- /dev/null +++ b/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Tile.kt @@ -0,0 +1,21 @@ +package dev.inmo.jsuikit.elements + +import androidx.compose.runtime.Composable +import dev.inmo.jsuikit.modifiers.UIKitTile +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 Tile( + attrs: Attrs = Attrs.empty(), + contentBuilder: ContentBuilder +) = Div( + { + include(UIKitTile) + attrs.builder(this) + }, + contentBuilder +) diff --git a/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitScreenSizeModifier.kt b/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitScreenSizeModifier.kt index f5e4248..61d2871 100644 --- a/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitScreenSizeModifier.kt +++ b/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitScreenSizeModifier.kt @@ -20,3 +20,12 @@ sealed class UIKitScreenSizeModifier(val name: String) { } fun UIKitModifier.applyWhenScreenSizeIs(size: UIKitScreenSizeModifier) = size.modify(this) + +val UIKitModifier.onSmallScreens + get() = applyWhenScreenSizeIs(UIKitScreenSizeModifier.Small) +val UIKitModifier.onMediumScreens + get() = applyWhenScreenSizeIs(UIKitScreenSizeModifier.Medium) +val UIKitModifier.onLargeScreens + get() = applyWhenScreenSizeIs(UIKitScreenSizeModifier.Large) +val UIKitModifier.onXLargeScreens + get() = applyWhenScreenSizeIs(UIKitScreenSizeModifier.XLarge) diff --git a/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitTile.kt b/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitTile.kt new file mode 100644 index 0000000..49a2161 --- /dev/null +++ b/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitTile.kt @@ -0,0 +1,15 @@ +package dev.inmo.jsuikit.modifiers + +sealed class UIKitTile( + override val classes: Array = emptyArray(), + override val otherAttrs: Map = emptyMap() +) : UIKitModifier { + + object Default : UIKitTile(arrayOf("uk-tile-default")) + object Muted : UIKitTile(arrayOf("uk-tile-muted")) + object Primary : UIKitTile(arrayOf("uk-tile-primary")) + object Secondary : UIKitTile(arrayOf("uk-tile-secondary")) + + companion object : UIKitTile(arrayOf("uk-tile")) + +}