kjsuikit/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Alert.kt

50 lines
1.2 KiB
Kotlin
Raw Normal View History

package dev.inmo.jsuikit.elements
import androidx.compose.runtime.Composable
import dev.inmo.jsuikit.buildAndAddAttribute
2022-02-09 07:53:56 +00:00
import dev.inmo.jsuikit.modifiers.*
import dev.inmo.jsuikit.utils.Attrs
import dev.inmo.jsuikit.utils.Milliseconds
2022-02-09 07:53:56 +00:00
import org.jetbrains.compose.web.dom.*
import org.w3c.dom.HTMLAnchorElement
import org.w3c.dom.HTMLDivElement
@Composable
fun Alert(
2022-02-09 07:48:06 +00:00
attrs: Attrs<HTMLDivElement> = Attrs.empty(),
animation: UIKitAnimation? = UIKitAnimation.Fade,
duration: Milliseconds? = null,
selClose: String? = null,
content: ContentBuilder<HTMLDivElement>
) = Div(
{
attrs.builder(this)
2022-02-09 09:47:02 +00:00
include(UIKitAlert)
buildAndAddAttribute("uk-alert") {
"animation" to animation ?.classes ?.firstOrNull()
"duration" to duration
"sel-close" to selClose
}
},
content
)
2022-02-09 07:53:56 +00:00
@Composable
fun AlertCloseButton(
attrs: Attrs<HTMLAnchorElement> = Attrs.empty(),
content: ContentBuilder<HTMLAnchorElement> = @Composable {}
) {
A(
null,
{
2022-02-09 09:28:47 +00:00
include(UIKitAlert.Close, UIKitIcon)
2022-02-09 07:53:56 +00:00
attr("uk-close", "")
2022-02-09 09:28:47 +00:00
classes("uk-close")
2022-02-09 07:53:56 +00:00
attrs.builder(this)
},
content
)
}