From 9fe7c458e9ddf7264ea55c8efd43cde103b9e989 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 16 Nov 2022 01:28:34 +0600 Subject: [PATCH] complete rework --- .../core/ui/MavenInfoView.kt | 1 + .../core/ui/ProjectTypeView.kt | 1 + .../core/ui/utils/UIElements.kt | 4 +++- .../core/ui/GpgSigningOptionDrawer.kt | 6 ++++-- .../core/ui/LicensesDrawer.kt | 6 ++++-- .../core/ui/ListViewDrawer.kt | 6 ++++-- .../core/ui/ProjectTypeDrawer.kt | 7 +++++-- .../core/ui/utils/ActualUIElements.kt | 19 ++++++++++++++++--- .../core/ui/utils/NoTransform.kt | 9 +++++++++ core/src/jsMain/resources/css/internal.css | 4 ++++ core/src/jsMain/resources/index.html | 1 + .../core/ui/utils/ActualUIElements.kt | 6 +++++- 12 files changed, 57 insertions(+), 13 deletions(-) create mode 100644 core/src/jsMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/utils/NoTransform.kt create mode 100644 core/src/jsMain/resources/css/internal.css diff --git a/core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/MavenInfoView.kt b/core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/MavenInfoView.kt index f0d56ea..aca1351 100644 --- a/core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/MavenInfoView.kt +++ b/core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/MavenInfoView.kt @@ -74,6 +74,7 @@ class MavenInfoView : VerticalView("Project information") { ) { projectVcsUrlProperty = it } ButtonsPanel( + "Gpg signing", GpgSigning.Disabled, GpgSigning.Optional, GpgSigning.Enabled diff --git a/core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/ProjectTypeView.kt b/core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/ProjectTypeView.kt index 5d1d855..ce06582 100644 --- a/core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/ProjectTypeView.kt +++ b/core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/ProjectTypeView.kt @@ -20,6 +20,7 @@ class ProjectTypeView : VerticalView("Project type") { override val content: @Composable () -> Unit = { ButtonsPanel( + "Project type", MultiplatformProjectType, JVMProjectType, JSProjectType diff --git a/core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/utils/UIElements.kt b/core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/utils/UIElements.kt index 9ae93f9..9e8c749 100644 --- a/core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/utils/UIElements.kt +++ b/core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/utils/UIElements.kt @@ -27,15 +27,17 @@ expect fun SwitchWithLabel( @Composable expect fun ButtonsPanel( + title: String, data: Iterable, itemDrawer: @Composable (T) -> Unit ) @Composable fun ButtonsPanel( + title: String, vararg data: T, itemDrawer: @Composable (T) -> Unit -) = ButtonsPanel(data.toList(), itemDrawer) +) = ButtonsPanel(title, data.toList(), itemDrawer) @Composable expect fun DefaultDivider() diff --git a/core/src/jsMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/GpgSigningOptionDrawer.kt b/core/src/jsMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/GpgSigningOptionDrawer.kt index e4a858d..3a7b932 100644 --- a/core/src/jsMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/GpgSigningOptionDrawer.kt +++ b/core/src/jsMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/GpgSigningOptionDrawer.kt @@ -4,8 +4,10 @@ import androidx.compose.runtime.Composable import dev.inmo.jsuikit.elements.DefaultButton import dev.inmo.jsuikit.modifiers.UIKitButton import dev.inmo.jsuikit.modifiers.UIKitMargin +import dev.inmo.jsuikit.modifiers.UIKitUtility import dev.inmo.kmppscriptbuilder.core.models.GpgSigning import dev.inmo.kmppscriptbuilder.core.ui.utils.Drawer +import dev.inmo.kmppscriptbuilder.core.ui.utils.NoTransform actual class GpgSigningOptionDrawer( private val mavenInfoView: MavenInfoView @@ -13,9 +15,9 @@ actual class GpgSigningOptionDrawer( @Composable override fun GpgSigning.draw() { if (mavenInfoView.gpgSignProperty == this) { - DefaultButton(name, UIKitButton.Type.Primary) + DefaultButton(name, UIKitButton.Type.Primary, UIKitMargin.Small.Horizontal, UIKitUtility.NoTransform, UIKitUtility.Border.Rounded) } else { - DefaultButton(name, UIKitButton.Type.Default) { + DefaultButton(name, UIKitButton.Type.Default, UIKitMargin.Small.Horizontal, UIKitUtility.NoTransform, UIKitUtility.Border.Rounded) { mavenInfoView.gpgSignProperty = this } } diff --git a/core/src/jsMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/LicensesDrawer.kt b/core/src/jsMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/LicensesDrawer.kt index 5990f7c..c737703 100644 --- a/core/src/jsMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/LicensesDrawer.kt +++ b/core/src/jsMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/LicensesDrawer.kt @@ -5,10 +5,12 @@ import dev.inmo.jsuikit.elements.DefaultButton import dev.inmo.jsuikit.elements.Divider import dev.inmo.jsuikit.modifiers.UIKitButton import dev.inmo.jsuikit.modifiers.UIKitMargin +import dev.inmo.jsuikit.modifiers.UIKitUtility import dev.inmo.jsuikit.modifiers.builder import dev.inmo.jsuikit.utils.Attrs import dev.inmo.kmppscriptbuilder.core.ui.utils.CommonTextField import dev.inmo.kmppscriptbuilder.core.ui.utils.Drawer +import dev.inmo.kmppscriptbuilder.core.ui.utils.NoTransform import org.jetbrains.compose.web.dom.Div actual object LicensesDrawer : Drawer { @@ -32,7 +34,7 @@ actual object LicensesDrawer : Drawer { Divider.Common() } - DefaultButton("Add empty license", UIKitButton.Type.Primary, UIKitMargin.Small) { + DefaultButton("Add empty license", UIKitButton.Type.Primary, UIKitMargin.Small, UIKitUtility.NoTransform, UIKitUtility.Border.Rounded) { licensesListState.add(LicenseState()) } @@ -50,7 +52,7 @@ actual object LicensesDrawer : Drawer { license.url ?: "", "License URL", ) { license.url = it } - DefaultButton("Remove", UIKitButton.Type.Danger, UIKitMargin.Small) { + DefaultButton("Remove", UIKitButton.Type.Default, UIKitMargin.Small, UIKitUtility.NoTransform, UIKitUtility.Border.Rounded) { licensesListState.remove(license) } } diff --git a/core/src/jsMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/ListViewDrawer.kt b/core/src/jsMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/ListViewDrawer.kt index bc41c88..13d57cf 100644 --- a/core/src/jsMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/ListViewDrawer.kt +++ b/core/src/jsMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/ListViewDrawer.kt @@ -4,18 +4,20 @@ import androidx.compose.runtime.Composable import dev.inmo.jsuikit.elements.DefaultButton import dev.inmo.jsuikit.modifiers.UIKitButton import dev.inmo.jsuikit.modifiers.UIKitMargin +import dev.inmo.jsuikit.modifiers.UIKitUtility import dev.inmo.jsuikit.modifiers.builder import dev.inmo.kmppscriptbuilder.core.ui.utils.Drawer +import dev.inmo.kmppscriptbuilder.core.ui.utils.NoTransform import org.jetbrains.compose.web.dom.Div actual class ListViewDrawer : Drawer> { @Composable override fun ListView.draw() { - DefaultButton(addItemText, UIKitButton.Type.Primary ) { itemsList.add(createItem()) } + DefaultButton(addItemText, UIKitButton.Type.Primary, UIKitUtility.NoTransform, UIKitUtility.Border.Rounded ) { itemsList.add(createItem()) } itemsList.forEach { item -> Div(UIKitMargin.Small.builder()) { buildView(item) - DefaultButton(removeItemText, UIKitButton.Type.Danger, UIKitMargin.Small) { + DefaultButton(removeItemText, UIKitButton.Type.Default, UIKitMargin.Small, UIKitUtility.NoTransform, UIKitUtility.Border.Rounded) { itemsList.remove(item) } } diff --git a/core/src/jsMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/ProjectTypeDrawer.kt b/core/src/jsMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/ProjectTypeDrawer.kt index 9d20311..b567e4f 100644 --- a/core/src/jsMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/ProjectTypeDrawer.kt +++ b/core/src/jsMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/ProjectTypeDrawer.kt @@ -4,8 +4,11 @@ import androidx.compose.runtime.Composable import dev.inmo.jsuikit.elements.DefaultButton import dev.inmo.jsuikit.modifiers.UIKitButton import dev.inmo.jsuikit.modifiers.UIKitMargin +import dev.inmo.jsuikit.modifiers.UIKitText +import dev.inmo.jsuikit.modifiers.UIKitUtility import dev.inmo.kmppscriptbuilder.core.models.ProjectType import dev.inmo.kmppscriptbuilder.core.ui.utils.Drawer +import dev.inmo.kmppscriptbuilder.core.ui.utils.NoTransform actual class ProjectTypeDrawer( private val projectTypeView: ProjectTypeView @@ -13,9 +16,9 @@ actual class ProjectTypeDrawer( @Composable override fun ProjectType.draw() { if (projectTypeView.projectType == this) { - DefaultButton(name, UIKitButton.Type.Primary) + DefaultButton(name, UIKitButton.Type.Primary, UIKitMargin.Small.Horizontal, UIKitUtility.NoTransform, UIKitUtility.Border.Rounded) } else { - DefaultButton(name, UIKitButton.Type.Default) { + DefaultButton(name, UIKitButton.Type.Default, UIKitMargin.Small.Horizontal, UIKitUtility.NoTransform, UIKitUtility.Border.Rounded) { projectTypeView.projectType = this } } diff --git a/core/src/jsMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/utils/ActualUIElements.kt b/core/src/jsMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/utils/ActualUIElements.kt index 8b2b6db..d9f562f 100644 --- a/core/src/jsMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/utils/ActualUIElements.kt +++ b/core/src/jsMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/utils/ActualUIElements.kt @@ -9,6 +9,7 @@ import dev.inmo.jsuikit.elements.Icon import dev.inmo.jsuikit.elements.Label import dev.inmo.jsuikit.elements.drawAsFormInputPart import dev.inmo.jsuikit.modifiers.UIKitButton +import dev.inmo.jsuikit.modifiers.UIKitCustom import dev.inmo.jsuikit.modifiers.UIKitFlex import dev.inmo.jsuikit.modifiers.UIKitForm import dev.inmo.jsuikit.modifiers.UIKitInverse @@ -18,6 +19,8 @@ import dev.inmo.jsuikit.modifiers.UIKitUtility import dev.inmo.jsuikit.modifiers.builder import dev.inmo.jsuikit.modifiers.include import dev.inmo.jsuikit.utils.Attrs +import kotlinx.browser.window +import kotlinx.coroutines.withTimeout import org.jetbrains.compose.web.attributes.InputType import org.jetbrains.compose.web.dom.Div import org.jetbrains.compose.web.dom.Legend @@ -59,7 +62,12 @@ actual fun CommonTextField( placeholder = hint, attributesCustomizer = { onFocusIn { onFocusChanged(true) } - onFocusOut { onFocusChanged(false) } + onFocusOut { + window.setTimeout( // avoid immediate hiding of potential interface data with additional delay + { onFocusChanged(false) }, + 100 + ) + } }, onChange = onChange ) @@ -84,7 +92,7 @@ actual fun SwitchWithLabel( onCheckedChange(!checked) }, attributesCustomizer = { - include(UIKitUtility.Inline) + include(UIKitUtility.Inline, UIKitUtility.NoTransform, UIKitUtility.Border.Rounded) } ) { if (checked) { @@ -95,8 +103,13 @@ actual fun SwitchWithLabel( } @Composable -actual fun ButtonsPanel(data: Iterable, itemDrawer: @Composable (T) -> Unit) { +actual fun ButtonsPanel( + title: String, + data: Iterable, + itemDrawer: @Composable (T) -> Unit +) { Flex(UIKitFlex.Alignment.Vertical.Middle, UIKitMargin.Small) { + Div(UIKitMargin.Small.Horizontal.builder()) { Text(title) } data.forEach { itemDrawer(it) } } } diff --git a/core/src/jsMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/utils/NoTransform.kt b/core/src/jsMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/utils/NoTransform.kt new file mode 100644 index 0000000..d39b514 --- /dev/null +++ b/core/src/jsMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/utils/NoTransform.kt @@ -0,0 +1,9 @@ +package dev.inmo.kmppscriptbuilder.core.ui.utils + +import dev.inmo.jsuikit.modifiers.UIKitCustom +import dev.inmo.jsuikit.modifiers.UIKitUtility + +val ClassNoTransform = UIKitCustom(arrayOf("no-transform")) + +val UIKitUtility.Companion.NoTransform + get() = ClassNoTransform diff --git a/core/src/jsMain/resources/css/internal.css b/core/src/jsMain/resources/css/internal.css new file mode 100644 index 0000000..da71244 --- /dev/null +++ b/core/src/jsMain/resources/css/internal.css @@ -0,0 +1,4 @@ +.no-transform { + text-transform: none; +} + diff --git a/core/src/jsMain/resources/index.html b/core/src/jsMain/resources/index.html index 77a9789..eb56fb2 100644 --- a/core/src/jsMain/resources/index.html +++ b/core/src/jsMain/resources/index.html @@ -5,6 +5,7 @@ Kotlin Publication Scripts Builder + diff --git a/core/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/utils/ActualUIElements.kt b/core/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/utils/ActualUIElements.kt index a527d5c..ea0c222 100644 --- a/core/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/utils/ActualUIElements.kt +++ b/core/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/utils/ActualUIElements.kt @@ -80,8 +80,12 @@ actual fun TitleText(text: String) { } @Composable -actual fun ButtonsPanel(data: Iterable, itemDrawer: @Composable (T) -> Unit) { +actual fun ButtonsPanel( + title: String, + data: Iterable, + itemDrawer: @Composable (T) -> Unit) { Row { + Text(title, Modifier.padding(8.dp)) data.forEach { itemDrawer(it) } } }