JSUIKitKBindings/src/main/kotlin/dev/inmo/jsuikit/elements/Grid.kt

52 lines
1.4 KiB
Kotlin
Raw Normal View History

2022-01-12 10:27:49 +00:00
package dev.inmo.jsuikit.elements
2021-12-22 08:38:12 +00:00
import androidx.compose.runtime.Composable
2022-01-12 13:58:52 +00:00
import dev.inmo.jsuikit.modifiers.UIKitModifier
import dev.inmo.jsuikit.modifiers.include
import org.jetbrains.compose.web.dom.*
2021-12-22 08:38:12 +00:00
import org.w3c.dom.HTMLDivElement
@Composable
fun GridColumn(
modifiers: Array<UIKitModifier> = emptyArray(),
attributesCustomizer: AttrBuilderContext<HTMLDivElement> = {},
2021-12-22 08:38:12 +00:00
builder: @Composable ElementScope<HTMLDivElement>.() -> Unit
) {
Div(
{
include(*modifiers)
attributesCustomizer()
2021-12-22 08:38:12 +00:00
}
) {
builder()
}
}
@Composable
fun Grid(
modifiers: Array<UIKitModifier> = emptyArray(),
2021-12-22 08:38:12 +00:00
masonry: Boolean = false,
parallax: Int? = null,
marginClass: String? = null,
firstColumnClass: String? = null,
attributesCustomizer: AttrBuilderContext<HTMLDivElement> = {},
2021-12-22 08:38:12 +00:00
builder: @Composable ElementScope<HTMLDivElement>.() -> Unit
) {
val attrs = listOfNotNull(
if (masonry) "masonry" to "true" else null,
parallax ?.let { "parallax" to it.toString() },
marginClass ?.let { "margin" to it },
firstColumnClass ?.let { "first-column" to it },
)
Div(
{
attr("uk-grid", attrs.joinToString(";") { (k, v) -> "$k: $v" })
classes("uk-grid")
include(*modifiers)
attributesCustomizer()
2021-12-22 08:38:12 +00:00
}
) {
builder()
}
}