Skip to content
This repository was archived by the owner on Mar 13, 2018. It is now read-only.

Commit f880291

Browse files
author
Scott J. Miles
committed
separate activeTheme and theme concepts from theme-aware controls, so that an inherited theme is not expressed as an attribute
1 parent f9f66ab commit f880291

4 files changed

Lines changed: 31 additions & 25 deletions

File tree

polymer-ui-icon/polymer-ui-icon.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,10 @@
136136
this.style.backgroundImage = 'url(' + this.src + ')';
137137
this.updateIcon();
138138
},
139-
themeChanged: function(old) {
139+
activeThemeChanged: function(old) {
140140
this.super(arguments);
141141
this.style.backgroundPosition = '';
142-
this.bx = calcThemeOffset(this.theme, this);
142+
this.bx = calcThemeOffset(this.activeTheme, this);
143143
this.updateIcon();
144144
},
145145
updateIcon: function() {

polymer-ui-menu/polymer-ui-menu.html

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,22 +57,23 @@
5757
<link rel="import" href="../../polymer-elements/polymer-selector/polymer-selector.html">
5858
<link rel="import" href="../polymer-ui-theme-aware/polymer-ui-theme-aware.html">
5959

60-
<polymer-element name="polymer-ui-menu" extends="polymer-selector"
61-
attributes="theme" on-polymer-select="selectionChange">
60+
<polymer-element name="polymer-ui-menu" extends="polymer-selector" attributes="theme" on-polymer-select="selectionChange">
6261
<template>
6362
<link rel="stylesheet" href="polymer-ui-menu.css">
6463
<shadow></shadow>
6564
</template>
6665
<script>
6766
Polymer('polymer-ui-menu', {
67+
activeTheme: '',
68+
validateTheme: PolymerUI.validateTheme,
6869
enteredView: function() {
69-
if (!this.theme) {
70-
this.findTheme();
71-
}
70+
this.validateTheme();
71+
},
72+
themeChanged: function() {
73+
this.activeTheme = this.theme;
7274
},
73-
findTheme: PolymerUI.findTheme,
74-
themeChanged: function(old) {
75-
this.classList.switch(old, this.theme);
75+
activeThemeChanged: function(old) {
76+
this.classList.switch(old, this.activeTheme);
7677
},
7778
selectionChange: function(e, detail) {
7879
if (detail.isSelected) {

polymer-ui-sidebar-menu/metadata.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
<polymer-ui-menu-item label="Favorites 3"></polymer-ui-menu-item>
1313
<polymer-ui-menu-item label="Favorites 4"></polymer-ui-menu-item>
1414
</polymer-ui-submenu-item>
15-
<polymer-ui-menu-item icon="settings" label="Explore">
15+
<polymer-ui-submenu-item icon="settings" label="Explore">
1616
<polymer-ui-menu-item label="Explore 1"></polymer-ui-menu-item>
1717
<polymer-ui-menu-item label="Explore 2"></polymer-ui-menu-item>
18-
</polymer-ui-menu-item>
18+
</polymer-ui-submenu-item>
1919
</polymer-ui-sidebar-menu>
2020
</template>
2121
<template id="imports">

polymer-ui-theme-aware/polymer-ui-theme-aware.html

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,30 @@
55
-->
66
<polymer-element name="polymer-ui-theme-aware" attributes="theme">
77
<script>
8-
PolymerUI = {
9-
findTheme: function() {
10-
var p = this, theme = null;
11-
while (p && !theme) {
12-
theme = p.getAttribute && p.getAttribute('theme');
13-
p = p.parentNode || p.host;
8+
PolymerUI = {
9+
validateTheme: function() {
10+
var theme = this.theme;
11+
if (!theme) {
12+
var p = this;
13+
while (p && !theme) {
14+
theme = p.getAttribute && p.getAttribute('theme');
15+
p = p.parentNode || p.host;
16+
}
1417
}
15-
this.theme = theme;
18+
this.activeTheme = this.theme || theme;
1619
}
1720
};
1821
Polymer('polymer-ui-theme-aware', {
22+
activeTheme: '',
23+
validateTheme: PolymerUI.validateTheme,
1924
enteredView: function() {
20-
if (!this.theme) {
21-
this.findTheme();
22-
}
25+
this.validateTheme();
26+
},
27+
themeChanged: function() {
28+
this.activeTheme = this.theme;
2329
},
24-
findTheme: PolymerUI.findTheme,
25-
themeChanged: function(old) {
26-
this.classList.switch(old, this.theme);
30+
activeThemeChanged: function(old) {
31+
this.classList.switch(old, this.activeTheme);
2732
}
2833
});
2934
</script>

0 commit comments

Comments
 (0)