feat(dialog themes): extended theme inheritance of dialogs#9762
Conversation
126a5d2 to
9f3b8fa
Compare
| @@ -0,0 +1,3 @@ | |||
| .container { | |||
| text-align: center; | |||
| } No newline at end of file | |||
There was a problem hiding this comment.
nit: No newline at end of file
There was a problem hiding this comment.
Do you mind explaining me the ideology behind this? 😓
There was a problem hiding this comment.
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.
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.
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.
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.
Indentation on this line should be 4, not 2. Also consider splitting this onto multiple lines.
| 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.
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.
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.$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.
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-themeit was meant to be watched,unless one-way binding (::) was applied.
Related to #9475
cc @ErinCoughlan, @ThomasBurleson, @topherfangio