Skip to content
This repository was archived by the owner on May 14, 2020. It is now read-only.

Commit 96a08e6

Browse files
committed
Display "undefined" values
1 parent 1a0b0b0 commit 96a08e6

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

src/JSONUndefinedNode.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import React from 'react';
2+
import reactMixin from 'react-mixin';
3+
import { SquashClickEventMixin } from './mixins';
4+
import hexToRgb from './utils/hexToRgb';
5+
6+
const styles = {
7+
base: {
8+
paddingTop: 3,
9+
paddingBottom: 3,
10+
paddingRight: 0,
11+
marginLeft: 14,
12+
WebkitUserSelect: 'text',
13+
MozUserSelect: 'text'
14+
},
15+
label: {
16+
display: 'inline-block',
17+
marginRight: 5
18+
}
19+
};
20+
21+
@reactMixin.decorate(SquashClickEventMixin)
22+
export default class JSONUndefinedNode extends React.Component {
23+
render() {
24+
let backgroundColor = 'transparent';
25+
if (this.props.previousValue !== this.props.value) {
26+
const bgColor = hexToRgb(this.props.theme.base06);
27+
backgroundColor = `rgba(${bgColor.r}, ${bgColor.g}, ${bgColor.b}, 0.1)`;
28+
}
29+
return (
30+
<li style={{ ...styles.base, backgroundColor }} onClick={::this.handleClick}>
31+
<label style={{
32+
...styles.label,
33+
color: this.props.theme.base0D,
34+
...this.props.styles.getLabelStyle('Undefined', true)
35+
}}>
36+
{this.props.keyName}:
37+
</label>
38+
<span style={{
39+
color: this.props.theme.base08,
40+
...this.props.styles.getValueStyle('Undefined', true)
41+
}}>undefined</span>
42+
</li>
43+
);
44+
}
45+
}

src/grab-node.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import JSONNumberNode from './JSONNumberNode';
88
import JSONBooleanNode from './JSONBooleanNode';
99
import JSONNullNode from './JSONNullNode';
1010
import JSONDateNode from './JSONDateNode';
11+
import JSONUndefinedNode from './JSONUndefinedNode';
1112

1213
export default function(key, value, prevValue, theme, styles, getItemString, initialExpanded = false) {
1314
const nodeType = objType(value);
@@ -27,6 +28,8 @@ export default function(key, value, prevValue, theme, styles, getItemString, ini
2728
return <JSONDateNode keyName={key} previousValue={prevValue} theme={theme} value={value} key={key} styles={styles} />;
2829
} else if (nodeType === 'Null') {
2930
return <JSONNullNode keyName={key} previousValue={prevValue} theme={theme} value={value} key={key} styles={styles} />;
31+
} else if (nodeType === 'Undefined') {
32+
return <JSONUndefinedNode keyName={key} previousValue={prevValue} theme={theme} value={value} key={key} styles={styles} />;
3033
}
3134
return false;
3235
}

0 commit comments

Comments
 (0)