diff --git a/CHANGELOG.md b/CHANGELOG.md index fbdf774..8e77a6d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## 0.0.47 +* Add support of `Close` element + ## 0.0.46 * Add support of `UIKitOverlay` diff --git a/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Close.kt b/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Close.kt new file mode 100644 index 0000000..6e5a17b --- /dev/null +++ b/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Close.kt @@ -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 = Attrs.empty(), + contentBuilder: ContentBuilder = {} + ) = A( + href, + { + include(UIKitClose) + attrs.builder(this) + }, + contentBuilder + ) + + fun drawAsButton( + attrs: Attrs = Attrs.empty(), + contentBuilder: ContentBuilder = {} + ) = Button( + { + type(ButtonType.Button) + include(UIKitClose) + attrs.builder(this) + }, + contentBuilder + ) +} diff --git a/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitClose.kt b/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitClose.kt new file mode 100644 index 0000000..c0b425a --- /dev/null +++ b/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitClose.kt @@ -0,0 +1,17 @@ +package dev.inmo.jsuikit.modifiers + +sealed class UIKitClose( + override val classes: Array = emptyArray(), + override val otherAttrs: Map = emptyMap() +) : UIKitModifier { + + object Large : UIKitClose( + arrayOf("uk-close-large") + ) + + companion object : UIKitClose( + arrayOf("uk-close"), + mapOf("uk-close" to "") + ) + +}