-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreact.html
56 lines (56 loc) · 2.08 KB
/
react.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
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.3.1/react.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.3.1/react-dom.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.34/browser.min.js"></script>
<link href="http://www.opentip.org/js/build/build.css?v=2" media="all" rel="stylesheet" type="text/css">
<link href="https://raw.github.com/enyo/opentip/master/css/opentip.css" media="all" rel="stylesheet" type="text/css">
<style>
.link{
display: inline-block;
margin: 5px;
background: yellow;
}
.border{
background: green;
border: 1px solid red;
float: left;
}
</style>
</head>
<body>
<div id="root"></div>
<script type="text/babel">
var initialPages = [
{
title: 'Google',
url: 'google.com',
},
{
title: 'Microsoft',
url: '',
},
{
title: 'Apple',
url: 'apple.com',
},
];
class Demo extends React.Component {
render() {
return <ul>{this.props.pages.map(function(page, i){
return <li key={i} style={{overflow: 'hidden'}}>{(function(){
if (! page.url) {
return <span className="border"><span className="link">{page.title}</span></span>;
}
return <a href="{page.url}" className="link">{page.title}</a>;
}())}</li>
})}</ul>
}
}
ReactDOM.render(
<Demo name="deeemo" pages={initialPages} />,
document.getElementById('root')
);
</script>
</body>
</html>