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

[Badge] Remove style-propable mixin #3185

Merged
merged 1 commit into from
Feb 5, 2016
Merged

Conversation

newoga
Copy link
Contributor

@newoga newoga commented Feb 5, 2016

No description provided.

badge,
} = state.muiTheme;

const [
Copy link
Member

Choose a reason for hiding this comment

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

You really like ternary monsters 😆 😆 what's wrong with let + if/else chain? 😆

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Haha! 😅 😅 That monster (I agree it's a monster) was an attempt to make the previous ternary simpler:

const badgeBackgroundColor = this.props.primary
  ? theme.primaryColor
  : this.props.secondary
    ? theme.secondaryColor
    : theme.color;

const badgeTextColor = this.props.primary
  ? theme.primaryTextColor
  : this.props.secondary
    ? theme.secondaryTextColor
    : theme.textColor;

I can switch it to use let + if/else even though lets make me sad 😁 Though I agree, ternarys beyond one level deep are too complicated.

Copy link
Member

Choose a reason for hiding this comment

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

Refering to the example @newoga quoted - Perfectly readable. I think it's just what you're used to. To me this is the perfect use case for nested ternaries. (But what do I know?! 😆 )

This on the other hand:

  const [
    badgeBackgroundColor,
    badgeTextColor,
  ] = primary ? [badge.primaryColor, badge.primaryTextColor] :
    secondary ? [badge.secondaryColor, badge.secondaryTextColor] :
    [badge.color, badge.textColor];

😱

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it's just what you're used to.

I agree, I suppose the standard if/else is probably easiest for most though.

@alitaheri
Copy link
Member

@newoga You're doing an awesome job. thanks a lot 👍

@newoga
Copy link
Contributor Author

newoga commented Feb 5, 2016

@newoga You're doing an awesome job. thanks a lot 👍

Thanks @alitaheri!

@newoga
Copy link
Contributor Author

newoga commented Feb 5, 2016

Done:

  1. Switch the setState to use nextContext.muiTheme || this.state.muiTheme.
  2. Simplified primary and secondary checks to if-else

@alitaheri
Copy link
Member

Awesome job @newoga 👍 👍

All green here 😄

@@ -41,80 +93,40 @@ const Badge = React.createClass({
*/
style: React.PropTypes.object,
},

Copy link
Member

Choose a reason for hiding this comment

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

Don't worry too much about this. The es6 class codmode add them automatically.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point! Thanks for reminding me. I'd say 80+% of the components I've switched so far are candidates/ready to be switched to classes using the codemod 👍

oliviertassinari added a commit that referenced this pull request Feb 5, 2016
[Badge] Remove style-propable mixin
@oliviertassinari oliviertassinari merged commit e73ff60 into mui:master Feb 5, 2016
@oliviertassinari
Copy link
Member

@newoga Thanks!

@newoga newoga deleted the #2852/badge branch February 6, 2016 23:25
@zannager zannager added the component: badge This is the name of the generic UI component, not the React module! label Mar 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: badge This is the name of the generic UI component, not the React module!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants