add support of close element

This commit is contained in:
InsanusMokrassar 2022-03-25 16:45:30 +06:00
parent 061b55b164
commit b4a0ff6ece
3 changed files with 56 additions and 0 deletions

View File

@ -2,6 +2,8 @@
## 0.0.47 ## 0.0.47
* Add support of `Close` element
## 0.0.46 ## 0.0.46
* Add support of `UIKitOverlay` * Add support of `UIKitOverlay`

View 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
)
}

View 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 "")
)
}