-
Notifications
You must be signed in to change notification settings - Fork 1
/
debug.jsx
60 lines (52 loc) · 1.32 KB
/
debug.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// @flow
const debug = require("debug")("TapeUI:UIDebug")
import * as React from "react"
import { map, pipe, join } from "@asd14/m"
import { baseStyle } from "./debug.style"
type PropsType = {|
label: string,
value?: Object,
top?: number | string,
left?: number | string,
width?: number | string,
height?: number | string,
|}
class UIDebug extends React.PureComponent<PropsType> {
static defaultProps = {
value: {},
top: "center",
left: "center",
width: "50%",
height: "50%",
}
/**
* When called, it should examine this.props and this.state and return a
* single React element. This element can be either a representation of a
* native DOM component, such as <div />, or another composite component
* that you've defined yourself.
*
* @return {Component}
*/
render = (): React.Node => {
const { label, value, top, left, width, height } = this.props
return (
<box
class={[baseStyle]}
label={`[ ${label} ]`}
top={top}
left={left}
width={width}
height={height}
content={pipe(
Object.entries,
map(
([entryKey, entryValue]): string =>
`${entryKey}: ${JSON.stringify(entryValue)}`
),
join("\n")
)(value)}
/>
)
}
}
export { UIDebug }