From 16873dad5bc3989a5cef561bdc31c9ddcda63029 Mon Sep 17 00:00:00 2001 From: Kamran Ahmed Date: Mon, 27 Aug 2018 23:14:08 +0500 Subject: Load next batch and group headings --- public/img/galaxy.svg | 1 - src/components/group-heading/index.js | 12 +++++++++--- src/components/repository-grid/index.js | 9 +++++++-- src/components/repository-list/index.js | 9 +++++++-- src/containers/feed/index.js | 14 ++++++++++++-- src/containers/feed/styles.css | 6 ++++++ src/redux/github/actions.js | 9 ++++++--- 7 files changed, 47 insertions(+), 13 deletions(-) delete mode 100644 public/img/galaxy.svg diff --git a/public/img/galaxy.svg b/public/img/galaxy.svg deleted file mode 100644 index 5afc146..0000000 --- a/public/img/galaxy.svg +++ /dev/null @@ -1 +0,0 @@ -galaxy \ No newline at end of file diff --git a/src/components/group-heading/index.js b/src/components/group-heading/index.js index 762d36d..2ba89a2 100644 --- a/src/components/group-heading/index.js +++ b/src/components/group-heading/index.js @@ -10,7 +10,7 @@ class GroupHeading extends React.Component { const currentMoment = moment(); const yesterdayMoment = moment().subtract(1, 'day'); - // For "day" jumps show the day name + // For "day" jumps return the day name if (this.props.dateJump === 'day') { if (startMoment.isSame(currentMoment, 'day')) { return 'Today'; @@ -21,14 +21,20 @@ class GroupHeading extends React.Component { return startMoment.format('dddd'); } - return startMoment.fromNow(); + // Return the relative date + const formattedDate = startMoment.fromNow(); + if (formattedDate === 'a year ago') { + return 'Last Year'; + } + + return formattedDate; } getSubtitle() { const startMoment = moment(this.props.start); const endMoment = moment(this.props.end); - if (startMoment.isSame(endMoment, 'day')) { + if (startMoment.isSame(endMoment, 'day') || this.props.dateJump === 'day') { return startMoment.format('MMMM D, YYYY'); } diff --git a/src/components/repository-grid/index.js b/src/components/repository-grid/index.js index d99a38f..8413a8e 100644 --- a/src/components/repository-grid/index.js +++ b/src/components/repository-grid/index.js @@ -13,7 +13,11 @@ class RepositoryGrid extends React.Component { if (counter !== 0) { groupHeading = (
- +
); } @@ -45,7 +49,8 @@ class RepositoryGrid extends React.Component { } RepositoryGrid.propTypes = { - repositories: PropTypes.array.isRequired + repositories: PropTypes.array.isRequired, + dateJump: PropTypes.string.isRequired }; export default RepositoryGrid; diff --git a/src/components/repository-list/index.js b/src/components/repository-list/index.js index be6cc76..862df11 100644 --- a/src/components/repository-list/index.js +++ b/src/components/repository-list/index.js @@ -15,7 +15,11 @@ class RepositoryList extends React.Component { if (counter !== 0) { groupHeading = (
- +
); } @@ -47,7 +51,8 @@ class RepositoryList extends React.Component { } RepositoryGrid.propTypes = { - repositories: PropTypes.array.isRequired + repositories: PropTypes.array.isRequired, + dateJump: PropTypes.string.isRequired }; export default RepositoryList; diff --git a/src/containers/feed/index.js b/src/containers/feed/index.js index 6121ec5..d39da28 100644 --- a/src/containers/feed/index.js +++ b/src/containers/feed/index.js @@ -107,11 +107,21 @@ class FeedContainer extends React.Component {
{ this.props.preference.viewType === 'grid' - ? - : + ? + : } { this.props.github.processing && } + + { + !this.props.github.processing && ( + + ) + }
diff --git a/src/containers/feed/styles.css b/src/containers/feed/styles.css index 9d43a7b..8ab4795 100644 --- a/src/containers/feed/styles.css +++ b/src/containers/feed/styles.css @@ -29,3 +29,9 @@ .row-group .group-heading { margin: auto; } + +.load-next-date { + padding: 10px 20px; + display: block; + margin: 25px auto auto; +} diff --git a/src/redux/github/actions.js b/src/redux/github/actions.js index c61fd50..5474144 100644 --- a/src/redux/github/actions.js +++ b/src/redux/github/actions.js @@ -1,4 +1,5 @@ import axios from 'axios'; +import moment from 'moment'; import { FETCH_TRENDING_FAILED, @@ -12,7 +13,9 @@ const API_URL = 'https://api.github.com/search/repositories'; const transformFilters = (filters) => { const transformedFilters = {}; - const reposDate = `created:${filters.dateRange.start.format('YYYY-MM-DD')}..${filters.dateRange.end.format('YYYY-MM-DD')}`; + const startMoment = moment(filters.dateRange.start); + const endMoment = moment(filters.dateRange.end); + const reposDate = `created:${startMoment.format('YYYY-MM-DD')}..${endMoment.format('YYYY-MM-DD')}`; const reposLanguage = filters.language ? `language:${filters.language} ` : ''; if (filters.token) { @@ -40,8 +43,8 @@ export const fetchTrending = function (filters) { dispatch({ type: FETCH_TRENDING_SUCCESS, payload: { - start: filters.dateRange.start.format(), - end: filters.dateRange.end.format(), + start: moment(filters.dateRange.start).format(), + end: moment(filters.dateRange.end).format(), data: response.data } }); -- cgit v1.3