-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathApp.js
67 lines (61 loc) · 1.41 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
// @flow
import React, { Component } from 'react';
import Home from './sites/home/Home';
import BabelSite from './sites/babelrc/BabelSite';
import getCurrentSite from './utils/getCurrentSite';
import './App.css';
class App extends Component {
state: {
site: ?string,
};
constructor(props: {}) {
super(props);
this.state = {
site: getCurrentSite(),
}
}
componentDidMount() {
document.title = `${this.getTitle()} - Config Wizard`;
}
render() {
return (
<div className="App">
{this.getTitle() === 'Home' &&
<h1 className="App__Header">
{`Config Wizard:`} <strong className="App__Header__Site">{this.getTitle()}</strong>
</h1>
}
<a className="App__GH" href="https://github.com/brigand/config-wizard" target="_blank">
View on Github
</a>
<div className="App__Content">
{this.renderSite()}
</div>
</div>
);
}
getTitle(): string {
const {site} = this.state;
if (site === null) {
return 'Home';
}
if (site === 'babelrc') {
return '.babelrc';
}
if (site === 'eslintrc') {
return '.eslintrc';
}
return '';
}
renderSite() {
const {site} = this.state;
if (site === null) {
return <Home />
}
if (site === 'babelrc') {
return <BabelSite />;
}
return <div>unknown site</div>;
}
}
export default App;