From d5045bdba7c92cd6531cae2777028b01bc7b8a6f Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 30 Mar 2022 16:40:51 +0600 Subject: [PATCH 1/6] start 0.0.48 --- CHANGELOG.md | 2 ++ gradle.properties | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e77a6d..eba9c81 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Changelog +## 0.0.48 + ## 0.0.47 * Add support of `Close` element diff --git a/gradle.properties b/gradle.properties index 16a4a5c..5d89877 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,4 +9,4 @@ android.enableJetifier=true # Project data group=dev.inmo -version=0.0.47 +version=0.0.48 From e6b0ca580a7ac89d3dece519ca68ce5f2f9312d3 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 30 Mar 2022 16:41:07 +0600 Subject: [PATCH 2/6] support of breadcrumb --- CHANGELOG.md | 2 + .../dev/inmo/jsuikit/elements/Breadcrumb.kt | 50 +++++++++++++++++++ .../inmo/jsuikit/modifiers/UIKitBreadcrumb.kt | 8 +++ 3 files changed, 60 insertions(+) create mode 100644 src/jsMain/kotlin/dev/inmo/jsuikit/elements/Breadcrumb.kt create mode 100644 src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitBreadcrumb.kt diff --git a/CHANGELOG.md b/CHANGELOG.md index eba9c81..190de63 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## 0.0.48 +* Added support of `Breadcrumb` + ## 0.0.47 * Add support of `Close` element diff --git a/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Breadcrumb.kt b/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Breadcrumb.kt new file mode 100644 index 0000000..ab2751d --- /dev/null +++ b/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Breadcrumb.kt @@ -0,0 +1,50 @@ +package dev.inmo.jsuikit.elements + +import androidx.compose.runtime.Composable +import dev.inmo.jsuikit.modifiers.UIKitBreadcrumb +import dev.inmo.jsuikit.modifiers.include +import dev.inmo.jsuikit.utils.Attrs +import org.jetbrains.compose.web.dom.* +import org.w3c.dom.* + +@Composable +fun Breadcrumb( + data: Iterable, + rootAttrs: Attrs = Attrs.empty(), + elementAttrs: Attrs = Attrs.empty(), + elementContent: @Composable ElementScope.(T) -> Unit = {}, +) { + Ul( + { + include(UIKitBreadcrumb) + rootAttrs.builder(this) + } + ) { + data.forEach { + Li({ elementAttrs.builder(this) }) { + elementContent(it) + } + } + } +} + +@Composable +fun BreadcrumbActiveElement( + href: String? = "#", + elementAttrs: Attrs = Attrs.empty(), + elementContent: @Composable ElementScope.() -> Unit = {}, +) { + A(href, { elementAttrs.builder(this) }) { + elementContent() + } +} + +@Composable +fun BreadcrumbInactiveElement( + elementAttrs: Attrs = Attrs.empty(), + elementContent: @Composable ElementScope.() -> Unit = {}, +) { + Span({ elementAttrs.builder(this) }) { + elementContent() + } +} diff --git a/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitBreadcrumb.kt b/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitBreadcrumb.kt new file mode 100644 index 0000000..42c9ad9 --- /dev/null +++ b/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitBreadcrumb.kt @@ -0,0 +1,8 @@ +package dev.inmo.jsuikit.modifiers + +sealed class UIKitBreadcrumb( + override val classes: Array = emptyArray(), + override val otherAttrs: Map = emptyMap() +) : UIKitModifier { + companion object : UIKitBreadcrumb(arrayOf("uk-breadcrumb")) +} From 33b1a7af6548290b36e1e2b96a5e00f14b6f0b1a Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 30 Mar 2022 20:33:19 +0600 Subject: [PATCH 3/6] fixes in dropdown position --- src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitDropdown.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitDropdown.kt b/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitDropdown.kt index b1374b0..2aef2d5 100644 --- a/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitDropdown.kt +++ b/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitDropdown.kt @@ -43,6 +43,8 @@ sealed class UIKitDropdown(classname: String) : UIKitModifier { } + override fun toString(): String = name + } sealed class Mode(name: String) : AttributeValue(name) { From 82f00fa23b88853ac136017915bdc73062aafbd2 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 30 Mar 2022 20:48:38 +0600 Subject: [PATCH 4/6] All attribute values now will print their name as result of toString --- .../kotlin/dev/inmo/jsuikit/modifiers/AttributeValue.kt | 4 +++- src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitDropdown.kt | 2 -- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/AttributeValue.kt b/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/AttributeValue.kt index 1db9ac2..7bf209c 100644 --- a/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/AttributeValue.kt +++ b/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/AttributeValue.kt @@ -1,3 +1,5 @@ package dev.inmo.jsuikit.modifiers -sealed class AttributeValue(val name: String) +sealed class AttributeValue(val name: String) { + override fun toString(): String = name +} diff --git a/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitDropdown.kt b/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitDropdown.kt index 2aef2d5..b1374b0 100644 --- a/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitDropdown.kt +++ b/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitDropdown.kt @@ -43,8 +43,6 @@ sealed class UIKitDropdown(classname: String) : UIKitModifier { } - override fun toString(): String = name - } sealed class Mode(name: String) : AttributeValue(name) { From b177760c737730532ac7072331ac2e75c1c426b6 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 30 Mar 2022 21:08:29 +0600 Subject: [PATCH 5/6] add UIKDropdown#Mode for none and hover and click --- src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitDropdown.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitDropdown.kt b/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitDropdown.kt index b1374b0..b1f4f1b 100644 --- a/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitDropdown.kt +++ b/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitDropdown.kt @@ -50,6 +50,9 @@ sealed class UIKitDropdown(classname: String) : UIKitModifier { object Click : Mode("click") object Hover : Mode("hover") + object None : Mode("") + object HoverAndClick : Mode("$Hover, $Click") + } sealed class Flip(name: String) : AttributeValue(name) { From be4d63f0e0187a4610a1a3b0e2b97bb58b6b67e8 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 31 Mar 2022 09:12:01 +0600 Subject: [PATCH 6/6] improvements in UIKitModifier tools --- CHANGELOG.md | 2 ++ .../dev/inmo/jsuikit/modifiers/UIKitModifier.kt | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 190de63..be2f8e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,8 @@ ## 0.0.48 * Added support of `Breadcrumb` +* Add opportunity to summarize `UIKitModifier` +* Add opportunity to simply create attributes builder using `UIKitModifier` of array of them ## 0.0.47 diff --git a/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitModifier.kt b/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitModifier.kt index 0e826e0..bfffeb6 100644 --- a/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitModifier.kt +++ b/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitModifier.kt @@ -1,6 +1,9 @@ package dev.inmo.jsuikit.modifiers +import dev.inmo.jsuikit.utils.Attrs import org.jetbrains.compose.web.attributes.AttrsScope +import org.jetbrains.compose.web.dom.AttrBuilderContext +import org.w3c.dom.Element interface UIKitModifier { val classes: Array @@ -15,3 +18,16 @@ fun AttrsScope<*>.include(vararg container: UIKitModifier?) { it ?.otherAttrs ?.let { attrs -> attrs.forEach { (k, v) -> attr(k, v) } } } } + +fun UIKitModifier.asAttributesBuilder(): AttrBuilderContext = { + include(this@asAttributesBuilder) +} +operator fun UIKitModifier.plus(other: UIKitModifier): UIKitModifier = UIKitCustom( + classes + other.classes, + otherAttrs + other.otherAttrs +) +fun UIKitModifier.builder() = Attrs(this).builder +fun Array.builder() = Attrs(*this).builder +inline fun attrsBuilder(vararg modifiers: UIKitModifier) = modifiers.builder() +@JsName("plusBuilder") +operator fun UIKitModifier.plus(other: UIKitModifier): AttrBuilderContext = Attrs(this@plus, other).builder