File tree Expand file tree Collapse file tree 5 files changed +49
-5
lines changed Expand file tree Collapse file tree 5 files changed +49
-5
lines changed Original file line number Diff line number Diff line change 11import React from 'react' ;
22import './App.css' ;
3+
34import Stories from './Stories' ;
45
5- const App = ( { stories } ) =>
6+ const App = ( { stories, onArchive } ) =>
67 < div className = "app" >
7- < Stories stories = { stories } />
8+ < Stories
9+ stories = { stories }
10+ onArchive = { onArchive }
11+ />
812 </ div >
913
1014export default App ;
Original file line number Diff line number Diff line change 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+ } ;
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ const COLUMNS = {
2424 } ,
2525} ;
2626
27- const Stories = ( { stories } ) =>
27+ const Stories = ( { stories, onArchive } ) =>
2828 < div className = "stories" >
2929 < StoriesHeader columns = { COLUMNS } />
3030
@@ -33,6 +33,7 @@ const Stories = ({ stories }) =>
3333 key = { story . objectID }
3434 story = { story }
3535 columns = { COLUMNS }
36+ onArchive = { onArchive }
3637 />
3738 ) }
3839 </ div >
Original file line number Diff line number Diff line change 11import React from 'react' ;
2+ import { ButtonInline } from './Button' ;
23import './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 ) ;
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ const stories = [
2323] ;
2424
2525ReactDOM . render (
26- < App stories = { stories } /> ,
26+ < App stories = { stories } onArchive = { ( objectID ) => { console . log ( objectID ) ; } } /> ,
2727 document . getElementById ( 'root' )
2828) ;
2929registerServiceWorker ( ) ;
You can’t perform that action at this time.
0 commit comments