Skip to content

Commit

Permalink
Remove style-propable mixin from flat-button-label
Browse files Browse the repository at this point in the history
Signed-off-by: Neil Gabbadon <[email protected]>
  • Loading branch information
newoga committed Feb 5, 2016
1 parent 37ce0b8 commit 01e35f1
Showing 1 changed file with 22 additions and 15 deletions.
37 changes: 22 additions & 15 deletions src/buttons/flat-button-label.jsx
Original file line number Diff line number Diff line change
@@ -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: {
Expand All @@ -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: {
Expand All @@ -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() {
Expand All @@ -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 (
<span style={this.prepareStyles(mergedRootStyles)}>{label}</span>
<span style={prepareStyles(styles.root, style)}>{label}</span>
);
},

});

export default FlatButtonLabel;

0 comments on commit 01e35f1

Please sign in to comment.