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

Commit a454798

Browse files
committed
Merge pull request #15 from mdziekon/undefined-values
Display undefined values
2 parents 1a0b0b0 + 8af14ac commit a454798

File tree

3 files changed

+50
-1
lines changed

3 files changed

+50
-1
lines changed

examples/src/App.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ export default class App extends Component {
1010
bool: true,
1111
date: new Date(),
1212
object: {
13-
foo: 'bar'
13+
foo: 'bar',
14+
baz: undefined
1415
},
1516
immutable: Map({ key: 'value' })
1617
};

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)