diff options
author | joffrey-bion <joffrey.bion@gmail.com> | 2021-02-16 23:58:40 +0100 |
---|---|---|
committer | joffrey-bion <joffrey.bion@gmail.com> | 2021-02-17 00:34:23 +0100 |
commit | e484acb64a46050eb1d6f7117c96abf4308622fb (patch) | |
tree | 1a4806594e8e84ade8da5cfdc34929fae54d7613 /sw-ui/src/main/kotlin/com | |
parent | Remove unused receiver (diff) | |
download | seven-wonders-e484acb64a46050eb1d6f7117c96abf4308622fb.tar.gz seven-wonders-e484acb64a46050eb1d6f7117c96abf4308622fb.tar.bz2 seven-wonders-e484acb64a46050eb1d6f7117c96abf4308622fb.zip |
Add blueprintjs Spinner component
Diffstat (limited to 'sw-ui/src/main/kotlin/com')
-rw-r--r-- | sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpSpinner.kt | 38 | ||||
-rw-r--r-- | sw-ui/src/main/kotlin/com/palantir/blueprintjs/blueprintjsHelpers.kt | 24 |
2 files changed, 56 insertions, 6 deletions
diff --git a/sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpSpinner.kt b/sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpSpinner.kt new file mode 100644 index 00000000..5439833c --- /dev/null +++ b/sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpSpinner.kt @@ -0,0 +1,38 @@ +@file:JsModule("@blueprintjs/core") + +package com.palantir.blueprintjs + +import react.PureComponent +import react.RState +import react.ReactElement + +external interface ISpinnerProps : IProps, IIntentProps { + /** + * Width and height of the spinner in pixels. The size cannot be less than + * 10px. + * + * Constants are available for common sizes: + * - `Spinner.SIZE_SMALL = 20px` + * - `Spinner.SIZE_STANDARD = 50px` + * - `Spinner.SIZE_LARGE = 100px` + * + * @default Spinner.SIZE_STANDARD = 50 + */ + var size: Int? + /** + * HTML tag for the two wrapper elements. If rendering a `<Spinner>` inside + * an `<svg>`, change this to an SVG element like `"g"`. + * @default "div" + */ + var tagName: String? + /** + * A value between 0 and 1 (inclusive) representing how far along the operation is. + * Values below 0 or above 1 will be interpreted as 0 or 1 respectively. + * Omitting this prop will result in an "indeterminate" spinner where the head spins indefinitely. + */ + var value: Double? +} + +external class Spinner : PureComponent<ISpinnerProps, RState> { + override fun render(): ReactElement +} diff --git a/sw-ui/src/main/kotlin/com/palantir/blueprintjs/blueprintjsHelpers.kt b/sw-ui/src/main/kotlin/com/palantir/blueprintjs/blueprintjsHelpers.kt index 5d3c481e..ab3daf6e 100644 --- a/sw-ui/src/main/kotlin/com/palantir/blueprintjs/blueprintjsHelpers.kt +++ b/sw-ui/src/main/kotlin/com/palantir/blueprintjs/blueprintjsHelpers.kt @@ -112,12 +112,24 @@ fun RBuilder.bpText( block: RHandler<ITextProps> = {}, ): ReactElement = child(Text::class) { attrs { - if (ellipsize != null) { - this.ellipsize = ellipsize - } - if (tagName != null) { - this.tagName = tagName - } + ellipsize?.let { this.ellipsize = it } + tagName?.let { this.tagName = it } + } + block() +} + +fun RBuilder.bpSpinner( + size: Int? = null, + value: Double? = null, + intent: Intent? = null, + tagName: String? = null, + block: RHandler<ISpinnerProps> = {}, +): ReactElement = child(Spinner::class) { + attrs { + size?.let { this.size = it } + value?.let { this.value = it } + intent?.let { this.intent = it } + tagName?.let { this.tagName = it } } block() } |