Merge pull request #48 from InsanusMokrassar/0.0.47

0.0.47
This commit is contained in:
InsanusMokrassar 2022-03-25 21:01:54 +06:00 committed by GitHub
commit 186eff482d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 79 additions and 13 deletions

View File

@ -1,5 +1,9 @@
# Changelog
## 0.0.47
* Add support of `Close` element
## 0.0.46
* Add support of `UIKitOverlay`

View File

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

View File

@ -0,0 +1,45 @@
package dev.inmo.jsuikit.elements
import androidx.compose.runtime.Composable
import androidx.compose.web.events.SyntheticMouseEvent
import dev.inmo.jsuikit.modifiers.UIKitClose
import dev.inmo.jsuikit.modifiers.include
import dev.inmo.jsuikit.utils.Attrs
import org.jetbrains.compose.web.attributes.ButtonType
import org.jetbrains.compose.web.attributes.type
import org.jetbrains.compose.web.dom.*
import org.w3c.dom.HTMLAnchorElement
import org.w3c.dom.HTMLButtonElement
object Close {
@Composable
fun drawAsLink(
href: String = "#",
attrs: Attrs<HTMLAnchorElement> = Attrs.empty(),
contentBuilder: ContentBuilder<HTMLAnchorElement> = {}
) = A(
href,
{
include(UIKitClose)
attrs.builder(this)
},
contentBuilder
)
@Composable
fun drawAsButton(
attrs: Attrs<HTMLButtonElement> = Attrs.empty(),
contentBuilder: ContentBuilder<HTMLButtonElement> = {},
onClick: ((SyntheticMouseEvent) -> Unit)? = null
) = Button(
{
type(ButtonType.Button)
include(UIKitClose)
attrs.builder(this)
onClick ?.let {
onClick(onClick)
}
},
contentBuilder
)
}

View File

@ -77,15 +77,15 @@ sealed class Icon(val name: String) {
object Grid : App("grid")
sealed class More(iconName: String) : App("more${iconName.takeIf { it.isNotEmpty() } ?.let { "-$it" } ?: "" }") {
object Vertical : More("vertical")
companion object : More("more")
companion object : More("")
}
sealed class Plus(iconName: String) : App("plus${iconName.takeIf { it.isNotEmpty() } ?.let { "-$it" } ?: "" }") {
object Circle : Plus("circle")
companion object : Plus("plus")
companion object : Plus("")
}
sealed class Minus(iconName: String) : App("minus${iconName.takeIf { it.isNotEmpty() } ?.let { "-$it" } ?: "" }") {
object Circle : Minus("circle")
companion object : Minus("minus")
companion object : Minus("")
}
object Close : App("close")
object Check : App("check")
@ -93,7 +93,7 @@ sealed class Icon(val name: String) {
object Refresh : App("refresh")
sealed class Play(iconName: String) : App("play${iconName.takeIf { it.isNotEmpty() } ?.let { "-$it" } ?: "" }") {
object Circle : Play("circle")
companion object : Play("play")
companion object : Play("")
}
}
sealed class Devices(iconName: String) : Icon(iconName) {
@ -102,11 +102,11 @@ sealed class Icon(val name: String) {
object Laptop : Devices("laptop")
sealed class Tablet(iconName: String) : Devices("tablet${iconName.takeIf { it.isNotEmpty() } ?.let { "-$it" } ?: "" }") {
object Landscape : Tablet("landscape")
companion object : Tablet("tablet")
companion object : Tablet("")
}
sealed class Phone(iconName: String) : Devices("phone${iconName.takeIf { it.isNotEmpty() } ?.let { "-$it" } ?: "" }") {
object Landscape : Phone("landscape")
companion object : Phone("phone")
companion object : Phone("")
}
}
sealed class Storage(iconName: String) : Icon(iconName) {
@ -114,7 +114,7 @@ sealed class Icon(val name: String) {
object Text : File("text")
object Pdf : File("pdf")
object Edit : File("edit")
companion object : File("file")
companion object : File("")
}
object Copy : Storage("copy")
object Folder : Storage("folder")
@ -177,7 +177,7 @@ sealed class Icon(val name: String) {
object Foursquare : Brands("foursquare")
sealed class Github(iconName: String) : Brands("github${iconName.takeIf { it.isNotEmpty() } ?.let { "-$it" } ?: "" }") {
object Alt : Github("alt")
companion object : Github("github")
companion object : Github("")
}
object Gitter : Brands("gitter")
object Google : Brands("google")

View File

@ -95,7 +95,7 @@ fun SubNav(
@Composable
fun <T> Nav(
title: String,
data: SnapshotStateList<T>,
data: Iterable<T>,
vararg ulModifiers: UIKitModifier,
titleModifiers: Array<UIKitModifier> = emptyArray(),
multiple: Boolean? = null,
@ -134,7 +134,7 @@ fun <T> Nav(
@Composable
fun <T> DefaultNav(
title: String,
data: SnapshotStateList<T>,
data: Iterable<T>,
vararg ulModifiers: UIKitModifier,
titleModifiers: Array<UIKitModifier> = emptyArray(),
multiple: Boolean? = null,
@ -163,7 +163,7 @@ fun <T> DefaultNav(
@Composable
fun <T> PrimaryNav(
title: String,
data: SnapshotStateList<T>,
data: Iterable<T>,
vararg ulModifiers: UIKitModifier,
titleModifiers: Array<UIKitModifier> = emptyArray(),
multiple: Boolean? = null,
@ -192,7 +192,7 @@ fun <T> PrimaryNav(
@Composable
fun <T> SubNav(
title: String,
data: SnapshotStateList<T>,
data: Iterable<T>,
vararg ulModifiers: UIKitModifier,
titleModifiers: Array<UIKitModifier> = emptyArray(),
multiple: Boolean? = null,

View File

@ -0,0 +1,17 @@
package dev.inmo.jsuikit.modifiers
sealed class UIKitClose(
override val classes: Array<String> = emptyArray(),
override val otherAttrs: Map<String, String> = emptyMap()
) : UIKitModifier {
object Large : UIKitClose(
arrayOf("uk-close-large")
)
companion object : UIKitClose(
arrayOf("uk-close"),
mapOf("uk-close" to "")
)
}