@ucd-lib/theme-elements 0.0.1 → 0.0.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.
Files changed (49) hide show
  1. package/{ucd-theme-alert → brand/ucd-theme-alert}/ucd-theme-alert.js +0 -0
  2. package/{ucd-theme-alert → brand/ucd-theme-alert}/ucd-theme-alert.tpl.js +0 -0
  3. package/{ucd-theme-collapse → brand/ucd-theme-collapse}/ucd-theme-collapse.js +20 -21
  4. package/{ucd-theme-collapse → brand/ucd-theme-collapse}/ucd-theme-collapse.tpl.js +1 -1
  5. package/brand/ucd-theme-header/ucd-theme-header.js +268 -0
  6. package/brand/ucd-theme-header/ucd-theme-header.tpl.js +146 -0
  7. package/{ucd-theme-image-gallery → brand/ucd-theme-image-gallery}/ucd-theme-image-gallery.js +0 -0
  8. package/{ucd-theme-image-gallery → brand/ucd-theme-image-gallery}/ucd-theme-image-gallery.tpl.js +0 -0
  9. package/{ucd-theme-list-accordion → brand/ucd-theme-list-accordion}/ucd-theme-list-accordion.js +47 -44
  10. package/{ucd-theme-list-accordion → brand/ucd-theme-list-accordion}/ucd-theme-list-accordion.tpl.js +2 -2
  11. package/{ucd-theme-message-area → brand/ucd-theme-message-area}/ucd-theme-message-area.js +0 -0
  12. package/{ucd-theme-message-area → brand/ucd-theme-message-area}/ucd-theme-message-area.tpl.js +0 -0
  13. package/brand/ucd-theme-pagination/ucd-theme-pagination.js +284 -0
  14. package/brand/ucd-theme-pagination/ucd-theme-pagination.tpl.js +93 -0
  15. package/brand/ucd-theme-primary-nav/ucd-theme-primary-nav.js +589 -0
  16. package/brand/ucd-theme-primary-nav/ucd-theme-primary-nav.tpl.js +106 -0
  17. package/brand/ucd-theme-quick-links/ucd-theme-quick-links.js +269 -0
  18. package/brand/ucd-theme-quick-links/ucd-theme-quick-links.tpl.js +114 -0
  19. package/{ucd-theme-form-search/ucd-theme-form-search.js → brand/ucd-theme-search-form/ucd-theme-search-form.js} +14 -15
  20. package/{ucd-theme-form-search/ucd-theme-form-search.tpl.js → brand/ucd-theme-search-form/ucd-theme-search-form.tpl.js} +0 -0
  21. package/brand/ucd-theme-search-popup/ucd-theme-search-popup.js +91 -0
  22. package/{ucd-theme-header-search-popup/ucd-theme-header-search-popup.tpl.js → brand/ucd-theme-search-popup/ucd-theme-search-popup.tpl.js} +8 -1
  23. package/brand/ucd-theme-slim-select/ucd-theme-slim-select.js +58 -0
  24. package/brand/ucd-theme-slim-select/ucd-theme-slim-select.tpl.js +26 -0
  25. package/brand/ucd-theme-subnav/ucd-theme-subnav.js +196 -0
  26. package/brand/ucd-theme-subnav/ucd-theme-subnav.tpl.js +60 -0
  27. package/package.json +6 -4
  28. package/ucdlib/ucdlib-branding-bar/book.js +4 -0
  29. package/ucdlib/ucdlib-branding-bar/logo.js +67 -0
  30. package/ucdlib/ucdlib-branding-bar/ucdlib-branding-bar.js +101 -0
  31. package/ucdlib/ucdlib-branding-bar/ucdlib-branding-bar.tpl.js +102 -0
  32. package/ucdlib/ucdlib-icon/ucdlib-icon.js +138 -0
  33. package/ucdlib/ucdlib-icon/ucdlib-icon.tpl.js +22 -0
  34. package/ucdlib/ucdlib-icons/academic.js +154 -0
  35. package/ucdlib/ucdlib-icons/ucdlib-icons.js +78 -0
  36. package/ucdlib/ucdlib-icons/utils.js +29 -0
  37. package/ucdlib/ucdlib-iconset/ucdlib-iconset.js +170 -0
  38. package/ucdlib/ucdlib-pages/ucdlib-pages.js +150 -0
  39. package/utils/controllers/break-points.js +26 -0
  40. package/utils/controllers/index.js +11 -0
  41. package/utils/controllers/intersection-observer.js +58 -0
  42. package/utils/controllers/mutation-observer.js +52 -0
  43. package/utils/controllers/wait.js +43 -0
  44. package/utils/directives/motion-collapse.js +1 -1
  45. package/utils/mixins/index.js +8 -0
  46. package/utils/mixins/main-dom-element.js +23 -0
  47. package/utils/mixins/mixin.js +21 -0
  48. package/utils/mixins/nav-element.js +103 -0
  49. package/ucd-theme-header-search-popup/ucd-theme-header-search-popup.js +0 -40
@@ -0,0 +1,23 @@
1
+ /**
2
+ * @function MainDomElement
3
+ * @param {Class} superClass - LitElement or child class.
4
+ * @description set render context for lit element to main DOM instead of the
5
+ * default shadow root
6
+ *
7
+ * @returns {Class} LitElement updated createRenderRoot function.
8
+ */
9
+ const MainDomElement = (superClass) => class extends superClass {
10
+
11
+ /**
12
+ * @method createRenderRoot
13
+ * @description set the root element to render into
14
+ *
15
+ * @returns {LitElement}
16
+ */
17
+ createRenderRoot() {
18
+ return this;
19
+ }
20
+
21
+ };
22
+
23
+ export {MainDomElement};
@@ -0,0 +1,21 @@
1
+ /**
2
+ * From:
3
+ * https://stackoverflow.com/questions/41839198/applying-behaviors-with-js-mixins-in-polymer-2
4
+ **/
5
+ class MixinBuilder {
6
+ constructor(superclass) {
7
+ this.superclass = superclass;
8
+ }
9
+ with(...mixins) {
10
+ return mixins.reduce((c, mixin) => mixin(c), this.superclass);
11
+ }
12
+ }
13
+ const Mixin = (superclass) => new MixinBuilder(superclass);
14
+
15
+ // Set global if available
16
+ // Hummmm...
17
+ // if( typeof window !== 'undefined' ) {
18
+ // window.Mixin = Mixin;
19
+ // }
20
+
21
+ export default Mixin;
@@ -0,0 +1,103 @@
1
+ /**
2
+ * @function NavElement
3
+ * @param {Class} superClass - LitElement or child class.
4
+ * @description Adds utilities for navigation to a LitElement
5
+ *
6
+ * @returns {Class} LitElement with Nav utilities attached
7
+ */
8
+ const NavElement = (superClass) => class extends superClass {
9
+
10
+ constructor() {
11
+ super();
12
+ this.navItems = [];
13
+ this.maxDepth = 2;
14
+ }
15
+
16
+ /**
17
+ * @method parseChildren
18
+ * @description Creates a tree-like nav Array structure from element children
19
+ * @param {HTMLCollection} children - Element children (non-shadow)
20
+ * @returns {Array}
21
+ */
22
+ parseNavChildren( children=this.children ){
23
+ if ( !children ) return [];
24
+ children = Array.from(this.children);
25
+ let navItems = children.map((child) => this._makeNavItemTree(child)).filter(navItem => navItem.linkText);
26
+ return navItems;
27
+ }
28
+
29
+ /**
30
+ * @method _makeNavItemTree
31
+ * @private
32
+ * @description Extracts menu item data from DOM Element
33
+ * @param {Element} ele - Element
34
+ * @returns {Object} Formatted object describing the menu item and its children
35
+ */
36
+ _makeNavItemTree(ele){
37
+ let linkText, href, subItems = [], isOpen=false, inlineStyles={}, newTab=false;
38
+ if ( ele.tagName === 'LI' && ele.children.length > 0) ele = ele.children[0];
39
+
40
+ if ( ele.tagName === 'A' ) {
41
+ linkText = ele.innerText;
42
+ href = ele.href;
43
+ } else if ( ele.tagName === 'LI' ) {
44
+ linkText = ele.innerText;
45
+ } else if ( ele.tagName === 'OL' || ele.tagName === 'UL' ) {
46
+ linkText = ele.getAttribute('link-text');
47
+ href = ele.getAttribute('href');
48
+ isOpen = ele.hasAttribute('is-open');
49
+
50
+ for (const child of Array.from(ele.children)) {
51
+ let childItem = this._makeNavItemTree(child);
52
+ if ( childItem.linkText ) subItems.push(childItem);
53
+ }
54
+ }
55
+ if (ele.getAttribute('target') == '_blank') newTab = true;
56
+
57
+ if ( linkText ) linkText = linkText.trim();
58
+ return {linkText, href, subItems, isOpen, inlineStyles, newTab};
59
+ }
60
+
61
+ /**
62
+ * @method getNavItem
63
+ * @description Retrieves an item from the navItems array.
64
+ * @param {Array} location - Coordinates of the item in the 'navItems' array. i.e. [0, 1, 4].
65
+ * @returns {Object}
66
+ */
67
+ getNavItem(location){
68
+ let accessor = "this.navItems";
69
+ if ( location && location.length > 0) {
70
+ accessor += "[" + location.join("].subItems[") + "]";
71
+ }
72
+ return eval(accessor);
73
+ }
74
+
75
+ /**
76
+ * @method itemHasSubNav
77
+ * @description Utility function for determining if a menu has subitems
78
+ * @param {Object} navItem - A member of the navItems array.
79
+ * @returns {Boolean}
80
+ */
81
+ itemHasSubNav(navItem){
82
+ if ( navItem && navItem.subItems && navItem.subItems.length) return true;
83
+ return false;
84
+ }
85
+
86
+ /**
87
+ * @method clearMobileAnimationStyles
88
+ * @description Removes inline styles on a nav element (used for mobile transition animation)
89
+ * @param {Object} navItem - Member of the this.navItems array
90
+ */
91
+ clearItemInlineStyles(navItem){
92
+ if (
93
+ navItem &&
94
+ navItem.inlineStyles &&
95
+ Object.keys(navItem.inlineStyles).length > 0
96
+ ) {
97
+ navItem.inlineStyles = {};
98
+ this.requestUpdate();
99
+ }
100
+ }
101
+ };
102
+
103
+ export {NavElement};
@@ -1,40 +0,0 @@
1
- import { LitElement } from 'lit';
2
- import {render, styles} from "./ucd-theme-header-search-popup.tpl.js";
3
-
4
-
5
- export default class UcdThemeHeaderSearchPopup extends LitElement {
6
-
7
- static get properties() {
8
- return {
9
- buttonText: {type: String, attribute: "button-text"},
10
- opened: {type: Boolean}
11
- };
12
- }
13
-
14
- static get styles() {
15
- return styles();
16
- }
17
-
18
- constructor() {
19
- super();
20
- this.render = render.bind(this);
21
- this.buttonText = "Toggle Search";
22
- this.opened = false;
23
-
24
- }
25
-
26
- _onBtnClick(){
27
- this.opened = !this.opened;
28
- }
29
-
30
- open(){
31
- this.opened = true;
32
- }
33
-
34
- close(){
35
- this.opened = false;
36
- }
37
-
38
- }
39
-
40
- customElements.define('ucd-theme-header-search-popup', UcdThemeHeaderSearchPopup);