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,