File tree Expand file tree Collapse file tree 4 files changed +57
-15
lines changed Expand file tree Collapse file tree 4 files changed +57
-15
lines changed Original file line number Diff line number Diff line change 66.Result + .Result {
77 margin-top : 10px ;
88}
9+
10+ .Result dl {
11+ display : flex;
12+ flex-wrap : wrap;
13+ }
14+
15+ .Result dl dt {
16+ width : 20% ;
17+ }
18+
19+ .Result dl dd {
20+ width : 80% ;
21+ margin : 0 ;
22+ }
Original file line number Diff line number Diff line change @@ -3,12 +3,27 @@ import React from "react";
33
44import "./Result.css" ;
55
6- function Result ( { result } ) {
7- return < div className = "Result" > Hi I'm result</ div > ;
6+ function Result ( { fields, title } ) {
7+ return (
8+ < div className = "Result" >
9+ < h3 > { title } </ h3 >
10+ < dl >
11+ { Object . keys ( fields ) . map ( key => {
12+ return (
13+ < React . Fragment key = { key } >
14+ < dt > { `${ key } :` } </ dt >
15+ < dd > { fields [ key ] } </ dd >
16+ </ React . Fragment >
17+ ) ;
18+ } ) }
19+ </ dl >
20+ </ div >
21+ ) ;
822}
923
1024Result . propTypes = {
11- result : PropTypes . object . isRequired
25+ fields : PropTypes . object . isRequired ,
26+ title : PropTypes . string . isRequired
1227} ;
1328
1429export default Result ;
Original file line number Diff line number Diff line change @@ -3,20 +3,12 @@ import React from "react";
33
44import "./Results.css" ;
55
6- import Result from "./Result" ;
7-
8- function Results ( { results } ) {
9- return (
10- < div className = "Results" >
11- { results . map ( result => (
12- < Result key = { result . getRaw ( "id" ) } result = { result } />
13- ) ) }
14- </ div >
15- ) ;
6+ function Results ( { children } ) {
7+ return < div className = "Results" > { children } </ div > ;
168}
179
1810Results . propTypes = {
19- results : PropTypes . array . isRequired
11+ children : PropTypes . arrayOf ( PropTypes . element ) . isRequired
2012} ;
2113
2214export default Results ;
Original file line number Diff line number Diff line change @@ -3,6 +3,11 @@ import React, { Component } from "react";
33
44import withAppSearch from "../app-search/withAppSearch" ;
55import Results from "../components/Results" ;
6+ import Result from "../components/Result" ;
7+
8+ function capitalizeFirstLetter ( string ) {
9+ return string . charAt ( 0 ) . toUpperCase ( ) + string . slice ( 1 ) ;
10+ }
611
712class ResultsContainer extends Component {
813 static propTypes = {
@@ -12,7 +17,23 @@ class ResultsContainer extends Component {
1217 render ( ) {
1318 const { results } = this . props ;
1419
15- return < Results results = { results } /> ;
20+ return (
21+ < Results >
22+ { results . map ( result => (
23+ < Result
24+ fields = { {
25+ [ `${ capitalizeFirstLetter ( "description" ) } ` ] : result . getRaw (
26+ "description"
27+ ) ,
28+ [ `${ capitalizeFirstLetter ( "version" ) } ` ] : result . getRaw ( "version" )
29+ } }
30+ key = { `result-${ result . getRaw ( "id" ) } ` }
31+ result = { result }
32+ title = { result . getRaw ( "name" ) }
33+ />
34+ ) ) }
35+ </ Results >
36+ ) ;
1637 }
1738}
1839
You can’t perform that action at this time.
0 commit comments