forked from benmvp/react-workshop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
100 lines (92 loc) · 3.08 KB
/
index.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
class EmailListItem extends React.Component {
render() {
let {
email: {from, subject}
} = this.props;
return (
<div>
<span>{from}</span>
<span>{subject}</span>
</div>
);
}
}
class EmailList extends React.Component {
render() {
let {emails, onItemSelect} = this.props;
let emailComponents = emails.map((email) => (
<li key={email.id}>
<EmailListItem
email={email}
/>
</li>
));
return (
<ul>
{emailComponents}
</ul>
);
}
}
class EmailView extends React.Component {
render() {
return (
<div>
<h2>View selected email</h2>
</div>
);
}
}
class EmailForm extends React.Component {
render() {
return (
<div>
<h2>Add a new email</h2>
</div>
);
}
}
const emails = [
{
id: 1,
date: '01/19/2016',
from: '[email protected]',
to: '[email protected]',
unread: false,
subject: 'Mauris lacinia sapien quis libero.',
message: 'Duis consequat dui nec nisi volutpat eleifend. Donec ut dolor. Morbi vel lectus in quam fringilla rhoncus.<br /><br />Mauris enim leo, rhoncus sed, vestibulum sit amet, cursus id, turpis. Integer aliquet, massa id lobortis convallis, tortor risus dapibus augue, vel accumsan tellus nisi eu orci. Mauris lacinia sapien quis libero.<br /><br />Nullam sit amet turpis elementum ligula vehicula consequat. Morbi a ipsum. Integer a nibh.<br /><br />😎😋😛<br /><br /> Maecenas rhoncus aliquam lacus.'
},
{
id: 2,
date: '11/18/2015',
from: '[email protected]',
to: '[email protected]',
unread: false,
subject: 'Mauris ullamcorper purus sit amet nulla.',
message: '<em><strong>Sed ante.</strong></em> Vivamus tortor. Duis mattis egestas metus.<br /><br />Aenean fermentum. 😀 Nulla neque libero, convallis eget, eleifend luctus, ultricies eu, nibh.<br /><br />Quisque id justo sit amet sapien dignissim vestibulum. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Nulla dapibus dolor vel est. Donec odio justo, sollicitudin ut, suscipit a, feugiat et, eros.'
},
{
id: 3,
date: '04/12/2016',
from: '[email protected]',
to: '[email protected]',
unread: false,
subject: 'Suspendisse potenti.',
message: 'Sed sagittis. Nam congue, risus semper porta volutpat, quam pede lobortis ligula, sit amet eleifend pede libero quis orci. Nullam molestie nibh in lectus.<br /><br />Pellentesque at nulla. Suspendisse potenti.'
}
];
class EmailApp extends React.Component {
render() {
return (
<main>
<EmailList emails={emails} />
<EmailView />
<EmailForm />
</main>
);
}
}
ReactDOM.render(
<EmailApp />,
document.getElementById('app')
);