@ucd-lib/theme-elements 0.0.12 → 0.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/brand/ucd-theme-brand-textbox/ucd-theme-brand-textbox.js +16 -0
- package/brand/ucd-theme-brand-textbox/ucd-theme-brand-textbox.tpl.js +1 -1
- package/brand/ucd-theme-list-accordion/ucd-theme-list-accordion.tpl.js +3 -0
- package/package.json +1 -1
- package/ucdlib/ucdlib-icon/ucdlib-icon.js +19 -7
- package/ucdlib/ucdlib-iconset/ucdlib-iconset.js +23 -5
- package/ucdlib/ucdlib-sils-search-redirect/ucdlib-sils-search-redirect.tpl.js +3 -0
|
@@ -55,6 +55,22 @@ export default class UcdThemeBrandTextbox extends LitElement {
|
|
|
55
55
|
return out;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
/**
|
|
59
|
+
* @method _onSlotchange
|
|
60
|
+
* @param {Event} e
|
|
61
|
+
* @description fires when a slot value changes.
|
|
62
|
+
* assigns category-brand__background class so that slotted children are correct color
|
|
63
|
+
* @private
|
|
64
|
+
*/
|
|
65
|
+
_onSlotchange(e){
|
|
66
|
+
const childNodes = e.target.assignedNodes({flatten: true});
|
|
67
|
+
childNodes.forEach(child => {
|
|
68
|
+
if ( child.nodeType === Node.ELEMENT_NODE ){
|
|
69
|
+
child.classList.add('category-brand__background');
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
58
74
|
}
|
|
59
75
|
|
|
60
76
|
customElements.define('ucd-theme-brand-textbox', UcdThemeBrandTextbox);
|
package/package.json
CHANGED
|
@@ -44,17 +44,19 @@ export default class UcdlibIcon extends LitElement {
|
|
|
44
44
|
* @private
|
|
45
45
|
*/
|
|
46
46
|
disconnectedCallback() {
|
|
47
|
-
|
|
47
|
+
if ( this._setListener ){
|
|
48
|
+
window.removeEventListener('ucdlib-iconset-added', this._onAddedIconset);
|
|
49
|
+
}
|
|
48
50
|
super.disconnectedCallback();
|
|
49
51
|
}
|
|
50
52
|
|
|
51
53
|
/**
|
|
52
|
-
* @method
|
|
53
|
-
* @description Lit lifecyle method called
|
|
54
|
+
* @method willUpdate
|
|
55
|
+
* @description Lit lifecyle method called right before element updates
|
|
54
56
|
* @param {Map} props - Updated properties
|
|
55
57
|
* @private
|
|
56
58
|
*/
|
|
57
|
-
|
|
59
|
+
willUpdate(props){
|
|
58
60
|
if ( props.has('icon') || props.has('src') ){
|
|
59
61
|
if ( this.src ) {
|
|
60
62
|
this._updateIcon();
|
|
@@ -85,17 +87,27 @@ export default class UcdlibIcon extends LitElement {
|
|
|
85
87
|
_updateIcon(){
|
|
86
88
|
// using the icon attribute
|
|
87
89
|
if ( this._usesIconSet() ) {
|
|
90
|
+
|
|
91
|
+
// previously using the src attribute. remove it.
|
|
88
92
|
if ( this._img && this._img.parentNode ) this.renderRoot.removeChild(this._img);
|
|
89
93
|
|
|
94
|
+
// empty icon name, remove it
|
|
90
95
|
if ( this._iconName === '') {
|
|
91
96
|
if ( this._iconset ) this._iconset.removeIcon(this);
|
|
97
|
+
|
|
98
|
+
// check if iconset exists, add event listener if it doesn't
|
|
92
99
|
} else if ( this._iconsetName ){
|
|
93
100
|
this._iconset = this._getIconset();
|
|
94
|
-
if ( this._iconset ) {
|
|
101
|
+
if ( this._iconset && this._iconset.applyIcon ) {
|
|
95
102
|
this._iconset.applyIcon(this, this._iconName);
|
|
96
|
-
|
|
103
|
+
if ( this._setListener ){
|
|
104
|
+
window.removeEventListener('ucdlib-iconset-added', this._onAddedIconset);
|
|
105
|
+
this._setListener = false;
|
|
106
|
+
}
|
|
97
107
|
} else {
|
|
98
|
-
|
|
108
|
+
if ( !this._setListener ){
|
|
109
|
+
this._setListener = window.addEventListener('ucdlib-iconset-added', this._onAddedIconset);
|
|
110
|
+
}
|
|
99
111
|
}
|
|
100
112
|
}
|
|
101
113
|
|
|
@@ -10,6 +10,7 @@ import { MutationObserverController } from '../../utils/controllers';
|
|
|
10
10
|
* @property {String} name - Name of the icon set. Usage: <ucdlib-icon icon="{thisProperty}:{icon}"></ucdlib-icon>
|
|
11
11
|
* @property {Number} size - The size of an individual icon. Note that icons must be square.
|
|
12
12
|
* @property {String} label - Optional friendly label for iconset.
|
|
13
|
+
* @property {String} suppressWarnings - Suppress any "you're doing it wrong" console warnings
|
|
13
14
|
* @example
|
|
14
15
|
* <ucdlib-iconset name="arrows">
|
|
15
16
|
<svg>
|
|
@@ -28,6 +29,7 @@ export default class UcdlibIconset extends Mixin(LitElement)
|
|
|
28
29
|
name: {type: String},
|
|
29
30
|
size: {type: Number},
|
|
30
31
|
label: {type: String},
|
|
32
|
+
suppressWarnings: {type: Boolean, attribute: 'suppress-warnings'},
|
|
31
33
|
_iconMap: {type: Object, state: true}
|
|
32
34
|
};
|
|
33
35
|
}
|
|
@@ -40,7 +42,7 @@ export default class UcdlibIconset extends Mixin(LitElement)
|
|
|
40
42
|
this.label = "";
|
|
41
43
|
this.size = 24;
|
|
42
44
|
this._iconMap = {};
|
|
43
|
-
this.
|
|
45
|
+
this.suppressWarnings = false;
|
|
44
46
|
}
|
|
45
47
|
|
|
46
48
|
/**
|
|
@@ -51,12 +53,28 @@ export default class UcdlibIconset extends Mixin(LitElement)
|
|
|
51
53
|
*/
|
|
52
54
|
updated( props ){
|
|
53
55
|
if (props.has('name') && this.name ) {
|
|
54
|
-
this.
|
|
55
|
-
new CustomEvent('ucdlib-iconset-added', {bubbles: true, composed: true})
|
|
56
|
-
);
|
|
56
|
+
this.dispatchLoadEvent();
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
+
/**
|
|
61
|
+
* @method firstUpdated
|
|
62
|
+
* @description Lit lifecycle method when element is first updated
|
|
63
|
+
*/
|
|
64
|
+
firstUpdated(){
|
|
65
|
+
this.style.display = "none";
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* @method dispatchLoadEvent
|
|
70
|
+
* @description fires off a 'ucdlib-iconset-added' event so ucdlib-icon elements can re-render if applicable
|
|
71
|
+
*/
|
|
72
|
+
dispatchLoadEvent(){
|
|
73
|
+
this.dispatchEvent(
|
|
74
|
+
new CustomEvent('ucdlib-iconset-added', {bubbles: true, composed: true})
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
60
78
|
/**
|
|
61
79
|
* @method getIconNames
|
|
62
80
|
* @description Returns a list of icon names for this set
|
|
@@ -173,7 +191,7 @@ export default class UcdlibIconset extends Mixin(LitElement)
|
|
|
173
191
|
iconMap[icon.id] = icon;
|
|
174
192
|
});
|
|
175
193
|
|
|
176
|
-
if ( !Object.keys(iconMap).length ) {
|
|
194
|
+
if ( !Object.keys(iconMap).length && !this.suppressWarnings ) {
|
|
177
195
|
console.warn('No g elements with an id attribute found!.');
|
|
178
196
|
}
|
|
179
197
|
this._iconMap = iconMap;
|