aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/pl/treksoft/kvision/html
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/pl/treksoft/kvision/html')
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/html/Div.kt12
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/html/Label.kt10
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/html/Tag.kt26
3 files changed, 25 insertions, 23 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/html/Div.kt b/src/main/kotlin/pl/treksoft/kvision/html/Div.kt
index 38dc5817..6d8e05ef 100644
--- a/src/main/kotlin/pl/treksoft/kvision/html/Div.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/html/Div.kt
@@ -27,17 +27,17 @@ import pl.treksoft.kvision.core.Container
* Simple component rendered as *div*.
*
* @constructor
- * @param text element text
- * @param rich determines if [text] can contain HTML code
+ * @param content element text
+ * @param rich determines if [content] can contain HTML code
*/
open class Div(
- text: String,
+ content: String,
rich: Boolean = false,
align: Align? = null,
classes: Set<String> = setOf(),
init: (Div.() -> Unit)? = null
) :
- Tag(TAG.DIV, text, rich, align, classes) {
+ Tag(TAG.DIV, content, rich, align, classes) {
init {
@Suppress("LeakingThis")
@@ -51,13 +51,13 @@ open class Div(
* It takes the same parameters as the constructor of the built component.
*/
fun Container.div(
- text: String,
+ content: String,
rich: Boolean = false,
align: Align? = null,
classes: Set<String> = setOf(),
init: (Div.() -> Unit)? = null
): Div {
- val div = Div(text, rich, align, classes).apply { init?.invoke(this) }
+ val div = Div(content, rich, align, classes).apply { init?.invoke(this) }
this.add(div)
return div
}
diff --git a/src/main/kotlin/pl/treksoft/kvision/html/Label.kt b/src/main/kotlin/pl/treksoft/kvision/html/Label.kt
index e56362ef..2ec45274 100644
--- a/src/main/kotlin/pl/treksoft/kvision/html/Label.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/html/Label.kt
@@ -27,10 +27,10 @@ import pl.treksoft.kvision.core.Container
* Simple label component rendered as *span*.
*
* @constructor
- * @param text label text
- * @param rich determines if [text] can contain HTML code
+ * @param content label text
+ * @param rich determines if [content] can contain HTML code
*/
-open class Label(text: String, rich: Boolean = false) : Tag(TAG.SPAN, text, rich) {
+open class Label(content: String, rich: Boolean = false) : Tag(TAG.SPAN, content, rich) {
companion object {
/**
* DSL builder extension function.
@@ -38,9 +38,9 @@ open class Label(text: String, rich: Boolean = false) : Tag(TAG.SPAN, text, rich
* It takes the same parameters as the constructor of the built component.
*/
fun Container.label(
- text: String, rich: Boolean = false, init: (Label.() -> Unit)? = null
+ content: String, rich: Boolean = false, init: (Label.() -> Unit)? = null
): Label {
- val label = Label(text, rich).apply { init?.invoke(this) }
+ val label = Label(content, rich).apply { init?.invoke(this) }
this.add(label)
return label
}
diff --git a/src/main/kotlin/pl/treksoft/kvision/html/Tag.kt b/src/main/kotlin/pl/treksoft/kvision/html/Tag.kt
index 78cde306..fce5acaa 100644
--- a/src/main/kotlin/pl/treksoft/kvision/html/Tag.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/html/Tag.kt
@@ -74,7 +74,9 @@ enum class TAG(internal val tagName: String) {
TH("th"),
TBODY("tbody"),
TR("tr"),
- TD("td")
+ TD("td"),
+
+ FORM("form")
}
/**
@@ -93,14 +95,14 @@ enum class Align(val className: String) {
*
* @constructor
* @param type tag type
- * @param text text content of the tag
- * @param rich determines if [text] can contain HTML code
- * @param align text align
+ * @param content content text of the tag
+ * @param rich determines if [content] can contain HTML code
+ * @param align content align
* @param classes a set of CSS class names
* @param init an initializer extension function
*/
open class Tag(
- type: TAG, text: String? = null, rich: Boolean = false, align: Align? = null,
+ type: TAG, content: String? = null, rich: Boolean = false, align: Align? = null,
classes: Set<String> = setOf(), init: (Tag.() -> Unit)? = null
) : SimplePanel(classes) {
@@ -111,9 +113,9 @@ open class Tag(
/**
* Text content of the tag.
*/
- var text by refreshOnUpdate(text)
+ var content by refreshOnUpdate(content)
/**
- * Determines if [text] can contain HTML code.
+ * Determines if [content] can contain HTML code.
*/
var rich by refreshOnUpdate(rich)
/**
@@ -127,11 +129,11 @@ open class Tag(
}
override fun render(): VNode {
- return if (text != null) {
+ return if (content != null) {
if (rich) {
- render(type.tagName, arrayOf(KVManager.virtualize("<span>$text</span>")) + childrenVNodes())
+ render(type.tagName, arrayOf(KVManager.virtualize("<span>$content</span>")) + childrenVNodes())
} else {
- render(type.tagName, childrenVNodes() + arrayOf(text))
+ render(type.tagName, childrenVNodes() + arrayOf(content))
}
} else {
render(type.tagName, childrenVNodes())
@@ -153,10 +155,10 @@ open class Tag(
* It takes the same parameters as the constructor of the built component.
*/
fun Container.tag(
- type: TAG, text: String? = null, rich: Boolean = false, align: Align? = null,
+ type: TAG, content: String? = null, rich: Boolean = false, align: Align? = null,
classes: Set<String> = setOf(), init: (Tag.() -> Unit)? = null
): Tag {
- val tag = Tag(type, text, rich, align, classes, init)
+ val tag = Tag(type, content, rich, align, classes, init)
this.add(tag)
return tag
}