Compare commits

..

39 Commits

Author SHA1 Message Date
13556a293c add opportunity to customize table header cells 2022-01-25 19:35:08 +06:00
a4d4ec3db8 start 0.0.22 2022-01-25 19:34:59 +06:00
6f095de81d Merge pull request #21 from InsanusMokrassar/0.0.21
0.0.21
2022-01-25 13:15:51 +06:00
6b60d22e1e upfill UIKitWidth 2022-01-25 13:15:37 +06:00
4e0cc3621c start 0.0.21 2022-01-25 13:15:04 +06:00
4943490910 Merge pull request #20 from InsanusMokrassar/0.0.20
0.0.20
2022-01-25 12:54:38 +06:00
b60a3bc279 fixes in buttons 2022-01-25 12:54:19 +06:00
228138757d start 0.0.20 2022-01-25 12:53:47 +06:00
f1dedf1e09 Merge pull request #19 from InsanusMokrassar/0.0.19
0.0.19
2022-01-25 12:39:35 +06:00
936bb2d6fd create cards implementation and upgrade labels 2022-01-25 12:39:09 +06:00
0da87743e8 start 0.0.19 2022-01-25 12:38:37 +06:00
36eeb012c6 Merge pull request #18 from InsanusMokrassar/0.0.18
0.0.18
2022-01-25 11:25:47 +06:00
58f8f99e10 add uk-flex to UIKitFlex base class 2022-01-25 11:24:58 +06:00
d1c03e5c48 start 0.0.18 2022-01-25 11:22:36 +06:00
bd19572d78 Merge pull request #17 from InsanusMokrassar/0.0.17
0.0.17
2022-01-25 00:02:49 +06:00
9449eccec1 headingCustomizer -> headerCellCustomizer + add index and title parameters for it 2022-01-25 00:02:29 +06:00
f518933195 start 0.0.17 2022-01-25 00:00:42 +06:00
23f3ecb0d4 Merge pull request #16 from InsanusMokrassar/0.0.16
0.0.16
2022-01-24 21:46:41 +06:00
c6023d3075 add opportunity to customize NavDivider 2022-01-24 21:39:47 +06:00
7b72f99f66 start 0.0.16 2022-01-24 21:39:40 +06:00
66c3f97f65 Merge pull request #15 from InsanusMokrassar/0.0.15
0.0.15
2022-01-21 22:41:49 +06:00
40c3c0f437 add support of link icons type 2022-01-21 22:41:26 +06:00
e46b2e0ddd start 0.0.15 2022-01-21 22:41:18 +06:00
2db4e48571 Merge pull request #14 from InsanusMokrassar/0.0.14
0.0.14
2022-01-21 22:20:16 +06:00
e13a2fd241 add DefaultTable parameter cellAttributes 2022-01-21 22:20:02 +06:00
b3b19ed2b7 start 0.0.14 2022-01-21 22:16:03 +06:00
d590762d28 Merge pull request #13 from InsanusMokrassar/0.0.13
0.0.13
2022-01-21 21:37:39 +06:00
65703d1c22 add Icon#Custom 2022-01-21 21:37:16 +06:00
814045a43f start 0.0.13 2022-01-21 21:37:07 +06:00
1f36657857 Merge pull request #12 from InsanusMokrassar/0.0.12
0.0.12
2022-01-21 20:29:00 +06:00
a2830e5e85 add rowAttributes customizer for tables 2022-01-21 20:28:19 +06:00
484564e323 start 0.0.12 2022-01-21 20:27:31 +06:00
b5e93bc829 Merge pull request #11 from InsanusMokrassar/0.0.11
0.0.11
2022-01-21 11:32:00 +06:00
4282165d79 upfill navs 2022-01-21 11:31:00 +06:00
1e452c78d1 start 0.0.11 2022-01-21 11:30:47 +06:00
5fa388c169 Merge pull request #10 from InsanusMokrassar/0.0.10
0.0.10
2022-01-21 10:57:06 +06:00
763e1fa5ac upfill utilities 2022-01-21 10:55:14 +06:00
150efa1719 start 0.0.10 2022-01-21 10:55:01 +06:00
20bf43b8a1 Merge pull request #9 from InsanusMokrassar/0.0.9
0.0.9
2022-01-20 20:06:36 +06:00
17 changed files with 629 additions and 72 deletions

View File

@@ -1,5 +1,60 @@
# 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
* Add opportunity to customize `NavDivider`
## 0.0.15
* Add support of link icons
## 0.0.14
* Add DefaultTable parameter cellCustomizer
## 0.0.13
* Add `Icon#Custom`
## 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

View File

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

View File

@@ -14,7 +14,6 @@ import org.w3c.dom.events.Event
fun DefaultButton(
vararg modifiers: UIKitModifier,
disabled: Boolean = false,
buttonType: UIKitButton.Type = UIKitButton.Type.Default,
onClick: ((SyntheticMouseEvent) -> Unit)? = null,
attributesCustomizer: AttrBuilderContext<HTMLButtonElement> = {},
contentAllocator: ContentBuilder<HTMLButtonElement>
@@ -22,8 +21,7 @@ fun DefaultButton(
Button(
{
onClick ?.let { onClick(it) }
classes("uk-button")
include(*modifiers, buttonType)
include(UIKitButton, *modifiers)
if (disabled) {
disabled()
}
@@ -39,12 +37,11 @@ fun DefaultButton(
text: String,
vararg modifiers: UIKitModifier,
disabled: Boolean = false,
buttonType: UIKitButton.Type = UIKitButton.Type.Default,
preTextContentAllocator: ContentBuilder<HTMLButtonElement>? = null,
afterTextContentAllocator: ContentBuilder<HTMLButtonElement>? = null,
attributesCustomizer: AttrBuilderContext<HTMLButtonElement> = {},
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() }
Text(text)
afterTextContentAllocator ?.apply { afterTextContentAllocator() }

View 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
)
}

View File

@@ -219,13 +219,15 @@ sealed class Icon(val name: String) {
}
attributesCustomizer()
}
if (type == UIKitIconType.Button) {
Button(configurer)
} else {
Span(configurer)
when (type) {
UIKitIconType.Default -> Span(configurer)
UIKitIconType.Link -> A(href = "#", configurer)
UIKitIconType.Button -> Button(configurer)
}
}
class Custom(name: String) : Icon(name)
@Composable
fun drawAsButton(
vararg modifiers: UIKitModifier,
@@ -241,4 +243,12 @@ sealed class Icon(val name: String) {
attributesCustomizer: AttrBuilderContext<out HTMLElement> = {},
onClick: ((Event) -> Unit)? = null
) = invoke(*modifiers, type = UIKitIconType.Default, ratio = ratio, onClick = onClick, attributesCustomizer = attributesCustomizer)
@Composable
fun drawAsLink(
vararg modifiers: UIKitModifier,
ratio: Float? = null,
attributesCustomizer: AttrBuilderContext<out HTMLElement> = {},
onClick: ((Event) -> Unit)? = null
) = invoke(*modifiers, type = UIKitIconType.Link, ratio = ratio, onClick = onClick, attributesCustomizer = attributesCustomizer)
}

View File

@@ -1,41 +1,20 @@
package dev.inmo.jsuikit.elements
import androidx.compose.runtime.Composable
import dev.inmo.jsuikit.modifiers.UIKitModifier
import dev.inmo.jsuikit.modifiers.include
import dev.inmo.jsuikit.modifiers.*
import dev.inmo.jsuikit.utils.Attrs
import org.jetbrains.compose.web.dom.*
import org.w3c.dom.HTMLSpanElement
sealed interface Label {
val suffix: String
@Composable
fun draw(
text: String,
vararg modifiers: UIKitModifier,
attributesCustomizer: AttrBuilderContext<HTMLSpanElement> = {},
) = 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"
@Composable
fun Label(
text: String,
attrs: Attrs<HTMLSpanElement>
) = Span(
{
include(UIKitLabel)
attrs.builder(this)
}
) {
Text(text)
}

View File

@@ -27,8 +27,7 @@ fun Nav(
"animation" to animation
"duration" to duration ?.toString()
}
classes("uk-nav")
include(*modifiers)
include(*modifiers, UIKitNav)
attributesCustomizer()
}
) {
@@ -36,6 +35,63 @@ 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,
@@ -59,8 +115,7 @@ fun <T> Nav(
"animation" to animation
"duration" to duration ?.toString()
}
classes("uk-nav")
include(*ulModifiers)
include(*ulModifiers, UIKitNav)
ulCustomizer()
}
) {
@@ -76,6 +131,93 @@ fun <T> Nav(
}
}
@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,
@@ -92,6 +234,24 @@ fun NavHeader(
}
}
@Composable
fun NavItemElement(
vararg modifiers: UIKitModifier,
attributesCustomizer: AttrBuilderContext<HTMLLIElement> = {},
contentAllocator: ContentBuilder<HTMLAnchorElement>
) {
Li(
{
include(*modifiers)
attributesCustomizer()
}
) {
A("#") {
contentAllocator()
}
}
}
@Composable
fun NavElement(
vararg modifiers: UIKitModifier,
@@ -109,6 +269,9 @@ fun NavElement(
}
@Composable
fun NavDivider() {
Li({ include(UIKitNav.Divider) })
fun NavDivider(
vararg modifiers: UIKitModifier,
attributesCustomizer: AttrBuilderContext<HTMLLIElement> = {},
) {
Li({ include(UIKitNav.Divider, *modifiers);attributesCustomizer() })
}

View File

@@ -3,20 +3,23 @@ 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.jetbrains.compose.web.dom.Text
import org.w3c.dom.*
@Composable
fun <T> DefaultTable(
heading: List<String>,
headerBuilders: List<ContentBuilder<HTMLTableCellElement>>,
dataList: SnapshotStateList<T>,
vararg tableModifiers: UIKitModifier,
attributesCustomizer: AttrBuilderContext<HTMLTableElement> = {},
headingCustomizer: AttrBuilderContext<HTMLTableCellElement> = {},
cellFiller: @Composable (i: Int, t: T) -> Unit
headerCellCustomizer: AttrsBuilder<HTMLTableCellElement>.(i: Int) -> 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 headingIndexes = heading.indices
val headingIndexes = headerBuilders.indices
Table(
{
classes("uk-table")
@@ -26,22 +29,30 @@ fun <T> DefaultTable(
) {
Thead {
Tr {
heading.forEach {
headerBuilders.forEachIndexed { i, t ->
Th(
{
headingCustomizer()
headerCellCustomizer(i)
}
) {
Text(it)
t()
}
}
}
}
Tbody {
dataList.forEach {
Tr {
Tr(
{
rowAttributes(it)
}
) {
headingIndexes.forEach { i ->
Td {
Td(
{
cellCustomizer(i, it)
}
) {
cellFiller(i, it)
}
}
@@ -50,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
)
}

View File

@@ -1,7 +1,7 @@
package dev.inmo.jsuikit.modifiers
sealed class UIKitButton(suffix: String) : UIKitModifier {
override val classes: Array<String> = arrayOf("uk-button-$suffix")
sealed class UIKitButton(suffix: String?) : UIKitModifier {
override val classes: Array<String> = arrayOf("uk-button${suffix?.let { "-$it" } ?: ""}")
sealed class Type(suffix: String) : UIKitButton(suffix) {
object Default : Type("default")
@@ -11,4 +11,6 @@ sealed class UIKitButton(suffix: String) : UIKitModifier {
object Text : Type("text")
object Link : Type("link")
}
companion object : UIKitButton(null)
}

View 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)
}

View File

@@ -1,7 +1,7 @@
package dev.inmo.jsuikit.modifiers
sealed class UIKitFlex(suffix: String) : UIKitModifier {
override val classes: Array<String> = arrayOf("uk-flex-$suffix")
sealed class UIKitFlex(suffix: String?) : UIKitModifier {
override val classes: Array<String> = arrayOf("uk-flex${suffix ?.let { "-$it" } ?: ""}")
object Inline : UIKitFlex("inline")
@@ -76,4 +76,6 @@ sealed class UIKitFlex(suffix: String) : UIKitModifier {
object NoWrap : UIKitFlex("nowrap")
companion object : UIKitFlex(null)
}

View 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)
}

View File

@@ -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")
}

View File

@@ -18,3 +18,5 @@ sealed class UIKitScreenSizeModifier(val name: String) {
modifier
)
}
fun UIKitModifier.applyWhenScreenSizeIs(size: UIKitScreenSizeModifier) = size.modify(this)

View File

@@ -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")
}

View File

@@ -3,8 +3,9 @@ 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 Auto : UIKitWidth("auto")
object Expand : UIKitWidth("expand")
object Full : UIKitWidth("1-1")
object Half : UIKitWidth("1-2")
@@ -12,22 +13,70 @@ sealed class UIKitWidth(classname: String) : UIKitModifier {
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
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()
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
}
}

View File

@@ -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>