From 14cdd31388ef2d50011c0b1a4cc5a2ef34fad04f Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Thu, 16 Apr 2020 16:13:22 -0500 Subject: [PATCH] Basic theme switcher (no persistence) --- app/gabsocial/features/preferences/index.js | 66 ++++++++++++++++++++- 1 file changed, 63 insertions(+), 3 deletions(-) diff --git a/app/gabsocial/features/preferences/index.js b/app/gabsocial/features/preferences/index.js index 080dd46b1..bb2c5650a 100644 --- a/app/gabsocial/features/preferences/index.js +++ b/app/gabsocial/features/preferences/index.js @@ -3,13 +3,29 @@ import { connect } from 'react-redux'; import { defineMessages, injectIntl } from 'react-intl'; import ImmutablePureComponent from 'react-immutable-pure-component'; import PropTypes from 'prop-types'; +import ImmutablePropTypes from 'react-immutable-proptypes'; +import { changeSetting } from 'gabsocial/actions/settings'; import Column from '../ui/components/column'; const messages = defineMessages({ heading: { id: 'column.preferences', defaultMessage: 'Preferences' }, }); -const mapStateToProps = state => ({}); +// TODO: Pull dynamically +const themes = { + cobalt: 'cobalt', + 'gabsocial-light': 'Light', + default: 'Dark', + contrast: 'High contrast', + halloween: 'Halloween', + neenster: 'neenster', + glinner: 'glinner', + lime: 'lime', +}; + +const mapStateToProps = state => ({ + settings: state.get('settings'), +}); export default @connect(mapStateToProps) @injectIntl @@ -18,17 +34,61 @@ class Preferences extends ImmutablePureComponent { static propTypes = { dispatch: PropTypes.func.isRequired, intl: PropTypes.object.isRequired, + settings: ImmutablePropTypes.map, }; + constructor(props) { + super(props); + this.state = { isLoading: false }; + } + componentWillMount() { // this.props.dispatch(fetchPreferences()); } + getFormData = (form) => { + return Object.fromEntries( + Array.from(form).map(i => [i.name, i.value]) + ); + } + + onThemeChange = e => { + const { dispatch } = this.props; + dispatch(changeSetting(['theme'], e.target.value)); + } + render() { - const { intl } = this.props; + const { settings, intl } = this.props; return ( - + +
+
+
+
+
+ +
+ +
+
+
+
+
+
+
); }