diff options
Diffstat (limited to 'sw-ui/src/main/kotlin')
-rw-r--r-- | sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpText.kt | 30 | ||||
-rw-r--r-- | sw-ui/src/main/kotlin/com/palantir/blueprintjs/blueprintjsHelpers.kt | 16 |
2 files changed, 46 insertions, 0 deletions
diff --git a/sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpText.kt b/sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpText.kt new file mode 100644 index 00000000..6bf4323e --- /dev/null +++ b/sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpText.kt @@ -0,0 +1,30 @@ +@file:JsModule("@blueprintjs/core") + +package com.palantir.blueprintjs + +import react.PureComponent +import react.RState +import react.ReactElement + +external interface ITextProps : IProps { + /** + * Indicates that this component should be truncated with an ellipsis if it overflows its container. + * The `title` attribute will also be added when content overflows to show the full text of the children on hover. + * @default false + */ + var ellipsize: Boolean? + /** + * HTML tag name to use for rendered element. + * @default "div" + */ + var tagName: String? +} + +external interface ITextState : RState { + var textContent: String + var isContentOverflowing: Boolean +} + +external class Text : PureComponent<ITextProps, ITextState> { + 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 326f2fc4..5d3c481e 100644 --- a/sw-ui/src/main/kotlin/com/palantir/blueprintjs/blueprintjsHelpers.kt +++ b/sw-ui/src/main/kotlin/com/palantir/blueprintjs/blueprintjsHelpers.kt @@ -106,6 +106,22 @@ fun RBuilder.bpTag( block() } +fun RBuilder.bpText( + ellipsize: Boolean? = null, + tagName: String? = null, + block: RHandler<ITextProps> = {}, +): ReactElement = child(Text::class) { + attrs { + if (ellipsize != null) { + this.ellipsize = ellipsize + } + if (tagName != null) { + this.tagName = tagName + } + } + block() +} + fun RBuilder.bpNonIdealState( icon: IconName? = null, title: ReactElement? = null, |