From de50eff6acda8b28940cff9b955cfbded3c68b58 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Mon, 24 Oct 2016 18:07:40 +0200 Subject: Add opening images in a modal window --- .../javascripts/components/reducers/index.jsx | 2 ++ .../javascripts/components/reducers/modal.jsx | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 app/assets/javascripts/components/reducers/modal.jsx (limited to 'app/assets/javascripts/components/reducers') diff --git a/app/assets/javascripts/components/reducers/index.jsx b/app/assets/javascripts/components/reducers/index.jsx index da9ab1a21..e9256b8ec 100644 --- a/app/assets/javascripts/components/reducers/index.jsx +++ b/app/assets/javascripts/components/reducers/index.jsx @@ -5,6 +5,7 @@ import compose from './compose'; import follow from './follow'; import notifications from './notifications'; import { loadingBarReducer } from 'react-redux-loading-bar'; +import modal from './modal'; export default combineReducers({ timelines, @@ -13,4 +14,5 @@ export default combineReducers({ follow, notifications, loadingBar: loadingBarReducer, + modal, }); diff --git a/app/assets/javascripts/components/reducers/modal.jsx b/app/assets/javascripts/components/reducers/modal.jsx new file mode 100644 index 000000000..b529b6aa8 --- /dev/null +++ b/app/assets/javascripts/components/reducers/modal.jsx @@ -0,0 +1,21 @@ +import { MEDIA_OPEN, MODAL_CLOSE } from '../actions/modal'; +import Immutable from 'immutable'; + +const initialState = Immutable.Map({ + url: '', + open: false +}); + +export default function modal(state = initialState, action) { + switch(action.type) { + case MEDIA_OPEN: + return state.withMutations(map => { + map.set('url', action.url); + map.set('open', true); + }); + case MODAL_CLOSE: + return state.set('open', false); + default: + return state; + } +}; -- cgit