Add filter clearing logic
This commit is contained in:
@@ -149,9 +149,14 @@
|
|||||||
border-color: #000d00;
|
border-color: #000d00;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
padding: 0;
|
||||||
|
span {
|
||||||
|
display: inline-block;
|
||||||
|
min-height: 30px;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.map-wrapper {
|
.map-wrapper {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
display: block;
|
display: block;
|
||||||
|
@@ -7,13 +7,14 @@ import SuperBlock from './Super-Block.jsx';
|
|||||||
import FullStack from './Full-Stack.jsx';
|
import FullStack from './Full-Stack.jsx';
|
||||||
import CodingPrep from './Coding-Prep.jsx';
|
import CodingPrep from './Coding-Prep.jsx';
|
||||||
|
|
||||||
const clearIcon = (<i className='fa fa-times' />);
|
const clearIcon = <i className='fa fa-times' />;
|
||||||
const searchIcon = (<i className='fa fa-search' />);
|
const searchIcon = <i className='fa fa-search' />;
|
||||||
export default class ShowMap extends PureComponent {
|
export default class ShowMap extends PureComponent {
|
||||||
static displayName = 'Map';
|
static displayName = 'Map';
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
superBlocks: PropTypes.array,
|
clearFilter: PropTypes.func,
|
||||||
filter: PropTypes.string,
|
filter: PropTypes.string,
|
||||||
|
superBlocks: PropTypes.array,
|
||||||
updateFilter: PropTypes.func
|
updateFilter: PropTypes.func
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -31,8 +32,10 @@ export default class ShowMap extends PureComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { superBlocks, updateFilter, filter } = this.props;
|
const { superBlocks, updateFilter, clearFilter, filter } = this.props;
|
||||||
const inputIcon = filter ? clearIcon : searchIcon;
|
const inputIcon = !filter ?
|
||||||
|
searchIcon :
|
||||||
|
<span onClick={ clearFilter }>{ clearIcon }</span>;
|
||||||
const inputClass = classnames({
|
const inputClass = classnames({
|
||||||
'map-filter': true,
|
'map-filter': true,
|
||||||
filled: !!filter
|
filled: !!filter
|
||||||
|
@@ -6,9 +6,14 @@ import { createSelector } from 'reselect';
|
|||||||
|
|
||||||
import Map from './Map.jsx';
|
import Map from './Map.jsx';
|
||||||
import contain from '../../../utils/professor-x';
|
import contain from '../../../utils/professor-x';
|
||||||
import { fetchChallenges, updateFilter } from '../redux/actions';
|
import {
|
||||||
|
clearFilter,
|
||||||
|
fetchChallenges,
|
||||||
|
updateFilter
|
||||||
|
} from '../redux/actions';
|
||||||
|
|
||||||
const bindableActions = {
|
const bindableActions = {
|
||||||
|
clearFilter,
|
||||||
fetchChallenges,
|
fetchChallenges,
|
||||||
updateFilter
|
updateFilter
|
||||||
};
|
};
|
||||||
@@ -59,6 +64,7 @@ const fetchOptions = {
|
|||||||
export class ShowMap extends PureComponent {
|
export class ShowMap extends PureComponent {
|
||||||
static displayName = 'ShowMap';
|
static displayName = 'ShowMap';
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
|
clearFilter: PropTypes.func,
|
||||||
filter: PropTypes.string,
|
filter: PropTypes.string,
|
||||||
superBlocks: PropTypes.array,
|
superBlocks: PropTypes.array,
|
||||||
updateFilter: PropTypes.func
|
updateFilter: PropTypes.func
|
||||||
|
@@ -13,3 +13,5 @@ export const updateFilter = createAction(
|
|||||||
types.updateFilter,
|
types.updateFilter,
|
||||||
e => e.target.value
|
e => e.target.value
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const clearFilter = createAction(types.clearFilter);
|
||||||
|
@@ -16,6 +16,10 @@ export default handleActions(
|
|||||||
[types.updateFilter]: (state, { payload = ''}) => ({
|
[types.updateFilter]: (state, { payload = ''}) => ({
|
||||||
...state,
|
...state,
|
||||||
filter: payload
|
filter: payload
|
||||||
|
}),
|
||||||
|
[types.clearFilter]: (state) => ({
|
||||||
|
...state,
|
||||||
|
filter: ''
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
initialState
|
initialState
|
||||||
|
@@ -3,5 +3,6 @@ import createTypes from '../../../utils/create-types';
|
|||||||
export default createTypes([
|
export default createTypes([
|
||||||
'fetchChallenges',
|
'fetchChallenges',
|
||||||
'fetchChallengesCompleted',
|
'fetchChallengesCompleted',
|
||||||
'updateFilter'
|
'updateFilter',
|
||||||
|
'clearFilter'
|
||||||
], 'map');
|
], 'map');
|
||||||
|
Reference in New Issue
Block a user