@@ -2,24 +2,43 @@ import React from 'react';
2
2
import styled from 'styled-components' ;
3
3
import { SimpleImg } from 'react-simple-img' ;
4
4
5
+ import { Response } from '../../utils/fetcher' ;
6
+
5
7
import imageSrc from '../../public/images/open.svg' ;
6
8
import data from './data.json' ;
7
9
10
+ interface Props {
11
+ stars : Response | undefined ;
12
+ }
13
+
14
+ interface Project {
15
+ id : string ;
16
+ name : string ;
17
+ description : string ;
18
+ url : string ;
19
+ tags : string [ ] ;
20
+ }
21
+
8
22
const Wrapper = styled . div `
9
23
display: grid;
10
24
grid-template-columns: repeat(auto-fill, minmax(20em, 1fr));
11
25
gap: 17px;
12
26
padding-top: 2em;
27
+ max-width: 70em;
28
+
29
+ @media (min-width: 320px) and (max-width: 480px) {
30
+ max-width: 100%;
31
+ }
13
32
` ;
14
33
15
34
const Element = styled . a `
16
- box-shadow: #212121 0px 10px 30px -15px;
35
+ box-shadow: #232527 0px 10px 30px -15px;
17
36
display: flex;
18
37
justify-content: space-between;
19
38
flex-direction: column;
20
39
align-items: flex-start;
21
40
position: relative;
22
- background-color: #212121 ;
41
+ background-color: #232527 ;
23
42
padding: 2rem 1.75rem;
24
43
border-radius: 3px;
25
44
transition: all 0.25s cubic-bezier(0.645, 0.045, 0.355, 1) 0s;
@@ -74,28 +93,33 @@ const Tag = styled.li`
74
93
margin-right: 15px;
75
94
` ;
76
95
77
- const Projects = ( ) => (
96
+ const Projects = ( { stars } : Props ) : JSX . Element => (
78
97
< Wrapper >
79
- { data . map ( element => (
80
- < Element key = { element . name } href = { element . url } target = "_blank" rel = "noopener noreferrer" >
81
- < header >
82
- < Top >
83
- < Header > { element . name } </ Header >
84
- < Img src = { imageSrc } placeholder = "black" width = "1.3em" height = "1.3em" alt = "Open" />
85
- </ Top >
86
- < Description >
87
- { element . description }
88
- </ Description >
89
- </ header >
90
- < footer >
91
- < Tags >
92
- { element . tags . map ( name => (
93
- < Tag key = { name } > { name } </ Tag >
94
- ) ) }
95
- </ Tags >
96
- </ footer >
97
- </ Element >
98
- ) ) }
98
+ { data . map ( ( element : Project ) => {
99
+ const starCount = stars ?. repositoryOwner . repositories . nodes . filter ( data => element . id === data . name ) . map ( element => element . stargazers . totalCount ) ;
100
+
101
+ return (
102
+ < Element key = { element . name } href = { element . url } target = "_blank" rel = "noopener noreferrer" >
103
+ < header >
104
+ < Top >
105
+ < Header > { element . name } </ Header >
106
+ < Img src = { imageSrc } placeholder = "black" width = "1.3em" height = "1.3em" alt = "Open" />
107
+ </ Top >
108
+ { stars ? < p > 🟊 { starCount } </ p > : '' }
109
+ < Description >
110
+ { element . description }
111
+ </ Description >
112
+ </ header >
113
+ < footer >
114
+ < Tags >
115
+ { element . tags . map ( name => (
116
+ < Tag key = { name } > { name } </ Tag >
117
+ ) ) }
118
+ </ Tags >
119
+ </ footer >
120
+ </ Element >
121
+ ) ;
122
+ } ) }
99
123
</ Wrapper >
100
124
) ;
101
125
0 commit comments