mirror of
https://github.com/InsanusMokrassar/JSUIKitKBindings.git
synced 2024-11-26 12:08:46 +00:00
improvements in UIKitModifier tools
This commit is contained in:
parent
b177760c73
commit
be4d63f0e0
@ -3,6 +3,8 @@
|
||||
## 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
|
||||
|
||||
|
@ -1,6 +1,9 @@
|
||||
package dev.inmo.jsuikit.modifiers
|
||||
|
||||
import dev.inmo.jsuikit.utils.Attrs
|
||||
import org.jetbrains.compose.web.attributes.AttrsScope
|
||||
import org.jetbrains.compose.web.dom.AttrBuilderContext
|
||||
import org.w3c.dom.Element
|
||||
|
||||
interface UIKitModifier {
|
||||
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) } }
|
||||
}
|
||||
}
|
||||
|
||||
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