-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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
Conversation
badge, | ||
} = state.muiTheme; | ||
|
||
const [ |
There was a problem hiding this comment.
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? 😆
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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];
😱
There was a problem hiding this comment.
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.
@newoga You're doing an awesome job. thanks a lot 👍 |
Thanks @alitaheri! |
Done:
|
Awesome job @newoga 👍 👍 All green here 😄 |
@@ -41,80 +93,40 @@ const Badge = React.createClass({ | |||
*/ | |||
style: React.PropTypes.object, | |||
}, | |||
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 👍
[Badge] Remove style-propable mixin
@newoga Thanks! |
No description provided.