fixes in buttons

This commit is contained in:
InsanusMokrassar 2022-01-25 12:54:19 +06:00
parent 228138757d
commit b60a3bc279
3 changed files with 8 additions and 7 deletions

View File

@ -2,6 +2,8 @@
## 0.0.20 ## 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 ## 0.0.19
* Create `Card`s implementation * Create `Card`s implementation

View File

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

View File

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