diff --git a/app/gabsocial/features/forms/index.js b/app/gabsocial/features/forms/index.js
index 1eb13ac0e..d8a801d9a 100644
--- a/app/gabsocial/features/forms/index.js
+++ b/app/gabsocial/features/forms/index.js
@@ -7,7 +7,11 @@ export class SimpleForm extends ImmutablePureComponent {
static propTypes = {
children: PropTypes.node,
- onSubmit: PropTypes.function,
+ onSubmit: PropTypes.func,
+ }
+
+ static defaultProps = {
+ onSubmit: e => e.preventDefault(),
}
render() {
@@ -79,3 +83,66 @@ export class Checkbox extends ImmutablePureComponent {
}
}
+
+export class RadioGroup extends ImmutablePureComponent {
+
+ static propTypes = {
+ label: PropTypes.string,
+ children: PropTypes.node,
+ }
+
+ render() {
+ const { label, children, onChange } = this.props;
+
+ const childrenWithProps = React.Children.map(children, child =>
+ React.cloneElement(child, { onChange })
+ );
+
+ return (
+
+ );
+ }
+
+}
+
+export class RadioItem extends ImmutablePureComponent {
+
+ static propTypes = {
+ label: PropTypes.string,
+ hint: PropTypes.string,
+ value: PropTypes.string.isRequired,
+ checked: PropTypes.bool.isRequired,
+ onChange: PropTypes.func,
+ }
+
+ static defaultProps = {
+ checked: false,
+ }
+
+ render() {
+ const { label, hint, value, checked, onChange } = this.props;
+ const id = uuidv4();
+
+ return (
+
+
+
+ );
+ }
+
+}
diff --git a/app/gabsocial/features/preferences/index.js b/app/gabsocial/features/preferences/index.js
index 35454a7ec..130b3e34f 100644
--- a/app/gabsocial/features/preferences/index.js
+++ b/app/gabsocial/features/preferences/index.js
@@ -6,7 +6,12 @@ import PropTypes from 'prop-types';
import ImmutablePropTypes from 'react-immutable-proptypes';
import { changeSetting } from 'gabsocial/actions/settings';
import Column from '../ui/components/column';
-import { SimpleForm, FieldsGroup } from 'gabsocial/features/forms';
+import {
+ SimpleForm,
+ FieldsGroup,
+ RadioGroup,
+ RadioItem,
+} from 'gabsocial/features/forms';
import SettingsCheckbox from './components/settings_checkbox';
const messages = defineMessages({
@@ -60,19 +65,12 @@ class Preferences extends ImmutablePureComponent {
dispatch(changeSetting(['defaultPrivacy'], e.target.value));
}
- handleCheckboxSetting = path => {
- const { dispatch } = this.props;
- return (e) => {
- dispatch(changeSetting(path, e.target.checked));
- };
- }
-
render() {
const { settings, intl } = this.props;
return (
-
+
@@ -98,31 +96,26 @@ class Preferences extends ImmutablePureComponent {
-
+
+
+
+
+