Skip to content

Commit 55de134

Browse files
committed
part 4
1 parent 6cb35b0 commit 55de134

File tree

6 files changed

+104
-6
lines changed

6 files changed

+104
-6
lines changed

src/components/App.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@ import './App.css';
33

44
import Stories from './Stories';
55

6-
const App = ({ stories }) =>
6+
const App = ({ stories, onArchive }) =>
77
<div className="app">
8-
<Stories stories={stories} />
8+
<Stories
9+
stories={stories}
10+
onArchive={onArchive}
11+
/>
912
</div>
1013

1114
export default App;

src/components/Button.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import React from 'react';
2+
3+
const ButtonInline = ({
4+
onClick,
5+
type = 'button',
6+
children
7+
}) =>
8+
<Button
9+
type={type}
10+
className="button-inline"
11+
onClick={onClick}
12+
>
13+
{children}
14+
</Button>
15+
16+
const Button = ({
17+
onClick,
18+
className,
19+
type = 'button',
20+
children
21+
}) =>
22+
<button
23+
type={type}
24+
className={className}
25+
onClick={onClick}
26+
>
27+
{children}
28+
</button>
29+
30+
export default Button;
31+
32+
export {
33+
ButtonInline
34+
};

src/components/Stories.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const COLUMNS = {
2525
},
2626
};
2727

28-
const Stories = ({ stories }) =>
28+
const Stories = ({ stories, onArchive }) =>
2929
<div className="stories">
3030
<StoriesHeader columns={COLUMNS} />
3131

@@ -34,6 +34,7 @@ const Stories = ({ stories }) =>
3434
key={story.objectID}
3535
story={story}
3636
columns={COLUMNS}
37+
onArchive={onArchive}
3738
/>
3839
)}
3940
</div>

src/components/Story.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
import React from 'react';
2+
import { ButtonInline } from './Button';
23
import './Story.css';
34

4-
const Story = ({ story, columns }) => {
5+
const Story = ({ story, columns, onArchive }) => {
56
const {
67
title,
78
url,
89
author,
910
num_comments,
1011
points,
12+
objectID,
1113
} = story;
1214

1315
return (
@@ -25,6 +27,9 @@ const Story = ({ story, columns }) => {
2527
{points}
2628
</span>
2729
<span style={{ width: columns.archive.width }}>
30+
<ButtonInline onClick={() => onArchive(objectID)}>
31+
Archive
32+
</ButtonInline>
2833
</span>
2934
</div>
3035
);

src/index.css

Lines changed: 56 additions & 1 deletion
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+
}

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const stories = [
2323
];
2424

2525
ReactDOM.render(
26-
<App stories={stories} />,
26+
<App stories={stories} onArchive={() => {}} />,
2727
document.getElementById('root')
2828
);
2929
registerServiceWorker();

0 commit comments

Comments
 (0)