about summary refs log tree commit diff
path: root/app/javascript/flavours/glitch/reducers/dropdown_menu.js
diff options
context:
space:
mode:
authorThibaut Girka <thib@sitedethib.com>2018-03-30 12:45:23 +0200
committerThibaut Girka <thib@sitedethib.com>2018-03-30 12:45:23 +0200
commit48bcf4d6e89658abac5405683e823c68f27248f0 (patch)
tree1acfd9ce37c661f4616b6ecfea199dd1e63c0119 /app/javascript/flavours/glitch/reducers/dropdown_menu.js
parent2871a82fccf2b60ca25379f0557d457fae5df534 (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/dropdown_menu.js')
-rw-r--r--app/javascript/flavours/glitch/reducers/dropdown_menu.js18
1 files changed, 18 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;
+  }
+}