From 7730a8ad565c167029681fd15d98be6c7dce0492 Mon Sep 17 00:00:00 2001 From: Joffrey Bion Date: Sun, 22 Mar 2020 23:06:19 +0100 Subject: Migrate game browser to blueprint components --- sw-ui-kt/src/main/kotlin/blueprintjsHelpers.kt | 46 ++++++++++++-------------- 1 file changed, 22 insertions(+), 24 deletions(-) (limited to 'sw-ui-kt/src/main/kotlin/blueprintjsHelpers.kt') diff --git a/sw-ui-kt/src/main/kotlin/blueprintjsHelpers.kt b/sw-ui-kt/src/main/kotlin/blueprintjsHelpers.kt index 5344b64e..0d9cb9bd 100644 --- a/sw-ui-kt/src/main/kotlin/blueprintjsHelpers.kt +++ b/sw-ui-kt/src/main/kotlin/blueprintjsHelpers.kt @@ -1,21 +1,21 @@ package com.palantir.blueprintjs -import org.w3c.dom.HTMLElement import org.w3c.dom.events.Event import org.w3c.dom.events.MouseEvent import react.RBuilder -import react.RElementBuilder import react.RHandler import react.ReactElement typealias IconName = String -fun RBuilder.icon( +fun RBuilder.bpIcon( name: IconName, size: Int = Icon.SIZE_STANDARD, intent: Intent = Intent.NONE, title: String? = null, - alt: String? = null + alt: String? = null, + className: String? = null, + block: RHandler = {} ): ReactElement = child(Icon::class) { attrs { this.icon = name @@ -23,13 +23,16 @@ fun RBuilder.icon( this.htmlTitle = title this.intent = intent this.title = alt + this.className = className } + block() } fun RBuilder.bpButton( minimal: Boolean = false, large: Boolean = false, disabled: Boolean = false, + title: String? = null, icon: IconName? = null, rightIcon: IconName? = null, intent: Intent = Intent.NONE, @@ -37,6 +40,7 @@ fun RBuilder.bpButton( block: RHandler = {} ): ReactElement = child(Button::class) { attrs { + this.title = title this.minimal = minimal this.large = large this.disabled = disabled @@ -48,7 +52,7 @@ fun RBuilder.bpButton( block() } -fun RBuilder.inputGroup( +fun RBuilder.bpInputGroup( large: Boolean = false, placeholder: String = "", rightElement: ReactElement? = null, @@ -62,22 +66,16 @@ fun RBuilder.inputGroup( } } -data class ButtonProps( - override var className: String? = null, - override var intent: Intent? = Intent.NONE, - override var disabled: Boolean? = false, - override var icon: IconName? = null, - override var onClick: ((event: MouseEvent) -> Unit)? = null, - override var text: String? = null, - override var active: Boolean? = true, - override var alignText: Alignment? = null, - override var elementRef: ((ref: HTMLElement?) -> Any)? = null, - override var fill: Boolean? = null, - override var large: Boolean? = null, - override var loading: Boolean? = null, - override var minimal: Boolean? = null, - override var outlined: Boolean? = null, - override var rightIcon: IconName? = null, - override var small: Boolean? = null, - override var type: String? = null -) : IButtonProps +fun RBuilder.bpTag( + intent: Intent? = null, + minimal: Boolean? = null, + active: Boolean? = null, + block: RHandler = {} +): ReactElement = child(Tag::class) { + attrs { + this.intent = intent + this.minimal = minimal + this.active = active + } + block() +} -- cgit