@ucd-lib/theme-elements 1.2.3 → 1.2.4

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ucd-lib/theme-elements",
3
- "version": "1.2.3",
3
+ "version": "1.2.4",
4
4
  "description": "Custom elements for the UCD brand theme",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -60,7 +60,7 @@ export default class UcdlibHeader extends LitElement {
60
60
  this.silenceWarnings = false;
61
61
  this.mobileWidth = 755;
62
62
  this.isDemo = false;
63
-
63
+
64
64
  this._transitioning = false;
65
65
  this._hasPrimaryNav = false;
66
66
  this._hasSearch = false;
@@ -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 ( navItem.isOpen ) classes['sf--hover'] = true;
368
- if ( navItem.isClosing ) classes.closing = true;
369
- if (navItem.megaFocus) classes['mega-focus'] = true;
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
  /**