forked from rwieruch/favesound-redux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sort by Date Implemented rwieruch#96
- Loading branch information
VikasDayananda
committed
Oct 21, 2018
1 parent
4b185e5
commit 002d010
Showing
15 changed files
with
187 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import PropTypes from 'prop-types'; | ||
import React from 'react'; | ||
import map from '../../services/map'; | ||
import classNames from 'classnames'; | ||
import { connect } from 'react-redux'; | ||
import { bindActionCreators } from 'redux'; | ||
import * as actions from '../../actions/index'; | ||
import * as dateSortTypes from '../../constants/dateSortTypes'; | ||
import { DATE_SORT_NAMES } from '../../constants/sort'; | ||
import ButtonActive from '../../components/ButtonActive'; | ||
import ButtonInline from '../../components/ButtonInline'; | ||
|
||
function hasActiveSort(activeDateSort) { | ||
return activeDateSort !== dateSortTypes.NONE; | ||
} | ||
|
||
function DateSort({ | ||
activeDateSort, | ||
onSort, | ||
}) { | ||
const sortIconClass = classNames( | ||
'stream-interaction-icon', | ||
{ | ||
'stream-interaction-icon-active': hasActiveSort(activeDateSort) | ||
} | ||
); | ||
|
||
return ( | ||
<div className="stream-interaction"> | ||
<div className={sortIconClass} title={'Sort Stream'}> | ||
<ButtonInline onClick={() => onSort(dateSortTypes.NONE)}> | ||
<i className="fa fa-sort"/> | ||
</ButtonInline> | ||
</div> | ||
<div className="stream-interaction-content"> | ||
{ | ||
map((value, key) => { | ||
return ( | ||
<span key={key}> | ||
<ButtonActive onClick={() => onSort(value)} isActive={value === activeDateSort}> | ||
{DATE_SORT_NAMES[value]} | ||
</ButtonActive> | ||
</span> | ||
); | ||
}, dateSortTypes) | ||
} | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
function mapStateToProps(state) { | ||
return { | ||
activeDateSort: state.sort.dateSortType | ||
}; | ||
} | ||
|
||
function mapDispatchToProps(dispatch) { | ||
return { | ||
onSort: (dateSortType) => bindActionCreators(actions.dateSortStream, dispatch)(dateSortType) | ||
}; | ||
} | ||
|
||
DateSort.propTypes = { | ||
activeDateSort: PropTypes.string, | ||
onSort: PropTypes.func | ||
}; | ||
|
||
export default connect(mapStateToProps, mapDispatchToProps)(DateSort); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export const NONE = 'NONE'; | ||
|
||
export const PAST_6MONTH = 'PAST_6MONTH'; | ||
export const PAST_YEAR = 'PAST_YEAR'; | ||
export const OLDER = 'OLDER'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.