/
App.js
100 lines (87 loc) · 2.38 KB
/
App.js
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import React, { Component } from 'react';
import styles from './index.css';
import classNames from 'classnames/bind';
import ReadableBad from './1-readable/bad';
import ReadableGood from './1-readable/good';
import ReusableBad from './2-reusable/bad';
import ReusableGood from './2-reusable/good';
import RefactorableBad from './3-refactorable/bad';
import RefactorableGood from './3-refactorable/good';
const examples = {
readable: {
bad: ReadableBad,
good: ReadableGood,
},
reusable: {
bad: ReusableBad,
good: ReusableGood,
},
refactorable: {
bad: RefactorableBad,
good: RefactorableGood,
},
};
const cx = classNames.bind(styles);
const titleClass = cx({
center: true,
});
class App extends Component {
constructor() {
super();
this.state = {
section: 'reusable',
quality: 'bad',
};
}
onSelectSection(e) {
this.setState({
section: e.target.value,
});
}
onSelectQuality(e) {
this.setState({
quality: e.target.value,
});
}
render() {
return (
<div className="container">
<div className="row">
<h2 className={titleClass}>Software Architecture Pyramid</h2>
</div>
<div className="row">
<div className="six columns">
<label htmlFor="pyramidSectionSelector">Pyramid Section</label>
<select
className="u-full-width"
id="pyramidSectionSelector"
onChange={this.onSelectSection.bind(this)}
value={this.state.section}
>
<option value="readable">Readable</option>
<option value="reusable">Reusable</option>
<option value="refactorable">Refactorable</option>
</select>
</div>
<div className="six columns">
<label htmlFor="qualitySelector">Quality</label>
<select
className="u-full-width"
id="qualitySelector"
onChange={this.onSelectQuality.bind(this)}
value={this.state.quality}
>
<option value="bad">Bad</option>
<option value="good">Good</option>
</select>
</div>
</div>
<hr />
<div className="row">
{React.createElement(examples[this.state.section][this.state.quality])}
</div>
</div>
);
}
}
export default App;