From c150ad2c34ad3fcbfcb03f38404308bd6cf48a92 Mon Sep 17 00:00:00 2001 From: Berkeley Martinez Date: Wed, 23 Mar 2016 16:19:16 -0700 Subject: [PATCH] Add filter clearing logic --- client/less/map.less | 7 ++++++- common/app/routes/map/components/Map.jsx | 13 ++++++++----- common/app/routes/map/components/Show.jsx | 8 +++++++- common/app/routes/map/redux/actions.js | 2 ++ common/app/routes/map/redux/reducer.js | 4 ++++ common/app/routes/map/redux/types.js | 3 ++- 6 files changed, 29 insertions(+), 8 deletions(-) diff --git a/client/less/map.less b/client/less/map.less index 11e9fc307c..beddce7d86 100644 --- a/client/less/map.less +++ b/client/less/map.less @@ -149,9 +149,14 @@ border-color: #000d00; color: #fff; cursor: pointer; + padding: 0; + span { + display: inline-block; + min-height: 30px; + width: 100%; + } } - .map-wrapper { position: absolute; display: block; diff --git a/common/app/routes/map/components/Map.jsx b/common/app/routes/map/components/Map.jsx index c455e9f035..fd1d46c840 100644 --- a/common/app/routes/map/components/Map.jsx +++ b/common/app/routes/map/components/Map.jsx @@ -7,13 +7,14 @@ import SuperBlock from './Super-Block.jsx'; import FullStack from './Full-Stack.jsx'; import CodingPrep from './Coding-Prep.jsx'; -const clearIcon = (); -const searchIcon = (); +const clearIcon = ; +const searchIcon = ; export default class ShowMap extends PureComponent { static displayName = 'Map'; static propTypes = { - superBlocks: PropTypes.array, + clearFilter: PropTypes.func, filter: PropTypes.string, + superBlocks: PropTypes.array, updateFilter: PropTypes.func }; @@ -31,8 +32,10 @@ export default class ShowMap extends PureComponent { } render() { - const { superBlocks, updateFilter, filter } = this.props; - const inputIcon = filter ? clearIcon : searchIcon; + const { superBlocks, updateFilter, clearFilter, filter } = this.props; + const inputIcon = !filter ? + searchIcon : + { clearIcon }; const inputClass = classnames({ 'map-filter': true, filled: !!filter diff --git a/common/app/routes/map/components/Show.jsx b/common/app/routes/map/components/Show.jsx index f52f16a300..181b94ca66 100644 --- a/common/app/routes/map/components/Show.jsx +++ b/common/app/routes/map/components/Show.jsx @@ -6,9 +6,14 @@ import { createSelector } from 'reselect'; import Map from './Map.jsx'; import contain from '../../../utils/professor-x'; -import { fetchChallenges, updateFilter } from '../redux/actions'; +import { + clearFilter, + fetchChallenges, + updateFilter +} from '../redux/actions'; const bindableActions = { + clearFilter, fetchChallenges, updateFilter }; @@ -59,6 +64,7 @@ const fetchOptions = { export class ShowMap extends PureComponent { static displayName = 'ShowMap'; static propTypes = { + clearFilter: PropTypes.func, filter: PropTypes.string, superBlocks: PropTypes.array, updateFilter: PropTypes.func diff --git a/common/app/routes/map/redux/actions.js b/common/app/routes/map/redux/actions.js index c34787d72b..0868fe4957 100644 --- a/common/app/routes/map/redux/actions.js +++ b/common/app/routes/map/redux/actions.js @@ -13,3 +13,5 @@ export const updateFilter = createAction( types.updateFilter, e => e.target.value ); + +export const clearFilter = createAction(types.clearFilter); diff --git a/common/app/routes/map/redux/reducer.js b/common/app/routes/map/redux/reducer.js index 66fbadcd48..c3f4179e4f 100644 --- a/common/app/routes/map/redux/reducer.js +++ b/common/app/routes/map/redux/reducer.js @@ -16,6 +16,10 @@ export default handleActions( [types.updateFilter]: (state, { payload = ''}) => ({ ...state, filter: payload + }), + [types.clearFilter]: (state) => ({ + ...state, + filter: '' }) }, initialState diff --git a/common/app/routes/map/redux/types.js b/common/app/routes/map/redux/types.js index cb56398f0b..a6447dfe50 100644 --- a/common/app/routes/map/redux/types.js +++ b/common/app/routes/map/redux/types.js @@ -3,5 +3,6 @@ import createTypes from '../../../utils/create-types'; export default createTypes([ 'fetchChallenges', 'fetchChallengesCompleted', - 'updateFilter' + 'updateFilter', + 'clearFilter' ], 'map');