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

fix(button): apply color classes correctly. #195

Closed
wants to merge 1 commit into from

Conversation

devversion
Copy link
Member

Fixes #75. Closes #89

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Mar 17, 2016
@@ -48,6 +57,18 @@ export class MdButton {
TimerWrapper.setTimeout(() => { this.isMouseDown = false; }, 100);
}

_updateColor(newColor: string) {
if (this._color != null && this._color != '') {
this.renderer.setElementClass(this.elementRef.nativeElement, `md-${newColor}`, false);
Copy link
Member

Choose a reason for hiding this comment

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

Should be this._color in the template expression

Copy link
Member Author

Choose a reason for hiding this comment

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

Indeed - fixed it, thanks!

@devversion devversion force-pushed the fix/button-color-theme branch from 0659ebe to 2f337d1 Compare March 18, 2016 12:18

if (newColor != null && newColor != '') {
this.renderer.setElementClass(this.elementRef.nativeElement, `md-${newColor}`, true);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

There's a bit of repetition between lines 61-63 and lines 65-67. Can you refactor to share more code, like:

_updateColor(newColor: string): void {
   this._setElementColor(this._color, false);
   this._setElementColor(newColor, true);
   this._color = newColor;
}

_setElementColor(color: string, bool: boolean): void {
   if (color != null && color != '') {
      this.renderer.setElementClass(this.elementRef.nativeElement, `md-${color}`, bool);
   }
}

Copy link
Member Author

Choose a reason for hiding this comment

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

@kara Changed it as discussed. Thanks for the suggestion.

@devversion devversion force-pushed the fix/button-color-theme branch from 2f337d1 to 1b8b156 Compare March 18, 2016 17:08
@jelbourn
Copy link
Member

LGTM

@jelbourn jelbourn closed this in 62265cc Mar 18, 2016
@devversion devversion deleted the fix/button-color-theme branch March 18, 2016 17:20
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla: yes PR author has agreed to Google's Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

md-button attaches class "md-undefined" to host element when on color provided
4 participants