-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathday5.html
119 lines (111 loc) · 3.1 KB
/
day5.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
117
118
119
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Fullstackreact Tutorials Day 4</title>
<!-- Script tags including React -->
<script crossorigin src="https://unpkg.com/react@16/umd/react.production.min.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.production.min.js"></script>
<script crossorigin src="https://unpkg.com/babel-standalone/babel.min.js"></script>
<!-- css -->
<link href="timeline.css" rel="stylesheet" type="text/css" />
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="demo">
<div id="app"></div>
</div>
<script type="text/babel">
const activities = [
{
timestamp: new Date().getTime(),
text: "Ate lunch",
user:{
id: 1,
name: 'Nate',
avatar: "http://www.croop.cl/UI/twitter/images/doug.jpg"
},
comments: [{from: "Ari",text:"me too!"}]
},
{
timestamp: new Date().getTime(),
text: "Woke up early for a beautiful run",
user:{
id: 2,
name: 'Ari',
avatar: "http://www.croop.cl/UI/twitter/images/doug.jpg"
},
comments: [{from: "Nate",text:"I am so jealous"}]
}
];
{/* Header */}
class Header extends React.Component{
render(){
return(
<div className="header">
<div className="menuIcon">
<div className="dashTop"></div>
<div className="dashBottom"></div>
<div className="circle"></div>
</div>
<span className="title">{this.props.title}</span>
<input type="text" className="searchInput" placeholder="Search ..."/>
<div className="fa fa-search searchIcon"></div>
</div>
)
}
}
{/* ActivityItem */}
class ActivityItem extends React.Component{
render(){
const {activity} = this.props; // ES6 destructuring
return(
<div className="item">
<div className="avatar">
<img src={activity.user.avatar} alt={activity.text} />
{activity.user.name}
</div>
<span className="time">{activity.timestamp}</span>
<p>{activity.text}</p>
<div className="commentCount">{activity.comments.length}</div>
</div>
)
}
}
{/* Content */}
class Content extends React.Component{
render(){
const {activities} = this.props; // ES6 destructuring
return(
<div className="content">
<div className="line"></div>
{/* Timeline item */}
{activities.map((activity) => {
return(
<ActivityItem activity={activity}/>
)
})}
{/*...*/}
</div>
)
}
}
{/* container */}
class App extends React. Component{
render(){
return (
<div className="notificationsFrame">
<div className="panel">
{/* content goes here */}
<Header title="Timeline Dynamic"/>
<Content activities={activities}/>
</div>
</div>
)
}
}
var mount = document.querySelector('#app');
ReactDOM.render(<App/>,mount);
</script>
</body>
</html>