summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKamran Ahmed <kamranahmed.se@gmail.com>2018-08-27 15:21:43 +0500
committerKamran Ahmed <kamranahmed.se@gmail.com>2018-08-27 15:21:43 +0500
commit4c71ab478558f293022a90cec1d865fd180e170d (patch)
tree8e5cc6a9701ca5bd7d1b68634a09ecab56ff485e /src
parentMinor UI changes (diff)
downloadgithunt-4c71ab478558f293022a90cec1d865fd180e170d.tar.gz
List item for grids and refactor
Diffstat (limited to 'src')
-rw-r--r--src/components/repository-grid/grid-item/index.js16
-rw-r--r--src/components/repository-grid/index.js1
-rw-r--r--src/components/repository-list/index.js64
-rw-r--r--src/components/repository-list/list-item/index.js57
-rw-r--r--src/components/repository-list/list-item/styles.css6
5 files changed, 92 insertions, 52 deletions
diff --git a/src/components/repository-grid/grid-item/index.js b/src/components/repository-grid/grid-item/index.js
index f98017e..6496c77 100644
--- a/src/components/repository-grid/grid-item/index.js
+++ b/src/components/repository-grid/grid-item/index.js
@@ -34,12 +34,16 @@ class GridItem extends React.Component {
<p>{ this.props.repository.description || 'No description given.' }</p>
</div>
<div className="repo-footer">
- <span className="d-inline-block mr-3">
- <span className="repo-language-color ml-0"></span>
- <span itemProp="programmingLanguage">
- { this.props.repository.language }
- </span>
- </span>
+ {
+ this.props.repository.language && (
+ <span className="d-inline-block mr-3">
+ <span className="repo-language-color ml-0"></span>
+ <span itemProp="programmingLanguage">
+ { this.props.repository.language }
+ </span>
+ </span>
+ )
+ }
<a className="muted-link d-inline-block mr-3"
href={ `${this.props.repository.html_url}/stargazers` }
target="_blank">
diff --git a/src/components/repository-grid/index.js b/src/components/repository-grid/index.js
index 578ff87..d99a38f 100644
--- a/src/components/repository-grid/index.js
+++ b/src/components/repository-grid/index.js
@@ -32,7 +32,6 @@ class RepositoryGrid extends React.Component {
}
render() {
- console.log(this.props.repositories);
return (
<div className="repositories-grid">
{
diff --git a/src/components/repository-list/index.js b/src/components/repository-list/index.js
index 5742ef7..be6cc76 100644
--- a/src/components/repository-list/index.js
+++ b/src/components/repository-list/index.js
@@ -1,41 +1,53 @@
import React from 'react';
-import ListItem from './list-item';
+import PropTypes from 'prop-types';
import './styles.css';
+import ListItem from './list-item';
+import GroupHeading from '../group-heading';
+import RepositoryGrid from '../repository-grid';
class RepositoryList extends React.Component {
- render() {
- return (
- <div className="repositories-list">
- <div className="row list-container">
- <ListItem/>
- <ListItem/>
- <ListItem/>
- <ListItem/>
- <ListItem/>
- <ListItem/>
- <ListItem/>
- <ListItem/>
- <ListItem/>
- </div>
+
+ renderGroup(repositoryGroup, counter) {
+ let groupHeading = '';
+ // for the first repository group, we have the
+ // heading among the filters out of the grid
+ if (counter !== 0) {
+ groupHeading = (
<div className="row row-group">
- <div className="group-heading">
- <div className="col">
- <h4>Yesterday <span className="small text-muted">July 11, 2019</span></h4>
- </div>
- </div>
+ <GroupHeading/>
</div>
+ );
+ }
+
+ const groupKey = `${repositoryGroup.start}_${repositoryGroup.end}_${counter}`;
+ const repositories = repositoryGroup.data.items;
+
+ return (
+ <div key={ groupKey } data-group-key={ groupKey }>
+ { groupHeading }
<div className="row list-container">
- <ListItem/>
- <ListItem/>
- <ListItem/>
- <ListItem/>
- <ListItem/>
- <ListItem/>
+ { repositories.map(repository => <ListItem repository={ repository } key={ repository.id }/>) }
</div>
</div>
);
}
+
+ render() {
+ return (
+ <div className="repositories-list">
+ {
+ this.props.repositories.map((repositoryGroup, counter) => {
+ return this.renderGroup(repositoryGroup, counter);
+ })
+ }
+ </div>
+ );
+ }
}
+RepositoryGrid.propTypes = {
+ repositories: PropTypes.array.isRequired
+};
+
export default RepositoryList;
diff --git a/src/components/repository-list/list-item/index.js b/src/components/repository-list/list-item/index.js
index 916662b..fd70619 100644
--- a/src/components/repository-list/list-item/index.js
+++ b/src/components/repository-list/list-item/index.js
@@ -1,6 +1,8 @@
import React from 'react';
+import PropTypes from 'prop-types';
import './styles.css';
+import moment from 'moment';
class ListItem extends React.Component {
render() {
@@ -8,47 +10,68 @@ class ListItem extends React.Component {
<div className="col-12 list-item-container">
<div className="list-item-body">
<div className="repo-header">
- <h3><a href="#"><span className="text-normal">ValveSoftware / </span>Proton</a></h3>
- <p className="repo-meta text-muted small">Built by &middot; <a href="#">kamranahmedse</a> &middot; July 12, 2018</p>
+ <h3>
+ <a href={ this.props.repository.html_url } target="_blank">
+ <span className="text-normal">{ this.props.repository.owner.login } / </span>
+ { this.props.repository.name }
+ </a>
+ </h3>
+ <p className="repo-meta text-muted small">Built by &middot; <a href={ this.props.repository.owner.html_url } target="_blank">{ this.props.repository.owner.login }</a> &middot; { moment(this.props.repository.created_at).format('MMMM D YYYY') }</p>
</div>
<div className="repo-body">
- <p>Create React apps with no build configuration</p>
+ <p>{ this.props.repository.description || 'No description given.' }</p>
</div>
<div className="repo-footer">
- <span className="d-inline-block mr-3">
- <span className="repo-language-color ml-0"></span>
- <span itemProp="programmingLanguage">
- PHP
- </span>
- </span>
- <a className="muted-link d-inline-block mr-3" href="/ValveSoftware/Proton/stargazers">
+ {
+ this.props.repository.language && (
+ <span className="d-inline-block mr-3">
+ <span className="repo-language-color ml-0"></span>
+ <span itemProp="programmingLanguage">
+ { this.props.repository.language }
+ </span>
+ </span>
+ )
+ }
+ <a className="muted-link d-inline-block mr-3"
+ href={ `${this.props.repository.html_url}/stargazers` }
+ target="_blank">
<svg viewBox="0 0 14 16" version="1.1" width="14" height="16" role="img">
<path fillRule="evenodd" d="M14 6l-4.9-.64L7 1 4.9 5.36 0 6l3.6 3.26L2.67 14 7 11.67 11.33 14l-.93-4.74L14 6z"/>
</svg>
- 1,532
+ { this.props.repository.stargazers_count.toLocaleString() }
</a>
- <a className="muted-link d-inline-block mr-3" href="/ValveSoftware/Proton/network">
+ <a className="muted-link d-inline-block mr-3"
+ href={ `${this.props.repository.html_url}/network/members` }
+ target="_blank">
<svg viewBox="0 0 10 16" version="1.1" width="10" height="16" role="img">
<path fillRule="evenodd"
d="M8 1a1.993 1.993 0 0 0-1 3.72V6L5 8 3 6V4.72A1.993 1.993 0 0 0 2 1a1.993 1.993 0 0 0-1 3.72V6.5l3 3v1.78A1.993 1.993 0 0 0 5 15a1.993 1.993 0 0 0 1-3.72V9.5l3-3V4.72A1.993 1.993 0 0 0 8 1zM2 4.2C1.34 4.2.8 3.65.8 3c0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2zm3 10c-.66 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2zm3-10c-.66 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2z"></path>
</svg>
- 30
+ { this.props.repository.forks.toLocaleString() }
</a>
- <a className="muted-link d-inline-block mr-3" href="/ValveSoftware/Proton/network">
+ <a className="muted-link d-inline-block mr-3"
+ href={ `${this.props.repository.html_url}/watchers` }
+ target="_blank">
<svg className="octicon octicon-eye v-align-text-bottom" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true">
<path fillRule="evenodd" d="M8.06 2C3 2 0 8 0 8s3 6 8.06 6C13 14 16 8 16 8s-3-6-7.94-6zM8 12c-2.2 0-4-1.78-4-4 0-2.2 1.8-4 4-4 2.22 0 4 1.8 4 4 0 2.22-1.78 4-4 4zm2-4c0 1.11-.89 2-2 2-1.11 0-2-.89-2-2 0-1.11.89-2 2-2 1.11 0 2 .89 2 2z"></path>
</svg>
- 55
+ { this.props.repository.watchers.toLocaleString() }
</a>
</div>
</div>
- <a href="#" className="author-link d-none d-lg-block d-xl-block d-md-block">
- <img className='author-img' src="https://avatars0.githubusercontent.com/u/4921183?s=460&v=4"/>
+ <a href={ this.props.repository.owner.html_url }
+ target="_blank"
+ className="author-link d-none d-lg-block d-xl-block d-md-block">
+ <img className='author-img' src={ this.props.repository.owner.avatar_url }/>
</a>
</div>
);
}
}
+ListItem.propTypes = {
+ repository: PropTypes.object.isRequired
+};
+
export default ListItem;
diff --git a/src/components/repository-list/list-item/styles.css b/src/components/repository-list/list-item/styles.css
index 417a9be..28530eb 100644
--- a/src/components/repository-list/list-item/styles.css
+++ b/src/components/repository-list/list-item/styles.css
@@ -29,13 +29,15 @@
.list-item-container .repo-body p {
margin-bottom: 0;
+ display: block;
+ max-width: 80%;
}
.list-item-container .repo-footer svg {
position: relative;
top: -1px;
margin-right: 6px;
- fill: black;
+ fill: #6c757d;
}
.list-item-container .repo-meta a {
@@ -51,7 +53,7 @@
}
.list-item-container .repo-footer a {
- color: black;
+ color: #6c757d;
text-decoration: none;
}