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/index.jsx | 78 ++++++++++++++++++++++++++++++++++++++ src/settings/components/setting.js | 46 ---------------------- src/settings/components/site.scss | 8 ++++ src/settings/index.html | 10 +---- src/settings/index.js | 15 -------- src/settings/index.jsx | 18 +++++++++ src/settings/site.scss | 8 ---- 7 files changed, 105 insertions(+), 78 deletions(-) create mode 100644 src/settings/components/index.jsx delete mode 100644 src/settings/components/setting.js create mode 100644 src/settings/components/site.scss delete mode 100644 src/settings/index.js create mode 100644 src/settings/index.jsx delete mode 100644 src/settings/site.scss (limited to 'src') diff --git a/src/settings/components/index.jsx b/src/settings/components/index.jsx new file mode 100644 index 0000000..e57b09d --- /dev/null +++ b/src/settings/components/index.jsx @@ -0,0 +1,78 @@ +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'; + +class SettingsComponent extends React.Component { + constructor(props, context) { + super(props, context); + + this.state = { + settings: { + json: '', + } + }; + this.context.store.subscribe(this.stateChanged.bind(this)); + } + + componentDidMount() { + this.context.store.dispatch(settingActions.load()); + } + + stateChanged() { + let settings = this.context.store.getState(); + this.setState({ settings }); + } + + render() { + return ( +
+

Configure Vim-Vixen

+ +
+ + - - -
+
diff --git a/src/settings/index.js b/src/settings/index.js deleted file mode 100644 index c8d6cc4..0000000 --- a/src/settings/index.js +++ /dev/null @@ -1,15 +0,0 @@ -import './site.scss'; -import SettingComponent from 'settings/components/setting'; -import settingReducer from 'settings/reducers/setting'; -import { createStore } from 'shared/store'; - -const store = createStore(settingReducer); -let settingComponent = null; - -store.subscribe(() => { - settingComponent.update(); -}); - -document.addEventListener('DOMContentLoaded', () => { - settingComponent = new SettingComponent(document.body, store); -}); diff --git a/src/settings/index.jsx b/src/settings/index.jsx new file mode 100644 index 0000000..7516fb7 --- /dev/null +++ b/src/settings/index.jsx @@ -0,0 +1,18 @@ +import React from 'react'; +import ReactDOM from 'react-dom'; +import SettingsComponent from './components'; +import reducer from 'settings/reducers/setting'; +import Provider from 'shared/store/provider'; +import { createStore } from 'shared/store'; + +const store = createStore(reducer); + +document.addEventListener('DOMContentLoaded', () => { + let wrapper = document.getElementById('vimvixen-settings'); + ReactDOM.render( + + + , + wrapper + ); +}); diff --git a/src/settings/site.scss b/src/settings/site.scss deleted file mode 100644 index 5707c8a..0000000 --- a/src/settings/site.scss +++ /dev/null @@ -1,8 +0,0 @@ -.vimvixen-settings-form { - textarea[name=plain-json] { - font-family: monospace; - width: 100%; - min-height: 64ex; - resize: vertical; - } -} -- cgit v1.2.3