diff options
author | Thibaut Girka <thib@sitedethib.com> | 2018-03-30 12:45:23 +0200 |
---|---|---|
committer | Thibaut Girka <thib@sitedethib.com> | 2018-03-30 12:45:23 +0200 |
commit | 48bcf4d6e89658abac5405683e823c68f27248f0 (patch) | |
tree | 1acfd9ce37c661f4616b6ecfea199dd1e63c0119 /app/javascript/flavours/glitch/reducers | |
parent | 2871a82fccf2b60ca25379f0557d457fae5df534 (diff) |
[Glitch] Remove pointer events on the entire UI when a dropdown menu is open
Port 913a38111ff5b0cb7f412bec93e8314859c88855 to glitch-soc
Diffstat (limited to 'app/javascript/flavours/glitch/reducers')
-rw-r--r-- | app/javascript/flavours/glitch/reducers/dropdown_menu.js | 18 | ||||
-rw-r--r-- | app/javascript/flavours/glitch/reducers/index.js | 2 |
2 files changed, 20 insertions, 0 deletions
diff --git a/app/javascript/flavours/glitch/reducers/dropdown_menu.js b/app/javascript/flavours/glitch/reducers/dropdown_menu.js new file mode 100644 index 000000000..5449884cc --- /dev/null +++ b/app/javascript/flavours/glitch/reducers/dropdown_menu.js @@ -0,0 +1,18 @@ +import Immutable from 'immutable'; +import { + DROPDOWN_MENU_OPEN, + DROPDOWN_MENU_CLOSE, +} from '../actions/dropdown_menu'; + +const initialState = Immutable.Map({ openId: null, placement: null }); + +export default function dropdownMenu(state = initialState, action) { + switch (action.type) { + case DROPDOWN_MENU_OPEN: + return state.merge({ openId: action.id, placement: action.placement }); + case DROPDOWN_MENU_CLOSE: + return state.get('openId') === action.id ? state.set('openId', null) : state; + default: + return state; + } +} diff --git a/app/javascript/flavours/glitch/reducers/index.js b/app/javascript/flavours/glitch/reducers/index.js index e9c8d7c1d..173f95cd2 100644 --- a/app/javascript/flavours/glitch/reducers/index.js +++ b/app/javascript/flavours/glitch/reducers/index.js @@ -1,4 +1,5 @@ import { combineReducers } from 'redux-immutable'; +import dropdown_menu from './dropdown_menu'; import timelines from './timelines'; import meta from './meta'; import alerts from './alerts'; @@ -27,6 +28,7 @@ import lists from './lists'; import listEditor from './list_editor'; const reducers = { + dropdown_menu, timelines, meta, alerts, |