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

[eslint] Refactor some component to use const instead of let #3300

Merged
merged 1 commit into from
Feb 12, 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
16 changes: 10 additions & 6 deletions src/app-bar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ const AppBar = React.createClass({
},

render() {
let {
const {
title,
titleStyle,
iconStyleRight,
Expand Down Expand Up @@ -254,18 +254,20 @@ const AppBar = React.createClass({
}

if (showMenuIconButton) {
let iconElementLeftNode = iconElementLeft;

if (iconElementLeft) {
switch (iconElementLeft.type.displayName) {
case 'IconButton':
iconElementLeft = React.cloneElement(iconElementLeft, {
iconElementLeftNode = React.cloneElement(iconElementLeft, {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the auto fixer be making this change?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay I see, I suppose you made some minor manual fixes along the way.

iconStyle: Object.assign({}, styles.iconButtonIconStyle, iconElementLeft.props.iconStyle),
});
break;
}

menuElementLeft = (
<div style={prepareStyles(Object.assign({}, styles.iconButtonStyle))}>
{iconElementLeft}
{iconElementLeftNode}
</div>
);
} else {
Expand All @@ -289,24 +291,26 @@ const AppBar = React.createClass({
}, iconStyleRight);

if (iconElementRight) {
let iconElementRightNode = iconElementRight;

switch (iconElementRight.type.displayName) {
case 'IconMenu':
case 'IconButton':
iconElementRight = React.cloneElement(iconElementRight, {
iconElementRightNode = React.cloneElement(iconElementRight, {
iconStyle: Object.assign({}, styles.iconButtonIconStyle, iconElementRight.props.iconStyle),
});
break;

case 'FlatButton':
iconElementRight = React.cloneElement(iconElementRight, {
iconElementRightNode = React.cloneElement(iconElementRight, {
style: Object.assign({}, styles.flatButton, iconElementRight.props.style),
});
break;
}

menuElementRight = (
<div style={prepareStyles(iconRightStyle)}>
{iconElementRight}
{iconElementRightNode}
</div>
);
} else if (iconClassNameRight) {
Expand Down
31 changes: 16 additions & 15 deletions src/before-after-wrapper.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ import getMuiTheme from './styles/getMuiTheme';
* and afterElement have a defined style position.
*/

const styles = {
box: {
boxSizing: 'border-box',
},
};

const BeforeAfterWrapper = React.createClass({

propTypes: {
Expand Down Expand Up @@ -86,7 +92,7 @@ const BeforeAfterWrapper = React.createClass({
},

render() {
let {
const {
beforeStyle,
afterStyle,
beforeElementType,
Expand All @@ -102,26 +108,21 @@ const BeforeAfterWrapper = React.createClass({
let beforeElement;
let afterElement;

beforeStyle = {
boxSizing: 'border-box',
};

afterStyle = {
boxSizing: 'border-box',
};

if (this.props.beforeStyle) beforeElement =
React.createElement(this.props.beforeElementType,
if (beforeStyle) {
beforeElement = React.createElement(this.props.beforeElementType,
{
style: prepareStyles(Object.assign(beforeStyle, this.props.beforeStyle)),
style: prepareStyles(Object.assign({}, styles.box, beforeStyle)),
key: '::before',
});
if (this.props.afterStyle) afterElement =
React.createElement(this.props.afterElementType,
}

if (afterStyle) {
afterElement = React.createElement(this.props.afterElementType,
{
style: prepareStyles(Object.assign(afterStyle, this.props.afterStyle)),
style: prepareStyles(Object.assign({}, styles.box, afterStyle)),
key: '::after',
});
}

let children = [beforeElement, this.props.children, afterElement];

Expand Down
7 changes: 4 additions & 3 deletions src/popover/popover.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ const Popover = React.createClass({
},

renderLayer() {
let {
const {
animated,
animation,
children,
Expand All @@ -202,10 +202,11 @@ const Popover = React.createClass({
} = this.props;

let Animation = animation || PopoverDefaultAnimation;
let styleRoot = style;

if (!Animation) {
Animation = Paper;
style = {
styleRoot = {
position: 'fixed',
};
if (!this.state.open) {
Expand All @@ -214,7 +215,7 @@ const Popover = React.createClass({
}

return (
<Animation {...other} style={style} open={this.state.open && !this.state.closing}>
<Animation {...other} style={styleRoot} open={this.state.open && !this.state.closing}>
{children}
</Animation>
);
Expand Down