Skip to content

Commit ce38594

Browse files
committed
Display stars
1 parent 9e6392f commit ce38594

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

src/App.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ const SearchRepos = ({ searchText }) => (
6969
return (
7070
<List>
7171
{data.search.nodes.map(repo => (
72-
<Repository {...repo} />
72+
<Repository repo={repo} />
7373
))}
7474
</List>
7575
);

src/ui/Repository.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,34 @@ import {
77
ListItemText,
88
Typography
99
} from "@material-ui/core";
10+
import Stars from "@material-ui/icons/Stars";
1011
import React from "react";
1112

12-
export default function Repository({ id, owner, name, stargazers }) {
13+
export default function Repository({ repo }) {
14+
const starText = repo.viewerHasStarred ? "Unstar" : "Star";
15+
1316
return (
1417
<React.Fragment>
1518
<ListItem alignItems="flex-start">
1619
<ListItemAvatar>
17-
<Avatar alt={owner.login} src={owner.avatarUrl} />
20+
<Avatar alt={repo.owner.login} src={repo.owner.avatarUrl} />
1821
</ListItemAvatar>
1922
<ListItemText
20-
primary={name}
23+
primary={repo.name}
2124
secondary={
2225
<React.Fragment>
2326
<Typography component="span" color="textPrimary">
24-
{owner.login}
27+
{repo.owner.login}
2528
</Typography>
2629
</React.Fragment>
2730
}
2831
/>
2932
<ListItemSecondaryAction>
30-
<Chip label={stargazers.totalCount + " Stars"} />
33+
<Chip
34+
label={`${starText} ${repo.stargazers.totalCount}`}
35+
clickable
36+
icon={<Stars />}
37+
/>
3138
</ListItemSecondaryAction>
3239
</ListItem>
3340
</React.Fragment>

0 commit comments

Comments
 (0)