Merge pull request #35 from InsanusMokrassar/0.0.34

0.0.34
This commit is contained in:
InsanusMokrassar 2022-02-09 16:10:11 +06:00 committed by GitHub
commit f7eecc01e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 83 additions and 3 deletions

View File

@ -1,5 +1,10 @@
# Changelog
## 0.0.34
* Add `Alert`
* Add `Animation#KenBurns`
## 0.0.33
* Fixes in attributes building and related things

View File

@ -9,4 +9,4 @@ android.enableJetifier=true
# Project data
group=dev.inmo
version=0.0.33
version=0.0.34

View File

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

View File

@ -211,8 +211,7 @@ sealed class Icon(val name: String) {
onClick: ((Event) -> Unit)? = null
) {
val configurer: AttrBuilderContext<out HTMLElement> = {
classes("uk-icon")
include(*modifiers, type)
include(*modifiers, type, UIKitIcon)
attr("uk-icon", "icon: $name${if (ratio != null) { "; ratio: $ratio" } else ""}")
onClick ?.let { _ ->
onClick { onClick(it.nativeEvent) }

View File

@ -0,0 +1,18 @@
package dev.inmo.jsuikit.modifiers
sealed class UIKitAlert(classname: String) : UIKitModifier {
override val classes: Array<String> = 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")
}

View File

@ -60,4 +60,6 @@ sealed class UIKitAnimation (name: String) : UIKitModifier, AttributeValue(name)
object Fast : UIKitAnimation("fast")
object KenBurns : UIKitAnimation("kenburns")
}

View File

@ -0,0 +1,7 @@
package dev.inmo.jsuikit.modifiers
sealed class UIKitIcon(classname: String) : UIKitModifier {
override val classes: Array<String> = arrayOf(classname)
companion object : UIKitIcon("uk-icon")
}