mirror of
https://github.com/InsanusMokrassar/JSUIKitKBindings.git
synced 2025-12-04 13:26:27 +00:00
Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a2830e5e85 | |||
| 484564e323 | |||
| b5e93bc829 | |||
| 4282165d79 | |||
| 1e452c78d1 | |||
| 5fa388c169 | |||
| 763e1fa5ac | |||
| 150efa1719 | |||
| 20bf43b8a1 | |||
| 93dd63c6b1 | |||
| eb06ff80a1 | |||
| 25ba9188e3 | |||
| 19ca960b35 | |||
| ef3b711e2b | |||
| 6bebb8b8d4 | |||
| c013a978d4 | |||
| 9f342f428a |
22
CHANGELOG.md
22
CHANGELOG.md
@@ -1,3 +1,25 @@
|
||||
# Changelog
|
||||
|
||||
## 0.0.12
|
||||
|
||||
* Add `rowAttributes` to table fun
|
||||
|
||||
## 0.0.11
|
||||
|
||||
* Upfill `Nav` and `UIKitNav`
|
||||
|
||||
## 0.0.10
|
||||
|
||||
* Filling of `UIKitUtility`
|
||||
|
||||
## 0.0.9
|
||||
|
||||
* Improving of `Nav` support
|
||||
|
||||
## 0.0.8
|
||||
|
||||
Removing of redundant non standard things
|
||||
|
||||
## 0.0.7
|
||||
|
||||
Rewrite project onto multiplatform paradigm and return back varargs instead of most `Array<UIKitModifier>`
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
# JSUIKit Kotlin
|
||||
|
||||
**IMPORTANT NOTICE**: ___Currently it is possible that you will have issues with `vararg` arguments passing to the functions.
|
||||
Use `arrayOf(...)` instead___
|
||||
|
||||
Hello :) This library is a wrapper for JavaScript/CSS [UIKit](https://getuikit.com) framework. It uses the same
|
||||
structure as in [UIKit Docs](https://getuikit.com/docs/introduction) and in most cases you may use it.
|
||||
|
||||
@@ -11,10 +8,10 @@ for you in case you are using it too.
|
||||
|
||||
## How to include
|
||||
|
||||
Last version: [](https://maven-badges.herokuapp.com/maven-central/dev.inmo/jsuikitkotlin)
|
||||
Last version: [](https://maven-badges.herokuapp.com/maven-central/dev.inmo/kjsuikit)
|
||||
|
||||
```groovy
|
||||
implementation "dev.inmo:jsuikitkotlin:$jsuikitkotlin_version"
|
||||
implementation "dev.inmo:kjsuikit:$kjsuikit_version"
|
||||
```
|
||||
|
||||
**THIS LIBRARY DO NOT ADD ANY JS OR CSS**. So, you must download and include UIKit js/css by yourself. See
|
||||
|
||||
@@ -9,4 +9,4 @@ android.enableJetifier=true
|
||||
# Project data
|
||||
|
||||
group=dev.inmo
|
||||
version=0.0.7
|
||||
version=0.0.12
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
package dev.inmo.jsuikit.elements
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.snapshots.SnapshotStateList
|
||||
import dev.inmo.jsuikit.buildAndAddAttribute
|
||||
import dev.inmo.jsuikit.modifiers.*
|
||||
import dev.inmo.jsuikit.utils.Milliseconds
|
||||
import org.jetbrains.compose.web.dom.*
|
||||
import org.w3c.dom.HTMLLIElement
|
||||
import org.w3c.dom.HTMLUListElement
|
||||
import org.jetbrains.compose.web.dom.Text
|
||||
import org.w3c.dom.*
|
||||
|
||||
@Composable
|
||||
fun Nav(
|
||||
@@ -26,8 +27,7 @@ fun Nav(
|
||||
"animation" to animation
|
||||
"duration" to duration ?.toString()
|
||||
}
|
||||
classes("uk-nav")
|
||||
include(*modifiers)
|
||||
include(*modifiers, UIKitNav)
|
||||
attributesCustomizer()
|
||||
}
|
||||
) {
|
||||
@@ -35,6 +35,223 @@ fun Nav(
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun DefaultNav(
|
||||
vararg modifiers: UIKitModifier,
|
||||
multiple: Boolean? = null,
|
||||
collapsible: Boolean? = null,
|
||||
animation: UIKitAnimation? = null,
|
||||
duration: Milliseconds? = null,
|
||||
attributesCustomizer: AttrBuilderContext<HTMLUListElement> = {},
|
||||
dataAllocator: ContentBuilder<HTMLUListElement>
|
||||
) = Nav(
|
||||
modifiers = modifiers + UIKitNav.Default,
|
||||
multiple,
|
||||
collapsible,
|
||||
animation,
|
||||
duration,
|
||||
attributesCustomizer,
|
||||
dataAllocator
|
||||
)
|
||||
|
||||
@Composable
|
||||
fun PrimaryNav(
|
||||
vararg modifiers: UIKitModifier,
|
||||
multiple: Boolean? = null,
|
||||
collapsible: Boolean? = null,
|
||||
animation: UIKitAnimation? = null,
|
||||
duration: Milliseconds? = null,
|
||||
attributesCustomizer: AttrBuilderContext<HTMLUListElement> = {},
|
||||
dataAllocator: ContentBuilder<HTMLUListElement>
|
||||
) = Nav(
|
||||
modifiers = modifiers + UIKitNav.Primary,
|
||||
multiple,
|
||||
collapsible,
|
||||
animation,
|
||||
duration,
|
||||
attributesCustomizer,
|
||||
dataAllocator
|
||||
)
|
||||
|
||||
@Composable
|
||||
fun SubNav(
|
||||
vararg modifiers: UIKitModifier,
|
||||
multiple: Boolean? = null,
|
||||
collapsible: Boolean? = null,
|
||||
animation: UIKitAnimation? = null,
|
||||
duration: Milliseconds? = null,
|
||||
attributesCustomizer: AttrBuilderContext<HTMLUListElement> = {},
|
||||
dataAllocator: ContentBuilder<HTMLUListElement>
|
||||
) = Nav(
|
||||
modifiers = modifiers + UIKitNav.SubNav,
|
||||
multiple,
|
||||
collapsible,
|
||||
animation,
|
||||
duration,
|
||||
attributesCustomizer,
|
||||
dataAllocator
|
||||
)
|
||||
|
||||
@Composable
|
||||
fun <T> Nav(
|
||||
title: String,
|
||||
data: SnapshotStateList<T>,
|
||||
vararg ulModifiers: UIKitModifier,
|
||||
titleModifiers: Array<UIKitModifier> = emptyArray(),
|
||||
multiple: Boolean? = null,
|
||||
collapsible: Boolean? = null,
|
||||
animation: UIKitAnimation? = null,
|
||||
duration: Milliseconds? = null,
|
||||
besidesTitleAndList: ContentBuilder<HTMLUListElement>? = null,
|
||||
titleCustomizer: AttrBuilderContext<HTMLLIElement> = {},
|
||||
ulCustomizer: AttrBuilderContext<HTMLUListElement> = {},
|
||||
elementAllocator: @Composable ElementScope<HTMLUListElement>.(T) -> Unit
|
||||
) {
|
||||
Ul(
|
||||
{
|
||||
buildAndAddAttribute("uk-nav") {
|
||||
"multiple" to multiple ?.toString()
|
||||
"collapsible" to collapsible ?.toString()
|
||||
"animation" to animation
|
||||
"duration" to duration ?.toString()
|
||||
}
|
||||
include(*ulModifiers, UIKitNav)
|
||||
ulCustomizer()
|
||||
}
|
||||
) {
|
||||
NavHeader(
|
||||
title,
|
||||
*titleModifiers,
|
||||
attributesCustomizer = titleCustomizer
|
||||
)
|
||||
besidesTitleAndList ?.let { it() }
|
||||
data.forEach {
|
||||
elementAllocator(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun <T> DefaultNav(
|
||||
title: String,
|
||||
data: SnapshotStateList<T>,
|
||||
vararg ulModifiers: UIKitModifier,
|
||||
titleModifiers: Array<UIKitModifier> = emptyArray(),
|
||||
multiple: Boolean? = null,
|
||||
collapsible: Boolean? = null,
|
||||
animation: UIKitAnimation? = null,
|
||||
duration: Milliseconds? = null,
|
||||
besidesTitleAndList: ContentBuilder<HTMLUListElement>? = null,
|
||||
titleCustomizer: AttrBuilderContext<HTMLLIElement> = {},
|
||||
ulCustomizer: AttrBuilderContext<HTMLUListElement> = {},
|
||||
elementAllocator: @Composable ElementScope<HTMLUListElement>.(T) -> Unit
|
||||
) = Nav(
|
||||
title,
|
||||
data,
|
||||
ulModifiers = ulModifiers + UIKitNav.Default,
|
||||
titleModifiers,
|
||||
multiple,
|
||||
collapsible,
|
||||
animation,
|
||||
duration,
|
||||
besidesTitleAndList,
|
||||
titleCustomizer,
|
||||
ulCustomizer,
|
||||
elementAllocator
|
||||
)
|
||||
|
||||
@Composable
|
||||
fun <T> PrimaryNav(
|
||||
title: String,
|
||||
data: SnapshotStateList<T>,
|
||||
vararg ulModifiers: UIKitModifier,
|
||||
titleModifiers: Array<UIKitModifier> = emptyArray(),
|
||||
multiple: Boolean? = null,
|
||||
collapsible: Boolean? = null,
|
||||
animation: UIKitAnimation? = null,
|
||||
duration: Milliseconds? = null,
|
||||
besidesTitleAndList: ContentBuilder<HTMLUListElement>? = null,
|
||||
titleCustomizer: AttrBuilderContext<HTMLLIElement> = {},
|
||||
ulCustomizer: AttrBuilderContext<HTMLUListElement> = {},
|
||||
elementAllocator: @Composable ElementScope<HTMLUListElement>.(T) -> Unit
|
||||
) = Nav(
|
||||
title,
|
||||
data,
|
||||
ulModifiers = ulModifiers + UIKitNav.Primary,
|
||||
titleModifiers,
|
||||
multiple,
|
||||
collapsible,
|
||||
animation,
|
||||
duration,
|
||||
besidesTitleAndList,
|
||||
titleCustomizer,
|
||||
ulCustomizer,
|
||||
elementAllocator
|
||||
)
|
||||
|
||||
@Composable
|
||||
fun <T> SubNav(
|
||||
title: String,
|
||||
data: SnapshotStateList<T>,
|
||||
vararg ulModifiers: UIKitModifier,
|
||||
titleModifiers: Array<UIKitModifier> = emptyArray(),
|
||||
multiple: Boolean? = null,
|
||||
collapsible: Boolean? = null,
|
||||
animation: UIKitAnimation? = null,
|
||||
duration: Milliseconds? = null,
|
||||
besidesTitleAndList: ContentBuilder<HTMLUListElement>? = null,
|
||||
titleCustomizer: AttrBuilderContext<HTMLLIElement> = {},
|
||||
ulCustomizer: AttrBuilderContext<HTMLUListElement> = {},
|
||||
elementAllocator: @Composable ElementScope<HTMLUListElement>.(T) -> Unit
|
||||
) = Nav(
|
||||
title,
|
||||
data,
|
||||
ulModifiers = ulModifiers + UIKitNav.SubNav,
|
||||
titleModifiers,
|
||||
multiple,
|
||||
collapsible,
|
||||
animation,
|
||||
duration,
|
||||
besidesTitleAndList,
|
||||
titleCustomizer,
|
||||
ulCustomizer,
|
||||
elementAllocator
|
||||
)
|
||||
|
||||
@Composable
|
||||
fun NavHeader(
|
||||
text: String,
|
||||
vararg modifiers: UIKitModifier,
|
||||
attributesCustomizer: AttrBuilderContext<HTMLLIElement> = {},
|
||||
) {
|
||||
Li(
|
||||
{
|
||||
include(*modifiers, UIKitNav.Header)
|
||||
attributesCustomizer()
|
||||
}
|
||||
) {
|
||||
Text(text)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun NavItemElement(
|
||||
vararg modifiers: UIKitModifier,
|
||||
attributesCustomizer: AttrBuilderContext<HTMLLIElement> = {},
|
||||
contentAllocator: ContentBuilder<HTMLAnchorElement>
|
||||
) {
|
||||
Li(
|
||||
{
|
||||
include(*modifiers)
|
||||
attributesCustomizer()
|
||||
}
|
||||
) {
|
||||
A("#") {
|
||||
contentAllocator()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun NavElement(
|
||||
vararg modifiers: UIKitModifier,
|
||||
@@ -44,9 +261,14 @@ fun NavElement(
|
||||
Li(
|
||||
{
|
||||
include(*modifiers)
|
||||
attributesCustomizer
|
||||
attributesCustomizer()
|
||||
}
|
||||
) {
|
||||
contentAllocator()
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun NavDivider() {
|
||||
Li({ include(UIKitNav.Divider) })
|
||||
}
|
||||
|
||||
@@ -3,9 +3,10 @@ package dev.inmo.jsuikit.elements
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.snapshots.SnapshotStateList
|
||||
import dev.inmo.jsuikit.modifiers.*
|
||||
import org.jetbrains.compose.web.attributes.AttrsBuilder
|
||||
import org.jetbrains.compose.web.dom.*
|
||||
import org.w3c.dom.HTMLProgressElement
|
||||
import org.w3c.dom.HTMLTableElement
|
||||
import org.jetbrains.compose.web.dom.Text
|
||||
import org.w3c.dom.*
|
||||
|
||||
@Composable
|
||||
fun <T> DefaultTable(
|
||||
@@ -13,6 +14,8 @@ fun <T> DefaultTable(
|
||||
dataList: SnapshotStateList<T>,
|
||||
vararg tableModifiers: UIKitModifier,
|
||||
attributesCustomizer: AttrBuilderContext<HTMLTableElement> = {},
|
||||
headingCustomizer: AttrBuilderContext<HTMLTableCellElement> = {},
|
||||
rowAttributes: AttrsBuilder<HTMLTableRowElement>.(t: T) -> Unit = {},
|
||||
cellFiller: @Composable (i: Int, t: T) -> Unit
|
||||
) {
|
||||
val headingIndexes = heading.indices
|
||||
@@ -28,7 +31,7 @@ fun <T> DefaultTable(
|
||||
heading.forEach {
|
||||
Th(
|
||||
{
|
||||
include(UIKitExtension.TextTransformUnset)
|
||||
headingCustomizer()
|
||||
}
|
||||
) {
|
||||
Text(it)
|
||||
@@ -38,7 +41,11 @@ fun <T> DefaultTable(
|
||||
}
|
||||
Tbody {
|
||||
dataList.forEach {
|
||||
Tr {
|
||||
Tr(
|
||||
{
|
||||
rowAttributes(it)
|
||||
}
|
||||
) {
|
||||
headingIndexes.forEach { i ->
|
||||
Td {
|
||||
cellFiller(i, it)
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
package dev.inmo.jsuikit.modifiers
|
||||
|
||||
sealed class UIKitExtension(classname: String) : UIKitModifier {
|
||||
override val classes: Array<String> = arrayOf(classname)
|
||||
object TextTransformUnset : UIKitExtension("text_transform_unset")
|
||||
object CursorPointer : UIKitExtension("cursor_pointer")
|
||||
}
|
||||
@@ -3,8 +3,8 @@ package dev.inmo.jsuikit.modifiers
|
||||
sealed class UIKitNav(classname: String) : UIKitModifier {
|
||||
override val classes: Array<String> = arrayOf(classname)
|
||||
|
||||
object Accordion : UIKitNav("uk-nav-parent-icon")
|
||||
object Subnav : UIKitNav("uk-nav-sub")
|
||||
object ParentIcon : UIKitNav("uk-nav-parent-icon")
|
||||
object SubNav : UIKitNav("uk-nav-sub")
|
||||
|
||||
object Header : UIKitNav("uk-nav-header")
|
||||
object Divider : UIKitNav("uk-nav-divider")
|
||||
@@ -14,4 +14,6 @@ sealed class UIKitNav(classname: String) : UIKitModifier {
|
||||
object Primary : UIKitNav("uk-nav-primary")
|
||||
|
||||
object Center : UIKitNav("uk-nav-center")
|
||||
|
||||
companion object : UIKitNav("uk-nav")
|
||||
}
|
||||
|
||||
@@ -3,10 +3,110 @@ package dev.inmo.jsuikit.modifiers
|
||||
sealed class UIKitUtility(classname: String) : UIKitModifier {
|
||||
override val classes: Array<String> = arrayOf(classname)
|
||||
|
||||
object Panel : UIKitUtility("uk-panel")
|
||||
|
||||
sealed class Float(suffix: String) : UIKitUtility("uk-float-$suffix") {
|
||||
object Left : Float("left")
|
||||
object Right : Float("right")
|
||||
}
|
||||
object Clearfix : Float("clearfix")
|
||||
|
||||
sealed class Overflow(suffix: String) : UIKitUtility("uk-overflow-$suffix") {
|
||||
object Hidden : Overflow("hidden")
|
||||
object Auto : Overflow("auto")
|
||||
}
|
||||
|
||||
sealed class Resize(suffix: String?) : UIKitUtility("uk-resize${suffix ?.let { "-$it" } ?: ""}") {
|
||||
object Vertical : Resize("vertical")
|
||||
companion object : Resize(null)
|
||||
}
|
||||
|
||||
sealed class Display(suffix: String) : UIKitUtility("uk-display-$suffix") {
|
||||
object Block : Display("block")
|
||||
sealed class Inline(suffix: String?) : Display("inline${suffix ?.let { "-$it" } ?: ""}") {
|
||||
object Block : Inline("block")
|
||||
companion object : Inline(null)
|
||||
}
|
||||
}
|
||||
|
||||
sealed class Inline(suffix: String?) : UIKitUtility("uk-inline${suffix ?.let { "-$it" } ?: ""}") {
|
||||
object Clip : Inline("clip")
|
||||
companion object : Inline(null)
|
||||
}
|
||||
|
||||
sealed class Responsive(suffix: String) : UIKitUtility("uk-responsive-$suffix") {
|
||||
object Width : Responsive("width")
|
||||
object Height : Responsive("height")
|
||||
}
|
||||
object PreserveWidth : UIKitUtility("uk-preserve-width")
|
||||
|
||||
sealed class Border(suffix: String) : UIKitUtility("uk-border-$suffix") {
|
||||
object Rounded : Border("rounded")
|
||||
object Circle : Border("circle")
|
||||
object Pill : Border("pill")
|
||||
}
|
||||
|
||||
sealed class BoxShadow(suffix: String) : UIKitUtility("uk-box-shadow-$suffix") {
|
||||
object Small : BoxShadow("small")
|
||||
object Medium : BoxShadow("medium")
|
||||
object Large : BoxShadow("large")
|
||||
object XLarge : BoxShadow("xlarge")
|
||||
|
||||
object Bottom : BoxShadow("bottom")
|
||||
|
||||
sealed class Hover(suffix: String) : BoxShadow("hover-$suffix") {
|
||||
object Small : Hover("small")
|
||||
object Medium : Hover("medium")
|
||||
object Large : Hover("large")
|
||||
object XLarge : Hover("xlarge")
|
||||
}
|
||||
}
|
||||
|
||||
object DropCap : UIKitUtility("uk-dropcap")
|
||||
|
||||
object Logo : UIKitUtility("uk-logo")
|
||||
|
||||
sealed class Blend(suffix: String) : UIKitUtility("uk-blend-$suffix") {
|
||||
object Multiply : Blend("multiply")
|
||||
object Screen : Blend("screen")
|
||||
object Overlay : Blend("overlay")
|
||||
object Darken : Blend("darken")
|
||||
object Lighten : Blend("lighten")
|
||||
sealed class Color(suffix: String?) : Blend("color${suffix ?.let { "-$it" } ?: ""}") {
|
||||
object Dodge : Color("dodge")
|
||||
object Burn : Color("burn")
|
||||
companion object : Color(null)
|
||||
}
|
||||
object HardLight : Blend("hard-light")
|
||||
object SoftLight : Blend("soft-light")
|
||||
object Difference : Blend("difference")
|
||||
object Exclusion : Blend("exclusion")
|
||||
object Hue : Blend("hue")
|
||||
object Saturation : Blend("saturation")
|
||||
object Luminosity : Blend("luminosity")
|
||||
}
|
||||
|
||||
sealed class Transform(suffix: String) : UIKitUtility("uk-transform-$suffix") {
|
||||
object Center : Transform("center")
|
||||
sealed class Origin(suffix: String) : Transform("origin-$suffix") {
|
||||
sealed class Top(suffix: String) : Origin("top-$suffix") {
|
||||
object Left : Top("left")
|
||||
object Center : Top("center")
|
||||
object Right : Top("right")
|
||||
}
|
||||
sealed class Center(suffix: String) : Origin("center-$suffix") {
|
||||
object Left : Center("left")
|
||||
object Right : Center("right")
|
||||
}
|
||||
sealed class Bottom(suffix: String) : Origin("bottom-$suffix") {
|
||||
object Left : Bottom("left")
|
||||
object Center : Bottom("center")
|
||||
object Right : Bottom("right")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
object Disabled : UIKitUtility("uk-disabled")
|
||||
object Drag : UIKitUtility("uk-drag")
|
||||
object Active : UIKitUtility("uk-active")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user