summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/components/repository-grid/index.js2
-rw-r--r--src/components/repository-grid/styles.css4
-rw-r--r--src/components/top-nav/index.js51
-rw-r--r--src/components/top-nav/styles.css1
-rw-r--r--src/containers/feed/index.js10
-rw-r--r--src/containers/feed/styles.css4
-rw-r--r--src/redux/preference/actions.js11
-rw-r--r--src/redux/preference/reducer.js8
-rw-r--r--src/redux/preference/types.js1
9 files changed, 80 insertions, 12 deletions
diff --git a/src/components/repository-grid/index.js b/src/components/repository-grid/index.js
index 8b9a276..78c8dfc 100644
--- a/src/components/repository-grid/index.js
+++ b/src/components/repository-grid/index.js
@@ -1,5 +1,7 @@
import React from 'react';
+
import GridItem from './grid-item';
+import './styles.css';
class RepositoryGrid extends React.Component {
render() {
diff --git a/src/components/repository-grid/styles.css b/src/components/repository-grid/styles.css
new file mode 100644
index 0000000..ddda54a
--- /dev/null
+++ b/src/components/repository-grid/styles.css
@@ -0,0 +1,4 @@
+.grid-container {
+ margin-top: 20px;
+ padding: 0 5px;
+}
diff --git a/src/components/top-nav/index.js b/src/components/top-nav/index.js
index 24f0747..7f36321 100644
--- a/src/components/top-nav/index.js
+++ b/src/components/top-nav/index.js
@@ -1,4 +1,7 @@
import React from 'react';
+import PropTypes from 'prop-types';
+import classNames from 'classnames';
+
import './styles.css';
const TopNav = (props) => (
@@ -12,12 +15,54 @@ const TopNav = (props) => (
</div>
</a>
<div className="float-right duration-btns">
- <a href="#" className="btn btn-primary">Weekly</a>
- <a href="#" className="btn btn-light">Monthly</a>
- <a href="#" className="btn btn-light">Daily</a>
+ <a href="javascript:void(0)"
+ onClick={ () => props.updateDateType('yearly') }
+ className={
+ classNames('btn', {
+ 'btn-primary': props.selectedDateType === 'yearly',
+ 'btn-light': props.selectedDateType !== 'yearly',
+ })
+ }>
+ Yearly
+ </a>
+ <a href="javascript:void(0)"
+ onClick={ () => props.updateDateType('monthly') }
+ className={
+ classNames('btn', {
+ 'btn-primary': props.selectedDateType === 'monthly',
+ 'btn-light': props.selectedDateType !== 'monthly',
+ })
+ }>
+ Monthly
+ </a>
+ <a href="javascript:void(0)"
+ onClick={ () => props.updateDateType('weekly') }
+ className={
+ classNames('btn', {
+ 'btn-primary': props.selectedDateType === 'weekly',
+ 'btn-light': props.selectedDateType !== 'weekly',
+ })
+ }>
+ Weekly
+ </a>
+ <a href="javascript:void(0)"
+ onClick={ () => props.updateDateType('daily') }
+ className={
+ classNames('btn', {
+ 'btn-primary': props.selectedDateType === 'daily',
+ 'btn-light': props.selectedDateType !== 'daily',
+ })
+ }>
+ Daily
+ </a>
</div>
</div>
</div>
);
+TopNav.propTypes = {
+ updateDateType: PropTypes.func.isRequired,
+ selectedDateType: PropTypes.string
+};
+
export default TopNav;
diff --git a/src/components/top-nav/styles.css b/src/components/top-nav/styles.css
index c91d753..15230f8 100644
--- a/src/components/top-nav/styles.css
+++ b/src/components/top-nav/styles.css
@@ -34,5 +34,6 @@
.duration-btns a.btn {
margin-left: 10px;
margin-top: 24px;
+ box-shadow: none;
}
diff --git a/src/containers/feed/index.js b/src/containers/feed/index.js
index 12441ee..224d5b8 100644
--- a/src/containers/feed/index.js
+++ b/src/containers/feed/index.js
@@ -5,14 +5,17 @@ import './styles.css';
import TopNav from '../../components/top-nav';
import Filters from '../../components/filters';
import RepositoryGrid from '../../components/repository-grid';
-import { updateLanguage, updateViewType } from '../../redux/preference/actions';
import RepositoryList from '../../components/repository-list';
+import { updateDateType, updateLanguage, updateViewType } from '../../redux/preference/actions';
class FeedContainer extends React.Component {
render() {
return (
<div className="page-wrap">
- <TopNav/>
+ <TopNav
+ updateDateType={ this.props.updateDateType }
+ selectedDateType={ this.props.preference.dateType }
+ />
<div className="container mt-4 mb-5 pb-4">
<div className="header-row clearfix">
@@ -45,7 +48,8 @@ const mapStateToProps = store => {
const mapDispatchToProps = {
updateLanguage,
- updateViewType
+ updateViewType,
+ updateDateType
};
export default connect(mapStateToProps, mapDispatchToProps)(FeedContainer);
diff --git a/src/containers/feed/styles.css b/src/containers/feed/styles.css
index 11fbe5d..9d43a7b 100644
--- a/src/containers/feed/styles.css
+++ b/src/containers/feed/styles.css
@@ -22,10 +22,6 @@
float: right;
}
-.grid-container {
- margin-top: 20px;
-}
-
.row-group {
margin-top: 35px;
}
diff --git a/src/redux/preference/actions.js b/src/redux/preference/actions.js
index 3183b81..8f115c0 100644
--- a/src/redux/preference/actions.js
+++ b/src/redux/preference/actions.js
@@ -1,4 +1,4 @@
-import { UPDATE_LANGUAGE, UPDATE_OPTIONS, UPDATE_VIEW_TYPE } from './types';
+import { UPDATE_DATE_TYPE, UPDATE_LANGUAGE, UPDATE_OPTIONS, UPDATE_VIEW_TYPE } from './types';
export const updateOptions = function (setting) {
return dispatch => {
@@ -26,3 +26,12 @@ export const updateLanguage = function (language) {
});
};
};
+
+export const updateDateType = function (dateType) {
+ return dispatch => {
+ dispatch({
+ type: UPDATE_DATE_TYPE,
+ payload: dateType
+ });
+ };
+};
diff --git a/src/redux/preference/reducer.js b/src/redux/preference/reducer.js
index 8c1819f..dfdec5c 100644
--- a/src/redux/preference/reducer.js
+++ b/src/redux/preference/reducer.js
@@ -1,7 +1,8 @@
-import { RESET_OPTIONS, UPDATE_LANGUAGE, UPDATE_OPTIONS, UPDATE_VIEW_TYPE } from './types';
+import { RESET_OPTIONS, UPDATE_DATE_TYPE, UPDATE_LANGUAGE, UPDATE_OPTIONS, UPDATE_VIEW_TYPE } from './types';
const initialState = {
viewType: 'grid',
+ dateType: 'weekly',
language: '',
options: {
token: '',
@@ -20,6 +21,11 @@ export default function reducer(state = initialState, action) {
...state,
options: initialState.options
};
+ case UPDATE_DATE_TYPE:
+ return {
+ ...state,
+ dateType: action.payload
+ };
case UPDATE_VIEW_TYPE:
return {
...state,
diff --git a/src/redux/preference/types.js b/src/redux/preference/types.js
index 9874e13..e5e52a4 100644
--- a/src/redux/preference/types.js
+++ b/src/redux/preference/types.js
@@ -1,4 +1,5 @@
export const UPDATE_OPTIONS = 'UPDATE_OPTIONS';
export const RESET_OPTIONS = 'RESET_OPTIONS';
export const UPDATE_VIEW_TYPE = 'UPDATE_VIEW_TYPE';
+export const UPDATE_DATE_TYPE = 'UPDATE_DATE_TYPE';
export const UPDATE_LANGUAGE = 'UPDATE_LANGUAGE';