Skip to content

Commit 4d4948d

Browse files
committed
part 03
1 parent 2fc830f commit 4d4948d

File tree

6 files changed

+145
-6
lines changed

6 files changed

+145
-6
lines changed

src/components/App.css

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.app {
2+
margin: 20px;
3+
}
4+
5+
.interactions, .error {
6+
text-align: center;
7+
}

src/components/Stories.css

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
.stories {
2+
margin: 20px 0;
3+
}
4+
5+
.stories-header {
6+
display: flex;
7+
line-height: 24px;
8+
font-size: 16px;
9+
padding: 0 10px;
10+
justify-content: space-between;
11+
}
12+
13+
.stories-header > span {
14+
overflow: hidden;
15+
text-overflow: ellipsis;
16+
padding: 0 5px;
17+
}

src/components/Stories.js

+37
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,51 @@ import React from 'react';
22
import './Stories.css';
33
import Story from './Story';
44

5+
const COLUMNS = {
6+
title: {
7+
label: 'Title',
8+
width: '40%',
9+
},
10+
author: {
11+
label: 'Author',
12+
width: '30%',
13+
},
14+
comments: {
15+
label: 'Comments',
16+
width: '10%',
17+
},
18+
points: {
19+
label: 'Points',
20+
width: '10%',
21+
},
22+
archive: {
23+
width: '10%',
24+
},
25+
};
26+
527
const Stories = ({ stories }) =>
628
<div className="stories">
29+
<StoriesHeader columns={COLUMNS} />
30+
731
{(stories || []).map(story =>
832
<Story
933
key={story.objectID}
1034
story={story}
35+
columns={COLUMNS}
1136
/>
1237
)}
1338
</div>
1439

40+
const StoriesHeader = ({ columns }) =>
41+
<div className="stories-header">
42+
{Object.keys(columns).map(key =>
43+
<span
44+
key={key}
45+
style={{ width: columns[key].width }}
46+
>
47+
{columns[key].label}
48+
</span>
49+
)}
50+
</div>
51+
1552
export default Stories;

src/components/Story.css

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
.story {
2+
display: flex;
3+
line-height: 24px;
4+
white-space: nowrap;
5+
margin: 10px 0;
6+
padding: 10px;
7+
background: #ffffff;
8+
border: 1px solid #e3e3e3;
9+
}
10+
11+
.story > span {
12+
overflow: hidden;
13+
text-overflow: ellipsis;
14+
padding: 0 5px;
15+
}

src/components/Story.js

+13-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import './Story.css';
33

4-
const Story = ({ story }) => {
4+
const Story = ({ story, columns }) => {
55
const {
66
title,
77
url,
@@ -12,12 +12,20 @@ const Story = ({ story }) => {
1212

1313
return (
1414
<div className="story">
15-
<span>
15+
<span style={{ width: columns.title.width }}>
1616
<a href={url}>{title}</a>
1717
</span>
18-
<span>{author}</span>
19-
<span>{num_comments}</span>
20-
<span>{points}</span>
18+
<span style={{ width: columns.author.width }}>
19+
{author}
20+
</span>
21+
<span style={{ width: columns.comments.width }}>
22+
{num_comments}
23+
</span>
24+
<span style={{ width: columns.points.width }}>
25+
{points}
26+
</span>
27+
<span style={{ width: columns.archive.width }}>
28+
</span>
2129
</div>
2230
);
2331
}

src/index.css

+56-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,60 @@
11
body {
2+
color: #222;
3+
background: #f4f4f4;
4+
font: 400 14px CoreSans, Arial,sans-serif;
5+
}
6+
7+
a {
8+
color: #222;
9+
}
10+
11+
a:hover {
12+
text-decoration: underline;
13+
}
14+
15+
ul, li {
16+
list-style: none;
17+
padding: 0;
218
margin: 0;
19+
}
20+
21+
input {
22+
padding: 10px;
23+
border-radius: 5px;
24+
outline: none;
25+
margin-right: 10px;
26+
border: 1px solid #dddddd;
27+
}
28+
29+
button {
30+
padding: 10px;
31+
border-radius: 5px;
32+
border: 1px solid #dddddd;
33+
background: transparent;
34+
color: #808080;
35+
cursor: pointer;
36+
}
37+
38+
button:hover {
39+
color: #222;
40+
}
41+
42+
.button-inline {
43+
border-width: 0;
44+
background: transparent;
45+
color: inherit;
46+
text-align: inherit;
47+
-webkit-font-smoothing: inherit;
348
padding: 0;
4-
font-family: sans-serif;
49+
font-size: inherit;
50+
cursor: pointer;
51+
}
52+
53+
.button-active {
54+
border-radius: 0;
55+
border-bottom: 1px solid #38BB6C;
556
}
57+
58+
*:focus {
59+
outline: none;
60+
}

0 commit comments

Comments
 (0)