From a128f5e1a8e70530380d30cc0cb5168fe7a9bdea Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Tue, 5 Nov 2019 10:50:01 +0100 Subject: Add labels/fields horizontal ratio option for FormPanel component. --- src/main/kotlin/pl/treksoft/kvision/form/check/CheckBox.kt | 7 ++++--- src/main/kotlin/pl/treksoft/kvision/form/check/Radio.kt | 7 ++++--- src/main/kotlin/pl/treksoft/kvision/form/check/RadioGroup.kt | 11 ++++++----- 3 files changed, 14 insertions(+), 11 deletions(-) (limited to 'src/main/kotlin/pl/treksoft/kvision/form/check') diff --git a/src/main/kotlin/pl/treksoft/kvision/form/check/CheckBox.kt b/src/main/kotlin/pl/treksoft/kvision/form/check/CheckBox.kt index ac25b30d..4fa30d7b 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/check/CheckBox.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/check/CheckBox.kt @@ -27,6 +27,7 @@ import pl.treksoft.kvision.core.StringBoolPair import pl.treksoft.kvision.core.Widget import pl.treksoft.kvision.form.BoolFormControl import pl.treksoft.kvision.form.FieldLabel +import pl.treksoft.kvision.form.FormHorizontalRatio import pl.treksoft.kvision.form.InvalidFeedback import pl.treksoft.kvision.panel.SimplePanel import pl.treksoft.kvision.utils.SnOn @@ -174,11 +175,11 @@ open class CheckBox( input.blur() } - override fun styleForHorizontalFormPanel() { + override fun styleForHorizontalFormPanel(horizontalRatio: FormHorizontalRatio) { addCssClass("form-group") addSurroundingCssClass("row") - addCssClass("offset-sm-2") - addCssClass("col-sm-10") + addCssClass("offset-sm-${horizontalRatio.labels}") + addCssClass("col-sm-${horizontalRatio.fields}") } override fun styleForInlineFormPanel() { diff --git a/src/main/kotlin/pl/treksoft/kvision/form/check/Radio.kt b/src/main/kotlin/pl/treksoft/kvision/form/check/Radio.kt index bb73da60..d2c58c87 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/check/Radio.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/check/Radio.kt @@ -27,6 +27,7 @@ import pl.treksoft.kvision.core.StringBoolPair import pl.treksoft.kvision.core.Widget import pl.treksoft.kvision.form.BoolFormControl import pl.treksoft.kvision.form.FieldLabel +import pl.treksoft.kvision.form.FormHorizontalRatio import pl.treksoft.kvision.form.InvalidFeedback import pl.treksoft.kvision.panel.SimplePanel import pl.treksoft.kvision.utils.SnOn @@ -189,11 +190,11 @@ open class Radio( input.blur() } - override fun styleForHorizontalFormPanel() { + override fun styleForHorizontalFormPanel(horizontalRatio: FormHorizontalRatio) { addCssClass("form-group") addSurroundingCssClass("row") - addCssClass("offset-sm-2") - addCssClass("col-sm-10") + addCssClass("offset-sm-${horizontalRatio.labels}") + addCssClass("col-sm-${horizontalRatio.fields}") } override fun styleForInlineFormPanel() { diff --git a/src/main/kotlin/pl/treksoft/kvision/form/check/RadioGroup.kt b/src/main/kotlin/pl/treksoft/kvision/form/check/RadioGroup.kt index bee57db4..b162abc8 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/check/RadioGroup.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/check/RadioGroup.kt @@ -25,6 +25,7 @@ import pl.treksoft.kvision.core.Container import pl.treksoft.kvision.core.StringBoolPair import pl.treksoft.kvision.core.StringPair import pl.treksoft.kvision.form.FieldLabel +import pl.treksoft.kvision.form.FormHorizontalRatio import pl.treksoft.kvision.form.InputSize import pl.treksoft.kvision.form.InvalidFeedback import pl.treksoft.kvision.form.StringFormControl @@ -216,13 +217,13 @@ open class RadioGroup( container.getChildren().filterIsInstance().firstOrNull()?.blur() } - override fun styleForHorizontalFormPanel() { + override fun styleForHorizontalFormPanel(horizontalRatio: FormHorizontalRatio) { addCssClass("row") - flabel.addCssClass("col-sm-2") + flabel.addCssClass("col-sm-${horizontalRatio.labels}") flabel.addCssClass("col-form-label") - container.addCssClass("col-sm-10") - invalidFeedback.addCssClass("offset-sm-2") - invalidFeedback.addCssClass("col-sm-10") + container.addCssClass("col-sm-${horizontalRatio.fields}") + invalidFeedback.addCssClass("offset-sm-${horizontalRatio.labels}") + invalidFeedback.addCssClass("col-sm-${horizontalRatio.fields}") } companion object { -- cgit