diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b60097..d410155 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 0.0.53 + +* Improvements in `UIKitPadding` +* Add support of UIKit lists + ## 0.0.52 * Improve work with UIKitModifiers diff --git a/gradle.properties b/gradle.properties index dc6199f..9d7cf4f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,4 +9,4 @@ android.enableJetifier=true # Project data group=dev.inmo -version=0.0.52 +version=0.0.53 diff --git a/src/jsMain/kotlin/dev/inmo/jsuikit/elements/List.kt b/src/jsMain/kotlin/dev/inmo/jsuikit/elements/List.kt index cc9ac3e..2e1f505 100644 --- a/src/jsMain/kotlin/dev/inmo/jsuikit/elements/List.kt +++ b/src/jsMain/kotlin/dev/inmo/jsuikit/elements/List.kt @@ -2,14 +2,32 @@ package dev.inmo.jsuikit.elements import androidx.compose.runtime.Composable import androidx.compose.runtime.snapshots.SnapshotStateList -import dev.inmo.jsuikit.modifiers.UIKitModifier -import dev.inmo.jsuikit.modifiers.include +import dev.inmo.jsuikit.modifiers.* +import dev.inmo.jsuikit.utils.Attrs import org.jetbrains.compose.web.dom.* import org.w3c.dom.HTMLHeadingElement import org.w3c.dom.HTMLUListElement @Composable fun List( + data: SnapshotStateList, + ukAttrs: Attrs = Attrs.empty(), + elementAllocator: @Composable ElementScope.(T) -> Unit +) { + Ul( + { + include(UIKitList) + ukAttrs.builder(this) + } + ) { + data.forEach { + elementAllocator(it) + } + } +} + +@Composable +fun ListWithTitle( title: String, data: SnapshotStateList, vararg titleModifiers: UIKitModifier, @@ -23,15 +41,27 @@ fun List( Text(title) } besidesTitleAndList ?.invoke() - Ul( - { - classes("uk-list") - include(*ulModifiers) - ulCustomizer() - } - ) { - data.forEach { - elementAllocator(it) - } - } + List(data, Attrs(*ulModifiers) { ulCustomizer(this) }, elementAllocator) } + +@Deprecated("Renamed", ReplaceWith("ListWithTitle", "dev.inmo.jsuikit.elements.ListWithTitle")) +@Composable +fun List( + title: String, + data: SnapshotStateList, + vararg titleModifiers: UIKitModifier, + ulModifiers: Array = emptyArray(), + besidesTitleAndList: (@Composable () -> Unit)? = null, + titleCustomizer: AttrBuilderContext = {}, + ulCustomizer: AttrBuilderContext = {}, + elementAllocator: @Composable ElementScope.(T) -> Unit +) = ListWithTitle( + title, + data, + *titleModifiers, + ulModifiers = ulModifiers, + besidesTitleAndList = besidesTitleAndList, + titleCustomizer = titleCustomizer, + ulCustomizer = ulCustomizer, + elementAllocator = elementAllocator +) diff --git a/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitList.kt b/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitList.kt new file mode 100644 index 0000000..b9e7497 --- /dev/null +++ b/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitList.kt @@ -0,0 +1,46 @@ +package dev.inmo.jsuikit.modifiers + +sealed class UIKitList( + vararg classes: String, + override val otherAttrs: Map = emptyMap() +) : UIKitModifier { + @Suppress("UNCHECKED_CAST") + override val classes: Array = classes as Array + + sealed class Style(vararg classes: String) : UIKitList(*classes) { + + object Disc : Style("uk-list-disc") + object Circle : Style("uk-list-circle") + object Square : Style("uk-list-square") + object Decimal : Style("uk-list-decimal") + object Hyphen : Style("uk-list-hyphen") + + } + + sealed class Size(vararg classes: String) : UIKitList(*classes) { + + object Large : Size("uk-list-large") + object Collapse : Size("uk-list-collapse") + + } + + sealed class Color(vararg classes: String) : UIKitList(*classes) { + + object Muted : Color("uk-list-muted") + object Emphasis : Color("uk-list-emphasis") + object Primary : Color("uk-list-primary") + object Secondary : Color("uk-list-secondary") + companion object { + val Bullet = UIKitList.Bullet + } + + } + + object Bullet: UIKitList("uk-list-bullet") + + object Divider: UIKitList("uk-list-divider") + + object Striped: UIKitList("uk-list-striped") + + companion object : UIKitList("uk-list") +} diff --git a/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitPadding.kt b/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitPadding.kt index ab7c57f..ab2481f 100644 --- a/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitPadding.kt +++ b/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitPadding.kt @@ -8,7 +8,10 @@ sealed class UIKitPadding(suffix: String?) : UIKitModifier { object Small : Size("small") object Large : Size("large") - companion object : Size(null) + companion object : Size(null) { + val Default + get() = this + } } @@ -25,5 +28,6 @@ sealed class UIKitPadding(suffix: String?) : UIKitModifier { } + companion object : Size(null) }