diff options
author | joffrey-bion <joffrey.bion@gmail.com> | 2021-02-15 01:29:58 +0100 |
---|---|---|
committer | joffrey-bion <joffrey.bion@gmail.com> | 2021-02-15 01:29:58 +0100 |
commit | 92ab4b1ac6f4b8d8558f9ce6e9cb6df8901c0e33 (patch) | |
tree | 2ea9b2169be4e4ae37c56324e04227da41cd6e44 /sw-ui/src/main/kotlin | |
parent | Fix transactions selector layout (diff) | |
download | seven-wonders-92ab4b1ac6f4b8d8558f9ce6e9cb6df8901c0e33.tar.gz seven-wonders-92ab4b1ac6f4b8d8558f9ce6e9cb6df8901c0e33.tar.bz2 seven-wonders-92ab4b1ac6f4b8d8558f9ce6e9cb6df8901c0e33.zip |
Add blueprintjs's Text component
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, |