From 4c71ab478558f293022a90cec1d865fd180e170d Mon Sep 17 00:00:00 2001 From: Kamran Ahmed Date: Mon, 27 Aug 2018 15:21:43 +0500 Subject: List item for grids and refactor --- src/components/repository-grid/grid-item/index.js | 16 ++++-- src/components/repository-grid/index.js | 1 - src/components/repository-list/index.js | 64 +++++++++++++--------- src/components/repository-list/list-item/index.js | 57 +++++++++++++------ .../repository-list/list-item/styles.css | 6 +- 5 files changed, 92 insertions(+), 52 deletions(-) (limited to 'src') 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 {

{ this.props.repository.description || 'No description given.' }

- - - - { this.props.repository.language } - - + { + this.props.repository.language && ( + + + + { this.props.repository.language } + + + ) + } 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 (
{ 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 ( -
-
- - - - - - - - - -
+ + 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 = (
-
-
-

Yesterday July 11, 2019

-
-
+
+ ); + } + + const groupKey = `${repositoryGroup.start}_${repositoryGroup.end}_${counter}`; + const repositories = repositoryGroup.data.items; + + return ( +
+ { groupHeading }
- - - - - - + { repositories.map(repository => ) }
); } + + render() { + return ( +
+ { + this.props.repositories.map((repositoryGroup, counter) => { + return this.renderGroup(repositoryGroup, counter); + }) + } +
+ ); + } } +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 {
- - + +
); } } +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; } -- cgit v1.3