mirror of
https://github.com/InsanusMokrassar/JSUIKitKBindings.git
synced 2024-11-29 21:48:46 +00:00
add support of close element
This commit is contained in:
parent
061b55b164
commit
b4a0ff6ece
@ -2,6 +2,8 @@
|
||||
|
||||
## 0.0.47
|
||||
|
||||
* Add support of `Close` element
|
||||
|
||||
## 0.0.46
|
||||
|
||||
* Add support of `UIKitOverlay`
|
||||
|
37
src/jsMain/kotlin/dev/inmo/jsuikit/elements/Close.kt
Normal file
37
src/jsMain/kotlin/dev/inmo/jsuikit/elements/Close.kt
Normal file
@ -0,0 +1,37 @@
|
||||
package dev.inmo.jsuikit.elements
|
||||
|
||||
import dev.inmo.jsuikit.modifiers.UIKitClose
|
||||
import dev.inmo.jsuikit.modifiers.include
|
||||
import dev.inmo.jsuikit.utils.Attrs
|
||||
import org.jetbrains.compose.web.attributes.ButtonType
|
||||
import org.jetbrains.compose.web.attributes.type
|
||||
import org.jetbrains.compose.web.dom.*
|
||||
import org.w3c.dom.HTMLAnchorElement
|
||||
import org.w3c.dom.HTMLButtonElement
|
||||
|
||||
object Close {
|
||||
fun drawAsLink(
|
||||
href: String = "#",
|
||||
attrs: Attrs<HTMLAnchorElement> = Attrs.empty(),
|
||||
contentBuilder: ContentBuilder<HTMLAnchorElement> = {}
|
||||
) = A(
|
||||
href,
|
||||
{
|
||||
include(UIKitClose)
|
||||
attrs.builder(this)
|
||||
},
|
||||
contentBuilder
|
||||
)
|
||||
|
||||
fun drawAsButton(
|
||||
attrs: Attrs<HTMLButtonElement> = Attrs.empty(),
|
||||
contentBuilder: ContentBuilder<HTMLButtonElement> = {}
|
||||
) = Button(
|
||||
{
|
||||
type(ButtonType.Button)
|
||||
include(UIKitClose)
|
||||
attrs.builder(this)
|
||||
},
|
||||
contentBuilder
|
||||
)
|
||||
}
|
17
src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitClose.kt
Normal file
17
src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitClose.kt
Normal file
@ -0,0 +1,17 @@
|
||||
package dev.inmo.jsuikit.modifiers
|
||||
|
||||
sealed class UIKitClose(
|
||||
override val classes: Array<String> = emptyArray(),
|
||||
override val otherAttrs: Map<String, String> = emptyMap()
|
||||
) : UIKitModifier {
|
||||
|
||||
object Large : UIKitClose(
|
||||
arrayOf("uk-close-large")
|
||||
)
|
||||
|
||||
companion object : UIKitClose(
|
||||
arrayOf("uk-close"),
|
||||
mapOf("uk-close" to "")
|
||||
)
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user