Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

feat(dialog themes): extended theme inheritance of dialogs #9762

Merged
merged 1 commit into from
Oct 27, 2016

Conversation

EladBezalel
Copy link
Member

  • 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

Note: rebased on #9475 until it would be merged in.

cc @ErinCoughlan, @ThomasBurleson, @topherfangio

@EladBezalel EladBezalel added the needs: review This PR is waiting on review from the team label Oct 5, 2016
@EladBezalel EladBezalel force-pushed the feat/dialog-theme-inheritance branch from 126a5d2 to 9f3b8fa Compare October 5, 2016 19:56
@@ -0,0 +1,3 @@
.container {
text-align: center;
}
Copy link
Contributor

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

Copy link
Member Author

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? 😓

Copy link
Contributor

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();
Copy link
Contributor

@ErinCoughlan ErinCoughlan Oct 6, 2016

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) {
Copy link
Contributor

@ErinCoughlan ErinCoughlan Oct 6, 2016

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 )
Copy link
Contributor

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'));
Copy link
Contributor

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) {
Copy link
Contributor

@ErinCoughlan ErinCoughlan Oct 6, 2016

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.

@ThomasBurleson
Copy link
Contributor

Let's avoid nitpicks for spacing, indentation, etc.
Readability and consistency are important.

@ThomasBurleson ThomasBurleson added needs: presubmit and removed needs: review This PR is waiting on review from the team labels Oct 9, 2016
@ThomasBurleson ThomasBurleson added this to the 1.1.2 milestone Oct 9, 2016
@ThomasBurleson
Copy link
Contributor

ThomasBurleson commented Oct 9, 2016

@EladBezalel - please squash commits and rebase.

@EladBezalel - comments also need breaking change information.

@ThomasBurleson ThomasBurleson added needs: rebase This PR needs to be rebased on the latest commits from master and conflicts need to be resolved in progress Mainly for in progress PRs, but may be used for issues that require multiple PRs labels Oct 9, 2016
@EladBezalel
Copy link
Member Author

@ErinCoughlan please rereview

);

it('should accept $q promise as a theme', inject(function($compile, $rootScope, $q, $mdTheming) {
$rootScope.promise = $mdTheming.defineTheme('red', { primary: 'red' });
Copy link
Contributor

@ErinCoughlan ErinCoughlan Oct 10, 2016

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);
Copy link
Contributor

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.

@ErinCoughlan
Copy link
Contributor

@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.

@EladBezalel EladBezalel force-pushed the feat/dialog-theme-inheritance branch from 23a08bb to fd25c3c Compare October 17, 2016 17:05
@EladBezalel EladBezalel added needs: presubmit and removed in progress Mainly for in progress PRs, but may be used for issues that require multiple PRs needs: rebase This PR needs to be rebased on the latest commits from master and conflicts need to be resolved labels Oct 17, 2016
- 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
@EladBezalel EladBezalel force-pushed the feat/dialog-theme-inheritance branch from fd25c3c to a65e080 Compare October 25, 2016 18:42
@jelbourn jelbourn merged commit b7ae33e into master Oct 27, 2016
@EladBezalel EladBezalel deleted the feat/dialog-theme-inheritance branch October 28, 2016 14:13
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants