mirror of
https://github.com/InsanusMokrassar/JSUIKitKBindings.git
synced 2025-12-25 07:36:31 +00:00
Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 13556a293c | |||
| a4d4ec3db8 | |||
| 6f095de81d | |||
| 6b60d22e1e | |||
| 4e0cc3621c | |||
| 4943490910 | |||
| b60a3bc279 | |||
| 228138757d | |||
| f1dedf1e09 | |||
| 936bb2d6fd | |||
| 0da87743e8 | |||
| 36eeb012c6 | |||
| 58f8f99e10 | |||
| d1c03e5c48 | |||
| bd19572d78 | |||
| 9449eccec1 | |||
| f518933195 | |||
| 23f3ecb0d4 |
27
CHANGELOG.md
27
CHANGELOG.md
@@ -1,5 +1,32 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 0.0.22
|
||||||
|
|
||||||
|
* Add opportunity to customize table header cells
|
||||||
|
|
||||||
|
## 0.0.21
|
||||||
|
|
||||||
|
* Upfill `UIKitWidth`
|
||||||
|
* New extension `UIKitModifier#applyWhenScreenSizeIs`
|
||||||
|
|
||||||
|
## 0.0.20
|
||||||
|
|
||||||
|
* Remove type of button from `DefaultButton` and add companion to `UIKitButton` to be able to use `uk-button` class
|
||||||
|
|
||||||
|
## 0.0.19
|
||||||
|
|
||||||
|
* Create `Card`s implementation
|
||||||
|
* Upgrade `Label` composable draw and create `UIKitLabel` modifiers
|
||||||
|
|
||||||
|
## 0.0.18
|
||||||
|
|
||||||
|
* Add base companion for `UIKitFlex` with result class `uk-flex`
|
||||||
|
|
||||||
|
## 0.0.17
|
||||||
|
|
||||||
|
* In `DefaultTable` `headingCustomizer` has been renamed to `headerCellCustomizer`
|
||||||
|
* Add index and title parameters for `headerCellCustomizer` in `DefaultTable`
|
||||||
|
|
||||||
## 0.0.16
|
## 0.0.16
|
||||||
|
|
||||||
* Add opportunity to customize `NavDivider`
|
* Add opportunity to customize `NavDivider`
|
||||||
|
|||||||
@@ -9,4 +9,4 @@ android.enableJetifier=true
|
|||||||
# Project data
|
# Project data
|
||||||
|
|
||||||
group=dev.inmo
|
group=dev.inmo
|
||||||
version=0.0.16
|
version=0.0.22
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import org.w3c.dom.events.Event
|
|||||||
fun DefaultButton(
|
fun DefaultButton(
|
||||||
vararg modifiers: UIKitModifier,
|
vararg modifiers: UIKitModifier,
|
||||||
disabled: Boolean = false,
|
disabled: Boolean = false,
|
||||||
buttonType: UIKitButton.Type = UIKitButton.Type.Default,
|
|
||||||
onClick: ((SyntheticMouseEvent) -> Unit)? = null,
|
onClick: ((SyntheticMouseEvent) -> Unit)? = null,
|
||||||
attributesCustomizer: AttrBuilderContext<HTMLButtonElement> = {},
|
attributesCustomizer: AttrBuilderContext<HTMLButtonElement> = {},
|
||||||
contentAllocator: ContentBuilder<HTMLButtonElement>
|
contentAllocator: ContentBuilder<HTMLButtonElement>
|
||||||
@@ -22,8 +21,7 @@ fun DefaultButton(
|
|||||||
Button(
|
Button(
|
||||||
{
|
{
|
||||||
onClick ?.let { onClick(it) }
|
onClick ?.let { onClick(it) }
|
||||||
classes("uk-button")
|
include(UIKitButton, *modifiers)
|
||||||
include(*modifiers, buttonType)
|
|
||||||
if (disabled) {
|
if (disabled) {
|
||||||
disabled()
|
disabled()
|
||||||
}
|
}
|
||||||
@@ -39,12 +37,11 @@ fun DefaultButton(
|
|||||||
text: String,
|
text: String,
|
||||||
vararg modifiers: UIKitModifier,
|
vararg modifiers: UIKitModifier,
|
||||||
disabled: Boolean = false,
|
disabled: Boolean = false,
|
||||||
buttonType: UIKitButton.Type = UIKitButton.Type.Default,
|
|
||||||
preTextContentAllocator: ContentBuilder<HTMLButtonElement>? = null,
|
preTextContentAllocator: ContentBuilder<HTMLButtonElement>? = null,
|
||||||
afterTextContentAllocator: ContentBuilder<HTMLButtonElement>? = null,
|
afterTextContentAllocator: ContentBuilder<HTMLButtonElement>? = null,
|
||||||
attributesCustomizer: AttrBuilderContext<HTMLButtonElement> = {},
|
attributesCustomizer: AttrBuilderContext<HTMLButtonElement> = {},
|
||||||
onClick: ((SyntheticMouseEvent) -> Unit)? = null
|
onClick: ((SyntheticMouseEvent) -> Unit)? = null
|
||||||
) = DefaultButton(*modifiers, disabled = disabled, buttonType = buttonType, onClick = onClick, attributesCustomizer = attributesCustomizer) {
|
) = DefaultButton(*modifiers, disabled = disabled, onClick = onClick, attributesCustomizer = attributesCustomizer) {
|
||||||
preTextContentAllocator ?.apply { preTextContentAllocator() }
|
preTextContentAllocator ?.apply { preTextContentAllocator() }
|
||||||
Text(text)
|
Text(text)
|
||||||
afterTextContentAllocator ?.apply { afterTextContentAllocator() }
|
afterTextContentAllocator ?.apply { afterTextContentAllocator() }
|
||||||
|
|||||||
79
src/jsMain/kotlin/dev/inmo/jsuikit/elements/Card.kt
Normal file
79
src/jsMain/kotlin/dev/inmo/jsuikit/elements/Card.kt
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
package dev.inmo.jsuikit.elements
|
||||||
|
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import dev.inmo.jsuikit.modifiers.*
|
||||||
|
import dev.inmo.jsuikit.utils.Attrs
|
||||||
|
import org.jetbrains.compose.web.dom.*
|
||||||
|
import org.w3c.dom.*
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun Card(
|
||||||
|
cardAttrs: Attrs<HTMLDivElement> = Attrs.empty(),
|
||||||
|
headerAttrs: Attrs<HTMLDivElement> = Attrs.empty(),
|
||||||
|
header: ContentBuilder<HTMLDivElement>? = null,
|
||||||
|
footerAttrs: Attrs<HTMLDivElement> = Attrs.empty(),
|
||||||
|
footer: ContentBuilder<HTMLDivElement>? = null,
|
||||||
|
bodyAttrs: Attrs<HTMLDivElement> = Attrs.empty(),
|
||||||
|
body: ContentBuilder<HTMLDivElement>
|
||||||
|
) {
|
||||||
|
Div(
|
||||||
|
{
|
||||||
|
include(UIKitCard)
|
||||||
|
cardAttrs.builder(this)
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
header ?.let {
|
||||||
|
Div(
|
||||||
|
{
|
||||||
|
include(UIKitCard.Parts.Header)
|
||||||
|
headerAttrs.builder(this)
|
||||||
|
},
|
||||||
|
header
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Div(
|
||||||
|
{
|
||||||
|
include(UIKitCard.Parts.Body)
|
||||||
|
bodyAttrs.builder(this)
|
||||||
|
},
|
||||||
|
body
|
||||||
|
)
|
||||||
|
footer ?.let {
|
||||||
|
Div(
|
||||||
|
{
|
||||||
|
include(UIKitCard.Parts.Footer)
|
||||||
|
footerAttrs.builder(this)
|
||||||
|
},
|
||||||
|
footer
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun CardTitle(
|
||||||
|
titleAttrs: Attrs<HTMLHeadingElement> = Attrs.empty(),
|
||||||
|
title: ContentBuilder<HTMLHeadingElement>
|
||||||
|
) {
|
||||||
|
H3(
|
||||||
|
{
|
||||||
|
include(UIKitCard.Title)
|
||||||
|
titleAttrs.builder(this)
|
||||||
|
},
|
||||||
|
title
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun CardBadge(
|
||||||
|
badgeAttrs: Attrs<HTMLDivElement> = Attrs.empty(),
|
||||||
|
badge: ContentBuilder<HTMLDivElement>
|
||||||
|
) {
|
||||||
|
Div(
|
||||||
|
{
|
||||||
|
include(UIKitCard.Badge, UIKitLabel)
|
||||||
|
badgeAttrs.builder(this)
|
||||||
|
},
|
||||||
|
badge
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -1,41 +1,20 @@
|
|||||||
package dev.inmo.jsuikit.elements
|
package dev.inmo.jsuikit.elements
|
||||||
|
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import dev.inmo.jsuikit.modifiers.UIKitModifier
|
import dev.inmo.jsuikit.modifiers.*
|
||||||
import dev.inmo.jsuikit.modifiers.include
|
import dev.inmo.jsuikit.utils.Attrs
|
||||||
import org.jetbrains.compose.web.dom.*
|
import org.jetbrains.compose.web.dom.*
|
||||||
import org.w3c.dom.HTMLSpanElement
|
import org.w3c.dom.HTMLSpanElement
|
||||||
|
|
||||||
sealed interface Label {
|
@Composable
|
||||||
val suffix: String
|
fun Label(
|
||||||
|
text: String,
|
||||||
@Composable
|
attrs: Attrs<HTMLSpanElement>
|
||||||
fun draw(
|
) = Span(
|
||||||
text: String,
|
{
|
||||||
vararg modifiers: UIKitModifier,
|
include(UIKitLabel)
|
||||||
attributesCustomizer: AttrBuilderContext<HTMLSpanElement> = {},
|
attrs.builder(this)
|
||||||
) = Span(
|
|
||||||
{
|
|
||||||
classes("uk-label", "uk-label-$suffix")
|
|
||||||
include(*modifiers)
|
|
||||||
attributesCustomizer()
|
|
||||||
}
|
|
||||||
) {
|
|
||||||
Text(text)
|
|
||||||
}
|
|
||||||
|
|
||||||
object Success : Label {
|
|
||||||
override val suffix: String
|
|
||||||
get() = "success"
|
|
||||||
}
|
|
||||||
|
|
||||||
object Warning : Label {
|
|
||||||
override val suffix: String
|
|
||||||
get() = "warning"
|
|
||||||
}
|
|
||||||
|
|
||||||
object Error : Label {
|
|
||||||
override val suffix: String
|
|
||||||
get() = "danger"
|
|
||||||
}
|
}
|
||||||
|
) {
|
||||||
|
Text(text)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,16 +10,16 @@ import org.w3c.dom.*
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun <T> DefaultTable(
|
fun <T> DefaultTable(
|
||||||
heading: List<String>,
|
headerBuilders: List<ContentBuilder<HTMLTableCellElement>>,
|
||||||
dataList: SnapshotStateList<T>,
|
dataList: SnapshotStateList<T>,
|
||||||
vararg tableModifiers: UIKitModifier,
|
vararg tableModifiers: UIKitModifier,
|
||||||
attributesCustomizer: AttrBuilderContext<HTMLTableElement> = {},
|
attributesCustomizer: AttrBuilderContext<HTMLTableElement> = {},
|
||||||
headingCustomizer: AttrBuilderContext<HTMLTableCellElement> = {},
|
headerCellCustomizer: AttrsBuilder<HTMLTableCellElement>.(i: Int) -> Unit = { },
|
||||||
rowAttributes: AttrsBuilder<HTMLTableRowElement>.(t: T) -> Unit = {},
|
rowAttributes: AttrsBuilder<HTMLTableRowElement>.(t: T) -> Unit = {},
|
||||||
cellCustomizer: AttrsBuilder<HTMLTableCellElement>.(i: Int, t: T) -> Unit = { _, _ -> },
|
cellCustomizer: AttrsBuilder<HTMLTableCellElement>.(i: Int, t: T) -> Unit = { _, _ -> },
|
||||||
cellFiller: @Composable ElementScope<HTMLTableCellElement>.(i: Int, t: T) -> Unit
|
cellFiller: @Composable ElementScope<HTMLTableCellElement>.(i: Int, t: T) -> Unit
|
||||||
) {
|
) {
|
||||||
val headingIndexes = heading.indices
|
val headingIndexes = headerBuilders.indices
|
||||||
Table(
|
Table(
|
||||||
{
|
{
|
||||||
classes("uk-table")
|
classes("uk-table")
|
||||||
@@ -29,13 +29,13 @@ fun <T> DefaultTable(
|
|||||||
) {
|
) {
|
||||||
Thead {
|
Thead {
|
||||||
Tr {
|
Tr {
|
||||||
heading.forEach {
|
headerBuilders.forEachIndexed { i, t ->
|
||||||
Th(
|
Th(
|
||||||
{
|
{
|
||||||
headingCustomizer()
|
headerCellCustomizer(i)
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
Text(it)
|
t()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -61,3 +61,37 @@ fun <T> DefaultTable(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun <T> DefaultTable(
|
||||||
|
heading: List<String>,
|
||||||
|
dataList: SnapshotStateList<T>,
|
||||||
|
vararg tableModifiers: UIKitModifier,
|
||||||
|
attributesCustomizer: AttrBuilderContext<HTMLTableElement> = {},
|
||||||
|
headerCellCustomizer: AttrsBuilder<HTMLTableCellElement>.(i: Int, title: String) -> Unit = { _, _ -> },
|
||||||
|
rowAttributes: AttrsBuilder<HTMLTableRowElement>.(t: T) -> Unit = {},
|
||||||
|
cellCustomizer: AttrsBuilder<HTMLTableCellElement>.(i: Int, t: T) -> Unit = { _, _ -> },
|
||||||
|
cellFiller: @Composable ElementScope<HTMLTableCellElement>.(i: Int, t: T) -> Unit
|
||||||
|
) {
|
||||||
|
val headersByIndex = heading.mapIndexed { index, s -> index to s }.toMap()
|
||||||
|
val headerCellCustomizer: AttrsBuilder<HTMLTableCellElement>.(i: Int) -> Unit = { i ->
|
||||||
|
val header = headersByIndex[i]
|
||||||
|
if (header != null) {
|
||||||
|
headerCellCustomizer(i, header)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
inline fun headerFactory(header: String): ContentBuilder<HTMLTableCellElement> = {
|
||||||
|
Text(header)
|
||||||
|
}
|
||||||
|
val headerBuilders = heading.map(::headerFactory)
|
||||||
|
return DefaultTable(
|
||||||
|
headerBuilders,
|
||||||
|
dataList,
|
||||||
|
tableModifiers = tableModifiers,
|
||||||
|
attributesCustomizer,
|
||||||
|
headerCellCustomizer,
|
||||||
|
rowAttributes,
|
||||||
|
cellCustomizer,
|
||||||
|
cellFiller
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package dev.inmo.jsuikit.modifiers
|
package dev.inmo.jsuikit.modifiers
|
||||||
|
|
||||||
sealed class UIKitButton(suffix: String) : UIKitModifier {
|
sealed class UIKitButton(suffix: String?) : UIKitModifier {
|
||||||
override val classes: Array<String> = arrayOf("uk-button-$suffix")
|
override val classes: Array<String> = arrayOf("uk-button${suffix?.let { "-$it" } ?: ""}")
|
||||||
|
|
||||||
sealed class Type(suffix: String) : UIKitButton(suffix) {
|
sealed class Type(suffix: String) : UIKitButton(suffix) {
|
||||||
object Default : Type("default")
|
object Default : Type("default")
|
||||||
@@ -11,4 +11,6 @@ sealed class UIKitButton(suffix: String) : UIKitModifier {
|
|||||||
object Text : Type("text")
|
object Text : Type("text")
|
||||||
object Link : Type("link")
|
object Link : Type("link")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object : UIKitButton(null)
|
||||||
}
|
}
|
||||||
|
|||||||
35
src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitCard.kt
Normal file
35
src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitCard.kt
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
package dev.inmo.jsuikit.modifiers
|
||||||
|
|
||||||
|
sealed class UIKitCard(suffix: String?) : UIKitModifier {
|
||||||
|
override val classes: Array<String> = arrayOf("uk-card${suffix ?.let { "-$it" } ?: ""}")
|
||||||
|
|
||||||
|
object Title : UIKitCard("title")
|
||||||
|
object Hover : UIKitCard("hover")
|
||||||
|
object Badge : Parts("badge")
|
||||||
|
|
||||||
|
sealed class Parts(suffix: String) : UIKitCard(suffix) {
|
||||||
|
object Header : Parts("header")
|
||||||
|
object Body : Parts("body")
|
||||||
|
object Footer : Parts("footer")
|
||||||
|
}
|
||||||
|
|
||||||
|
sealed class Style(suffix: String) : UIKitCard(suffix) {
|
||||||
|
object Default : Style("default")
|
||||||
|
object Primary : Style("primary")
|
||||||
|
object Secondary : Style("secondary")
|
||||||
|
}
|
||||||
|
|
||||||
|
sealed class Size(suffix: String) : UIKitCard(suffix) {
|
||||||
|
object Small : Size("small")
|
||||||
|
object Large : Size("large")
|
||||||
|
}
|
||||||
|
|
||||||
|
sealed class Media(suffix: String) : UIKitCard("media-$suffix") {
|
||||||
|
object Top : Media("top")
|
||||||
|
object Right : Media("right")
|
||||||
|
object Bottom : Media("bottom")
|
||||||
|
object Left : Media("left")
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object : UIKitCard(null)
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package dev.inmo.jsuikit.modifiers
|
package dev.inmo.jsuikit.modifiers
|
||||||
|
|
||||||
sealed class UIKitFlex(suffix: String) : UIKitModifier {
|
sealed class UIKitFlex(suffix: String?) : UIKitModifier {
|
||||||
override val classes: Array<String> = arrayOf("uk-flex-$suffix")
|
override val classes: Array<String> = arrayOf("uk-flex${suffix ?.let { "-$it" } ?: ""}")
|
||||||
|
|
||||||
object Inline : UIKitFlex("inline")
|
object Inline : UIKitFlex("inline")
|
||||||
|
|
||||||
@@ -76,4 +76,6 @@ sealed class UIKitFlex(suffix: String) : UIKitModifier {
|
|||||||
|
|
||||||
object NoWrap : UIKitFlex("nowrap")
|
object NoWrap : UIKitFlex("nowrap")
|
||||||
|
|
||||||
|
companion object : UIKitFlex(null)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
11
src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitLabel.kt
Normal file
11
src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitLabel.kt
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
package dev.inmo.jsuikit.modifiers
|
||||||
|
|
||||||
|
sealed class UIKitLabel(suffix: String?) : UIKitModifier {
|
||||||
|
override val classes: Array<String> = arrayOf("uk-label${suffix?.let { "-$it" } ?: ""}")
|
||||||
|
|
||||||
|
object Success : UIKitLabel("success")
|
||||||
|
object Warning : UIKitLabel("warning")
|
||||||
|
object Error : UIKitLabel("danger")
|
||||||
|
|
||||||
|
companion object : UIKitLabel(null)
|
||||||
|
}
|
||||||
@@ -18,3 +18,5 @@ sealed class UIKitScreenSizeModifier(val name: String) {
|
|||||||
modifier
|
modifier
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun UIKitModifier.applyWhenScreenSizeIs(size: UIKitScreenSizeModifier) = size.modify(this)
|
||||||
|
|||||||
@@ -3,8 +3,9 @@ package dev.inmo.jsuikit.modifiers
|
|||||||
sealed class UIKitWidth(classname: String) : UIKitModifier {
|
sealed class UIKitWidth(classname: String) : UIKitModifier {
|
||||||
override val classes: Array<String> = arrayOf("uk-width-$classname")
|
override val classes: Array<String> = arrayOf("uk-width-$classname")
|
||||||
|
|
||||||
object Full : UIKitWidth("1-1")
|
object Auto : UIKitWidth("auto")
|
||||||
object Expand : UIKitWidth("expand")
|
object Expand : UIKitWidth("expand")
|
||||||
|
object Full : UIKitWidth("1-1")
|
||||||
|
|
||||||
object Half : UIKitWidth("1-2")
|
object Half : UIKitWidth("1-2")
|
||||||
|
|
||||||
@@ -12,22 +13,70 @@ sealed class UIKitWidth(classname: String) : UIKitModifier {
|
|||||||
object TwoThird : UIKitWidth("2-3")
|
object TwoThird : UIKitWidth("2-3")
|
||||||
|
|
||||||
object OneFourth : UIKitWidth("1-4")
|
object OneFourth : UIKitWidth("1-4")
|
||||||
val TwoFourth get() = Half
|
|
||||||
object ThreeFourth : UIKitWidth("3-4")
|
object ThreeFourth : UIKitWidth("3-4")
|
||||||
val FourFourth get() = Full
|
|
||||||
|
|
||||||
object OneFifth : UIKitWidth("1-5")
|
object OneFifth : UIKitWidth("1-5")
|
||||||
object TwoFifth : UIKitWidth("2-5")
|
object TwoFifth : UIKitWidth("2-5")
|
||||||
object ThreeFifth : UIKitWidth("3-5")
|
object ThreeFifth : UIKitWidth("3-5")
|
||||||
object FourFifth : UIKitWidth("4-5")
|
object FourFifth : UIKitWidth("4-5")
|
||||||
val FiveFifth get() = Full
|
|
||||||
|
|
||||||
object OneSixth : UIKitWidth("1-6")
|
object OneSixth : UIKitWidth("1-6")
|
||||||
val TwoSixth get() = OneThird
|
|
||||||
val ThreeSixth get() = Half
|
|
||||||
val FourSixth get() = TwoThird
|
|
||||||
object FiveSixth : UIKitWidth("5-6")
|
object FiveSixth : UIKitWidth("5-6")
|
||||||
val SixSixth get() = Full
|
|
||||||
|
sealed class Child(suffix: String) : UIKitWidth("child-$suffix") {
|
||||||
|
object Full : Child("1-1")
|
||||||
|
|
||||||
|
object Half : Child("1-2")
|
||||||
|
|
||||||
|
object OneThird : Child("1-3")
|
||||||
|
object TwoThird : Child("2-3")
|
||||||
|
|
||||||
|
object OneFourth : Child("1-4")
|
||||||
|
object ThreeFourth : Child("3-4")
|
||||||
|
|
||||||
|
object OneFifth : Child("1-5")
|
||||||
|
object TwoFifth : Child("2-5")
|
||||||
|
object ThreeFifth : Child("3-5")
|
||||||
|
object FourFifth : Child("4-5")
|
||||||
|
|
||||||
|
object OneSixth : Child("1-6")
|
||||||
|
object FiveSixth : Child("5-6")
|
||||||
|
|
||||||
|
object Auto : Child("auto")
|
||||||
|
object Expand : Child("expand")
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
|
||||||
|
val TwoFourth get() = Half
|
||||||
|
val TwoSixth get() = OneThird
|
||||||
|
val ThreeSixth get() = Half
|
||||||
|
val FourSixth get() = TwoThird
|
||||||
|
val FourFourth get() = Full
|
||||||
|
val FiveFifth get() = Full
|
||||||
|
val SixSixth get() = Full
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sealed class Fixed(suffix: String) : UIKitWidth("fixed-$suffix") {
|
||||||
|
|
||||||
|
object Small : Fixed("small")
|
||||||
|
object Medium : Fixed("medium")
|
||||||
|
object Large : Fixed("large")
|
||||||
|
object XLarge : Fixed("xlarge")
|
||||||
|
object XXLarge : Fixed("2xlarge")
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
override fun toString() = classes.first()
|
override fun toString() = classes.first()
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
|
||||||
|
val TwoFourth get() = Half
|
||||||
|
val TwoSixth get() = OneThird
|
||||||
|
val ThreeSixth get() = Half
|
||||||
|
val FourSixth get() = TwoThird
|
||||||
|
val FourFourth get() = Full
|
||||||
|
val FiveFifth get() = Full
|
||||||
|
val SixSixth get() = Full
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package dev.inmo.jsuikit.utils
|
||||||
|
|
||||||
|
import dev.inmo.jsuikit.modifiers.UIKitModifier
|
||||||
|
import dev.inmo.jsuikit.modifiers.include
|
||||||
|
import org.jetbrains.compose.web.attributes.AttrsBuilder
|
||||||
|
import org.jetbrains.compose.web.dom.AttrBuilderContext
|
||||||
|
import org.w3c.dom.Element
|
||||||
|
|
||||||
|
class AttributesCollection<T : Element> (
|
||||||
|
private vararg val modifiers: UIKitModifier,
|
||||||
|
private val attrs: AttrBuilderContext<T> = {}
|
||||||
|
) {
|
||||||
|
val builder: AttrBuilderContext<T> = {
|
||||||
|
include(*modifiers)
|
||||||
|
attrs()
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
val Empty = Attrs<Element>()
|
||||||
|
|
||||||
|
@Suppress("UNCHECKED_CAST")
|
||||||
|
fun <T : Element> empty() = Empty as Attrs<T>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
typealias Attrs<T> = AttributesCollection<T>
|
||||||
Reference in New Issue
Block a user