diff --git a/CHANGELOG.md b/CHANGELOG.md index a2251e9..efd7c8b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 0.1.4 + +* Improvements in `UIKitGrid` +* Add support of `UIKitSticky` + ## 0.1.3 * Add support of sections diff --git a/gradle.properties b/gradle.properties index 91e5a9e..91954dc 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,4 +9,4 @@ android.enableJetifier=true # Project data group=dev.inmo -version=0.1.3 +version=0.1.4 diff --git a/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitGrid.kt b/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitGrid.kt index b6d4833..b97b769 100644 --- a/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitGrid.kt +++ b/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitGrid.kt @@ -1,20 +1,41 @@ package dev.inmo.jsuikit.modifiers -sealed class UIKitGrid(suffix: String) : UIKitModifier { - override val classes: Array = arrayOf("uk-grid-$suffix") +import dev.inmo.jsuikit.utils.buildAttribute - sealed class Gap(suffix: String) : UIKitGrid(suffix) { +sealed class UIKitGrid(vararg classnames: String) : UIKitModifier { + override val classes: Array = classnames as Array - object Small : Gap("small") - object Medium : Gap("medium") - object Large : Gap("large") - object Collapse : Gap("collapse") + sealed class Gap(classname: String) : UIKitGrid(classname) { + + object Small : Gap("uk-grid-small") + object Medium : Gap("uk-grid-medium") + object Large : Gap("uk-grid-large") + object Collapse : Gap("uk-grid-collapse") } - object Divider : UIKitGrid("divider") + object Divider : UIKitGrid("uk-grid-divider") - object MatchHeight : UIKitGrid("match") - object ItemMatchHeight : UIKitGrid("item-match") + object MatchHeight : UIKitGrid("uk-grid-match") + object ItemMatchHeight : UIKitGrid("uk-grid-item-match") + class Custom internal constructor(override val otherAttrs: Map) : UIKitGrid() + + companion object : UIKitGrid("uk-grid") { + operator fun invoke( + margin: UIKitMargin? = null, + firstColumnClass: String? = null, + masonry: Boolean? = null, + parallax: UInt? = null + ) = Custom( + mapOf( + buildAttribute("uk-grid") { + margin to margin ?.classes ?.joinToString(" ") + "first-column" to firstColumnClass + "masonry" to masonry + "parallax" to parallax + } + ) + ) + } } diff --git a/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitSticky.kt b/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitSticky.kt new file mode 100644 index 0000000..00c2d71 --- /dev/null +++ b/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitSticky.kt @@ -0,0 +1,47 @@ +package dev.inmo.jsuikit.modifiers + +import dev.inmo.jsuikit.utils.buildAttribute +import org.jetbrains.compose.web.css.CSSUnitLengthOrPercentage +import org.jetbrains.compose.web.css.CSSUnitValueTyped + +sealed class UIKitSticky( + position: Position? = null, + start: String? = null, + end: String? = null, + offset: CSSUnitValueTyped? = null, + overflowFlip: Boolean? = null, + animation: UIKitAnimation? = null, + classForActiveItems: String? = null, + classForInactiveItems: String? = null, + showOnUp: Boolean? = null, + media: String? = null, + targetOffset: CSSUnitValueTyped? = null +) : UIKitModifier { + override val otherAttrs: Map = mapOf( + buildAttribute("uk-sticky") { + "position" to position ?.name + "start" to start + "end" to end + "offset" to offset ?.toString() + "overflow-flip" to overflowFlip + "animation" to animation + "cls-active" to classForActiveItems + "cls-inactive" to classForInactiveItems + "show-on-up" to showOnUp + "media" to media + "target-offset" to targetOffset ?.toString() + } + ) + + sealed interface Position { + val name: String + object Top : Position { + override val name: String + get() = "top" + } + object Bottom : Position { + override val name: String + get() = "bottom" + } + } +}