diff --git a/CHANGELOG.md b/CHANGELOG.md index 2499d62..f330600 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## 0.0.11 +* Upfill `Nav` and `UIKitNav` + ## 0.0.10 * Filling of `UIKitUtility` diff --git a/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Nav.kt b/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Nav.kt index db843f1..1f66ddf 100644 --- a/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Nav.kt +++ b/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Nav.kt @@ -27,8 +27,7 @@ fun Nav( "animation" to animation "duration" to duration ?.toString() } - classes("uk-nav") - include(*modifiers) + include(*modifiers, UIKitNav) attributesCustomizer() } ) { @@ -36,6 +35,63 @@ fun Nav( } } +@Composable +fun DefaultNav( + vararg modifiers: UIKitModifier, + multiple: Boolean? = null, + collapsible: Boolean? = null, + animation: UIKitAnimation? = null, + duration: Milliseconds? = null, + attributesCustomizer: AttrBuilderContext = {}, + dataAllocator: ContentBuilder +) = Nav( + modifiers = modifiers + UIKitNav.Default, + multiple, + collapsible, + animation, + duration, + attributesCustomizer, + dataAllocator +) + +@Composable +fun PrimaryNav( + vararg modifiers: UIKitModifier, + multiple: Boolean? = null, + collapsible: Boolean? = null, + animation: UIKitAnimation? = null, + duration: Milliseconds? = null, + attributesCustomizer: AttrBuilderContext = {}, + dataAllocator: ContentBuilder +) = Nav( + modifiers = modifiers + UIKitNav.Primary, + multiple, + collapsible, + animation, + duration, + attributesCustomizer, + dataAllocator +) + +@Composable +fun SubNav( + vararg modifiers: UIKitModifier, + multiple: Boolean? = null, + collapsible: Boolean? = null, + animation: UIKitAnimation? = null, + duration: Milliseconds? = null, + attributesCustomizer: AttrBuilderContext = {}, + dataAllocator: ContentBuilder +) = Nav( + modifiers = modifiers + UIKitNav.SubNav, + multiple, + collapsible, + animation, + duration, + attributesCustomizer, + dataAllocator +) + @Composable fun Nav( title: String, @@ -59,8 +115,7 @@ fun Nav( "animation" to animation "duration" to duration ?.toString() } - classes("uk-nav") - include(*ulModifiers) + include(*ulModifiers, UIKitNav) ulCustomizer() } ) { @@ -76,6 +131,93 @@ fun Nav( } } +@Composable +fun DefaultNav( + title: String, + data: SnapshotStateList, + vararg ulModifiers: UIKitModifier, + titleModifiers: Array = emptyArray(), + multiple: Boolean? = null, + collapsible: Boolean? = null, + animation: UIKitAnimation? = null, + duration: Milliseconds? = null, + besidesTitleAndList: ContentBuilder? = null, + titleCustomizer: AttrBuilderContext = {}, + ulCustomizer: AttrBuilderContext = {}, + elementAllocator: @Composable ElementScope.(T) -> Unit +) = Nav( + title, + data, + ulModifiers = ulModifiers + UIKitNav.Default, + titleModifiers, + multiple, + collapsible, + animation, + duration, + besidesTitleAndList, + titleCustomizer, + ulCustomizer, + elementAllocator +) + +@Composable +fun PrimaryNav( + title: String, + data: SnapshotStateList, + vararg ulModifiers: UIKitModifier, + titleModifiers: Array = emptyArray(), + multiple: Boolean? = null, + collapsible: Boolean? = null, + animation: UIKitAnimation? = null, + duration: Milliseconds? = null, + besidesTitleAndList: ContentBuilder? = null, + titleCustomizer: AttrBuilderContext = {}, + ulCustomizer: AttrBuilderContext = {}, + elementAllocator: @Composable ElementScope.(T) -> Unit +) = Nav( + title, + data, + ulModifiers = ulModifiers + UIKitNav.Primary, + titleModifiers, + multiple, + collapsible, + animation, + duration, + besidesTitleAndList, + titleCustomizer, + ulCustomizer, + elementAllocator +) + +@Composable +fun SubNav( + title: String, + data: SnapshotStateList, + vararg ulModifiers: UIKitModifier, + titleModifiers: Array = emptyArray(), + multiple: Boolean? = null, + collapsible: Boolean? = null, + animation: UIKitAnimation? = null, + duration: Milliseconds? = null, + besidesTitleAndList: ContentBuilder? = null, + titleCustomizer: AttrBuilderContext = {}, + ulCustomizer: AttrBuilderContext = {}, + elementAllocator: @Composable ElementScope.(T) -> Unit +) = Nav( + title, + data, + ulModifiers = ulModifiers + UIKitNav.SubNav, + titleModifiers, + multiple, + collapsible, + animation, + duration, + besidesTitleAndList, + titleCustomizer, + ulCustomizer, + elementAllocator +) + @Composable fun NavHeader( text: String, @@ -92,6 +234,24 @@ fun NavHeader( } } +@Composable +fun NavItemElement( + vararg modifiers: UIKitModifier, + attributesCustomizer: AttrBuilderContext = {}, + contentAllocator: ContentBuilder +) { + Li( + { + include(*modifiers) + attributesCustomizer() + } + ) { + A("#") { + contentAllocator() + } + } +} + @Composable fun NavElement( vararg modifiers: UIKitModifier, diff --git a/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitNav.kt b/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitNav.kt index deb9aad..37c815e 100644 --- a/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitNav.kt +++ b/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitNav.kt @@ -3,8 +3,8 @@ package dev.inmo.jsuikit.modifiers sealed class UIKitNav(classname: String) : UIKitModifier { override val classes: Array = arrayOf(classname) - object Accordion : UIKitNav("uk-nav-parent-icon") - object Subnav : UIKitNav("uk-nav-sub") + object ParentIcon : UIKitNav("uk-nav-parent-icon") + object SubNav : UIKitNav("uk-nav-sub") object Header : UIKitNav("uk-nav-header") object Divider : UIKitNav("uk-nav-divider") @@ -14,4 +14,6 @@ sealed class UIKitNav(classname: String) : UIKitModifier { object Primary : UIKitNav("uk-nav-primary") object Center : UIKitNav("uk-nav-center") + + companion object : UIKitNav("uk-nav") }