From 990bd6385ff27f62baed0c757bca73537805007d Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 19 May 2022 13:21:29 +0600 Subject: [PATCH 01/12] start 0.1.3 --- CHANGELOG.md | 2 ++ gradle.properties | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 411493a..e7e8afd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Changelog +## 0.1.3 + ## 0.1.2 * New typealias `AttrsWithContentBuilder` diff --git a/gradle.properties b/gradle.properties index 5053701..91e5a9e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,4 +9,4 @@ android.enableJetifier=true # Project data group=dev.inmo -version=0.1.2 +version=0.1.3 From 29efe4b5cd1339f26b581308d35788bc4f33f492 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 19 May 2022 13:21:39 +0600 Subject: [PATCH 02/12] Improve support of navbars --- CHANGELOG.md | 2 + .../dev/inmo/jsuikit/elements/Navbar.kt | 28 +++++-- .../inmo/jsuikit/elements/NavbarNavBuilder.kt | 6 +- .../dev/inmo/jsuikit/modifiers/UIKitNavbar.kt | 81 +++++++++++++++++-- 4 files changed, 99 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e7e8afd..1fa6cce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## 0.1.3 +* Improve support of navbars + ## 0.1.2 * New typealias `AttrsWithContentBuilder` diff --git a/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Navbar.kt b/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Navbar.kt index 5c94117..9cc5f44 100644 --- a/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Navbar.kt +++ b/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Navbar.kt @@ -1,11 +1,25 @@ package dev.inmo.jsuikit.elements import androidx.compose.runtime.Composable -import dev.inmo.jsuikit.modifiers.UIKitModifier -import dev.inmo.jsuikit.modifiers.include +import dev.inmo.jsuikit.modifiers.* import org.jetbrains.compose.web.dom.* import org.w3c.dom.HTMLElement +@Composable +fun Navbar( + attributesCustomizer: AttrBuilderContext = {}, + contentBuilder: ContentBuilder +) { + Nav( + { + include(UIKitNavbar, UIKitNavbar.Container) + attributesCustomizer() + } + ) { + contentBuilder + } +} + @Composable fun Navbar( leftBuilder: NavbarNavBuilder? = null, @@ -14,22 +28,20 @@ fun Navbar( vararg navModifiers: UIKitModifier, attributesCustomizer: AttrBuilderContext = {}, ) { - Nav( + Navbar( { - attr("uk-navbar", "") - classes("uk-navbar-container", "uk-navbar") include(*navModifiers) attributesCustomizer() } ) { leftBuilder ?.let { - Div({ classes("uk-navbar-left") }) { it.draw() } + Div({ include(UIKitNavbar.Alignment.Left) }) { it.draw() } } centerBuilder ?.let { - Div({ classes("uk-navbar-center") }) { it.draw() } + Div({ include(UIKitNavbar.Alignment.Center) }) { it.draw() } } rightBuilder ?.let { - Div({ classes("uk-navbar-right") }) { it.draw() } + Div({ include(UIKitNavbar.Alignment.Right) }) { it.draw() } } } } diff --git a/src/jsMain/kotlin/dev/inmo/jsuikit/elements/NavbarNavBuilder.kt b/src/jsMain/kotlin/dev/inmo/jsuikit/elements/NavbarNavBuilder.kt index 184293a..69e6ba7 100644 --- a/src/jsMain/kotlin/dev/inmo/jsuikit/elements/NavbarNavBuilder.kt +++ b/src/jsMain/kotlin/dev/inmo/jsuikit/elements/NavbarNavBuilder.kt @@ -1,8 +1,7 @@ package dev.inmo.jsuikit.elements import androidx.compose.runtime.Composable -import dev.inmo.jsuikit.modifiers.UIKitModifier -import dev.inmo.jsuikit.modifiers.include +import dev.inmo.jsuikit.modifiers.* import org.jetbrains.compose.web.attributes.AttrsScope import org.jetbrains.compose.web.dom.* import org.w3c.dom.HTMLLIElement @@ -46,8 +45,7 @@ class NavbarNavBuilder( fun draw() { Ul( { - classes("uk-navbar-nav") - include(*modifiers) + include(UIKitNavbar.Nav, *modifiers) attributesCustomizer() } ) { diff --git a/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitNavbar.kt b/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitNavbar.kt index a23932a..24c5046 100644 --- a/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitNavbar.kt +++ b/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitNavbar.kt @@ -1,17 +1,86 @@ package dev.inmo.jsuikit.modifiers -sealed class UIKitNavbar(suffix: String) : UIKitModifier { - override val classes: Array = arrayOf("uk-navbar-$suffix") +import dev.inmo.jsuikit.types.Dropdown +import dev.inmo.jsuikit.utils.* - object Transparent : UIKitNavbar("transparent") - sealed class Dropdown(suffix: String?) : UIKitNavbar("dropdown${suffix ?.let { "-$it" } ?: ""}") { +sealed class UIKitNavbar(vararg classes: String) : UIKitModifier { + override val classes: Array = classes as Array + + object Transparent : UIKitNavbar("uk-navbar-transparent") + object Container : UIKitNavbar("uk-navbar-container") + sealed class Dropdown(suffix: String?) : UIKitNavbar("uk-navbar-dropdown${suffix ?.let { "-$it" } ?: ""}") { object Nav : Dropdown("nav") + sealed class Width(suffix: String) : Dropdown(suffix) { + object Two : Width("width-2") + object Three : Width("width-3") + object Four : Width("width-4") + object Five : Width("width-5") + } + companion object : Dropdown(null) } - object Item : UIKitNavbar("item") + sealed class Alignment(val suffix: String) : UIKitNavbar("uk-navbar-$suffix") { + object Left : Alignment("left") + sealed class Center(suffix: String) : Alignment(suffix) { + object Left : Center("center-left") + object Right : Center("center-right") - companion object { + companion object : Center("center") + } + object Right : Alignment("right") + } + object Item : UIKitNavbar("uk-navbar-item") + object Nav : UIKitNavbar("uk-navbar-nav") + object Subtitle : UIKitNavbar("uk-navbar-subtitle") + object Toggle : UIKitNavbar("uk-navbar-toggle") + object Sticky : UIKitNavbar("uk-navbar-sticky") + + class Component internal constructor( + override val otherAttrs: Map + ) : UIKitNavbar(*UIKitNavbar.classes) + + companion object : UIKitNavbar("uk-navbar") { val Logo = UIKitUtility.Logo + + operator fun invoke( + align: String? = null, + mode: String? = null, + delayShow: Milliseconds? = null, + delayHide: Milliseconds? = null, + boundary: String? = null, + boundaryAlign: Boolean? = null, + offset: Pixels? = null, + dropbar: Boolean? = null, + duration: Milliseconds? = null + ): Component { + return Component( + mapOf( + buildAttribute(UIKitNavbar.classes.first()) { + "align" to align + "mode" to mode + "delay-show" to delayShow + "delay-hide" to delayHide + "boundary" to boundary + "boundary-align" to boundaryAlign + "offset" to offset + "dropbar" to dropbar + "duration" to duration + } + ) + ) + } + + operator fun invoke( + align: Alignment? = null, + mode: UIKitDropdown.Mode? = null, + delayShow: Milliseconds? = null, + delayHide: Milliseconds? = null, + boundary: String? = null, + boundaryAlign: Boolean? = null, + offset: Pixels? = null, + dropbar: Boolean? = null, + duration: Milliseconds? = null + ): Component = invoke(align ?.suffix, mode ?.name, delayShow, delayHide, boundary, boundaryAlign, offset, dropbar, duration) } } From 3afe6c2815feded9cf095c417187992524c85a7a Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 19 May 2022 13:42:21 +0600 Subject: [PATCH 03/12] add support of sections --- CHANGELOG.md | 1 + .../inmo/jsuikit/modifiers/UIKitSection.kt | 23 +++++++++++++++++++ .../inmo/jsuikit/modifiers/UIKitUtility.kt | 9 +++++++- 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitSection.kt diff --git a/CHANGELOG.md b/CHANGELOG.md index 1fa6cce..a2251e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## 0.1.3 +* Add support of sections * Improve support of navbars ## 0.1.2 diff --git a/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitSection.kt b/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitSection.kt new file mode 100644 index 0000000..46d1b90 --- /dev/null +++ b/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitSection.kt @@ -0,0 +1,23 @@ +package dev.inmo.jsuikit.modifiers + +sealed class UIKitSection(vararg classes: String) : UIKitModifier { + override val classes: Array = classes as Array + + sealed class Style(suffix: String) : UIKitSection("uk-section-$suffix") { + object Default : Style("default") + object Muted : Style("muted") + object Primary : Style("primary") + object Secondary : Style("secondary") + } + + sealed class Size(suffix: String) : UIKitSection("uk-section-$suffix") { + object XSmall : Size("xsmall") + object Small : Size("small") + object Large : Size("large") + object XLarge : Size("xlarge") + } + + object Overlap : UIKitSection("uk-section-overlap") + + companion object : UIKitSection("uk-section") +} diff --git a/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitUtility.kt b/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitUtility.kt index 515e0b7..e1c62f2 100644 --- a/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitUtility.kt +++ b/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitUtility.kt @@ -38,7 +38,10 @@ sealed class UIKitUtility(classname: String) : UIKitModifier { object Width : Responsive("width") object Height : Responsive("height") } - object PreserveWidth : UIKitUtility("uk-preserve-width") + sealed class Preserve(suffix: String) : UIKitUtility("uk-preserve-$suffix") { + object Width : Preserve("width") + object Color : Preserve("color") + } sealed class Border(suffix: String) : UIKitUtility("uk-border-$suffix") { object Rounded : Border("rounded") @@ -112,4 +115,8 @@ sealed class UIKitUtility(classname: String) : UIKitModifier { object Open : UIKitUtility("uk-open") object Link : UIKitUtility("uk-link") + + companion object { + val PreserveWidth = Preserve.Width + } } From d78acce3c522e609bab1ddeba1c5047196b55325 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 19 May 2022 14:15:05 +0600 Subject: [PATCH 04/12] add several builders for AttrsWithContentBuilder --- .../dev/inmo/jsuikit/elements/DropArea.kt | 2 +- .../jsuikit/utils/AttrsWithContentBuilder.kt | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/jsMain/kotlin/dev/inmo/jsuikit/elements/DropArea.kt b/src/jsMain/kotlin/dev/inmo/jsuikit/elements/DropArea.kt index 1a18195..dbfd41e 100644 --- a/src/jsMain/kotlin/dev/inmo/jsuikit/elements/DropArea.kt +++ b/src/jsMain/kotlin/dev/inmo/jsuikit/elements/DropArea.kt @@ -10,7 +10,7 @@ import org.w3c.dom.HTMLDivElement @Composable fun DropArea( attrs: Attrs = Attrs.empty(), - inputAttrs: InputAttrs = Attrs.empty(), + inputAttrs: InputAttrs = InputAttrs.empty(), contentBuilder: ContentBuilder = {} ) = Div( { diff --git a/src/jsMain/kotlin/dev/inmo/jsuikit/utils/AttrsWithContentBuilder.kt b/src/jsMain/kotlin/dev/inmo/jsuikit/utils/AttrsWithContentBuilder.kt index 5bef24b..77603ea 100644 --- a/src/jsMain/kotlin/dev/inmo/jsuikit/utils/AttrsWithContentBuilder.kt +++ b/src/jsMain/kotlin/dev/inmo/jsuikit/utils/AttrsWithContentBuilder.kt @@ -1,10 +1,32 @@ package dev.inmo.jsuikit.utils +import dev.inmo.jsuikit.modifiers.UIKitModifier +import org.jetbrains.compose.web.attributes.AttrsScope import org.jetbrains.compose.web.dom.ContentBuilder import org.w3c.dom.Element typealias AttrsWithContentBuilder = Pair, ContentBuilder> +@Suppress("NOTHING_TO_INLINE") +inline fun AttrsWithContentBuilder(noinline builder: ContentBuilder) = AttrsWithContentBuilder( + Attrs.empty(), + builder +) + +@Suppress("NOTHING_TO_INLINE") +inline fun AttrsWithContentBuilder(attrs: Attrs) = AttrsWithContentBuilder( + attrs +) {} + +@Suppress("NOTHING_TO_INLINE") +inline fun AttrsWithContentBuilder( + modifier: UIKitModifier?, + vararg modifiers: UIKitModifier?, + noinline attrs: AttrsScope.() -> Unit = {} +) = AttrsWithContentBuilder( + Attrs(modifier, *modifiers, attrs = attrs) +) + inline val AttrsWithContentBuilder.attrs get() = first From faf238cf07c96bdda0db2a7f8bb32f64e3abc64f Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 19 May 2022 14:38:35 +0600 Subject: [PATCH 05/12] fix in navbar --- src/jsMain/kotlin/dev/inmo/jsuikit/elements/Navbar.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Navbar.kt b/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Navbar.kt index 9cc5f44..d50fbf2 100644 --- a/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Navbar.kt +++ b/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Navbar.kt @@ -16,7 +16,7 @@ fun Navbar( attributesCustomizer() } ) { - contentBuilder + contentBuilder() } } From ec584798ad950f29a7408c970e25a0ce29e8c9d2 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 19 May 2022 15:23:04 +0600 Subject: [PATCH 06/12] Update Navbar.kt --- src/jsMain/kotlin/dev/inmo/jsuikit/elements/Navbar.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Navbar.kt b/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Navbar.kt index d50fbf2..8394059 100644 --- a/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Navbar.kt +++ b/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Navbar.kt @@ -12,7 +12,7 @@ fun Navbar( ) { Nav( { - include(UIKitNavbar, UIKitNavbar.Container) + include(UIKitNavbar, UIKitNavbar(), UIKitNavbar.Container) attributesCustomizer() } ) { From 6a652249c0b0d8c63375492a417ee9c58592f36c Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 19 May 2022 18:43:11 +0600 Subject: [PATCH 07/12] improvements and fixes in Navbar and NavbarNav parts --- .../dev/inmo/jsuikit/elements/Navbar.kt | 31 ++++++++++++++++++- .../inmo/jsuikit/elements/NavbarNavBuilder.kt | 21 +++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Navbar.kt b/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Navbar.kt index 8394059..ca54814 100644 --- a/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Navbar.kt +++ b/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Navbar.kt @@ -2,7 +2,9 @@ package dev.inmo.jsuikit.elements import androidx.compose.runtime.Composable import dev.inmo.jsuikit.modifiers.* +import dev.inmo.jsuikit.utils.* import org.jetbrains.compose.web.dom.* +import org.w3c.dom.HTMLDivElement import org.w3c.dom.HTMLElement @Composable @@ -20,9 +22,10 @@ fun Navbar( } } +@Deprecated("Will be removed soon. Use the variant with AttrsWithContentBuilders") @Composable fun Navbar( - leftBuilder: NavbarNavBuilder? = null, + leftBuilder: NavbarNavBuilder?, centerBuilder: NavbarNavBuilder? = null, rightBuilder: NavbarNavBuilder? = null, vararg navModifiers: UIKitModifier, @@ -45,3 +48,29 @@ fun Navbar( } } } + +@Composable +fun Navbar( + leftBuilder: AttrsWithContentBuilder? = null, + centerBuilder: AttrsWithContentBuilder? = null, + rightBuilder: AttrsWithContentBuilder? = null, + vararg navModifiers: UIKitModifier, + attributesCustomizer: AttrBuilderContext = {}, +) { + Navbar( + attributesCustomizer = { + include(*navModifiers) + attributesCustomizer() + } + ) { + leftBuilder ?.let { + Div({ include(UIKitNavbar.Alignment.Left);leftBuilder.attributesBuilderContext(this) }, leftBuilder.builder) + } + centerBuilder ?.let { + Div({ include(UIKitNavbar.Alignment.Center);centerBuilder.attributesBuilderContext(this) }, centerBuilder.builder) + } + rightBuilder ?.let { + Div({ include(UIKitNavbar.Alignment.Right);rightBuilder.attributesBuilderContext(this) }, rightBuilder.builder) + } + } +} diff --git a/src/jsMain/kotlin/dev/inmo/jsuikit/elements/NavbarNavBuilder.kt b/src/jsMain/kotlin/dev/inmo/jsuikit/elements/NavbarNavBuilder.kt index 69e6ba7..087ca47 100644 --- a/src/jsMain/kotlin/dev/inmo/jsuikit/elements/NavbarNavBuilder.kt +++ b/src/jsMain/kotlin/dev/inmo/jsuikit/elements/NavbarNavBuilder.kt @@ -2,11 +2,31 @@ package dev.inmo.jsuikit.elements import androidx.compose.runtime.Composable import dev.inmo.jsuikit.modifiers.* +import dev.inmo.jsuikit.utils.* import org.jetbrains.compose.web.attributes.AttrsScope import org.jetbrains.compose.web.dom.* import org.w3c.dom.HTMLLIElement import org.w3c.dom.HTMLUListElement +@Composable +fun NavbarNav( + elements: List>, + modifiers: List, + attributesCustomizer: AttrBuilderContext = {} +) { + Ul( + { + include(UIKitNavbar.Nav, *modifiers.toTypedArray()) + attributesCustomizer() + } + ) { + elements.forEach { element -> + Li(element.attributesBuilderContext, element.builder) + } + } +} + +@Deprecated("Will be removed soon. Use NavbarNavPart with AttrsWithContentBuilder instead") interface NavbarNavElement { fun AttrsScope.setup() {} @Composable @@ -27,6 +47,7 @@ interface NavbarNavElement { } } +@Deprecated("Will be removed soon. Use NavbarNavPart with AttrsWithContentBuilder instead") class NavbarNavBuilder( private val modifiers: Array, private val elements: List, From 816f34172908ebdd402fce024b2b521aca07a340 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 19 May 2022 18:44:19 +0600 Subject: [PATCH 08/12] fixes in UIKitNavbar invoke --- src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitNavbar.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitNavbar.kt b/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitNavbar.kt index 24c5046..9b2c318 100644 --- a/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitNavbar.kt +++ b/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitNavbar.kt @@ -44,7 +44,7 @@ sealed class UIKitNavbar(vararg classes: String) : UIKitModifier { val Logo = UIKitUtility.Logo operator fun invoke( - align: String? = null, + align: String?, mode: String? = null, delayShow: Milliseconds? = null, delayHide: Milliseconds? = null, From b028b12103af25115ba4e246d7733a5a9d0301c1 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 19 May 2022 18:47:03 +0600 Subject: [PATCH 09/12] small fixes in UIKitNav --- src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitNav.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitNav.kt b/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitNav.kt index 27c925a..5e8c34f 100644 --- a/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitNav.kt +++ b/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitNav.kt @@ -14,6 +14,8 @@ sealed class UIKitNav(classname: String) : UIKitModifier { object Center : UIKitNav("uk-nav-center") + object Sub : UIKitNav("uk-nav-sub") + companion object : UIKitNav("uk-nav") { val SubNav = UIKitSubNav } From abe44fe1c6fe079aa5a1e75ebfbe48cd9f19b5d1 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 19 May 2022 18:50:06 +0600 Subject: [PATCH 10/12] fixes in signature of NavbarNav fun --- .../kotlin/dev/inmo/jsuikit/elements/NavbarNavBuilder.kt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/jsMain/kotlin/dev/inmo/jsuikit/elements/NavbarNavBuilder.kt b/src/jsMain/kotlin/dev/inmo/jsuikit/elements/NavbarNavBuilder.kt index 087ca47..c0fdd07 100644 --- a/src/jsMain/kotlin/dev/inmo/jsuikit/elements/NavbarNavBuilder.kt +++ b/src/jsMain/kotlin/dev/inmo/jsuikit/elements/NavbarNavBuilder.kt @@ -11,13 +11,12 @@ import org.w3c.dom.HTMLUListElement @Composable fun NavbarNav( elements: List>, - modifiers: List, - attributesCustomizer: AttrBuilderContext = {} + attrs: Attrs = Attrs.empty() ) { Ul( { - include(UIKitNavbar.Nav, *modifiers.toTypedArray()) - attributesCustomizer() + include(UIKitNavbar.Nav) + attrs.builder(this) } ) { elements.forEach { element -> From 67a6998f02710db42ea61acad479720c9cf723eb Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 19 May 2022 18:50:43 +0600 Subject: [PATCH 11/12] add new variant of NavbarNav --- .../kotlin/dev/inmo/jsuikit/elements/NavbarNavBuilder.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/jsMain/kotlin/dev/inmo/jsuikit/elements/NavbarNavBuilder.kt b/src/jsMain/kotlin/dev/inmo/jsuikit/elements/NavbarNavBuilder.kt index c0fdd07..b919dc1 100644 --- a/src/jsMain/kotlin/dev/inmo/jsuikit/elements/NavbarNavBuilder.kt +++ b/src/jsMain/kotlin/dev/inmo/jsuikit/elements/NavbarNavBuilder.kt @@ -25,6 +25,12 @@ fun NavbarNav( } } +@Composable +fun NavbarNav( + vararg elements: AttrsWithContentBuilder, + attrs: Attrs = Attrs.empty() +) = NavbarNav(elements.toList(), attrs) + @Deprecated("Will be removed soon. Use NavbarNavPart with AttrsWithContentBuilder instead") interface NavbarNavElement { fun AttrsScope.setup() {} From 53b020ab8d5d4ca6a5b948bcae31c6d2fa55bdf8 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 19 May 2022 18:56:52 +0600 Subject: [PATCH 12/12] improve AttrsWithContentBuilder functions --- .../jsuikit/utils/AttrsWithContentBuilder.kt | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/jsMain/kotlin/dev/inmo/jsuikit/utils/AttrsWithContentBuilder.kt b/src/jsMain/kotlin/dev/inmo/jsuikit/utils/AttrsWithContentBuilder.kt index 77603ea..f96a0b4 100644 --- a/src/jsMain/kotlin/dev/inmo/jsuikit/utils/AttrsWithContentBuilder.kt +++ b/src/jsMain/kotlin/dev/inmo/jsuikit/utils/AttrsWithContentBuilder.kt @@ -8,8 +8,12 @@ import org.w3c.dom.Element typealias AttrsWithContentBuilder = Pair, ContentBuilder> @Suppress("NOTHING_TO_INLINE") -inline fun AttrsWithContentBuilder(noinline builder: ContentBuilder) = AttrsWithContentBuilder( - Attrs.empty(), +inline fun AttrsWithContentBuilder( + vararg modifiers: UIKitModifier?, + noinline attrs: AttrsScope.() -> Unit = {}, + noinline builder: ContentBuilder +) = AttrsWithContentBuilder( + Attrs(*modifiers, attrs = attrs), builder ) @@ -18,15 +22,6 @@ inline fun AttrsWithContentBuilder(attrs: Attrs) = AttrsWithCon attrs ) {} -@Suppress("NOTHING_TO_INLINE") -inline fun AttrsWithContentBuilder( - modifier: UIKitModifier?, - vararg modifiers: UIKitModifier?, - noinline attrs: AttrsScope.() -> Unit = {} -) = AttrsWithContentBuilder( - Attrs(modifier, *modifiers, attrs = attrs) -) - inline val AttrsWithContentBuilder.attrs get() = first