aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/pl/treksoft/kvision/html
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2019-10-17 21:58:34 +0200
committerRobert Jaros <rjaros@finn.pl>2019-10-17 21:58:34 +0200
commit736b80835f67c9c34657074ebcfbe0752bef1c18 (patch)
tree82d1e18a9ec07692dfe5dd31f470b842a9950a89 /src/main/kotlin/pl/treksoft/kvision/html
parent53b325d52208bfd44ba6a524ce3dda5379aed699 (diff)
downloadkvision-736b80835f67c9c34657074ebcfbe0752bef1c18.tar.gz
kvision-736b80835f67c9c34657074ebcfbe0752bef1c18.tar.bz2
kvision-736b80835f67c9c34657074ebcfbe0752bef1c18.zip
Move DSL builder functions out of the companion objects (#93)
Diffstat (limited to 'src/main/kotlin/pl/treksoft/kvision/html')
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/html/Button.kt38
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/html/Canvas.kt30
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/html/Div.kt34
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/html/Footer.kt34
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/html/H1.kt34
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/html/H2.kt34
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/html/H3.kt34
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/html/H4.kt34
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/html/H5.kt34
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/html/H6.kt34
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/html/Header.kt34
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/html/Icon.kt26
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/html/Iframe.kt32
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/html/Image.kt28
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/html/Link.kt28
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/html/List.kt28
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/html/P.kt34
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/html/Section.kt34
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/html/Span.kt34
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/html/Tag.kt30
20 files changed, 305 insertions, 343 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/html/Button.kt b/src/main/kotlin/pl/treksoft/kvision/html/Button.kt
index aaa0f735..ec1d95f5 100644
--- a/src/main/kotlin/pl/treksoft/kvision/html/Button.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/html/Button.kt
@@ -155,25 +155,23 @@ open class Button(
}
return this
}
+}
- companion object {
- /**
- * DSL builder extension function.
- *
- * It takes the same parameters as the constructor of the built component.
- */
- fun Container.button(
- text: String,
- icon: String? = null,
- style: ButtonStyle = ButtonStyle.PRIMARY,
- type: ButtonType = ButtonType.BUTTON,
- disabled: Boolean = false,
- classes: Set<String> = setOf(),
- init: (Button.() -> Unit)? = null
- ): Button {
- val button = Button(text, icon, style, type, disabled, classes).apply { init?.invoke(this) }
- this.add(button)
- return button
- }
- }
+/**
+ * DSL builder extension function.
+ *
+ * It takes the same parameters as the constructor of the built component.
+ */
+fun Container.button(
+ text: String,
+ icon: String? = null,
+ style: ButtonStyle = ButtonStyle.PRIMARY,
+ type: ButtonType = ButtonType.BUTTON,
+ disabled: Boolean = false,
+ classes: Set<String> = setOf(),
+ init: (Button.() -> Unit)? = null
+): Button {
+ val button = Button(text, icon, style, type, disabled, classes).apply { init?.invoke(this) }
+ this.add(button)
+ return button
}
diff --git a/src/main/kotlin/pl/treksoft/kvision/html/Canvas.kt b/src/main/kotlin/pl/treksoft/kvision/html/Canvas.kt
index feb9a970..840d5dc7 100644
--- a/src/main/kotlin/pl/treksoft/kvision/html/Canvas.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/html/Canvas.kt
@@ -75,20 +75,20 @@ open class Canvas(
companion object {
internal var counter = 0
-
- /**
- * DSL builder extension function.
- *
- * It takes the same parameters as the constructor of the built component.
- */
- fun Container.canvas(
- canvasWidth: Int? = null, canvasHeight: Int? = null, classes: Set<String> = setOf(),
- init: (Canvas.() -> Unit)? = null
- ): Canvas {
- val canvas =
- Canvas(canvasWidth, canvasHeight, classes).apply { init?.invoke(this) }
- this.add(canvas)
- return canvas
- }
}
}
+
+/**
+ * DSL builder extension function.
+ *
+ * It takes the same parameters as the constructor of the built component.
+ */
+fun Container.canvas(
+ canvasWidth: Int? = null, canvasHeight: Int? = null, classes: Set<String> = setOf(),
+ init: (Canvas.() -> Unit)? = null
+): Canvas {
+ val canvas =
+ Canvas(canvasWidth, canvasHeight, classes).apply { init?.invoke(this) }
+ this.add(canvas)
+ return canvas
+}
diff --git a/src/main/kotlin/pl/treksoft/kvision/html/Div.kt b/src/main/kotlin/pl/treksoft/kvision/html/Div.kt
index 42d6b496..2ffabe49 100644
--- a/src/main/kotlin/pl/treksoft/kvision/html/Div.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/html/Div.kt
@@ -46,23 +46,21 @@ open class Div(
@Suppress("LeakingThis")
init?.invoke(this)
}
+}
- companion object {
- /**
- * DSL builder extension function.
- *
- * It takes the same parameters as the constructor of the built component.
- */
- fun Container.div(
- content: String? = null,
- rich: Boolean = false,
- align: Align? = null,
- classes: Set<String> = setOf(),
- init: (Div.() -> Unit)? = null
- ): Div {
- val div = Div(content, rich, align, classes).apply { init?.invoke(this) }
- this.add(div)
- return div
- }
- }
+/**
+ * DSL builder extension function.
+ *
+ * It takes the same parameters as the constructor of the built component.
+ */
+fun Container.div(
+ content: String? = null,
+ rich: Boolean = false,
+ align: Align? = null,
+ classes: Set<String> = setOf(),
+ init: (Div.() -> Unit)? = null
+): Div {
+ 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/Footer.kt b/src/main/kotlin/pl/treksoft/kvision/html/Footer.kt
index 8b44dfc0..c71e346f 100644
--- a/src/main/kotlin/pl/treksoft/kvision/html/Footer.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/html/Footer.kt
@@ -46,23 +46,21 @@ open class Footer(
@Suppress("LeakingThis")
init?.invoke(this)
}
+}
- companion object {
- /**
- * DSL builder extension function.
- *
- * It takes the same parameters as the constructor of the built component.
- */
- fun Container.footer(
- content: String? = null,
- rich: Boolean = false,
- align: Align? = null,
- classes: Set<String> = setOf(),
- init: (Footer.() -> Unit)? = null
- ): Footer {
- val footer = Footer(content, rich, align, classes).apply { init?.invoke(this) }
- this.add(footer)
- return footer
- }
- }
+/**
+ * DSL builder extension function.
+ *
+ * It takes the same parameters as the constructor of the built component.
+ */
+fun Container.footer(
+ content: String? = null,
+ rich: Boolean = false,
+ align: Align? = null,
+ classes: Set<String> = setOf(),
+ init: (Footer.() -> Unit)? = null
+): Footer {
+ val footer = Footer(content, rich, align, classes).apply { init?.invoke(this) }
+ this.add(footer)
+ return footer
}
diff --git a/src/main/kotlin/pl/treksoft/kvision/html/H1.kt b/src/main/kotlin/pl/treksoft/kvision/html/H1.kt
index 894baf72..6a3ac9cc 100644
--- a/src/main/kotlin/pl/treksoft/kvision/html/H1.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/html/H1.kt
@@ -46,23 +46,21 @@ open class H1(
@Suppress("LeakingThis")
init?.invoke(this)
}
+}
- companion object {
- /**
- * DSL builder extension function.
- *
- * It takes the same parameters as the constructor of the built component.
- */
- fun Container.h1(
- content: String? = null,
- rich: Boolean = false,
- align: Align? = null,
- classes: Set<String> = setOf(),
- init: (H1.() -> Unit)? = null
- ): H1 {
- val h1 = H1(content, rich, align, classes).apply { init?.invoke(this) }
- this.add(h1)
- return h1
- }
- }
+/**
+ * DSL builder extension function.
+ *
+ * It takes the same parameters as the constructor of the built component.
+ */
+fun Container.h1(
+ content: String? = null,
+ rich: Boolean = false,
+ align: Align? = null,
+ classes: Set<String> = setOf(),
+ init: (H1.() -> Unit)? = null
+): H1 {
+ val h1 = H1(content, rich, align, classes).apply { init?.invoke(this) }
+ this.add(h1)
+ return h1
}
diff --git a/src/main/kotlin/pl/treksoft/kvision/html/H2.kt b/src/main/kotlin/pl/treksoft/kvision/html/H2.kt
index 54e12b4a..7bdd3473 100644
--- a/src/main/kotlin/pl/treksoft/kvision/html/H2.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/html/H2.kt
@@ -46,23 +46,21 @@ open class H2(
@Suppress("LeakingThis")
init?.invoke(this)
}
+}
- companion object {
- /**
- * DSL builder extension function.
- *
- * It takes the same parameters as the constructor of the built component.
- */
- fun Container.h2(
- content: String? = null,
- rich: Boolean = false,
- align: Align? = null,
- classes: Set<String> = setOf(),
- init: (H2.() -> Unit)? = null
- ): H2 {
- val h2 = H2(content, rich, align, classes).apply { init?.invoke(this) }
- this.add(h2)
- return h2
- }
- }
+/**
+ * DSL builder extension function.
+ *
+ * It takes the same parameters as the constructor of the built component.
+ */
+fun Container.h2(
+ content: String? = null,
+ rich: Boolean = false,
+ align: Align? = null,
+ classes: Set<String> = setOf(),
+ init: (H2.() -> Unit)? = null
+): H2 {
+ val h2 = H2(content, rich, align, classes).apply { init?.invoke(this) }
+ this.add(h2)
+ return h2
}
diff --git a/src/main/kotlin/pl/treksoft/kvision/html/H3.kt b/src/main/kotlin/pl/treksoft/kvision/html/H3.kt
index af71cdc5..1a2efdbb 100644
--- a/src/main/kotlin/pl/treksoft/kvision/html/H3.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/html/H3.kt
@@ -46,23 +46,21 @@ open class H3(
@Suppress("LeakingThis")
init?.invoke(this)
}
+}
- companion object {
- /**
- * DSL builder extension function.
- *
- * It takes the same parameters as the constructor of the built component.
- */
- fun Container.h3(
- content: String? = null,
- rich: Boolean = false,
- align: Align? = null,
- classes: Set<String> = setOf(),
- init: (H3.() -> Unit)? = null
- ): H3 {
- val h3 = H3(content, rich, align, classes).apply { init?.invoke(this) }
- this.add(h3)
- return h3
- }
- }
+/**
+ * DSL builder extension function.
+ *
+ * It takes the same parameters as the constructor of the built component.
+ */
+fun Container.h3(
+ content: String? = null,
+ rich: Boolean = false,
+ align: Align? = null,
+ classes: Set<String> = setOf(),
+ init: (H3.() -> Unit)? = null
+): H3 {
+ val h3 = H3(content, rich, align, classes).apply { init?.invoke(this) }
+ this.add(h3)
+ return h3
}
diff --git a/src/main/kotlin/pl/treksoft/kvision/html/H4.kt b/src/main/kotlin/pl/treksoft/kvision/html/H4.kt
index 9c1b92ab..ae00b8a7 100644
--- a/src/main/kotlin/pl/treksoft/kvision/html/H4.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/html/H4.kt
@@ -46,23 +46,21 @@ open class H4(
@Suppress("LeakingThis")
init?.invoke(this)
}
+}
- companion object {
- /**
- * DSL builder extension function.
- *
- * It takes the same parameters as the constructor of the built component.
- */
- fun Container.h4(
- content: String? = null,
- rich: Boolean = false,
- align: Align? = null,
- classes: Set<String> = setOf(),
- init: (H4.() -> Unit)? = null
- ): H4 {
- val h4 = H4(content, rich, align, classes).apply { init?.invoke(this) }
- this.add(h4)
- return h4
- }
- }
+/**
+ * DSL builder extension function.
+ *
+ * It takes the same parameters as the constructor of the built component.
+ */
+fun Container.h4(
+ content: String? = null,
+ rich: Boolean = false,
+ align: Align? = null,
+ classes: Set<String> = setOf(),
+ init: (H4.() -> Unit)? = null
+): H4 {
+ val h4 = H4(content, rich, align, classes).apply { init?.invoke(this) }
+ this.add(h4)
+ return h4
}
diff --git a/src/main/kotlin/pl/treksoft/kvision/html/H5.kt b/src/main/kotlin/pl/treksoft/kvision/html/H5.kt
index ac993c4d..c40a0658 100644
--- a/src/main/kotlin/pl/treksoft/kvision/html/H5.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/html/H5.kt
@@ -46,23 +46,21 @@ open class H5(
@Suppress("LeakingThis")
init?.invoke(this)
}
+}
- companion object {
- /**
- * DSL builder extension function.
- *
- * It takes the same parameters as the constructor of the built component.
- */
- fun Container.h5(
- content: String? = null,
- rich: Boolean = false,
- align: Align? = null,
- classes: Set<String> = setOf(),
- init: (H5.() -> Unit)? = null
- ): H5 {
- val h5 = H5(content, rich, align, classes).apply { init?.invoke(this) }
- this.add(h5)
- return h5
- }
- }
+/**
+ * DSL builder extension function.
+ *
+ * It takes the same parameters as the constructor of the built component.
+ */
+fun Container.h5(
+ content: String? = null,
+ rich: Boolean = false,
+ align: Align? = null,
+ classes: Set<String> = setOf(),
+ init: (H5.() -> Unit)? = null
+): H5 {
+ val h5 = H5(content, rich, align, classes).apply { init?.invoke(this) }
+ this.add(h5)
+ return h5
}
diff --git a/src/main/kotlin/pl/treksoft/kvision/html/H6.kt b/src/main/kotlin/pl/treksoft/kvision/html/H6.kt
index eaef18ff..048ab5df 100644
--- a/src/main/kotlin/pl/treksoft/kvision/html/H6.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/html/H6.kt
@@ -46,23 +46,21 @@ open class H6(
@Suppress("LeakingThis")
init?.invoke(this)
}
+}
- companion object {
- /**
- * DSL builder extension function.
- *
- * It takes the same parameters as the constructor of the built component.
- */
- fun Container.h6(
- content: String? = null,
- rich: Boolean = false,
- align: Align? = null,
- classes: Set<String> = setOf(),
- init: (H6.() -> Unit)? = null
- ): H6 {
- val h6 = H6(content, rich, align, classes).apply { init?.invoke(this) }
- this.add(h6)
- return h6
- }
- }
+/**
+ * DSL builder extension function.
+ *
+ * It takes the same parameters as the constructor of the built component.
+ */
+fun Container.h6(
+ content: String? = null,
+ rich: Boolean = false,
+ align: Align? = null,
+ classes: Set<String> = setOf(),
+ init: (H6.() -> Unit)? = null
+): H6 {
+ val h6 = H6(content, rich, align, classes).apply { init?.invoke(this) }
+ this.add(h6)
+ return h6
}
diff --git a/src/main/kotlin/pl/treksoft/kvision/html/Header.kt b/src/main/kotlin/pl/treksoft/kvision/html/Header.kt
index 94a9c079..e62e884e 100644
--- a/src/main/kotlin/pl/treksoft/kvision/html/Header.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/html/Header.kt
@@ -46,23 +46,21 @@ open class Header(
@Suppress("LeakingThis")
init?.invoke(this)
}
+}
- companion object {
- /**
- * DSL builder extension function.
- *
- * It takes the same parameters as the constructor of the built component.
- */
- fun Container.header(
- content: String? = null,
- rich: Boolean = false,
- align: Align? = null,
- classes: Set<String> = setOf(),
- init: (Header.() -> Unit)? = null
- ): Header {
- val header = Header(content, rich, align, classes).apply { init?.invoke(this) }
- this.add(header)
- return header
- }
- }
+/**
+ * DSL builder extension function.
+ *
+ * It takes the same parameters as the constructor of the built component.
+ */
+fun Container.header(
+ content: String? = null,
+ rich: Boolean = false,
+ align: Align? = null,
+ classes: Set<String> = setOf(),
+ init: (Header.() -> Unit)? = null
+): Header {
+ val header = Header(content, rich, align, classes).apply { init?.invoke(this) }
+ this.add(header)
+ return header
}
diff --git a/src/main/kotlin/pl/treksoft/kvision/html/Icon.kt b/src/main/kotlin/pl/treksoft/kvision/html/Icon.kt
index a9fb03db..a54df1d6 100644
--- a/src/main/kotlin/pl/treksoft/kvision/html/Icon.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/html/Icon.kt
@@ -42,19 +42,17 @@ open class Icon(icon: String) : Tag(TAG.SPAN) {
icon.split(" ").forEach { cl.add(it to true) }
return cl
}
+}
- companion object {
- /**
- * DSL builder extension function.
- *
- * It takes the same parameters as the constructor of the built component.
- */
- fun Container.icon(
- icon: String, init: (Icon.() -> Unit)? = null
- ): Icon {
- val i = Icon(icon).apply { init?.invoke(this) }
- this.add(i)
- return i
- }
- }
+/**
+ * DSL builder extension function.
+ *
+ * It takes the same parameters as the constructor of the built component.
+ */
+fun Container.icon(
+ icon: String, init: (Icon.() -> Unit)? = null
+): Icon {
+ val i = Icon(icon).apply { init?.invoke(this) }
+ this.add(i)
+ return i
}
diff --git a/src/main/kotlin/pl/treksoft/kvision/html/Iframe.kt b/src/main/kotlin/pl/treksoft/kvision/html/Iframe.kt
index a3a067ba..dad33ed4 100644
--- a/src/main/kotlin/pl/treksoft/kvision/html/Iframe.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/html/Iframe.kt
@@ -132,22 +132,20 @@ open class Iframe(
open fun getIframeWindow(): Window {
return getElementJQueryD()[0].contentWindow
}
+}
- companion object {
- /**
- * DSL builder extension function.
- *
- * It takes the same parameters as the constructor of the built component.
- */
- fun Container.iframe(
- src: String? = null, srcdoc: String? = null, name: String? = null, iframeWidth: Int? = null,
- iframeHeight: Int? = null, sandbox: Set<Sandbox>? = null, classes: Set<String> = setOf(),
- init: (Iframe.() -> Unit)? = null
- ): Iframe {
- val iframe =
- Iframe(src, srcdoc, name, iframeWidth, iframeHeight, sandbox, classes).apply { init?.invoke(this) }
- this.add(iframe)
- return iframe
- }
- }
+/**
+ * DSL builder extension function.
+ *
+ * It takes the same parameters as the constructor of the built component.
+ */
+fun Container.iframe(
+ src: String? = null, srcdoc: String? = null, name: String? = null, iframeWidth: Int? = null,
+ iframeHeight: Int? = null, sandbox: Set<Sandbox>? = null, classes: Set<String> = setOf(),
+ init: (Iframe.() -> Unit)? = null
+): Iframe {
+ val iframe =
+ Iframe(src, srcdoc, name, iframeWidth, iframeHeight, sandbox, classes).apply { init?.invoke(this) }
+ this.add(iframe)
+ return iframe
}
diff --git a/src/main/kotlin/pl/treksoft/kvision/html/Image.kt b/src/main/kotlin/pl/treksoft/kvision/html/Image.kt
index 81873088..6496b042 100644
--- a/src/main/kotlin/pl/treksoft/kvision/html/Image.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/html/Image.kt
@@ -99,20 +99,18 @@ open class Image(
}
return cl
}
+}
- companion object {
- /**
- * DSL builder extension function.
- *
- * It takes the same parameters as the constructor of the built component.
- */
- fun Container.image(
- src: ResString, alt: String? = null, responsive: Boolean = false, shape: ImageShape? = null,
- centered: Boolean = false, classes: Set<String> = setOf(), init: (Image.() -> Unit)? = null
- ): Image {
- val image = Image(src, alt, responsive, shape, centered, classes).apply { init?.invoke(this) }
- this.add(image)
- return image
- }
- }
+/**
+ * DSL builder extension function.
+ *
+ * It takes the same parameters as the constructor of the built component.
+ */
+fun Container.image(
+ src: ResString, alt: String? = null, responsive: Boolean = false, shape: ImageShape? = null,
+ centered: Boolean = false, classes: Set<String> = setOf(), init: (Image.() -> Unit)? = null
+): Image {
+ val image = Image(src, alt, responsive, shape, centered, classes).apply { init?.invoke(this) }
+ this.add(image)
+ return image
}
diff --git a/src/main/kotlin/pl/treksoft/kvision/html/Link.kt b/src/main/kotlin/pl/treksoft/kvision/html/Link.kt
index 63104248..2c2f1723 100644
--- a/src/main/kotlin/pl/treksoft/kvision/html/Link.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/html/Link.kt
@@ -83,20 +83,18 @@ open class Link(
}
return this
}
+}
- companion object {
- /**
- * DSL builder extension function.
- *
- * It takes the same parameters as the constructor of the built component.
- */
- fun Container.link(
- label: String, url: String? = null, icon: String? = null, image: ResString? = null,
- classes: Set<String> = setOf(), init: (Link.() -> Unit)? = null
- ): Link {
- val link = Link(label, url, icon, image, classes).apply { init?.invoke(this) }
- this.add(link)
- return link
- }
- }
+/**
+ * DSL builder extension function.
+ *
+ * It takes the same parameters as the constructor of the built component.
+ */
+fun Container.link(
+ label: String, url: String? = null, icon: String? = null, image: ResString? = null,
+ classes: Set<String> = setOf(), init: (Link.() -> Unit)? = null
+): Link {
+ val link = Link(label, url, icon, image, classes).apply { init?.invoke(this) }
+ this.add(link)
+ return link
}
diff --git a/src/main/kotlin/pl/treksoft/kvision/html/List.kt b/src/main/kotlin/pl/treksoft/kvision/html/List.kt
index cf3f8be6..1d26007c 100644
--- a/src/main/kotlin/pl/treksoft/kvision/html/List.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/html/List.kt
@@ -133,20 +133,18 @@ open class ListTag(
}
return cl
}
+}
- companion object {
- /**
- * DSL builder extension function.
- *
- * It takes the same parameters as the constructor of the built component.
- */
- fun Container.listTag(
- type: ListType, elements: List<String>? = null, rich: Boolean = false,
- classes: Set<String> = setOf(), init: (ListTag.() -> Unit)? = null
- ): ListTag {
- val listTag = ListTag(type, elements, rich, classes, init)
- this.add(listTag)
- return listTag
- }
- }
+/**
+ * DSL builder extension function.
+ *
+ * It takes the same parameters as the constructor of the built component.
+ */
+fun Container.listTag(
+ type: ListType, elements: List<String>? = null, rich: Boolean = false,
+ classes: Set<String> = setOf(), init: (ListTag.() -> Unit)? = null
+): ListTag {
+ val listTag = ListTag(type, elements, rich, classes, init)
+ this.add(listTag)
+ return listTag
}
diff --git a/src/main/kotlin/pl/treksoft/kvision/html/P.kt b/src/main/kotlin/pl/treksoft/kvision/html/P.kt
index feadc54a..d5bb2c4d 100644
--- a/src/main/kotlin/pl/treksoft/kvision/html/P.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/html/P.kt
@@ -46,23 +46,21 @@ open class P(
@Suppress("LeakingThis")
init?.invoke(this)
}
+}
- companion object {
- /**
- * DSL builder extension function.
- *
- * It takes the same parameters as the constructor of the built component.
- */
- fun Container.p(
- content: String? = null,
- rich: Boolean = false,
- align: Align? = null,
- classes: Set<String> = setOf(),
- init: (P.() -> Unit)? = null
- ): P {
- val p = P(content, rich, align, classes).apply { init?.invoke(this) }
- this.add(p)
- return p
- }
- }
+/**
+ * DSL builder extension function.
+ *
+ * It takes the same parameters as the constructor of the built component.
+ */
+fun Container.p(
+ content: String? = null,
+ rich: Boolean = false,
+ align: Align? = null,
+ classes: Set<String> = setOf(),
+ init: (P.() -> Unit)? = null
+): P {
+ val p = P(content, rich, align, classes).apply { init?.invoke(this) }
+ this.add(p)
+ return p
}
diff --git a/src/main/kotlin/pl/treksoft/kvision/html/Section.kt b/src/main/kotlin/pl/treksoft/kvision/html/Section.kt
index 94413943..43dd8fcf 100644
--- a/src/main/kotlin/pl/treksoft/kvision/html/Section.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/html/Section.kt
@@ -46,23 +46,21 @@ open class Section(
@Suppress("LeakingThis")
init?.invoke(this)
}
+}
- companion object {
- /**
- * DSL builder extension function.
- *
- * It takes the same parameters as the constructor of the built component.
- */
- fun Container.section(
- content: String? = null,
- rich: Boolean = false,
- align: Align? = null,
- classes: Set<String> = setOf(),
- init: (Section.() -> Unit)? = null
- ): Section {
- val section = Section(content, rich, align, classes).apply { init?.invoke(this) }
- this.add(section)
- return section
- }
- }
+/**
+ * DSL builder extension function.
+ *
+ * It takes the same parameters as the constructor of the built component.
+ */
+fun Container.section(
+ content: String? = null,
+ rich: Boolean = false,
+ align: Align? = null,
+ classes: Set<String> = setOf(),
+ init: (Section.() -> Unit)? = null
+): Section {
+ val section = Section(content, rich, align, classes).apply { init?.invoke(this) }
+ this.add(section)
+ return section
}
diff --git a/src/main/kotlin/pl/treksoft/kvision/html/Span.kt b/src/main/kotlin/pl/treksoft/kvision/html/Span.kt
index bc5e93cd..862d0b2f 100644
--- a/src/main/kotlin/pl/treksoft/kvision/html/Span.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/html/Span.kt
@@ -46,23 +46,21 @@ open class Span(
@Suppress("LeakingThis")
init?.invoke(this)
}
+}
- companion object {
- /**
- * DSL builder extension function.
- *
- * It takes the same parameters as the constructor of the built component.
- */
- fun Container.span(
- content: String? = null,
- rich: Boolean = false,
- align: Align? = null,
- classes: Set<String> = setOf(),
- init: (Span.() -> Unit)? = null
- ): Span {
- val span = Span(content, rich, align, classes).apply { init?.invoke(this) }
- this.add(span)
- return span
- }
- }
+/**
+ * DSL builder extension function.
+ *
+ * It takes the same parameters as the constructor of the built component.
+ */
+fun Container.span(
+ content: String? = null,
+ rich: Boolean = false,
+ align: Align? = null,
+ classes: Set<String> = setOf(),
+ init: (Span.() -> Unit)? = null
+): Span {
+ val span = Span(content, rich, align, classes).apply { init?.invoke(this) }
+ this.add(span)
+ return span
}
diff --git a/src/main/kotlin/pl/treksoft/kvision/html/Tag.kt b/src/main/kotlin/pl/treksoft/kvision/html/Tag.kt
index a5e855ae..aefd3730 100644
--- a/src/main/kotlin/pl/treksoft/kvision/html/Tag.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/html/Tag.kt
@@ -192,21 +192,19 @@ open class Tag(
else
content += translate(this)
}
+}
- companion object {
- /**
- * DSL builder extension function.
- *
- * It takes the same parameters as the constructor of the built component.
- */
- fun Container.tag(
- type: TAG, content: String? = null, rich: Boolean = false, align: Align? = null,
- classes: Set<String> = setOf(), attributes: Map<String, String> = mapOf(),
- init: (Tag.() -> Unit)? = null
- ): Tag {
- val tag = Tag(type, content, rich, align, classes, attributes, init)
- this.add(tag)
- return tag
- }
- }
+/**
+ * DSL builder extension function.
+ *
+ * It takes the same parameters as the constructor of the built component.
+ */
+fun Container.tag(
+ type: TAG, content: String? = null, rich: Boolean = false, align: Align? = null,
+ classes: Set<String> = setOf(), attributes: Map<String, String> = mapOf(),
+ init: (Tag.() -> Unit)? = null
+): Tag {
+ val tag = Tag(type, content, rich, align, classes, attributes, init)
+ this.add(tag)
+ return tag
}