@ucd-lib/theme-elements 1.2.3 → 1.2.5
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/package.json +1 -1
- package/ucdlib/ucdlib-branding-bar/ucdlib-branding-bar.js +6 -2
- package/ucdlib/ucdlib-branding-bar/ucdlib-branding-bar.tpl.js +4 -0
- package/ucdlib/ucdlib-header/ucdlib-header.js +1 -1
- package/ucdlib/ucdlib-primary-nav/ucdlib-primary-nav.js +9 -3
- package/ucdlib/ucdlib-primary-nav/ucdlib-primary-nav.tpl.js +10 -0
- package/utils/mixins/nav-element.js +4 -3
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LitElement, svg } from 'lit';
|
|
1
|
+
import { LitElement, html, svg } from 'lit';
|
|
2
2
|
import {render, styles} from "./ucdlib-branding-bar.tpl.js";
|
|
3
3
|
|
|
4
4
|
import {Mixin, NavElement} from "../../utils/mixins";
|
|
@@ -28,6 +28,7 @@ export default class UcdlibBrandingBar extends Mixin(LitElement)
|
|
|
28
28
|
static get properties() {
|
|
29
29
|
return {
|
|
30
30
|
figure: {type: String},
|
|
31
|
+
figureUrl: {type: String, attribute: "figure-url"},
|
|
31
32
|
siteName: {type: String, attribute: "site-name"},
|
|
32
33
|
slogan: {type: String},
|
|
33
34
|
siteUrl: {type: String, attribute: "site-url"},
|
|
@@ -62,7 +63,7 @@ export default class UcdlibBrandingBar extends Mixin(LitElement)
|
|
|
62
63
|
*/
|
|
63
64
|
willUpdate(props){
|
|
64
65
|
if ( props.has("figure") && props.get("figure") !== undefined ){
|
|
65
|
-
const allowedKeywords = ['book', 'logo'];
|
|
66
|
+
const allowedKeywords = ['book', 'logo', 'custom'];
|
|
66
67
|
if ( !allowedKeywords.includes(props.get('figure')) ){
|
|
67
68
|
console.warn(`${props.get('figure')} is not a recognized "figure" keyword.
|
|
68
69
|
Allowed values: ${JSON.stringify(allowedKeywords)}
|
|
@@ -79,6 +80,9 @@ export default class UcdlibBrandingBar extends Mixin(LitElement)
|
|
|
79
80
|
* @returns {TemplateResult}
|
|
80
81
|
*/
|
|
81
82
|
_renderFigure(){
|
|
83
|
+
if( this.figureUrl ) {
|
|
84
|
+
return html`<img src="${this.figureUrl}" />`;
|
|
85
|
+
}
|
|
82
86
|
if ( this.figure === 'logo') return logo;
|
|
83
87
|
if ( this.figure === 'book' ) return bookLogo;
|
|
84
88
|
return svg``;
|
|
@@ -41,6 +41,8 @@ export default class UcdlibPrimaryNav extends Mixin(LitElement)
|
|
|
41
41
|
navItems: {type: Array},
|
|
42
42
|
maxDepth: {type: Number, attribute: "max-depth"},
|
|
43
43
|
mobileWidth: {type: Number, attribute: "mobile-width"},
|
|
44
|
+
mobileOnly: {type: Boolean, attribute: "mobile-only"},
|
|
45
|
+
desktopOnly: {type: Boolean, attribute: "desktop-only"},
|
|
44
46
|
_megaIsOpen: {type: Boolean, state: true}
|
|
45
47
|
};
|
|
46
48
|
}
|
|
@@ -60,6 +62,8 @@ export default class UcdlibPrimaryNav extends Mixin(LitElement)
|
|
|
60
62
|
this.hoverDelay = 300;
|
|
61
63
|
this.animationDuration = 300;
|
|
62
64
|
this.mobileWidth = 755;
|
|
65
|
+
this.mobileOnly = false;
|
|
66
|
+
this.desktopOnly = false;
|
|
63
67
|
|
|
64
68
|
this._classPrefix = "primary-nav";
|
|
65
69
|
this._acceptedNavTypes = ['superfish', 'mega'];
|
|
@@ -364,9 +368,11 @@ export default class UcdlibPrimaryNav extends Mixin(LitElement)
|
|
|
364
368
|
_makeLiClassMap(navItem, depth=0){
|
|
365
369
|
let classes = {};
|
|
366
370
|
classes[`depth-${depth}`] = true;
|
|
367
|
-
if
|
|
368
|
-
if
|
|
369
|
-
if
|
|
371
|
+
if( navItem.isOpen ) classes['sf--hover'] = true;
|
|
372
|
+
if( navItem.isClosing ) classes.closing = true;
|
|
373
|
+
if( navItem.megaFocus ) classes['mega-focus'] = true;
|
|
374
|
+
if( navItem.mobileOnly ) classes['mobile-only'] = true;
|
|
375
|
+
if( navItem.desktopOnly ) classes['desktop-only'] = true;
|
|
370
376
|
return classes;
|
|
371
377
|
}
|
|
372
378
|
|
|
@@ -351,6 +351,16 @@ return html`
|
|
|
351
351
|
}
|
|
352
352
|
}
|
|
353
353
|
|
|
354
|
+
@media (max-width: ${this.mobileWidth - 1}px) {
|
|
355
|
+
.desktop-only {
|
|
356
|
+
display: none !important;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
@media (min-width: ${this.mobileWidth}px) {
|
|
360
|
+
.mobile-only {
|
|
361
|
+
display: none !important;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
354
364
|
|
|
355
365
|
</style>
|
|
356
366
|
<nav
|
|
@@ -34,7 +34,7 @@ const NavElement = (superClass) => class extends superClass {
|
|
|
34
34
|
* @returns {Object} Formatted object describing the menu item and its children
|
|
35
35
|
*/
|
|
36
36
|
_makeNavItemTree(ele){
|
|
37
|
-
let linkText, href, subItems = [], isOpen=false, inlineStyles={}, newTab=false;
|
|
37
|
+
let linkText, href, subItems = [], isOpen=false, inlineStyles={}, newTab=false, mobileOnly=false, desktopOnly=false;
|
|
38
38
|
if ( ele.tagName === 'LI' && ele.children.length > 0) ele = ele.children[0];
|
|
39
39
|
|
|
40
40
|
if ( ele.tagName === 'A' ) {
|
|
@@ -53,9 +53,10 @@ const NavElement = (superClass) => class extends superClass {
|
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
if (ele.getAttribute('target') == '_blank') newTab = true;
|
|
56
|
-
|
|
56
|
+
if ( ele.hasAttribute('mobile-only') ) mobileOnly = true;
|
|
57
|
+
if ( ele.hasAttribute('desktop-only') ) desktopOnly = true;
|
|
57
58
|
if ( linkText ) linkText = linkText.trim();
|
|
58
|
-
return {linkText, href, subItems, isOpen, inlineStyles, newTab};
|
|
59
|
+
return {linkText, href, subItems, isOpen, inlineStyles, newTab, mobileOnly, desktopOnly};
|
|
59
60
|
}
|
|
60
61
|
|
|
61
62
|
/**
|