-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
116 lines (100 loc) · 5.03 KB
/
index.html
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="x-ua-compatible" content="IE=edge">
<title>React App</title>
<script src="https://unpkg.com/react@16/umd/react.production.min.js"></script>
<script src="https://unpkg.com/react-dom@16/umd/react-dom.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/7.0.0/polyfill.min.js"></script>
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-bootstrap/0.32.4/react-bootstrap.min.js"></script>
</head>
<body>
<script type="text/babel">
const Navbar = window.ReactBootstrap.Navbar
const NavItem = window.ReactBootstrap.NavItem
const Nav = window.ReactBootstrap.Nav
class App extends React.Component {
constructor(props) {
super(props)
this.state = { view: 'Home' }
this._changeView = this._changeView.bind(this)
}
_changeView(view) {
switch(view) {
case 'Home' :
this.setState({view: 'Home'})
break
case 'About' :
this.setState({view: 'About'})
break
case 'Contact' :
this.setState({view: 'Contact'})
break
default:
this.setState({view: 'Unknown'})
}
}
render() {
const { view } = this.state
const { _changeView } = this
return(
<div>
{/* Navigation */}
<Navbar>
<Navbar.Header>
<Navbar.Brand>
<a href="#"> React App</a>
</Navbar.Brand>
</Navbar.Header>
<Nav>
<NavItem onClick={() => _changeView('Home')}> Home </NavItem>
<NavItem onClick={() => _changeView('About')}> About </NavItem>
<NavItem onClick={() => _changeView('Contact')}> Contact </NavItem>
</Nav>
</Navbar>
{/* Routes */}
{
view === 'Home' ? <Home /> :
view === 'About' ? <About /> :
view === 'Contact' ? <Contact /> :
<Unknown />
}
</div>
)
}
}
const Home = () => (
<div style={{textAlign: 'center',paddingTop: '100px'}}>
<h1> Welcome to the Home Page!</h1>
<h3> Place your content here.</h3>
</div>
)
const About = () => (
<div style={{textAlign: 'center', paddingTop: '100px' }}>
<h1> Welcome to the About Page!</h1>
<h3> Place your content here.</h3>
</div>
)
const Contact = () => (
<div style={{textAlign: 'center', paddingTop: '100px' }}>
<h1> Welcome to the Contact Page!</h1>
<h3> Place your content here.</h3>
</div>
)
const Unknown = () => (
<div style={{textAlign: 'center', paddingTop: '100px' }}>
<h1> Welcome to the Unknown Page!</h1>
<h3>I am not sure why you are here...</h3>
</div>
)
ReactDOM.render(
<App />,
document.getElementById('root')
)
</script>
<div id="root"></div>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
</body>
</html>