Skip to content

Commit

Permalink
Merge pull request #3300 from oliviertassinari/eslint-prefer-const-2
Browse files Browse the repository at this point in the history
[eslint] Refactor some component to use const instead of let
  • Loading branch information
alitaheri committed Feb 12, 2016
2 parents 0e785fa + 2968034 commit 96e106b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 24 deletions.
16 changes: 10 additions & 6 deletions src/app-bar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ const AppBar = React.createClass({
},

render() {
let {
const {
title,
titleStyle,
iconStyleRight,
Expand Down Expand Up @@ -253,18 +253,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, {
iconStyle: Object.assign({}, styles.iconButtonIconStyle, iconElementLeft.props.iconStyle),
});
break;
}

menuElementLeft = (
<div style={prepareStyles(Object.assign({}, styles.iconButtonStyle))}>
{iconElementLeft}
{iconElementLeftNode}
</div>
);
} else {
Expand All @@ -288,24 +290,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

0 comments on commit 96e106b

Please sign in to comment.