2022-01-28 08:01:06 +00:00
|
|
|
package dev.inmo.jsuikit.utils
|
|
|
|
|
|
|
|
import androidx.compose.runtime.Composable
|
|
|
|
import org.jetbrains.compose.web.dom.ContentBuilder
|
|
|
|
import org.w3c.dom.Element
|
|
|
|
|
|
|
|
@Composable
|
2022-08-20 11:43:44 +00:00
|
|
|
inline fun optionallyDraw (
|
|
|
|
vararg bools: Boolean,
|
2022-01-28 08:01:06 +00:00
|
|
|
whatToDraw: @Composable () -> Unit
|
|
|
|
) {
|
2022-08-20 11:43:44 +00:00
|
|
|
if (bools.any { it }) {
|
2022-01-28 08:01:06 +00:00
|
|
|
whatToDraw()
|
|
|
|
}
|
|
|
|
}
|
2022-08-20 11:43:44 +00:00
|
|
|
|
|
|
|
@Composable
|
|
|
|
inline fun <T : Element> optionallyDraw (
|
|
|
|
attrs: Attrs<T>? = null,
|
|
|
|
noinline contentBuilder: ContentBuilder<T>? = null,
|
|
|
|
whatToDraw: @Composable () -> Unit
|
|
|
|
) = optionallyDraw(attrs != null || contentBuilder != null, whatToDraw = whatToDraw)
|