From f578bb1e48ec4d97bca92c7faf0dd8ed5aeceb39 Mon Sep 17 00:00:00 2001 From: =Corey Hulen Date: Tue, 1 Sep 2015 17:06:31 -0700 Subject: MM-2065 style refactoring --- web/react/components/setting_picture.jsx | 84 ++++++++++++++++++++++++++------ 1 file changed, 69 insertions(+), 15 deletions(-) (limited to 'web/react/components/setting_picture.jsx') diff --git a/web/react/components/setting_picture.jsx b/web/react/components/setting_picture.jsx index 5b12ad7e9..eaa839733 100644 --- a/web/react/components/setting_picture.jsx +++ b/web/react/components/setting_picture.jsx @@ -1,25 +1,33 @@ // Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved. // See License.txt for license information. -module.exports = React.createClass({ - setPicture: function(file) { +export default class SettingPicture extends React.Component { + constructor(props) { + super(props); + + this.setPicture = this.setPicture.bind(this); + } + + setPicture(file) { if (file) { var reader = new FileReader(); var img = this.refs.image.getDOMNode(); - reader.onload = function(e) { + reader.onload = function load(e) { $(img).attr('src', e.target.result); }; reader.readAsDataURL(file); } - }, - componentWillReceiveProps: function(nextProps) { + } + + componentWillReceiveProps(nextProps) { if (nextProps.picture) { this.setPicture(nextProps.picture); } - }, - render: function() { + } + + render() { var clientError = null; if (this.props.client_error) { clientError =
; @@ -31,14 +39,31 @@ module.exports = React.createClass({ var img = null; if (this.props.picture) { - img = (); + img = ( + + ); } else { - img = (); + img = ( + + ); } var confirmButton; if (this.props.loadingPicture) { - confirmButton = ; + confirmButton = ( + + ); } else { var confirmButtonClass = 'btn btn-sm'; if (this.props.submitActive) { @@ -46,9 +71,15 @@ module.exports = React.createClass({ } else { confirmButtonClass += ' btn-inactive disabled'; } - confirmButton = Save; + + confirmButton = ( + Save + ); } - var helpText = 'Upload a profile picture in either JPG or PNG format, at least ' + config.ProfileWidth + 'px in width and ' + config.ProfileHeight + 'px height.' + var helpText = 'Upload a profile picture in either JPG or PNG format, at least ' + config.ProfileWidth + 'px in width and ' + config.ProfileHeight + 'px height.'; var self = this; return ( @@ -65,13 +96,36 @@ module.exports = React.createClass({
  • {serverError} {clientError} - Select + Select + {confirmButton} - Cancel + Cancel
  • ); } -}); +} + +SettingPicture.propTypes = { + client_error: React.PropTypes.string, + server_error: React.PropTypes.string, + src: React.PropTypes.string, + picture: React.PropTypes.object, + loadingPicture: React.PropTypes.bool, + submitActive: React.PropTypes.bool, + submit: React.PropTypes.func, + title: React.PropTypes.string, + pictureChange: React.PropTypes.func +}; \ No newline at end of file -- cgit v1.2.3-1-g7c22