diff --git a/src/buttons/flat-button-label.jsx b/src/buttons/flat-button-label.jsx index 3ace97c8790b65..43f8ec12f49a64 100644 --- a/src/buttons/flat-button-label.jsx +++ b/src/buttons/flat-button-label.jsx @@ -1,8 +1,21 @@ import React from 'react'; import ContextPure from '../mixins/context-pure'; -import StylePropable from '../mixins/style-propable'; import getMuiTheme from '../styles/getMuiTheme'; +function getStyles(props, state) { + const { + baseTheme, + } = state.muiTheme; + + return { + root: { + position: 'relative', + paddingLeft: baseTheme.spacing.desktopGutterLess, + paddingRight: baseTheme.spacing.desktopGutterLess, + }, + }; +} + const FlatButtonLabel = React.createClass({ propTypes: { @@ -18,14 +31,12 @@ const FlatButtonLabel = React.createClass({ muiTheme: React.PropTypes.object, }, - //for passing default theme context to children childContextTypes: { muiTheme: React.PropTypes.object, }, mixins: [ ContextPure, - StylePropable, ], statics: { @@ -48,11 +59,10 @@ const FlatButtonLabel = React.createClass({ }; }, - //to update theme inside state whenever a new theme is passed down - //from the parent / owner using context componentWillReceiveProps(nextProps, nextContext) { - let newMuiTheme = nextContext.muiTheme ? nextContext.muiTheme : this.state.muiTheme; - this.setState({muiTheme: newMuiTheme}); + this.setState({ + muiTheme: nextContext.muiTheme || nextContext.muiTheme, + }); }, render: function() { @@ -61,19 +71,16 @@ const FlatButtonLabel = React.createClass({ style, } = this.props; - const contextKeys = this.constructor.getRelevantContextKeys(this.state.muiTheme); + const { + prepareStyles, + } = this.state.muiTheme; - const mergedRootStyles = this.mergeStyles({ - position: 'relative', - paddingLeft: contextKeys.spacingDesktopGutterLess, - paddingRight: contextKeys.spacingDesktopGutterLess, - }, style); + const styles = getStyles(this.props, this.state); return ( - {label} + {label} ); }, - }); export default FlatButtonLabel;