Compare commits

..

No commits in common. "53b020ab8d5d4ca6a5b948bcae31c6d2fa55bdf8" and "ec584798ad950f29a7408c970e25a0ce29e8c9d2" have entirely different histories.

5 changed files with 13 additions and 65 deletions

View File

@ -2,9 +2,7 @@ package dev.inmo.jsuikit.elements
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import dev.inmo.jsuikit.modifiers.* import dev.inmo.jsuikit.modifiers.*
import dev.inmo.jsuikit.utils.*
import org.jetbrains.compose.web.dom.* import org.jetbrains.compose.web.dom.*
import org.w3c.dom.HTMLDivElement
import org.w3c.dom.HTMLElement import org.w3c.dom.HTMLElement
@Composable @Composable
@ -22,10 +20,9 @@ fun Navbar(
} }
} }
@Deprecated("Will be removed soon. Use the variant with AttrsWithContentBuilders")
@Composable @Composable
fun Navbar( fun Navbar(
leftBuilder: NavbarNavBuilder?, leftBuilder: NavbarNavBuilder? = null,
centerBuilder: NavbarNavBuilder? = null, centerBuilder: NavbarNavBuilder? = null,
rightBuilder: NavbarNavBuilder? = null, rightBuilder: NavbarNavBuilder? = null,
vararg navModifiers: UIKitModifier, vararg navModifiers: UIKitModifier,
@ -48,29 +45,3 @@ fun Navbar(
} }
} }
} }
@Composable
fun Navbar(
leftBuilder: AttrsWithContentBuilder<HTMLDivElement>? = null,
centerBuilder: AttrsWithContentBuilder<HTMLDivElement>? = null,
rightBuilder: AttrsWithContentBuilder<HTMLDivElement>? = null,
vararg navModifiers: UIKitModifier,
attributesCustomizer: AttrBuilderContext<HTMLElement> = {},
) {
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)
}
}
}

View File

@ -2,36 +2,11 @@ package dev.inmo.jsuikit.elements
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import dev.inmo.jsuikit.modifiers.* import dev.inmo.jsuikit.modifiers.*
import dev.inmo.jsuikit.utils.*
import org.jetbrains.compose.web.attributes.AttrsScope import org.jetbrains.compose.web.attributes.AttrsScope
import org.jetbrains.compose.web.dom.* import org.jetbrains.compose.web.dom.*
import org.w3c.dom.HTMLLIElement import org.w3c.dom.HTMLLIElement
import org.w3c.dom.HTMLUListElement import org.w3c.dom.HTMLUListElement
@Composable
fun NavbarNav(
elements: List<AttrsWithContentBuilder<HTMLLIElement>>,
attrs: Attrs<HTMLUListElement> = Attrs.empty()
) {
Ul(
{
include(UIKitNavbar.Nav)
attrs.builder(this)
}
) {
elements.forEach { element ->
Li(element.attributesBuilderContext, element.builder)
}
}
}
@Composable
fun NavbarNav(
vararg elements: AttrsWithContentBuilder<HTMLLIElement>,
attrs: Attrs<HTMLUListElement> = Attrs.empty()
) = NavbarNav(elements.toList(), attrs)
@Deprecated("Will be removed soon. Use NavbarNavPart with AttrsWithContentBuilder instead")
interface NavbarNavElement { interface NavbarNavElement {
fun AttrsScope<HTMLLIElement>.setup() {} fun AttrsScope<HTMLLIElement>.setup() {}
@Composable @Composable
@ -52,7 +27,6 @@ interface NavbarNavElement {
} }
} }
@Deprecated("Will be removed soon. Use NavbarNavPart with AttrsWithContentBuilder instead")
class NavbarNavBuilder( class NavbarNavBuilder(
private val modifiers: Array<UIKitModifier>, private val modifiers: Array<UIKitModifier>,
private val elements: List<NavbarNavElement>, private val elements: List<NavbarNavElement>,

View File

@ -14,8 +14,6 @@ sealed class UIKitNav(classname: String) : UIKitModifier {
object Center : UIKitNav("uk-nav-center") object Center : UIKitNav("uk-nav-center")
object Sub : UIKitNav("uk-nav-sub")
companion object : UIKitNav("uk-nav") { companion object : UIKitNav("uk-nav") {
val SubNav = UIKitSubNav val SubNav = UIKitSubNav
} }

View File

@ -44,7 +44,7 @@ sealed class UIKitNavbar(vararg classes: String) : UIKitModifier {
val Logo = UIKitUtility.Logo val Logo = UIKitUtility.Logo
operator fun invoke( operator fun invoke(
align: String?, align: String? = null,
mode: String? = null, mode: String? = null,
delayShow: Milliseconds? = null, delayShow: Milliseconds? = null,
delayHide: Milliseconds? = null, delayHide: Milliseconds? = null,

View File

@ -8,12 +8,8 @@ import org.w3c.dom.Element
typealias AttrsWithContentBuilder<T> = Pair<Attrs<T>, ContentBuilder<T>> typealias AttrsWithContentBuilder<T> = Pair<Attrs<T>, ContentBuilder<T>>
@Suppress("NOTHING_TO_INLINE") @Suppress("NOTHING_TO_INLINE")
inline fun <T : Element> AttrsWithContentBuilder( inline fun <T : Element> AttrsWithContentBuilder(noinline builder: ContentBuilder<T>) = AttrsWithContentBuilder(
vararg modifiers: UIKitModifier?, Attrs.empty(),
noinline attrs: AttrsScope<T>.() -> Unit = {},
noinline builder: ContentBuilder<T>
) = AttrsWithContentBuilder(
Attrs(*modifiers, attrs = attrs),
builder builder
) )
@ -22,6 +18,15 @@ inline fun <T : Element> AttrsWithContentBuilder(attrs: Attrs<T>) = AttrsWithCon
attrs attrs
) {} ) {}
@Suppress("NOTHING_TO_INLINE")
inline fun <T : Element> AttrsWithContentBuilder(
modifier: UIKitModifier?,
vararg modifiers: UIKitModifier?,
noinline attrs: AttrsScope<T>.() -> Unit = {}
) = AttrsWithContentBuilder(
Attrs(modifier, *modifiers, attrs = attrs)
)
inline val <T : Element> AttrsWithContentBuilder<T>.attrs inline val <T : Element> AttrsWithContentBuilder<T>.attrs
get() = first get() = first