File tree Expand file tree Collapse file tree 5 files changed +89
-5
lines changed Expand file tree Collapse file tree 5 files changed +89
-5
lines changed Original file line number Diff line number Diff line change 1+ .app {
2+ margin : 20px ;
3+ }
4+
5+ .interactions , .error {
6+ text-align : center;
7+ }
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change @@ -3,14 +3,51 @@ import './Stories.css';
33
44import Story from './Story' ;
55
6+ const COLUMNS = {
7+ title : {
8+ label : 'Title' ,
9+ width : '40%' ,
10+ } ,
11+ author : {
12+ label : 'Author' ,
13+ width : '30%' ,
14+ } ,
15+ comments : {
16+ label : 'Comments' ,
17+ width : '10%' ,
18+ } ,
19+ points : {
20+ label : 'Points' ,
21+ width : '10%' ,
22+ } ,
23+ archive : {
24+ width : '10%' ,
25+ } ,
26+ } ;
27+
628const Stories = ( { stories } ) =>
729 < div className = "stories" >
30+ < StoriesHeader columns = { COLUMNS } />
31+
832 { ( stories || [ ] ) . map ( story =>
933 < Story
1034 key = { story . objectID }
1135 story = { story }
36+ columns = { COLUMNS }
1237 />
1338 ) }
1439 </ div >
1540
41+ const StoriesHeader = ( { columns } ) =>
42+ < div className = "stories-header" >
43+ { Object . keys ( columns ) . map ( key =>
44+ < span
45+ key = { key }
46+ style = { { width : columns [ key ] . width } }
47+ >
48+ { columns [ key ] . label }
49+ </ span >
50+ ) }
51+ </ div >
52+
1653export default Stories ;
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 11import React from 'react' ;
22import './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}
You can’t perform that action at this time.
0 commit comments