Skip to content

Commit 7836a8e

Browse files
committed
Place data div and rendered form side-by-side, improve and refactor styling
1 parent 127a27c commit 7836a8e

File tree

2 files changed

+59
-41
lines changed

2 files changed

+59
-41
lines changed

src/App.css

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
.App {
22
text-align: center;
3+
margin-bottom: 0.5em;
34
}
45

56
.App-logo {
@@ -26,18 +27,3 @@
2627
from { transform: rotate(0deg); }
2728
to { transform: rotate(360deg); }
2829
}
29-
30-
.data-title {
31-
text-align: center;
32-
margin-bottom: 0;
33-
}
34-
35-
.data-content {
36-
display: flex;
37-
justify-content: center;
38-
}
39-
40-
.demoform {
41-
width: 80%;
42-
margin: auto;
43-
}

src/App.js

Lines changed: 58 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,72 @@
1-
import {connect} from 'react-redux';
2-
import React, {Component} from 'react';
3-
import logo from './logo.svg';
4-
import './App.css';
1+
import { connect } from 'react-redux';
2+
import React from 'react';
3+
import Grid from "@material-ui/core/Grid";
4+
import Typography from "@material-ui/core/Typography";
5+
import withStyles from "@material-ui/core/styles/withStyles";
56
import { getData } from '@jsonforms/core';
67
import { JsonForms } from '@jsonforms/react';
8+
import logo from './logo.svg';
9+
import './App.css';
710

11+
const styles = {
12+
container: {
13+
padding: '2em'
14+
},
15+
title: {
16+
textAlign: 'center',
17+
padding: '0.25em'
18+
},
19+
dataContent: {
20+
display: 'flex',
21+
justifyContent: 'center',
22+
borderRadius: '0.25em'
23+
},
24+
demoform: {
25+
margin: 'auto'
26+
}
27+
};
828

9-
class App extends Component {
10-
render() {
11-
return (
12-
<div>
13-
<div className="App">
14-
<header className="App-header">
15-
<img src={logo} className="App-logo" alt="logo" />
16-
<h1 className="App-title">Welcome to JSON Forms with React</h1>
17-
<p className="App-intro">More Forms. Less Code.</p>
18-
</header>
19-
</div>
2029

21-
<h4 className="data-title">Bound data</h4>
22-
<div className="data-content">
23-
<pre>{this.props.dataAsString}</pre>
24-
</div>
30+
const App = ({ classes, dataAsString }) => (
31+
<div>
32+
<div className="App">
33+
<header className="App-header">
34+
<img src={logo} className="App-logo" alt="logo" />
35+
<h1 className="App-title">Welcome to JSON Forms with React</h1>
36+
<p className="App-intro">More Forms. Less Code.</p>
37+
</header>
38+
</div>
2539

26-
<div className="demoform">
40+
<Grid container justify={'center'} spacing={24} className={classes.container}>
41+
<Grid item sm={3}>
42+
<Typography
43+
variant={'display1'}
44+
className={classes.title}
45+
>
46+
Bound data
47+
</Typography>
48+
<div className={classes.dataContent} style={{ backgroundColor: '#cecece'}}>
49+
<pre>{dataAsString}</pre>
50+
</div>
51+
</Grid>
52+
<Grid item sm={6}>
53+
<Typography
54+
variant={'display1'}
55+
className={classes.title}
56+
>
57+
Rendered form
58+
</Typography>
59+
<div className={classes.demoform}>
2760
<JsonForms />
2861
</div>
29-
</div>
30-
);
31-
}
32-
33-
}
62+
</Grid>
63+
</Grid>
64+
</div>
65+
);
3466

3567
const mapStateToProps = state => {
3668
return { dataAsString: JSON.stringify(getData(state), null, 2) }
3769
};
3870

39-
export default connect(mapStateToProps, null)(App);
71+
export default connect(mapStateToProps, null)(withStyles(styles)(App));
4072

0 commit comments

Comments
 (0)