From 01349d2fac3942b1b0f6dd17ff0cb44f9d92c922 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 9 Feb 2022 13:43:56 +0600 Subject: [PATCH] add Alert and several things in animation --- CHANGELOG.md | 3 ++ .../kotlin/dev/inmo/jsuikit/elements/Alert.kt | 30 +++++++++++++++++++ .../dev/inmo/jsuikit/modifiers/UIKitAlert.kt | 18 +++++++++++ .../inmo/jsuikit/modifiers/UIKitAnimation.kt | 2 ++ 4 files changed, 53 insertions(+) create mode 100644 src/jsMain/kotlin/dev/inmo/jsuikit/elements/Alert.kt create mode 100644 src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitAlert.kt diff --git a/CHANGELOG.md b/CHANGELOG.md index ed80b69..a3240d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## 0.0.34 +* Add `Alert` +* Add `Animation#KenBurns` + ## 0.0.33 * Fixes in attributes building and related things diff --git a/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Alert.kt b/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Alert.kt new file mode 100644 index 0000000..b3a0c49 --- /dev/null +++ b/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Alert.kt @@ -0,0 +1,30 @@ +package dev.inmo.jsuikit.elements + +import androidx.compose.runtime.Composable +import dev.inmo.jsuikit.buildAndAddAttribute +import dev.inmo.jsuikit.modifiers.UIKitAnimation +import dev.inmo.jsuikit.utils.Attrs +import dev.inmo.jsuikit.utils.Milliseconds +import org.jetbrains.compose.web.dom.ContentBuilder +import org.jetbrains.compose.web.dom.Div +import org.w3c.dom.HTMLDivElement + +@Composable +fun Alert( + attrs: Attrs, + animation: UIKitAnimation? = UIKitAnimation.Fade, + duration: Milliseconds? = null, + selClose: String? = null, + content: ContentBuilder +) = Div( + { + attrs.builder(this) + + buildAndAddAttribute("uk-alert") { + "animation" to animation ?.classes ?.firstOrNull() + "duration" to duration + "sel-close" to selClose + } + }, + content +) diff --git a/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitAlert.kt b/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitAlert.kt new file mode 100644 index 0000000..dc1c2a7 --- /dev/null +++ b/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitAlert.kt @@ -0,0 +1,18 @@ +package dev.inmo.jsuikit.modifiers + +sealed class UIKitAlert(classname: String) : UIKitModifier { + override val classes: Array = arrayOf(classname) + + sealed class Style(classname: String) : UIKitAlert(classname) { + + object Primary : Style("uk-alert-primary") + object Success : Style("uk-alert-success") + object Warning : Style("uk-alert-warning") + object Danger : Style("uk-alert-danger") + + } + + object Close : UIKitAlert("uk-alert-close") + + companion object : UIKitAlert("uk-alert") +} diff --git a/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitAnimation.kt b/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitAnimation.kt index 422ea74..96216e6 100644 --- a/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitAnimation.kt +++ b/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitAnimation.kt @@ -60,4 +60,6 @@ sealed class UIKitAnimation (name: String) : UIKitModifier, AttributeValue(name) object Fast : UIKitAnimation("fast") + object KenBurns : UIKitAnimation("kenburns") + }