From 94d8e4fa223a590600181570ac949572b4669ef0 Mon Sep 17 00:00:00 2001 From: Neil Gabbadon Date: Tue, 9 Feb 2016 04:55:20 -0500 Subject: [PATCH] Remove style-propable from SelectField --- src/SelectField/SelectField.jsx | 51 +++++++++++++++------------------ 1 file changed, 23 insertions(+), 28 deletions(-) diff --git a/src/SelectField/SelectField.jsx b/src/SelectField/SelectField.jsx index 182f7ab2beca22..a4efa188660837 100644 --- a/src/SelectField/SelectField.jsx +++ b/src/SelectField/SelectField.jsx @@ -1,10 +1,25 @@ import React from 'react'; -import StylePropable from '../mixins/style-propable'; import TextField from '../text-field'; import DropDownMenu from '../DropDownMenu'; import getMuiTheme from '../styles/getMuiTheme'; import ContextPure from '../mixins/context-pure'; +function getStyles(props) { + return { + label: { + paddingLeft: 0, + top: props.floatingLabelText ? 6 : -4, + }, + icon: { + right: 0, + top: props.floatingLabelText ? 22 : 14, + }, + hideDropDownUnderline: { + borderTop: 'none', + }, + }; +} + const SelectField = React.createClass({ propTypes: { @@ -123,13 +138,11 @@ const SelectField = React.createClass({ muiTheme: React.PropTypes.object, }, - //for passing default theme context to children childContextTypes: { muiTheme: React.PropTypes.object, }, mixins: [ - StylePropable, ContextPure, ], @@ -162,33 +175,13 @@ const SelectField = 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}); - }, - - getStyles() { - const {floatingLabelText} = this.props; - - return { - label: { - paddingLeft: 0, - top: floatingLabelText ? 6 : -4, - }, - icon: { - right: 0, - top: floatingLabelText ? 22 : 14, - }, - hideDropDownUnderline: { - borderTop: 'none', - }, - }; + this.setState({ + muiTheme: nextContext.muiTheme || this.state.muiTheme, + }); }, render() { - const styles = this.getStyles(); const { autoWidth, children, @@ -214,6 +207,8 @@ const SelectField = React.createClass({ ...other, } = this.props; + const styles = getStyles(this.props, this.state); + return (