diff options
author | Joffrey Bion <joffrey.bion@booking.com> | 2020-05-22 15:22:39 +0200 |
---|---|---|
committer | Joffrey Bion <joffrey.bion@booking.com> | 2020-05-22 15:31:45 +0200 |
commit | cb9e7e65bd997294582794d0d80b888c27db8ba4 (patch) | |
tree | 745a54f7eb62917f1097707a7a8983d483ec779b /sw-ui/src/main | |
parent | Use callout component for action text (info bubble) (diff) | |
download | seven-wonders-cb9e7e65bd997294582794d0d80b888c27db8ba4.tar.gz seven-wonders-cb9e7e65bd997294582794d0d80b888c27db8ba4.tar.bz2 seven-wonders-cb9e7e65bd997294582794d0d80b888c27db8ba4.zip |
Add BP card component
Diffstat (limited to 'sw-ui/src/main')
3 files changed, 58 insertions, 0 deletions
diff --git a/sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpCard.kt b/sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpCard.kt new file mode 100644 index 00000000..dc8961f1 --- /dev/null +++ b/sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpCard.kt @@ -0,0 +1,28 @@ +@file:JsModule("@blueprintjs/core") +package com.palantir.blueprintjs + +import org.w3c.dom.events.MouseEvent +import react.PureComponent +import react.RState +import react.ReactElement + +external interface ICardProps : IProps { + var elevation: Elevation? + get() = definedExternally + set(value) = definedExternally + var interactive: Boolean? + get() = definedExternally + set(value) = definedExternally + var onClick: ((e: MouseEvent) -> Unit)? + get() = definedExternally + set(value) = definedExternally +} + +open external class Card : PureComponent<ICardProps, RState> { + override fun render(): ReactElement + + companion object { + var displayName: String + var defaultProps: ICardProps + } +} diff --git a/sw-ui/src/main/kotlin/com/palantir/blueprintjs/blueprintjs.kt b/sw-ui/src/main/kotlin/com/palantir/blueprintjs/blueprintjs.kt index 60fd4abf..7da41fc9 100644 --- a/sw-ui/src/main/kotlin/com/palantir/blueprintjs/blueprintjs.kt +++ b/sw-ui/src/main/kotlin/com/palantir/blueprintjs/blueprintjs.kt @@ -36,6 +36,22 @@ external enum class Alignment { RIGHT } +// export declare const Elevation: { +// ZERO: 0; +// ONE: 1; +// TWO: 2; +// THREE: 3; +// FOUR: 4; +// }; +// export declare type Elevation = typeof Elevation[keyof typeof Elevation]; +external enum class Elevation { + ZERO, + ONE, + TWO, + THREE, + FOUR +} + /** * A shared base interface for all Blueprint component props. */ 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 3106630d..a366c446 100644 --- a/sw-ui/src/main/kotlin/com/palantir/blueprintjs/blueprintjsHelpers.kt +++ b/sw-ui/src/main/kotlin/com/palantir/blueprintjs/blueprintjsHelpers.kt @@ -162,3 +162,17 @@ fun RBuilder.bpCallout( } block() } + +fun RBuilder.bpCard( + elevation: Elevation = Elevation.ZERO, + interactive: Boolean = false, + onClick: () -> Unit = {}, + block: RHandler<ICardProps> = {} +): ReactElement = child(Card::class) { + attrs { + this.elevation = elevation + this.interactive = interactive + this.onClick = { onClick() } + } + block() +} |