add opportunity to customize default header content of nav

This commit is contained in:
InsanusMokrassar 2022-04-03 23:58:08 +06:00
parent 18ffabf76d
commit 2ece25ef4e
2 changed files with 13 additions and 2 deletions

View File

@ -2,6 +2,8 @@
## 0.0.50 ## 0.0.50
* Add opportunity to customize content in title of `Nav` after text
## 0.0.49 ## 0.0.49
* Now it is possible to use optional title in navs builders * Now it is possible to use optional title in navs builders

View File

@ -1,7 +1,6 @@
package dev.inmo.jsuikit.elements package dev.inmo.jsuikit.elements
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.snapshots.SnapshotStateList
import dev.inmo.jsuikit.buildAndAddAttribute import dev.inmo.jsuikit.buildAndAddAttribute
import dev.inmo.jsuikit.modifiers.* import dev.inmo.jsuikit.modifiers.*
import dev.inmo.jsuikit.utils.Milliseconds import dev.inmo.jsuikit.utils.Milliseconds
@ -104,6 +103,7 @@ fun <T> Nav(
duration: Milliseconds? = null, duration: Milliseconds? = null,
besidesTitleAndList: ContentBuilder<HTMLUListElement>? = null, besidesTitleAndList: ContentBuilder<HTMLUListElement>? = null,
titleCustomizer: AttrBuilderContext<HTMLLIElement> = {}, titleCustomizer: AttrBuilderContext<HTMLLIElement> = {},
afterTitleBuilder: ContentBuilder<HTMLLIElement> = {},
ulCustomizer: AttrBuilderContext<HTMLUListElement> = {}, ulCustomizer: AttrBuilderContext<HTMLUListElement> = {},
elementAllocator: @Composable ElementScope<HTMLUListElement>.(T) -> Unit elementAllocator: @Composable ElementScope<HTMLUListElement>.(T) -> Unit
) { ) {
@ -123,7 +123,8 @@ fun <T> Nav(
NavHeader( NavHeader(
title, title,
*titleModifiers, *titleModifiers,
attributesCustomizer = titleCustomizer attributesCustomizer = titleCustomizer,
afterTitleContentBuilder = afterTitleBuilder
) )
} }
besidesTitleAndList ?.let { it() } besidesTitleAndList ?.let { it() }
@ -145,6 +146,7 @@ fun <T> DefaultNav(
duration: Milliseconds? = null, duration: Milliseconds? = null,
besidesTitleAndList: ContentBuilder<HTMLUListElement>? = null, besidesTitleAndList: ContentBuilder<HTMLUListElement>? = null,
titleCustomizer: AttrBuilderContext<HTMLLIElement> = {}, titleCustomizer: AttrBuilderContext<HTMLLIElement> = {},
afterTitleBuilder: ContentBuilder<HTMLLIElement> = {},
ulCustomizer: AttrBuilderContext<HTMLUListElement> = {}, ulCustomizer: AttrBuilderContext<HTMLUListElement> = {},
elementAllocator: @Composable ElementScope<HTMLUListElement>.(T) -> Unit elementAllocator: @Composable ElementScope<HTMLUListElement>.(T) -> Unit
) = Nav( ) = Nav(
@ -158,6 +160,7 @@ fun <T> DefaultNav(
duration, duration,
besidesTitleAndList, besidesTitleAndList,
titleCustomizer, titleCustomizer,
afterTitleBuilder,
ulCustomizer, ulCustomizer,
elementAllocator elementAllocator
) )
@ -174,6 +177,7 @@ fun <T> PrimaryNav(
duration: Milliseconds? = null, duration: Milliseconds? = null,
besidesTitleAndList: ContentBuilder<HTMLUListElement>? = null, besidesTitleAndList: ContentBuilder<HTMLUListElement>? = null,
titleCustomizer: AttrBuilderContext<HTMLLIElement> = {}, titleCustomizer: AttrBuilderContext<HTMLLIElement> = {},
afterTitleBuilder: ContentBuilder<HTMLLIElement> = {},
ulCustomizer: AttrBuilderContext<HTMLUListElement> = {}, ulCustomizer: AttrBuilderContext<HTMLUListElement> = {},
elementAllocator: @Composable ElementScope<HTMLUListElement>.(T) -> Unit elementAllocator: @Composable ElementScope<HTMLUListElement>.(T) -> Unit
) = Nav( ) = Nav(
@ -187,6 +191,7 @@ fun <T> PrimaryNav(
duration, duration,
besidesTitleAndList, besidesTitleAndList,
titleCustomizer, titleCustomizer,
afterTitleBuilder,
ulCustomizer, ulCustomizer,
elementAllocator elementAllocator
) )
@ -203,6 +208,7 @@ fun <T> SubNav(
duration: Milliseconds? = null, duration: Milliseconds? = null,
besidesTitleAndList: ContentBuilder<HTMLUListElement>? = null, besidesTitleAndList: ContentBuilder<HTMLUListElement>? = null,
titleCustomizer: AttrBuilderContext<HTMLLIElement> = {}, titleCustomizer: AttrBuilderContext<HTMLLIElement> = {},
afterTitleBuilder: ContentBuilder<HTMLLIElement> = {},
ulCustomizer: AttrBuilderContext<HTMLUListElement> = {}, ulCustomizer: AttrBuilderContext<HTMLUListElement> = {},
elementAllocator: @Composable ElementScope<HTMLUListElement>.(T) -> Unit elementAllocator: @Composable ElementScope<HTMLUListElement>.(T) -> Unit
) = Nav( ) = Nav(
@ -216,6 +222,7 @@ fun <T> SubNav(
duration, duration,
besidesTitleAndList, besidesTitleAndList,
titleCustomizer, titleCustomizer,
afterTitleBuilder,
ulCustomizer, ulCustomizer,
elementAllocator elementAllocator
) )
@ -225,6 +232,7 @@ fun NavHeader(
text: String, text: String,
vararg modifiers: UIKitModifier, vararg modifiers: UIKitModifier,
attributesCustomizer: AttrBuilderContext<HTMLLIElement> = {}, attributesCustomizer: AttrBuilderContext<HTMLLIElement> = {},
afterTitleContentBuilder: ContentBuilder<HTMLLIElement> = {}
) { ) {
Li( Li(
{ {
@ -233,6 +241,7 @@ fun NavHeader(
} }
) { ) {
Text(text) Text(text)
afterTitleContentBuilder()
} }
} }