add badge support

This commit is contained in:
InsanusMokrassar 2023-01-24 13:44:01 +06:00
parent 264bcae65e
commit 1d6c0db692
2 changed files with 32 additions and 0 deletions

View File

@ -0,0 +1,25 @@
package dev.inmo.jsuikit.elements
import androidx.compose.runtime.Composable
import dev.inmo.jsuikit.modifiers.UIKitBadge
import dev.inmo.jsuikit.modifiers.include
import org.jetbrains.compose.web.dom.AttrBuilderContext
import org.jetbrains.compose.web.dom.ContentBuilder
import org.jetbrains.compose.web.dom.Span
import org.jetbrains.compose.web.dom.Text
import org.w3c.dom.HTMLSpanElement
@Composable
fun Badge(
text: String,
onAfterText: ContentBuilder<HTMLSpanElement>? = null,
onBeforeText: ContentBuilder<HTMLSpanElement>? = null,
attrs: AttrBuilderContext<HTMLSpanElement>? = null
) = Span({
include(UIKitBadge)
attrs ?.invoke(this)
}) {
onAfterText ?.invoke(this)
Text(text)
onBeforeText ?.invoke(this)
}

View File

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