aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/pl/treksoft/kvision/html
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2020-05-15 16:55:22 +0200
committerRobert Jaros <rjaros@finn.pl>2020-05-15 16:55:22 +0200
commit73f1022ac23ae282a236bff5c9b68029428352e7 (patch)
tree024aca61b1df1f322d351cb284f1990540939e08 /src/main/kotlin/pl/treksoft/kvision/html
parent1e6d1ac500e238467ca96660f135084b62a76c07 (diff)
downloadkvision-73f1022ac23ae282a236bff5c9b68029428352e7.tar.gz
kvision-73f1022ac23ae282a236bff5c9b68029428352e7.tar.bz2
kvision-73f1022ac23ae282a236bff5c9b68029428352e7.zip
Allow nullable src property for the Image component.
Diffstat (limited to 'src/main/kotlin/pl/treksoft/kvision/html')
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/html/Image.kt8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/html/Image.kt b/src/main/kotlin/pl/treksoft/kvision/html/Image.kt
index f21d515f..e7ecf393 100644
--- a/src/main/kotlin/pl/treksoft/kvision/html/Image.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/html/Image.kt
@@ -50,7 +50,7 @@ enum class ImageShape(internal val className: String) {
* @param classes a set of CSS class names
*/
open class Image(
- src: ResString, alt: String? = null, responsive: Boolean = false, shape: ImageShape? = null,
+ src: ResString?, alt: String? = null, responsive: Boolean = false, shape: ImageShape? = null,
centered: Boolean = false, classes: Set<String> = setOf()
) : Widget(classes) {
/**
@@ -84,7 +84,9 @@ open class Image(
override fun getSnAttrs(): List<StringPair> {
val pr = super.getSnAttrs().toMutableList()
- pr.add("src" to src)
+ src?.let {
+ pr.add("src" to it)
+ }
alt?.let {
pr.add("alt" to translate(it))
}
@@ -112,7 +114,7 @@ open class Image(
* 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,
+ src: ResString?, alt: String? = null, responsive: Boolean = false, shape: ImageShape? = null,
centered: Boolean = false,
classes: Set<String>? = null,
className: String? = null,