diff options
author | Harrison Healey <harrisonmhealey@gmail.com> | 2016-03-22 10:03:17 -0400 |
---|---|---|
committer | Harrison Healey <harrisonmhealey@gmail.com> | 2016-03-22 10:03:17 -0400 |
commit | 4e3eb2bb181ff6baad9911e231558eee0a08291c (patch) | |
tree | f17fd6d8fce9feb44adc17a4880a4f7dc5cb6897 /webapp/components/spinner_button.jsx | |
parent | 8376ff623380d20b8e4e26fa6abb2dd775930a7c (diff) | |
download | chat-4e3eb2bb181ff6baad9911e231558eee0a08291c.tar.gz chat-4e3eb2bb181ff6baad9911e231558eee0a08291c.tar.bz2 chat-4e3eb2bb181ff6baad9911e231558eee0a08291c.zip |
Added SpinnerButton component to handle buttons that are also spinners
Diffstat (limited to 'webapp/components/spinner_button.jsx')
-rw-r--r-- | webapp/components/spinner_button.jsx | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/webapp/components/spinner_button.jsx b/webapp/components/spinner_button.jsx new file mode 100644 index 000000000..fcc9af8cd --- /dev/null +++ b/webapp/components/spinner_button.jsx @@ -0,0 +1,48 @@ +// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +import React from 'react'; + +import loadingGif from 'images/load.gif'; + +export default class SpinnerButton extends React.Component { + static get propTypes() { + return { + children: React.PropTypes.node, + spinning: React.PropTypes.bool.isRequired, + onClick: React.PropTypes.func + }; + } + + constructor(props) { + super(props); + + this.handleClick = this.handleClick.bind(this); + } + + handleClick(e) { + if (this.props.onClick) { + this.props.onClick(e); + } + } + + render() { + if (this.props.spinning) { + return ( + <img + className='spinner-button__gif' + src={loadingGif} + /> + ); + } + + return ( + <button + onClick={this.handleClick} + className='btn btn-sm btn-primary' + > + {this.props.children} + </button> + ); + } +} |