-
Notifications
You must be signed in to change notification settings - Fork 3.4k
feat(dialog themes): extended theme inheritance of dialogs #9762
Conversation
126a5d2
to
9f3b8fa
Compare
@@ -0,0 +1,3 @@ | |||
.container { | |||
text-align: center; | |||
} |
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.
nit: No newline at end of file
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.
Do you mind explaining me the ideology behind this? 😓
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.
Github tells me when there isn't a new line with a nice red icon, so I was trying to make it happy.
}; | ||
|
||
button[0].click(); | ||
$rootScope.$apply(); |
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 shouldn't need an $apply
after the click, since clicking triggers angular event update.
Ditto in other places too.
|
||
setParsedTheme(getTheme()); | ||
|
||
var unwatch = scope.$watch(getTheme, function (theme) { |
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.
nit: no space after function (Everywhere... it's inconsistent with the rest of the files)
return ctrl.$setTheme(theme); | ||
} | ||
|
||
$q.when( (typeof theme === 'function') ? theme() : theme ) |
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.
angular.isFunction(value);
perhaps
el.on('$destroy', $rootScope.$watch(lookupThemeName, updateThemeClass) ); | ||
if (ctrl) { | ||
var watchTheme = | ||
alwaysWatchTheme || ctrl.$shouldWatch || $mdUtil.parseAttributeBoolean(el.attr('md-theme-watch')); |
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.
Indentation on this line should be 4, not 2. Also consider splitting this onto multiple lines.
@@ -758,7 +769,7 @@ describe('$mdTheming service', function() { | |||
describe('md-theme directive', function() { | |||
beforeEach(module('material.core')); | |||
|
|||
it('should observe and set mdTheme controller', inject(function($compile, $rootScope) { | |||
it('should watch and set mdTheme controller', inject(function($compile, $rootScope) { |
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.
Maybe move the inject part on a newline to help with readability and line length.
This is also inconsistent within this file.
9f3b8fa
to
23a08bb
Compare
Let's avoid nitpicks for spacing, indentation, etc. |
@EladBezalel - please squash commits and rebase. @EladBezalel - comments also need breaking change information. |
@ErinCoughlan please rereview |
); | ||
|
||
it('should accept $q promise as a theme', inject(function($compile, $rootScope, $q, $mdTheming) { | ||
$rootScope.promise = $mdTheming.defineTheme('red', { primary: 'red' }); |
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.
This will be slightly more obvious that it is a promise if you wrap it in one. Otherwise, I have to look at the definition of defineTheme to verify that this test is testing what it says to.
Ditto for the other "returns a promise" tests.
$rootScope.themey = 'red'; | ||
var el = $compile('<div md-theme="{{themey}}"><span md-themable></span></div>')($rootScope); | ||
$rootScope.$apply(); | ||
|
||
expect(el.children().hasClass('md-red-theme')).toBe(true); | ||
$rootScope.$apply('themey = "blue"'); | ||
expect(el.children().hasClass('md-blue-theme')).toBe(false); | ||
expect(el.children().hasClass('md-red-theme')).toBe(true); | ||
expect(el.children().hasClass('md-blue-theme')).toBe(true); |
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'm wondering if you want to make these classes more generic, perhaps using toContain('blue').
This test relies on the knowledge that md-theme attribute adds a class in this specific format. If you ever change the format, the test will fail, when I'm not sure it should.
@ThomasBurleson Apologies for the nitpicks. I mainly only commented when two functions in a row were formatted differently. I will try not to comment on them any more. @EladBezalel Done the review. In general, looks good to me with a few test improvements. If you rebase, I can run the presubmit and see if there are any unexpected changes I didn't notice. |
23a08bb
to
fd25c3c
Compare
- Dialogs now can also inherit promise/function defined themes and listen to the targetElement theme changes - Removed wrong tests, we now assume that if an interpolation is being used in `md-theme` it was meant to be watched, unless one-way binding (::) was applied. Related to #9475
fd25c3c
to
a65e080
Compare
md-theme
it was meant to be watched,unless one-way binding (::) was applied.
Related to #9475
cc @ErinCoughlan, @ThomasBurleson, @topherfangio