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

Commit b8357dc

Browse files
bradrichjelbourn
authored andcommitted
fix(mdPanel): Panel and tooltip theming (#10031)
- Initialized theming through `$mdTheming` on the panel element and container after the panel is created. - Fixed the panel and tooltip theme Sass files to remove unthemed styles and complicated syntax. - Removed an unnecessary `$mdTheming` call from the tooltip directive. Fixes #10030
1 parent 342ee53 commit b8357dc

File tree

4 files changed

+42
-29
lines changed

4 files changed

+42
-29
lines changed

src/components/panel/panel-theme.scss

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
.md-panel {
2-
3-
background-color: '{{background-900-0.0}}';
4-
5-
&._md-panel-backdrop.md-THEME_NAME-theme {
6-
background-color: '{{background-900-1.0}}';
7-
}
8-
1+
._md-panel-backdrop.md-THEME_NAME-theme {
2+
background-color: '{{background-900-1.0}}';
93
}

src/components/panel/panel.js

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -453,15 +453,15 @@ angular
453453
* @returns {!MdPanelRef}
454454
*/
455455

456-
/**
457-
* @ngdoc method
458-
* @name MdPanelRef#updateAnimation
459-
* @description
460-
* Updates the animation configuration for a panel. You can use this to change
461-
* the panel's animation without having to re-create it.
462-
*
463-
* @param {!MdPanelAnimation} animation
464-
*/
456+
/**
457+
* @ngdoc method
458+
* @name MdPanelRef#updateAnimation
459+
* @description
460+
* Updates the animation configuration for a panel. You can use this to change
461+
* the panel's animation without having to re-create it.
462+
*
463+
* @param {!MdPanelAnimation} animation
464+
*/
465465

466466

467467
/*****************************************************************************
@@ -1108,6 +1108,9 @@ function MdPanelRef(config, $injector) {
11081108
/** @private @const {!angular.$mdUtil} */
11091109
this._$mdUtil = $injector.get('$mdUtil');
11101110

1111+
/** @private @const {!angular.$mdTheming} */
1112+
this._$mdTheming = $injector.get('$mdTheming');
1113+
11111114
/** @private @const {!angular.Scope} */
11121115
this._$rootScope = $injector.get('$rootScope');
11131116

@@ -1650,7 +1653,8 @@ MdPanelRef.prototype._createPanel = function() {
16501653

16511654

16521655
/**
1653-
* Adds the styles for the panel, such as positioning and z-index.
1656+
* Adds the styles for the panel, such as positioning and z-index. Also,
1657+
* themes the panel element and panel container using `$mdTheming`.
16541658
* @returns {!angular.$q.Promise<!MdPanelRef>}
16551659
* @private
16561660
*/
@@ -1661,9 +1665,13 @@ MdPanelRef.prototype._addStyles = function() {
16611665
self.panelEl.css('z-index', self.config['zIndex'] + 1);
16621666

16631667
var hideAndResolve = function() {
1668+
// Theme the element and container.
1669+
self._setTheming();
1670+
16641671
// Remove left: -9999px and add hidden class.
16651672
self.panelEl.css('left', '');
16661673
self.panelContainer.addClass(MD_PANEL_HIDDEN);
1674+
16671675
resolve(self);
16681676
};
16691677

@@ -1679,17 +1687,31 @@ MdPanelRef.prototype._addStyles = function() {
16791687
return; // Don't setup positioning.
16801688
}
16811689

1682-
// Wait for angular to finish processing the template, then position it
1683-
// correctly. This is necessary so that the panel will have a defined height
1684-
// and width.
1690+
// Wait for angular to finish processing the template
16851691
self._$rootScope['$$postDigest'](function() {
1692+
// Position it correctly. This is necessary so that the panel will have a
1693+
// defined height and width.
16861694
self._updatePosition(true);
1695+
1696+
// Theme the element and container.
1697+
self._setTheming();
1698+
16871699
resolve(self);
16881700
});
16891701
});
16901702
};
16911703

16921704

1705+
/**
1706+
* Sets the `$mdTheming` classes on the `panelContainer` and `panelEl`.
1707+
* @private
1708+
*/
1709+
MdPanelRef.prototype._setTheming = function() {
1710+
this._$mdTheming(this.panelEl);
1711+
this._$mdTheming(this.panelContainer);
1712+
};
1713+
1714+
16931715
/**
16941716
* Updates the position configuration of a panel
16951717
* @param {!MdPanelPosition} position
@@ -2210,6 +2232,7 @@ MdPanelRef.prototype.removeFromGroup = function(groupName) {
22102232
}
22112233
};
22122234

2235+
22132236
/**
22142237
* Possible default closeReasons for the close function.
22152238
* @enum {string}
@@ -2219,6 +2242,7 @@ MdPanelRef.closeReasons = {
22192242
ESCAPE: 'escapeToClose',
22202243
};
22212244

2245+
22222246
/*****************************************************************************
22232247
* MdPanelPosition *
22242248
*****************************************************************************/
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
.md-tooltip.md-THEME_NAME-theme {
1+
.md-panel.md-tooltip.md-THEME_NAME-theme {
22
color: '{{background-700-contrast}}';
3-
&.md-panel {
4-
background-color: '{{background-700}}';
5-
}
3+
background-color: '{{background-700}}';
64
}

src/components/tooltip/tooltip.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ angular
4646
* Defaults to bottom.
4747
*/
4848
function MdTooltipDirective($timeout, $window, $$rAF, $document, $interpolate,
49-
$mdUtil, $mdTheming, $mdPanel, $$mdTooltipRegistry) {
49+
$mdUtil, $mdPanel, $$mdTooltipRegistry) {
5050

5151
var ENTER_EVENTS = 'focus touchstart mouseenter';
5252
var LEAVE_EVENTS = 'blur touchcancel mouseleave';
@@ -81,9 +81,6 @@ function MdTooltipDirective($timeout, $window, $$rAF, $document, $interpolate,
8181
var origin, position, panelPosition, panelRef, autohide, showTimeout,
8282
elementFocusedOnWindowBlur = null;
8383

84-
// Initialize the theming of the tooltip.
85-
$mdTheming(element);
86-
8784
// Set defaults
8885
setDefaults();
8986

0 commit comments

Comments
 (0)