From d4d0adf02059b1cee8ed6503f7af499ed2893414 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 17 Feb 2022 15:16:30 +0600 Subject: [PATCH] vertical and horizontal in margins --- CHANGELOG.md | 1 + .../dev/inmo/jsuikit/modifiers/UIKitMargin.kt | 43 +++++++++++++------ 2 files changed, 32 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a345497..2ae7d4c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## 0.0.36 * Reorder arguments in `DefaultComment` fun +* Add `Vertical` and `Horizontal` members in margins ## 0.0.35 diff --git a/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitMargin.kt b/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitMargin.kt index b9c6865..9b6e51c 100644 --- a/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitMargin.kt +++ b/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitMargin.kt @@ -1,68 +1,87 @@ package dev.inmo.jsuikit.modifiers -sealed class UIKitMargin(val classname: String) : UIKitModifier { - override val classes: Array = arrayOf(classname) +sealed class UIKitMargin(vararg classnames: String) : UIKitModifier { + @Suppress("UNCHECKED_CAST") + override val classes: Array = classnames as Array - object Top : Small("uk-margin-top") - object Bottom : Small("uk-margin-bottom") - object Left : Small("uk-margin-left") - object Right : Small("uk-margin-right") + object Top : UIKitMargin("uk-margin-top") + object Bottom : UIKitMargin("uk-margin-bottom") + object Left : UIKitMargin("uk-margin-left") + object Right : UIKitMargin("uk-margin-right") + object Vertical : UIKitMargin() { override val classes: Array = Top.classes + Bottom.classes } + object Horizontal : UIKitMargin() { override val classes: Array = Left.classes + Right.classes } companion object : Small("uk-margin") - sealed class Small(classname: String) : UIKitMargin(classname) { + sealed class Small(vararg classnames: String) : UIKitMargin(*classnames) { object Top : Small("uk-margin-small-top") object Bottom : Small("uk-margin-small-bottom") object Left : Small("uk-margin-small-left") object Right : Small("uk-margin-small-right") + + object Vertical : Small() { + override val classes: Array = Top.classes + Bottom.classes + } + object Horizontal : Small() { + override val classes: Array = Left.classes + Right.classes + } + companion object : Small("uk-margin-small") } - sealed class Medium(classname: String) : UIKitMargin(classname) { + sealed class Medium(vararg classnames: String) : UIKitMargin(*classnames) { object Top : Medium("uk-margin-medium-top") object Bottom : Medium("uk-margin-medium-bottom") object Left : Medium("uk-margin-medium-left") object Right : Medium("uk-margin-medium-right") + object Vertical : Medium() { override val classes: Array = Top.classes + Bottom.classes } + object Horizontal : Medium() { override val classes: Array = Left.classes + Right.classes } companion object : Medium("uk-margin-medium") } - sealed class Large(classname: String) : UIKitMargin(classname) { + sealed class Large(vararg classnames: String) : UIKitMargin(*classnames) { object Top : Large("uk-margin-large-top") object Bottom : Large("uk-margin-large-bottom") object Left : Large("uk-margin-large-left") object Right : Large("uk-margin-large-right") + object Vertical : Large() { override val classes: Array = Top.classes + Bottom.classes } + object Horizontal : Large() { override val classes: Array = Left.classes + Right.classes } companion object : Large("uk-margin-large") } - sealed class XLarge(classname: String) : UIKitMargin(classname) { + sealed class XLarge(vararg classnames: String) : UIKitMargin(*classnames) { object Top : XLarge("uk-margin-xlarge-top") object Bottom : XLarge("uk-margin-xlarge-bottom") object Left : XLarge("uk-margin-xlarge-left") object Right : XLarge("uk-margin-xlarge-right") + object Vertical : XLarge() { override val classes: Array = Top.classes + Bottom.classes } + object Horizontal : XLarge() { override val classes: Array = Left.classes + Right.classes } companion object : XLarge("uk-margin-xlarge") } - sealed class Auto(classname: String) : UIKitMargin(classname) { + sealed class Auto(vararg classnames: String) : UIKitMargin(*classnames) { object Top : Auto("uk-margin-auto-top") object Bottom : Auto("uk-margin-auto-bottom") object Left : Auto("uk-margin-auto-left") object Right : Auto("uk-margin-auto-right") object Vertical : Auto("uk-margin-auto-vertical") + object Horizontal : Auto() { override val classes: Array = Left.classes + Right.classes } companion object : Auto("uk-margin-auto") } - sealed class Remove(classname: String) : UIKitMargin(classname) { + sealed class Remove(vararg classnames: String) : UIKitMargin(*classnames) { object Top : Remove("uk-margin-remove-top") object Bottom : Remove("uk-margin-remove-bottom") object Left : Remove("uk-margin-remove-left") object Right : Remove("uk-margin-remove-right") object Vertical : Remove("uk-margin-remove-vertical") + object Horizontal : Remove() { override val classes: Array = Left.classes + Right.classes } object Adjacent : Remove("uk-margin-remove-adjacent") object FirstChild : Remove("uk-margin-remove-first-child") object LastChild : Remove("uk-margin-remove-last-child")