From 6669f6b6ef2a3268dfeca87dbccc2ac8ef2fa30d Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Mon, 9 Oct 2017 13:42:16 +0900 Subject: use react in settings --- src/settings/components/site.scss | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 src/settings/components/site.scss (limited to 'src/settings/components/site.scss') diff --git a/src/settings/components/site.scss b/src/settings/components/site.scss new file mode 100644 index 0000000..5707c8a --- /dev/null +++ b/src/settings/components/site.scss @@ -0,0 +1,8 @@ +.vimvixen-settings-form { + textarea[name=plain-json] { + font-family: monospace; + width: 100%; + min-height: 64ex; + resize: vertical; + } +} -- cgit v1.2.3 From 805d1395fc869235f079438b5b4884a521c0230e Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Mon, 9 Oct 2017 17:03:52 +0900 Subject: save settings on the fly --- src/settings/actions/setting.js | 6 ++-- src/settings/components/index.jsx | 61 ++++++++++++++++++++++++--------------- src/settings/components/site.scss | 2 +- src/settings/reducers/setting.js | 2 ++ src/shared/default-settings.js | 1 + 5 files changed, 45 insertions(+), 27 deletions(-) (limited to 'src/settings/components/site.scss') diff --git a/src/settings/actions/setting.js b/src/settings/actions/setting.js index 3525f0a..c1b27c8 100644 --- a/src/settings/actions/setting.js +++ b/src/settings/actions/setting.js @@ -3,8 +3,7 @@ import messages from 'shared/messages'; import DefaultSettings from 'shared/default-settings'; const load = () => { - return browser.storage.local.get('settings').then((value) => { - let settings = value.settings; + return browser.storage.local.get('settings').then(({ settings }) => { if (settings) { return set(settings); } @@ -18,6 +17,8 @@ const save = (settings) => { }).then(() => { return browser.runtime.sendMessage({ type: messages.SETTINGS_RELOAD + }).then(() => { + return set(settings); }); }); }; @@ -25,6 +26,7 @@ const save = (settings) => { const set = (settings) => { return { type: actions.SETTING_SET_SETTINGS, + source: settings.source, json: settings.json, value: JSON.parse(settings.json), }; diff --git a/src/settings/components/index.jsx b/src/settings/components/index.jsx index e57b09d..4418942 100644 --- a/src/settings/components/index.jsx +++ b/src/settings/components/index.jsx @@ -2,7 +2,7 @@ import './site.scss'; import React from 'react'; import PropTypes from 'prop-types'; import * as settingActions from 'settings/actions/setting'; -import { validate } from 'shared/validators/setting'; +import * as validator from 'shared/validators/setting'; class SettingsComponent extends React.Component { constructor(props, context) { @@ -22,39 +22,42 @@ class SettingsComponent extends React.Component { stateChanged() { let settings = this.context.store.getState(); - this.setState({ settings }); + this.setState({ + settings: { + source: settings.source, + json: settings.json, + } + }); } render() { return (

Configure Vim-Vixen

+
- - -