adding in off-click of element handler

This commit is contained in:
Alex Windett 2017-02-28 17:54:33 +00:00 committed by Sérgio Ramos
parent 08acbe5944
commit 017f133611
3 changed files with 27 additions and 17 deletions

View File

@ -76,14 +76,22 @@ const arrowPosition = {
right: '10%' right: '10%'
}; };
const Header = ({ const Header = (props) => {
account = {},
tooltip = false, const {
handleToggle account,
}) => { handleToggle,
tooltip
} = props;
const handleToggleClick = (ev) => { const handleToggleClick = (ev) => {
ev.preventDefault(); ev.preventDefault();
handleToggle(); handleToggle(!tooltip);
};
const handleHideToggle = (ev) => {
ev.preventDefault();
handleToggle(false);
}; };
const tooltipComponent = !tooltip ? null : ( const tooltipComponent = !tooltip ? null : (
@ -103,7 +111,11 @@ const Header = ({
); );
return ( return (
<StyledHeader name='application-header'> <StyledHeader
name='application-header'
onBlur={handleHideToggle}
onFocus={handleHideToggle}
>
<Row> <Row>
<Column lg={10} xs={8}> <Column lg={10} xs={8}>
<Link to='/'> <Link to='/'>

View File

@ -10,7 +10,7 @@ const mapStateToProps = (state, ownProps) => ({
}); });
const mapDispatchToProps = (dispatch) => ({ const mapDispatchToProps = (dispatch) => ({
handleToggle: () => dispatch(toggleHeaderTooltip()) handleToggle: (bool) => dispatch(toggleHeaderTooltip(bool))
}); });
export default connect( export default connect(

View File

@ -2,13 +2,11 @@ import { handleActions } from 'redux-actions';
import { toggleHeaderTooltip } from '@state/actions'; import { toggleHeaderTooltip } from '@state/actions';
export default handleActions({ export default handleActions({
[toggleHeaderTooltip.toString()]: (state, action) => { [toggleHeaderTooltip.toString()]: (state, action) => ({
return { ...state,
...state, ui: {
ui: { ...state.ui,
...state.ui, tooltip: action.payload
tooltip: !state.ui.tooltip }
} })
};
}
}, {}); }, {});