mirror of
https://github.com/InsanusMokrassar/JSUIKitKBindings.git
synced 2024-12-22 08:37:24 +00:00
add badge support
This commit is contained in:
parent
264bcae65e
commit
1d6c0db692
25
src/jsMain/kotlin/dev/inmo/jsuikit/elements/Badge.kt
Normal file
25
src/jsMain/kotlin/dev/inmo/jsuikit/elements/Badge.kt
Normal 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)
|
||||||
|
}
|
@ -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")
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user