now project is multiplatform and correctly working

This commit is contained in:
2022-01-13 19:56:39 +06:00
parent 5880db3db1
commit 0beb781e2c
46 changed files with 92 additions and 98 deletions

View File

@@ -0,0 +1,3 @@
package dev.inmo.jsuikit.modifiers
sealed class AttributeValue(val name: String)

View File

@@ -0,0 +1,4 @@
package dev.inmo.jsuikit.modifiers
inline val UIKit
get() = js("UIkit")

View File

@@ -0,0 +1,8 @@
package dev.inmo.jsuikit.modifiers
sealed class UIKitAlign(classnameSuffix: String) : UIKitModifier {
override val classes: Array<String> = arrayOf("uk-align-$classnameSuffix")
object Left : UIKitAlign("left")
object Center : UIKitAlign("center")
object Right : UIKitAlign("right")
}

View File

@@ -0,0 +1,63 @@
package dev.inmo.jsuikit.modifiers
sealed class UIKitAnimation (name: String) : UIKitModifier, AttributeValue(name) {
override val classes: Array<String> = arrayOf("uk-animation-$name")
object Fade : UIKitAnimation("fade")
sealed class Scale(suffix: String) : UIKitAnimation("scale-$suffix") {
object Up : Scale("up")
object Down : Scale("down")
}
sealed class Slide(suffix: String) : UIKitAnimation("slide-$suffix") {
sealed class Top(suffixWithStroke: String) : Slide("top$suffixWithStroke") {
object Small : Top("-small")
object Medium : Top("-medium")
companion object : Top("")
}
sealed class Bottom(suffixWithStroke: String) : Slide("bottom$suffixWithStroke") {
object Small : Bottom("-small")
object Medium : Bottom("-medium")
companion object : Bottom("")
}
sealed class Left(suffixWithStroke: String) : Slide("left$suffixWithStroke") {
object Small : Left("-small")
object Medium : Left("-medium")
companion object : Left("")
}
sealed class Right(suffixWithStroke: String) : Slide("right$suffixWithStroke") {
object Small : Right("-small")
object Medium : Right("-medium")
companion object : Right("")
}
}
object Shake : UIKitAnimation("shake")
object Stroke : UIKitAnimation("stroke")
object Reverse : UIKitAnimation("reverse")
object Fast : UIKitAnimation("fast")
}

View File

@@ -0,0 +1,46 @@
package dev.inmo.jsuikit.modifiers
sealed class UIKitBackground(suffix: String) : UIKitModifier {
override val classes: Array<String> = arrayOf("uk-background-$suffix")
sealed class Color(suffix: String) : UIKitBackground(suffix) {
object Default : Color("default")
object Muted : Color("muted")
object Primary : Color("primary")
object Secondary : Color("secondary")
}
sealed class Size(suffix: String) : UIKitBackground(suffix) {
object Cover : Size("cover")
object Contain : Size("contain")
object FullWidth : Size("width-1-1")
object FullHeight : Size("height-1-1")
}
sealed class Position(suffix: String) : UIKitBackground(suffix) {
sealed class Top(suffix: String) : Position("top-$suffix") {
object Left : Top("left")
object Center : Top("center")
object Right : Top("right")
}
sealed class Center(suffix: String) : Position("center-$suffix") {
object Left : Position.Center("left")
object Center : Position.Center("center")
object Right : Position.Center("right")
}
sealed class Bottom(suffix: String) : Position("bottom-$suffix") {
object Left : Bottom("left")
object Center : Bottom("center")
object Right : Bottom("right")
}
}
object NoRepeat : Size("norepeat")
object Fixed : Size("fixed")
}

View File

@@ -0,0 +1,14 @@
package dev.inmo.jsuikit.modifiers
sealed class UIKitButton(suffix: String) : UIKitModifier {
override val classes: Array<String> = arrayOf("uk-button-$suffix")
sealed class Type(suffix: String) : UIKitButton(suffix) {
object Default : Type("default")
object Primary : Type("primary")
object Secondary : Type("secondary")
object Danger : Type("danger")
object Text : Type("text")
object Link : Type("link")
}
}

View File

@@ -0,0 +1,64 @@
package dev.inmo.jsuikit.modifiers
sealed class UIKitDropdown(classname: String) : UIKitModifier {
override val classes: Array<String> = arrayOf(classname)
object Nav : UIKitDropdown("uk-dropdown-nav")
object Grid : UIKitDropdown("uk-dropdown-grid")
sealed class Position(name: String) : AttributeValue(name) {
sealed class Bottom(name: String) : Position("bottom-$name") {
object Left : Bottom("left")
object Center : Bottom("center")
object Right : Bottom("right")
object Justify : Bottom("justify")
}
sealed class Top(name: String) : Position("top-$name") {
object Left : Top("left")
object Center : Top("center")
object Right : Top("right")
object Justify : Top("justify")
}
sealed class Left(name: String) : Position("left-$name") {
object Top : Left("top")
object Center : Left("center")
object Bottom : Left("bottom")
}
sealed class Right(name: String) : Position("right-$name") {
object Top : Right("top")
object Center : Right("center")
object Bottom : Right("bottom")
}
}
sealed class Mode(name: String) : AttributeValue(name) {
object Click : Mode("click")
object Hover : Mode("hover")
}
sealed class Flip(name: String) : AttributeValue(name) {
object True : Flip("true")
object False : Flip("false")
object X : Flip("x")
object Y : Flip("y")
}
}

View File

@@ -0,0 +1,7 @@
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")
}

View File

@@ -0,0 +1,79 @@
package dev.inmo.jsuikit.modifiers
sealed class UIKitFlex(suffix: String) : UIKitModifier {
override val classes: Array<String> = arrayOf("uk-flex-$suffix")
object Inline : UIKitFlex("inline")
sealed class Alignment(suffix: String) : UIKitFlex(suffix) {
sealed class Horizontal(suffix: String) : Alignment(suffix) {
object Left : Horizontal("left")
object Center : Horizontal("center")
object Right : Horizontal("right")
object Between : Horizontal("between")
object Around : Horizontal("around")
}
sealed class Vertical(suffix: String) : Alignment(suffix) {
object Stretch : Vertical("stretch")
object Top : Vertical("top")
object Middle : Vertical("middle")
object Bottom : Vertical("bottom")
}
}
sealed class Direction(suffix: String) : UIKitFlex(suffix) {
sealed class Row(suffix: String) : Direction(suffix) {
object Reverse : Row("row-reverse")
companion object : Row("row")
}
sealed class Column(suffix: String) : Direction(suffix) {
object Reverse : Column("column-reverse")
companion object : Column("column")
}
}
sealed class Wrap(suffix: String) : UIKitFlex(suffix) {
object Reverse : Wrap("wrap-reverse")
object Stretch : Wrap("wrap-stretch")
object Between : Wrap("wrap-between")
object Around : Wrap("wrap-around")
object Top : Wrap("wrap-top")
object Middle : Wrap("wrap-middle")
object Bottom : Wrap("wrap-bottom")
companion object : Wrap("wrap")
}
sealed class Order(suffix: String) : UIKitFlex(suffix) {
object First : Order("first")
object Last : Order("last")
}
sealed class Dimensions(suffix: String) : UIKitFlex(suffix) {
object None : Dimensions("none")
object Auto : Dimensions("auto")
object BasedOnFlex : Dimensions("1")
}
object NoWrap : UIKitFlex("nowrap")
}

View File

@@ -0,0 +1,20 @@
package dev.inmo.jsuikit.modifiers
sealed class UIKitGrid(suffix: String) : UIKitModifier {
override val classes: Array<String> = arrayOf("uk-grid-$suffix")
sealed class Gap(suffix: String) : UIKitGrid(suffix) {
object Small : Gap("small")
object Medium : Gap("medium")
object Large : Gap("large")
object Collapse : Gap("collapse")
}
object Divider : UIKitGrid("divider")
object MatchHeight : UIKitGrid("match")
object ItemMatchHeight : UIKitGrid("item-match")
}

View File

@@ -0,0 +1,11 @@
package dev.inmo.jsuikit.modifiers
sealed class UIKitIconType(suffix: String?) : UIKitModifier {
override val classes: Array<String> = suffix ?.let {
arrayOf("uk-icon-$suffix")
} ?: emptyArray()
object Default : UIKitIconType(null)
object Link : UIKitIconType("link")
object Button : UIKitIconType("button")
}

View File

@@ -0,0 +1,72 @@
package dev.inmo.jsuikit.modifiers
sealed class UIKitMargin(val classname: String) : UIKitModifier {
override val classes: Array<String> = arrayOf(classname)
object Top : Small("uk-margin-top")
object Bottom : Small("uk-margin-bottom")
object Left : Small("uk-margin-left")
object Right : Small("uk-margin-right")
companion object : Small("uk-margin")
sealed class Small(classname: String) : UIKitMargin(classname) {
object Top : Small("uk-margin-small-top")
object Bottom : Small("uk-margin-small-bottom")
object Left : Small("uk-margin-small-left")
object Right : Small("uk-margin-small-right")
companion object : Small("uk-margin-small")
}
sealed class Medium(classname: String) : UIKitMargin(classname) {
object Top : Medium("uk-margin-medium-top")
object Bottom : Medium("uk-margin-medium-bottom")
object Left : Medium("uk-margin-medium-left")
object Right : Medium("uk-margin-medium-right")
companion object : Medium("uk-margin-medium")
}
sealed class Large(classname: String) : UIKitMargin(classname) {
object Top : Large("uk-margin-large-top")
object Bottom : Large("uk-margin-large-bottom")
object Left : Large("uk-margin-large-left")
object Right : Large("uk-margin-large-right")
companion object : Large("uk-margin-large")
}
sealed class XLarge(classname: String) : UIKitMargin(classname) {
object Top : XLarge("uk-margin-xlarge-top")
object Bottom : XLarge("uk-margin-xlarge-bottom")
object Left : XLarge("uk-margin-xlarge-left")
object Right : XLarge("uk-margin-xlarge-right")
companion object : XLarge("uk-margin-xlarge")
}
sealed class Auto(classname: String) : UIKitMargin(classname) {
object Top : Auto("uk-margin-auto-top")
object Bottom : Auto("uk-margin-auto-bottom")
object Left : Auto("uk-margin-auto-left")
object Right : Auto("uk-margin-auto-right")
object Vertical : Auto("uk-margin-auto-vertical")
companion object : Auto("uk-margin-auto")
}
sealed class Remove(classname: String) : UIKitMargin(classname) {
object Top : Remove("uk-margin-remove-top")
object Bottom : Remove("uk-margin-remove-bottom")
object Left : Remove("uk-margin-remove-left")
object Right : Remove("uk-margin-remove-right")
object Vertical : Remove("uk-margin-remove-vertical")
object Adjacent : Remove("uk-margin-remove-adjacent")
object FirstChild : Remove("uk-margin-remove-first-child")
object LastChild : Remove("uk-margin-remove-last-child")
companion object : Remove("uk-margin-remove")
}
}

View File

@@ -0,0 +1,17 @@
package dev.inmo.jsuikit.modifiers
import org.jetbrains.compose.web.attributes.AttrsBuilder
interface UIKitModifier {
val classes: Array<String>
get() = emptyArray()
val otherAttrs: Map<String, String>
get() = emptyMap()
}
fun AttrsBuilder<*>.include(vararg container: UIKitModifier?) {
container.forEach {
it ?.classes ?.let { newClasses -> classes(*newClasses) }
it ?.otherAttrs ?.let { attrs -> attrs.forEach { (k, v) -> attr(k, v) } }
}
}

View File

@@ -0,0 +1,17 @@
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 Header : UIKitNav("uk-nav-header")
object Divider : UIKitNav("uk-nav-divider")
object Default : UIKitNav("uk-nav-default")
object Primary : UIKitNav("uk-nav-primary")
object Center : UIKitNav("uk-nav-center")
}

View File

@@ -0,0 +1,17 @@
package dev.inmo.jsuikit.modifiers
sealed class UIKitNavbar(suffix: String) : UIKitModifier {
override val classes: Array<String> = arrayOf("uk-navbar-$suffix")
object Transparent : UIKitNavbar("transparent")
sealed class Dropdown(suffix: String?) : UIKitNavbar("dropdown${suffix ?.let { "-$it" } ?: ""}") {
object Nav : Dropdown("nav")
companion object : Dropdown(null)
}
object Item : UIKitNavbar("item")
companion object {
val Logo = UIKitUtility.Logo
}
}

View File

@@ -0,0 +1,29 @@
package dev.inmo.jsuikit.modifiers
sealed class UIKitPadding(suffix: String?) : UIKitModifier {
override val classes: Array<String> = arrayOf("uk-padding${suffix ?.let { "-$it" } ?: ""}")
sealed class Size(suffix: String?) : UIKitPadding(suffix) {
object Small : Size("small")
object Large : Size("large")
companion object : Size(null)
}
sealed class Remove(suffix: String?) : UIKitPadding("remove${suffix ?.let { "-$it" } ?: ""}") {
object Top : Remove("top")
object Bottom : Remove("bottom")
object Left : Remove("left")
object Right : Remove("right")
object Vertical : Remove("vertical")
object Horizontal : Remove("horizontal")
companion object : Remove(null)
}
}

View File

@@ -0,0 +1,53 @@
package dev.inmo.jsuikit.modifiers
sealed class UIKitPosition(classname: String) : UIKitModifier {
override val classes: Array<String> = arrayOf(classname)
sealed class Top(classname: String) : UIKitPosition(classname) {
companion object : Top("uk-position-top")
object Left : Top("uk-position-top-left")
object Center : Top("uk-position-top-center")
object Right : Top("uk-position-top-right")
}
sealed class Left(classname: String) : UIKitPosition(classname) {
companion object : Left("uk-position-left")
}
sealed class Right(classname: String) : UIKitPosition(classname) {
companion object : Right("uk-position-right")
}
sealed class Center(classname: String) : UIKitPosition(classname) {
companion object : Center("uk-position-center")
sealed class Left(classname: String) : Center(classname) {
object Out : Left("uk-position-center-left-out")
companion object : Left("uk-position-center-left")
}
sealed class Right(classname: String) : Center(classname) {
object Out : Right("uk-position-center-right-out")
companion object : Right("uk-position-center-right")
}
}
sealed class Bottom(classname: String) : UIKitPosition(classname) {
companion object : Bottom("uk-position-bottom")
object Left : Bottom("uk-position-bottom-left")
object Center : Bottom("uk-position-bottom-center")
object Right : Bottom("uk-position-bottom-right")
}
sealed class Size(classname: String) : UIKitPosition(classname) {
object Small : Size("uk-position-small")
object Medium : Size("uk-position-medium")
object Large : Size("uk-position-large")
}
object Relative : UIKitPosition("uk-position-relative")
object Absolute : UIKitPosition("uk-position-absolute")
object Fixed : UIKitPosition("uk-position-fixed")
object ZIndex : UIKitPosition("uk-position-z-index")
object Cover : UIKitPosition("uk-position-cover")
}

View File

@@ -0,0 +1,20 @@
package dev.inmo.jsuikit.modifiers
sealed class UIKitScreenSizeModifier(val name: String) {
class UIKitScreenSizeModifierModified (
val modifier: UIKitScreenSizeModifier,
val base: UIKitModifier
) : UIKitModifier {
override val classes: Array<String> = base.classes.map { "$it@${modifier.name}" }.toTypedArray()
}
object Small : UIKitScreenSizeModifier("s")
object Medium : UIKitScreenSizeModifier("m")
object Large : UIKitScreenSizeModifier("l")
object XLarge : UIKitScreenSizeModifier("xl")
fun modify(modifier: UIKitModifier): UIKitModifier = UIKitScreenSizeModifierModified(
this,
modifier
)
}

View File

@@ -0,0 +1,13 @@
package dev.inmo.jsuikit.modifiers
sealed class UIKitTable(suffix: String) : UIKitModifier {
override val classes: Array<String> = arrayOf("uk-table-$suffix")
object Divider : UIKitTable("divider")
object Size {
object Small : UIKitTable("small")
object Large : UIKitTable("large")
}
object Hover : UIKitTable("hover")
object Justify : UIKitTable("justify")
}

View File

@@ -0,0 +1,25 @@
package dev.inmo.jsuikit.modifiers
sealed class UIKitText(suffix: String) : UIKitModifier {
override val classes: Array<String> = arrayOf("uk-text-$suffix")
object Lead : UIKitText("lead")
object Meta : UIKitText("meta")
sealed class Alignment(suffix: String) : UIKitText(suffix) {
object Left : Alignment("left")
object Right : Alignment("right")
object Center : Alignment("center")
object Justify : Alignment("justify")
}
sealed class Color(suffix: String) : UIKitText(suffix) {
object Muted : Color("muted")
object Emphasis : Color("emphasis")
object Primary : Color("primary")
object Secondary : Color("secondary")
object Success : Color("success")
object Warning : Color("warning")
object Danger : Color("danger")
}
}

View File

@@ -0,0 +1,46 @@
package dev.inmo.jsuikit.modifiers
class UIKitTooltipModifier(
text: String,
align: Align? = null,
delay: Int? = null,
offset: Int? = null,
duration: Int? = null,
animation: UIKitAnimation? = null
) : UIKitModifier {
private val parametersMap = listOfNotNull(
"title" to text,
align ?.let { it.k to it.v },
delay ?.let { "delay" to it.toString() },
offset ?.let { "offset" to it.toString() },
duration ?.let { "duration" to it.toString() },
animation ?.let { "animation" to it.name },
)
override val otherAttrs: Map<String, String> = mapOf(
"uk-tooltip" to parametersMap.joinToString(";") { (k, v) -> "$k: $v" }
)
sealed class Align(name: String) {
val k = "pos"
val v = name
sealed class Top(suffix: String) : Align("top$suffix") {
object Center : Top("")
object Left : Top("-left")
object Right : Top("-right")
}
sealed class Bottom(suffix: String) : Align("bottom$suffix") {
object Center : Bottom("")
object Left : Bottom("-left")
object Right : Bottom("-right")
}
object Left : Align("left")
object Right : Align("right")
}
}

View File

@@ -0,0 +1,12 @@
package dev.inmo.jsuikit.modifiers
sealed class UIKitUtility(classname: String) : UIKitModifier {
override val classes: Array<String> = arrayOf(classname)
sealed class Overflow(suffix: String) : UIKitUtility("uk-overflow-$suffix") {
object Hidden : Overflow("hidden")
object Auto : Overflow("auto")
}
object Logo : UIKitUtility("uk-logo")
}

View File

@@ -0,0 +1,33 @@
package dev.inmo.jsuikit.modifiers
sealed class UIKitWidth(classname: String) : UIKitModifier {
override val classes: Array<String> = arrayOf("uk-width-$classname")
object Full : UIKitWidth("1-1")
object Expand : UIKitWidth("expand")
object Half : UIKitWidth("1-2")
object OneThird : UIKitWidth("1-3")
object TwoThird : UIKitWidth("2-3")
object OneFourth : UIKitWidth("1-4")
val TwoFourth get() = Half
object ThreeFourth : UIKitWidth("3-4")
val FourFourth get() = Full
object OneFifth : UIKitWidth("1-5")
object TwoFifth : UIKitWidth("2-5")
object ThreeFifth : UIKitWidth("3-5")
object FourFifth : UIKitWidth("4-5")
val FiveFifth get() = Full
object OneSixth : UIKitWidth("1-6")
val TwoSixth get() = OneThird
val ThreeSixth get() = Half
val FourSixth get() = TwoThird
object FiveSixth : UIKitWidth("5-6")
val SixSixth get() = Full
override fun toString() = classes.first()
}