From 4377ec3969bbfb2fe87cada821ffafc142ffb686 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 22 May 2022 23:21:25 +0600 Subject: [PATCH] improvements --- CHANGELOG.md | 2 + .../dev/inmo/jsuikit/modifiers/UIKitGrid.kt | 41 ++++++++++++++----- 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f85421a..bb0f4bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## 0.1.4 +* Improvements in `UIKitGrid` + ## 0.1.3 * Add support of sections 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 + } + ) + ) + } }