Skip to content

Commit 8454c63

Browse files
committed
re-arrange components
1 parent d0a362e commit 8454c63

13 files changed

Lines changed: 48 additions & 38 deletions

File tree

src/demo/App.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@ import { JSONEditor } from "../lib";
66

77
const App = () => (
88
<div>
9+
<h3>Using default styles</h3>
910
<JSONEditor
1011
data={data}
1112
view="dual"
1213
collapsible
1314
onChange={this.onJsonChange}
1415
/>
16+
<h3>Using customized styles</h3>
1517
<JSONEditor
1618
data={data}
1719
view="dual"
@@ -25,26 +27,23 @@ const App = () => (
2527
const styles = {
2628
dualView: {
2729
display: "flex",
28-
backgroundColor: "black",
2930
},
3031
jsonViewer: {
3132
borderLeft: "1px dashed white",
32-
width: "40%",
33-
margin: 5,
3433
lineHeight: 1.25,
34+
width: "50%",
35+
borderLeft: "1px solid lightgrey",
36+
margin: 10,
3537
},
3638
jsonEditor: {
37-
width: "60%",
39+
width: "50%",
3840
fontSize: 12,
3941
fontFamily: "Lucida Console, monospace",
40-
margin: 5,
4142
lineHeight: 1.25,
4243
},
4344
root: {
4445
fontSize: 12,
45-
margin: 5,
4646
fontFamily: "Lucida Console, monospace",
47-
backgroundColor: "black",
4847
lineHeight: 1.25,
4948
/*color: "#3E3D32"*/
5049
},
@@ -73,7 +72,7 @@ const styles = {
7372
padding: 2,
7473
fontFamily: "Lucida Console, monospace",
7574
fontSize: 12,
76-
backgroundColor: "DimGray",
75+
backgroundColor: "gray",
7776
color: "khaki",
7877
width: "200%",
7978
},
@@ -100,7 +99,7 @@ const styles = {
10099
fontSize: 12,
101100
},
102101
text: {
103-
color: "khaki",
102+
color: "black",
104103
fontSize: 12,
105104
},
106105
number: {
@@ -113,7 +112,7 @@ const styles = {
113112
},
114113
collapseIcon: {
115114
cursor: "pointer",
116-
fontSize: 8,
115+
fontSize: 10,
117116
color: "teal",
118117
},
119118
};

src/lib/JSONEditor.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ import {
1212
CollapseIcon,
1313
isNodeCollapsed,
1414
toggleNodeCollapsed,
15-
} from "./CollapseIcon";
15+
} from "./components/shared/CollapseIcon";
1616

17-
import { Boolean } from "./components/Boolean";
18-
import { ParentLabel } from "./components/ParentLabel";
19-
import { Input } from "./components/Input";
17+
import Boolean from "./components/editor/Boolean";
18+
import ParentLabel from "./components/editor/ParentLabel";
19+
import Input from "./components/editor/Input";
2020
import { EDIT_KEY } from "./util";
2121
import { jsonEditorDefaultStyles } from "./util";
2222
import { getKey } from "./util";

src/lib/JSONViewer.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import {
44
CollapseIcon,
55
isNodeCollapsed,
66
toggleNodeCollapsed,
7-
} from "./CollapseIcon";
7+
} from "./components/shared/CollapseIcon";
88
import { jsonViewerDefaultStyles } from "./util";
99
import { getKey } from "./util";
10-
import { LabelAndValue } from "./components/LabelAndValue";
11-
import { ViewerLabel } from "./components/ViewerLabel";
10+
import LabelAndValue from "./components/viewer/LabelAndValue";
11+
import Label from "./components/viewer/Label";
1212

1313
export default class JSONViewer extends React.Component {
1414
static defaultProps = {
@@ -352,7 +352,7 @@ export default class JSONViewer extends React.Component {
352352
getLabel(value, type, marginLeft, isLastSibling, currentKey, parentKeyPath) {
353353
const { styles } = this.props;
354354
return (
355-
<ViewerLabel
355+
<Label
356356
key={getKey("label", currentKey + value, parentKeyPath, marginLeft)}
357357
value={value}
358358
type={type}
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import React from "react";
22

3-
export const AddIcon = (props) => {
3+
const AddIcon = (props) => {
44
let { addElement, addTo, hidden, styles } = props;
55
return (
66
<span hidden={hidden} title="add item" onClick={() => addElement(addTo)}>
77
<span style={styles.addButton}>&#43;</span>
88
</span>
99
);
1010
};
11+
12+
export default AddIcon;
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import React from "react";
22
import { merge } from "lodash";
3-
import { Label } from "./Label";
4-
import { RemoveIcon } from "./RemoveIcon";
3+
import Label from "./Label";
4+
import RemoveIcon from "./RemoveIcon";
55

6-
export class Boolean extends React.Component {
6+
export default class Boolean extends React.Component {
77
constructor(props) {
88
super(props);
99
this.state = {
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import React from "react";
22
import { merge } from "lodash";
3-
import { RemoveIcon } from "./RemoveIcon";
4-
import { SaveIcon } from "./SaveIcon";
5-
import { EDIT_KEY } from "../util";
6-
import { Label } from "./Label";
3+
import RemoveIcon from "./RemoveIcon";
4+
import SaveIcon from "./SaveIcon";
5+
import { EDIT_KEY } from "../../util";
6+
import Label from "./Label";
77

8-
export class Input extends React.Component {
8+
export default class Input extends React.Component {
99
constructor(props) {
1010
super(props);
1111
this.state = {
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import React from "react";
2-
import { EDIT_KEY } from "../util";
2+
import { EDIT_KEY } from "../../util";
33
import { merge } from "lodash";
44

5-
export const Label = (props) => {
5+
const Label = (props) => {
66
let { marginLeft, value, onEditableInputChange, styles } = props;
77
if (value === EDIT_KEY) {
88
return (
@@ -19,3 +19,5 @@ export const Label = (props) => {
1919
let style = merge({ marginLeft }, styles.label);
2020
return <div style={style}>{value}</div>;
2121
};
22+
23+
export default Label;
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import React from "react";
22
import { merge } from "lodash";
3-
import { AddIcon } from "./AddIcon";
4-
import { RemoveIcon } from "./RemoveIcon";
3+
import AddIcon from "./AddIcon";
4+
import RemoveIcon from "./RemoveIcon";
55

6-
export class ParentLabel extends React.Component {
6+
export default class ParentLabel extends React.Component {
77
constructor(props) {
88
super(props);
99
this.state = {
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from "react";
22

3-
export const RemoveIcon = (props) => {
3+
const RemoveIcon = (props) => {
44
let { removeElement, removeFrom, removeKey, hidden, styles } = props;
55
return (
66
<span
@@ -12,3 +12,5 @@ export const RemoveIcon = (props) => {
1212
</span>
1313
);
1414
};
15+
16+
export default RemoveIcon;
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import React from "react";
22

3-
export const SaveIcon = (props) => {
3+
const SaveIcon = (props) => {
44
let { saveElement, saveIn, saveKey, styles } = props;
55
return (
66
<span title="save item" onClick={() => saveElement(saveIn, saveKey)}>
77
<span style={styles.saveButton}>&#10003;</span>
88
</span>
99
);
1010
};
11+
12+
export default SaveIcon;

0 commit comments

Comments
 (0)