mirror of
https://github.com/InsanusMokrassar/JSUIKitKBindings.git
synced 2024-11-23 02:28:47 +00:00
commit
a756bab2a6
@ -1,5 +1,11 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 0.0.48
|
||||||
|
|
||||||
|
* Added support of `Breadcrumb`
|
||||||
|
* Add opportunity to summarize `UIKitModifier`
|
||||||
|
* Add opportunity to simply create attributes builder using `UIKitModifier` of array of them
|
||||||
|
|
||||||
## 0.0.47
|
## 0.0.47
|
||||||
|
|
||||||
* Add support of `Close` element
|
* Add support of `Close` element
|
||||||
|
@ -9,4 +9,4 @@ android.enableJetifier=true
|
|||||||
# Project data
|
# Project data
|
||||||
|
|
||||||
group=dev.inmo
|
group=dev.inmo
|
||||||
version=0.0.47
|
version=0.0.48
|
||||||
|
50
src/jsMain/kotlin/dev/inmo/jsuikit/elements/Breadcrumb.kt
Normal file
50
src/jsMain/kotlin/dev/inmo/jsuikit/elements/Breadcrumb.kt
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
package dev.inmo.jsuikit.elements
|
||||||
|
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import dev.inmo.jsuikit.modifiers.UIKitBreadcrumb
|
||||||
|
import dev.inmo.jsuikit.modifiers.include
|
||||||
|
import dev.inmo.jsuikit.utils.Attrs
|
||||||
|
import org.jetbrains.compose.web.dom.*
|
||||||
|
import org.w3c.dom.*
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun <T> Breadcrumb(
|
||||||
|
data: Iterable<T>,
|
||||||
|
rootAttrs: Attrs<HTMLUListElement> = Attrs.empty(),
|
||||||
|
elementAttrs: Attrs<HTMLLIElement> = Attrs.empty(),
|
||||||
|
elementContent: @Composable ElementScope<HTMLLIElement>.(T) -> Unit = {},
|
||||||
|
) {
|
||||||
|
Ul(
|
||||||
|
{
|
||||||
|
include(UIKitBreadcrumb)
|
||||||
|
rootAttrs.builder(this)
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
data.forEach {
|
||||||
|
Li({ elementAttrs.builder(this) }) {
|
||||||
|
elementContent(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun BreadcrumbActiveElement(
|
||||||
|
href: String? = "#",
|
||||||
|
elementAttrs: Attrs<HTMLAnchorElement> = Attrs.empty(),
|
||||||
|
elementContent: @Composable ElementScope<HTMLAnchorElement>.() -> Unit = {},
|
||||||
|
) {
|
||||||
|
A(href, { elementAttrs.builder(this) }) {
|
||||||
|
elementContent()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun BreadcrumbInactiveElement(
|
||||||
|
elementAttrs: Attrs<HTMLSpanElement> = Attrs.empty(),
|
||||||
|
elementContent: @Composable ElementScope<HTMLSpanElement>.() -> Unit = {},
|
||||||
|
) {
|
||||||
|
Span({ elementAttrs.builder(this) }) {
|
||||||
|
elementContent()
|
||||||
|
}
|
||||||
|
}
|
@ -1,3 +1,5 @@
|
|||||||
package dev.inmo.jsuikit.modifiers
|
package dev.inmo.jsuikit.modifiers
|
||||||
|
|
||||||
sealed class AttributeValue(val name: String)
|
sealed class AttributeValue(val name: String) {
|
||||||
|
override fun toString(): String = name
|
||||||
|
}
|
||||||
|
@ -0,0 +1,8 @@
|
|||||||
|
package dev.inmo.jsuikit.modifiers
|
||||||
|
|
||||||
|
sealed class UIKitBreadcrumb(
|
||||||
|
override val classes: Array<String> = emptyArray(),
|
||||||
|
override val otherAttrs: Map<String, String> = emptyMap()
|
||||||
|
) : UIKitModifier {
|
||||||
|
companion object : UIKitBreadcrumb(arrayOf("uk-breadcrumb"))
|
||||||
|
}
|
@ -50,6 +50,9 @@ sealed class UIKitDropdown(classname: String) : UIKitModifier {
|
|||||||
object Click : Mode("click")
|
object Click : Mode("click")
|
||||||
object Hover : Mode("hover")
|
object Hover : Mode("hover")
|
||||||
|
|
||||||
|
object None : Mode("")
|
||||||
|
object HoverAndClick : Mode("$Hover, $Click")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sealed class Flip(name: String) : AttributeValue(name) {
|
sealed class Flip(name: String) : AttributeValue(name) {
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
package dev.inmo.jsuikit.modifiers
|
package dev.inmo.jsuikit.modifiers
|
||||||
|
|
||||||
|
import dev.inmo.jsuikit.utils.Attrs
|
||||||
import org.jetbrains.compose.web.attributes.AttrsScope
|
import org.jetbrains.compose.web.attributes.AttrsScope
|
||||||
|
import org.jetbrains.compose.web.dom.AttrBuilderContext
|
||||||
|
import org.w3c.dom.Element
|
||||||
|
|
||||||
interface UIKitModifier {
|
interface UIKitModifier {
|
||||||
val classes: Array<String>
|
val classes: Array<String>
|
||||||
@ -15,3 +18,16 @@ fun AttrsScope<*>.include(vararg container: UIKitModifier?) {
|
|||||||
it ?.otherAttrs ?.let { attrs -> attrs.forEach { (k, v) -> attr(k, v) } }
|
it ?.otherAttrs ?.let { attrs -> attrs.forEach { (k, v) -> attr(k, v) } }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun <T : Element> UIKitModifier.asAttributesBuilder(): AttrBuilderContext<T> = {
|
||||||
|
include(this@asAttributesBuilder)
|
||||||
|
}
|
||||||
|
operator fun UIKitModifier.plus(other: UIKitModifier): UIKitModifier = UIKitCustom(
|
||||||
|
classes + other.classes,
|
||||||
|
otherAttrs + other.otherAttrs
|
||||||
|
)
|
||||||
|
fun <T: Element> UIKitModifier.builder() = Attrs<T>(this).builder
|
||||||
|
fun <T: Element> Array<out UIKitModifier>.builder() = Attrs<T>(*this).builder
|
||||||
|
inline fun <T: Element> attrsBuilder(vararg modifiers: UIKitModifier) = modifiers.builder<T>()
|
||||||
|
@JsName("plusBuilder")
|
||||||
|
operator fun <T: Element> UIKitModifier.plus(other: UIKitModifier): AttrBuilderContext<T> = Attrs<T>(this@plus, other).builder
|
||||||
|
Loading…
Reference in New Issue
Block a user