aboutsummaryrefslogtreecommitdiff
path: root/src/content
diff options
context:
space:
mode:
Diffstat (limited to 'src/content')
-rw-r--r--src/content/actions/addon.js15
-rw-r--r--src/content/actions/index.js4
-rw-r--r--src/content/reducers/addon.js24
3 files changed, 43 insertions, 0 deletions
diff --git a/src/content/actions/addon.js b/src/content/actions/addon.js
new file mode 100644
index 0000000..8d38025
--- /dev/null
+++ b/src/content/actions/addon.js
@@ -0,0 +1,15 @@
+import actions from 'content/actions';
+
+const enable = () => {
+ return { type: actions.ADDON_ENABLE };
+};
+
+const disable = () => {
+ return { type: actions.ADDON_DISABLE };
+};
+
+const toggleEnabled = () => {
+ return { type: actions.ADDON_TOGGLE_ENABLED };
+};
+
+export { enable, disable, toggleEnabled };
diff --git a/src/content/actions/index.js b/src/content/actions/index.js
index f8db948..085d510 100644
--- a/src/content/actions/index.js
+++ b/src/content/actions/index.js
@@ -1,5 +1,9 @@
export default {
// User input
+ ADDON_ENABLE: 'addon.enable',
+ ADDON_DISABLE: 'addon.disable',
+ ADDON_TOGGLE_ENABLED: 'addon.toggle.enabled',
+
INPUT_KEY_PRESS: 'input.key,press',
INPUT_CLEAR_KEYS: 'input.clear.keys',
INPUT_SET_KEYMAPS: 'input.set.keymaps',
diff --git a/src/content/reducers/addon.js b/src/content/reducers/addon.js
new file mode 100644
index 0000000..8cc5ef1
--- /dev/null
+++ b/src/content/reducers/addon.js
@@ -0,0 +1,24 @@
+import actions from 'content/actions';
+
+const defaultState = {
+ enabled: true,
+};
+
+export default function reducer(state = defaultState, action = {}) {
+ switch (action.type) {
+ case actions.ADDON_ENABLE:
+ return Object.assign({}, state, {
+ enabled: true,
+ });
+ case actions.ADDON_DISABLE:
+ return Object.assign({}, state, {
+ enabled: false,
+ });
+ case actions.ADDON_TOGGLE_ENABLED:
+ return Object.assign({}, state, {
+ enabled: !state.enabled,
+ });
+ default:
+ return state;
+ }
+}