about summary refs log tree commit diff
path: root/app/javascript/mastodon/features/home_timeline/components/setting_text.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/javascript/mastodon/features/home_timeline/components/setting_text.js')
-rw-r--r--app/javascript/mastodon/features/home_timeline/components/setting_text.js38
1 files changed, 38 insertions, 0 deletions
diff --git a/app/javascript/mastodon/features/home_timeline/components/setting_text.js b/app/javascript/mastodon/features/home_timeline/components/setting_text.js
new file mode 100644
index 000000000..dfa2939b7
--- /dev/null
+++ b/app/javascript/mastodon/features/home_timeline/components/setting_text.js
@@ -0,0 +1,38 @@
+import React from 'react';
+import PropTypes from 'prop-types';
+import ImmutablePropTypes from 'react-immutable-proptypes';
+
+class SettingText extends React.PureComponent {
+
+  constructor (props, context) {
+    super(props, context);
+    this.handleChange = this.handleChange.bind(this);
+  }
+
+  handleChange (e) {
+    this.props.onChange(this.props.settingKey, e.target.value)
+  }
+
+  render () {
+    const { settings, settingKey, label } = this.props;
+
+    return (
+      <input
+        className='setting-text'
+        value={settings.getIn(settingKey)}
+        onChange={this.handleChange}
+        placeholder={label}
+      />
+    );
+  }
+
+}
+
+SettingText.propTypes = {
+  settings: ImmutablePropTypes.map.isRequired,
+  settingKey: PropTypes.array.isRequired,
+  label: PropTypes.string.isRequired,
+  onChange: PropTypes.func.isRequired
+};
+
+export default SettingText;