Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Core] Remove dependency on utils/styles from components #3169

Merged
merged 1 commit into from
Feb 4, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions src/DropDownMenu/DropDownMenu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import ClearFix from '../clearfix';
import getMuiTheme from '../styles/getMuiTheme';
import Popover from '../popover/popover';
import PopoverAnimationFromTop from '../popover/popover-animation-from-top';
import {mergeStyles, prepareStyles} from '../utils/styles';

const DropDownMenu = React.createClass({

Expand Down Expand Up @@ -256,6 +255,10 @@ const DropDownMenu = React.createClass({
muiTheme,
} = this.state;

const {
prepareStyles,
} = muiTheme;

const styles = this.getStyles();

let displayValue = '';
Expand All @@ -282,14 +285,16 @@ const DropDownMenu = React.createClass({
{...other}
ref="root"
className={className}
style={prepareStyles(muiTheme, mergeStyles(styles.root, open && styles.rootWhenOpen, style))}
style={prepareStyles(Object.assign({}, styles.root, open && styles.rootWhenOpen, style))}
>
<ClearFix style={mergeStyles(styles.control)} onTouchTap={this._onControlTouchTap}>
<div style={prepareStyles(muiTheme, mergeStyles(styles.label, open && styles.labelWhenOpen, labelStyle))}>
<ClearFix style={styles.control} onTouchTap={this._onControlTouchTap}>
<div
style={prepareStyles(Object.assign({}, styles.label, open && styles.labelWhenOpen, labelStyle))}
>
{displayValue}
</div>
<DropDownArrow style={mergeStyles(styles.icon, iconStyle)}/>
<div style={prepareStyles(muiTheme, mergeStyles(styles.underline, underlineStyle))}/>
<DropDownArrow style={Object.assign({}, styles.icon, iconStyle)}/>
<div style={prepareStyles(Object.assign({}, styles.underline, underlineStyle))}/>
</ClearFix>
<Popover
anchorOrigin={{horizontal: 'left', vertical: 'top'}}
Expand Down
7 changes: 5 additions & 2 deletions src/Subheader/Subheader.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
import muiThemeable from './../muiThemeable';
import {mergeStyles, prepareStyles} from './../utils/styles';
import Typography from '../styles/typography';

const propTypes = {
Expand Down Expand Up @@ -39,6 +38,10 @@ let Subheader = (props) => {
...other,
} = props;

const {
prepareStyles,
} = muiTheme;

const styles = {
root: {
boxSizing: 'border-box',
Expand All @@ -52,7 +55,7 @@ let Subheader = (props) => {
};

return (
<div {...other} style={prepareStyles(muiTheme, mergeStyles(styles.root, style))}>
<div {...other} style={prepareStyles(Object.assign({}, styles.root, style))}>
{children}
</div>
);
Expand Down
4 changes: 2 additions & 2 deletions src/TextField/TextFieldHint.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
import Transitions from '../styles/transitions';
import {mergeStyles, prepareStyles} from '../utils/styles';

const propTypes = {
/**
Expand Down Expand Up @@ -38,6 +37,7 @@ const TextFieldHint = (props) => {
} = props;

const {
prepareStyles,
textField: {
hintColor,
},
Expand All @@ -54,7 +54,7 @@ const TextFieldHint = (props) => {
};

return (
<div style={prepareStyles(muiTheme, mergeStyles(styles.root, style))}>
<div style={prepareStyles(Object.assign({}, styles.root, style))}>
{text}
</div>
);
Expand Down
7 changes: 5 additions & 2 deletions src/TextField/TextFieldLabel.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
import Transitions from '../styles/transitions';
import {mergeStyles, prepareStyles} from '../utils/styles';

const propTypes = {
/**
Expand Down Expand Up @@ -79,10 +78,14 @@ const TextFieldLabel = (props) => {
},
};

const {
prepareStyles,
} = muiTheme;

return (
<label
className={className}
style={prepareStyles(muiTheme, mergeStyles(styles.root, style))}
style={prepareStyles(Object.assign({}, styles.root, style))}
htmlFor={htmlFor}
onTouchTap={onTouchTap}
>
Expand Down
16 changes: 8 additions & 8 deletions src/TextField/TextFieldUnderline.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
import Transitions from '../styles/transitions';
import {mergeStyles, prepareStyles} from '../utils/styles';

const propTypes = {
/**
Expand Down Expand Up @@ -72,6 +71,7 @@ const TextFieldUnderline = (props) => {
} = errorStyle;

const {
prepareStyles,
textField: {
borderColor,
disabledTextColor,
Expand Down Expand Up @@ -108,17 +108,17 @@ const TextFieldUnderline = (props) => {
},
};

let underline = mergeStyles(styles.root, style);
let focusedUnderline = mergeStyles(underline, styles.focus, focusStyle);
let underline = Object.assign({}, styles.root, style);
let focusedUnderline = Object.assign({}, underline, styles.focus, focusStyle);

if (disabled) underline = mergeStyles(underline, styles.disabled, disabledStyle);
if (focus) focusedUnderline = mergeStyles(focusedUnderline, {transform: 'scaleX(1)'});
if (error) focusedUnderline = mergeStyles(focusedUnderline, styles.error);
if (disabled) underline = Object.assign({}, underline, styles.disabled, disabledStyle);
if (focus) focusedUnderline = Object.assign({}, focusedUnderline, {transform: 'scaleX(1)'});
if (error) focusedUnderline = Object.assign({}, focusedUnderline, styles.error);

return (
<div>
<hr style={prepareStyles(muiTheme, underline)}/>
<hr style={prepareStyles(muiTheme, focusedUnderline)}/>
<hr style={prepareStyles(underline)}/>
<hr style={prepareStyles(focusedUnderline)}/>
</div>
);
};
Expand Down
7 changes: 5 additions & 2 deletions src/divider.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
import muiThemeable from './muiThemeable';
import {mergeStyles, prepareStyles} from './utils/styles';

const propTypes = {
/**
Expand Down Expand Up @@ -37,6 +36,10 @@ let Divider = (props) => {
...other,
} = props;

const {
prepareStyles,
} = muiTheme;

const styles = {
root: {
margin: 0,
Expand All @@ -49,7 +52,7 @@ let Divider = (props) => {
};

return (
<hr {...other} style={prepareStyles(muiTheme, mergeStyles(styles.root, style))} />
<hr {...other} style={prepareStyles(Object.assign({}, styles.root, style))} />
);
};

Expand Down
5 changes: 2 additions & 3 deletions src/flat-button.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import ContextPure from './mixins/context-pure';
import Transitions from './styles/transitions';
import Children from './utils/children';
import ColorManipulator from './utils/color-manipulator';
import {mergeStyles} from './utils/styles';
import Typography from './styles/typography';
import EnhancedButton from './enhanced-button';
import FlatButtonLabel from './buttons/flat-button-label';
Expand Down Expand Up @@ -258,7 +257,7 @@ const FlatButton = React.createClass({
const buttonBackgroundColor = backgroundColor || buttonColor;
const hovered = (this.state.hovered || this.state.isKeyboardFocused) && !disabled;

const mergedRootStyles = mergeStyles({
const mergedRootStyles = Object.assign({}, {
color: defaultTextColor,
transition: Transitions.easeOut(),
fontSize: Typography.fontStyleButtonFontSize,
Expand Down Expand Up @@ -297,7 +296,7 @@ const FlatButton = React.createClass({
}

const labelElement = label ? (
<FlatButtonLabel label={label} style={mergeStyles(labelStyleIcon, labelStyle)} />
<FlatButtonLabel label={label} style={Object.assign({}, labelStyleIcon, labelStyle)} />
) : undefined;

// Place label before or after children.
Expand Down
3 changes: 1 addition & 2 deletions src/lists/nested-list.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import {mergeStyles} from '../utils/styles';
import List from './list';

class NestedList extends React.Component {
Expand Down Expand Up @@ -35,7 +34,7 @@ class NestedList extends React.Component {
};

return (
<List style={mergeStyles(styles.root, style)}>
<List style={Object.assign({}, styles.root, style)}>
{
React.Children.map(children, (child) => {
return React.isValidElement(child) ? (
Expand Down