mirror of
https://github.com/wassname/talk.git
synced 2026-07-08 23:43:51 +08:00
Some docs
This commit is contained in:
@@ -19,7 +19,13 @@ export default class SortOption extends React.Component {
|
||||
}
|
||||
|
||||
SortOption.propTypes = {
|
||||
|
||||
// A simple callback to be called when clicking on this sort option.
|
||||
setSort: PropTypes.func.isRequired,
|
||||
|
||||
// Whether or not this sort option is active.
|
||||
active: PropTypes.bool.isRequired,
|
||||
|
||||
// Label to show next to the input control.
|
||||
label: PropTypes.string.isRequired,
|
||||
};
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
import withSortOption from '../hocs/withSortOption';
|
||||
import SortOption from '../components/SortOption';
|
||||
|
||||
/**
|
||||
* A factory creating a sort option component.
|
||||
* @param {string|function} label label to display, can be a callback for lazy evaluation.
|
||||
* @param {Object} sort sort parameters
|
||||
* @param {string} sort.sortBy
|
||||
* @param {string} sort.sortOrder
|
||||
* @return {Object} Component
|
||||
*/
|
||||
export const createSortOption = (label, sort) => withSortOption({...sort, label})(SortOption);
|
||||
|
||||
@@ -18,6 +18,14 @@ const mapDispatchToProps = (dispatch) =>
|
||||
dispatch
|
||||
);
|
||||
|
||||
/**
|
||||
* A HOC providing props to implement a sort option.
|
||||
* Provides the props `active`, `setSort`, `label`.
|
||||
* @param {Object} sort
|
||||
* @param {Object} sort.sortBy
|
||||
* @param {string} sort.sortOrder
|
||||
* @return {Object} HOC
|
||||
*/
|
||||
export default ({sortBy = 'created_at', sortOrder = 'DESC', label}) => hoistStatics((WrappedComponent) => {
|
||||
class WithSortOption extends React.Component {
|
||||
setSort = () => {
|
||||
|
||||
Reference in New Issue
Block a user