@@ -3,6 +3,7 @@ const ReactDOM = require('react-dom');
33const StylePropable = require ( './mixins/style-propable' ) ;
44const Transitions = require ( './styles/transitions' ) ;
55const ColorManipulator = require ( './utils/color-manipulator' ) ;
6+ const Children = require ( './utils/children' ) ;
67const Typography = require ( './styles/typography' ) ;
78const EnhancedButton = require ( './enhanced-button' ) ;
89const Paper = require ( './paper' ) ;
@@ -40,6 +41,10 @@ const RaisedButton = React.createClass({
4041 className : React . PropTypes . string ,
4142 disabled : React . PropTypes . bool ,
4243 label : validateLabel ,
44+ labelPosition : React . PropTypes . oneOf ( [
45+ 'before' ,
46+ 'after' ,
47+ ] ) ,
4348 onMouseDown : React . PropTypes . func ,
4449 onMouseUp : React . PropTypes . func ,
4550 onMouseLeave : React . PropTypes . func ,
@@ -55,6 +60,12 @@ const RaisedButton = React.createClass({
5560 fullWidth : React . PropTypes . bool ,
5661 } ,
5762
63+ getDefaultProps : function ( ) {
64+ return {
65+ labelPosition : 'before' , // Should be after but we keep it like for now (prevent breaking changes)
66+ } ;
67+ } ,
68+
5869 getInitialState ( ) {
5970 let zDepth = this . props . disabled ? 0 : 1 ;
6071 return {
@@ -160,18 +171,22 @@ const RaisedButton = React.createClass({
160171
161172 render ( ) {
162173 let {
174+ children,
163175 disabled,
164176 label,
177+ labelPosition,
178+ labelStyle,
165179 primary,
166180 secondary,
167- ...other } = this . props ;
181+ ...other ,
182+ } = this . props ;
168183
169184 let styles = this . getStyles ( ) ;
170185
171186 let labelElement ;
172187 if ( label ) {
173188 labelElement = (
174- < span style = { this . prepareStyles ( styles . label , this . props . labelStyle ) } >
189+ < span style = { this . prepareStyles ( styles . label , labelStyle ) } >
175190 { label }
176191 </ span >
177192 ) ;
@@ -190,6 +205,13 @@ const RaisedButton = React.createClass({
190205 onKeyboardFocus : this . _handleKeyboardFocus ,
191206 } ;
192207
208+ // Place label before or after children.
209+ const childrenFragment = labelPosition === 'before' ?
210+ { labelElement, children }
211+ :
212+ { children, labelElement } ;
213+ const enhancedButtonChildren = Children . create ( childrenFragment ) ;
214+
193215 return (
194216 < Paper
195217 style = { this . mergeStyles ( styles . root , this . props . style ) }
@@ -208,8 +230,7 @@ const RaisedButton = React.createClass({
208230 styles . overlay ,
209231 ( this . state . hovered && ! this . props . disabled ) && styles . overlayWhenHovered
210232 ) } >
211- { labelElement }
212- { this . props . children }
233+ { enhancedButtonChildren }
213234 </ div >
214235 </ EnhancedButton >
215236 </ Paper >
0 commit comments