aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/pl/treksoft/kvision/html
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2018-02-22 12:43:43 +0100
committerRobert Jaros <rjaros@finn.pl>2018-02-22 12:43:43 +0100
commite40c13c62de806169368adc7c2c4212f7df6413b (patch)
tree250e39d407cd2c6ef19c9a8ea0176a3215a4a818 /src/main/kotlin/pl/treksoft/kvision/html
parent1aefed336f9ef305f59d3668abc8a39c550e921d (diff)
downloadkvision-e40c13c62de806169368adc7c2c4212f7df6413b.tar.gz
kvision-e40c13c62de806169368adc7c2c4212f7df6413b.tar.bz2
kvision-e40c13c62de806169368adc7c2c4212f7df6413b.zip
Property values delegated to a map (idea by tieskedh)
Closes #2
Diffstat (limited to 'src/main/kotlin/pl/treksoft/kvision/html')
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/html/Button.kt42
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/html/Image.kt30
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/html/Link.kt24
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/html/List.kt18
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/html/Tag.kt24
5 files changed, 23 insertions, 115 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/html/Button.kt b/src/main/kotlin/pl/treksoft/kvision/html/Button.kt
index 79155395..e6f53737 100644
--- a/src/main/kotlin/pl/treksoft/kvision/html/Button.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/html/Button.kt
@@ -69,59 +69,31 @@ open class Button(
/**
* Button label.
*/
- var text = text
- set(value) {
- field = value
- refresh()
- }
+ var text by refreshOnUpdate(text)
/**
* Button icon.
*/
- var icon = icon
- set(value) {
- field = value
- refresh()
- }
+ var icon by refreshOnUpdate(icon)
/**
* Button style.
*/
- var style = style
- set(value) {
- field = value
- refresh()
- }
+ var style by refreshOnUpdate(style)
/**
* Determines if button is disabled.
*/
- var disabled = disabled
- set(value) {
- field = value
- refresh()
- }
+ var disabled by refreshOnUpdate(disabled)
/**
* Button image.
*/
- var image: ResString? = null
- set(value) {
- field = value
- refresh()
- }
+ var image: ResString? by refreshOnUpdate()
/**
* Button size.
*/
- var size: BUTTONSIZE? = null
- set(value) {
- field = value
- refresh()
- }
+ var size: BUTTONSIZE? by refreshOnUpdate()
/**
* Determines if the button takes all the space horizontally.
*/
- var block = false
- set(value) {
- field = value
- refresh()
- }
+ var block by refreshOnUpdate(false)
override fun render(): VNode {
val t = createLabelWithIcon(text, icon, image)
diff --git a/src/main/kotlin/pl/treksoft/kvision/html/Image.kt b/src/main/kotlin/pl/treksoft/kvision/html/Image.kt
index bd469afe..ac7829e8 100644
--- a/src/main/kotlin/pl/treksoft/kvision/html/Image.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/html/Image.kt
@@ -55,43 +55,23 @@ open class Image(
/**
* URL of the image.
*/
- var src = src
- set(value) {
- field = value
- refresh()
- }
+ var src by refreshOnUpdate(src)
/**
* The alternative text of the image.
*/
- var alt = alt
- set(value) {
- field = value
- refresh()
- }
+ var alt by refreshOnUpdate(alt)
/**
* Determines if the image is rendered as responsive.
*/
- var responsive = responsive
- set(value) {
- field = value
- refresh()
- }
+ var responsive by refreshOnUpdate(responsive)
/**
* The shape of the image.
*/
- var shape = shape
- set(value) {
- field = value
- refresh()
- }
+ var shape by refreshOnUpdate(shape)
/**
* Determines if the image is rendered as centered.
*/
- var centered = centered
- set(value) {
- field = value
- refresh()
- }
+ var centered by refreshOnUpdate(centered)
override fun render(): VNode {
return render("img")
diff --git a/src/main/kotlin/pl/treksoft/kvision/html/Link.kt b/src/main/kotlin/pl/treksoft/kvision/html/Link.kt
index e075d685..94c7c594 100644
--- a/src/main/kotlin/pl/treksoft/kvision/html/Link.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/html/Link.kt
@@ -44,35 +44,19 @@ open class Link(
/**
* Link label.
*/
- var label = label
- set(value) {
- field = value
- refresh()
- }
+ var label by refreshOnUpdate(label)
/**
* Link URL address.
*/
- var url = url
- set(value) {
- field = value
- refresh()
- }
+ var url by refreshOnUpdate(url)
/**
* Link icon.
*/
- var icon = icon
- set(value) {
- field = value
- refresh()
- }
+ var icon by refreshOnUpdate(icon)
/**
* Link image.
*/
- var image = image
- set(value) {
- field = value
- refresh()
- }
+ var image by refreshOnUpdate(image)
override fun render(): VNode {
val t = createLabelWithIcon(label, icon, image)
diff --git a/src/main/kotlin/pl/treksoft/kvision/html/List.kt b/src/main/kotlin/pl/treksoft/kvision/html/List.kt
index 2dadd546..185d2eea 100644
--- a/src/main/kotlin/pl/treksoft/kvision/html/List.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/html/List.kt
@@ -61,27 +61,15 @@ open class ListTag(
/**
* List type.
*/
- var type = type
- set(value) {
- field = value
- refresh()
- }
+ var type by refreshOnUpdate(type)
/**
* List of elements.
*/
- var elements = elements
- set(value) {
- field = value
- refresh()
- }
+ var elements by refreshOnUpdate(elements)
/**
* Determines if [elements] can contain HTML code.
*/
- var rich = rich
- set(value) {
- field = value
- refresh()
- }
+ var rich by refreshOnUpdate(rich)
init {
@Suppress("LeakingThis")
diff --git a/src/main/kotlin/pl/treksoft/kvision/html/Tag.kt b/src/main/kotlin/pl/treksoft/kvision/html/Tag.kt
index 62a647bc..a3b7f231 100644
--- a/src/main/kotlin/pl/treksoft/kvision/html/Tag.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/html/Tag.kt
@@ -98,35 +98,19 @@ open class Tag(
/**
* Tag type.
*/
- var type = type
- set(value) {
- field = value
- refresh()
- }
+ var type by refreshOnUpdate(type)
/**
* Text content of the tag.
*/
- var text = text
- set(value) {
- field = value
- refresh()
- }
+ var text by refreshOnUpdate(text)
/**
* Determines if [text] can contain HTML code.
*/
- var rich = rich
- set(value) {
- field = value
- refresh()
- }
+ var rich by refreshOnUpdate(rich)
/**
* Text align.
*/
- var align = align
- set(value) {
- field = value
- refresh()
- }
+ var align by refreshOnUpdate(align)
init {
@Suppress("LeakingThis")