@ucd-lib/theme-elements 0.0.4 → 0.0.8
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-header/ucd-theme-header.js +63 -6
- package/brand/ucd-theme-header/ucd-theme-header.tpl.js +55 -23
- package/brand/ucd-theme-pagination/ucd-theme-pagination.js +13 -6
- package/brand/ucd-theme-primary-nav/ucd-theme-primary-nav.js +19 -15
- package/brand/ucd-theme-quick-links/ucd-theme-quick-links.js +8 -7
- package/brand/ucd-theme-quick-links/ucd-theme-quick-links.tpl.js +1 -1
- package/brand/ucd-theme-search-form/ucd-theme-search-form.js +7 -1
- package/brand/ucd-theme-search-form/ucd-theme-search-form.tpl.js +8 -3
- package/brand/ucd-theme-search-popup/ucd-theme-search-popup.js +3 -3
- package/brand/ucd-theme-slim-select/ucd-theme-slim-select.js +15 -17
- package/brand/ucd-theme-subnav/ucd-theme-subnav.js +13 -10
- package/package.json +3 -3
- package/ucdlib/ucdlib-branding-bar/ucdlib-branding-bar.js +8 -3
- package/ucdlib/ucdlib-icon/ucdlib-icon.tpl.js +2 -0
- package/ucdlib/ucdlib-icons/sitefarm.js +108 -0
- package/ucdlib/ucdlib-icons/ucdlib-icons.js +1 -1
- package/ucdlib/ucdlib-icons/utils.js +2 -2
- package/ucdlib/ucdlib-iconset/ucdlib-iconset.js +5 -2
- package/ucdlib/ucdlib-pages/ucdlib-pages.js +4 -4
- package/utils/{break-points.js → controllers/break-points.js} +8 -9
- package/utils/controllers/index.js +11 -0
- package/utils/controllers/intersection-observer.js +53 -0
- package/utils/controllers/mutation-observer.js +47 -0
- package/utils/controllers/wait.js +42 -0
- package/utils/mixins/index.js +8 -0
- package/utils/{main-dom-element.js → mixins/main-dom-element.js} +0 -0
- package/utils/{mixin.js → mixins/mixin.js} +0 -0
- package/utils/{nav-element.js → mixins/nav-element.js} +1 -0
- package/utils/index.js +0 -14
- package/utils/mutation-observer.js +0 -51
- package/utils/wait.js +0 -65
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { LitElement } from 'lit';
|
|
2
2
|
import {render, styles} from "./ucd-theme-header.tpl.js";
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
IntersectionObserverController,
|
|
6
|
+
MutationObserverController,
|
|
7
|
+
WaitController } from '../../utils/controllers';
|
|
5
8
|
|
|
6
9
|
/**
|
|
7
10
|
* @class UcdThemeHeader
|
|
@@ -15,6 +18,7 @@ import { Mixin, MutationObserverElement, BreakPoints, Wait } from "../../utils/i
|
|
|
15
18
|
* @property {String} figureSrc - Site logo/icon to display next to site name
|
|
16
19
|
* @property {String} siteUrl - Url to use for links around site name and figure
|
|
17
20
|
* @property {Boolean} opened - Whether header is open in the mobile view
|
|
21
|
+
* @property {Boolean} preventFixed - Navbar will not be fixed to top of screen in desktop view
|
|
18
22
|
*
|
|
19
23
|
* @example
|
|
20
24
|
* <ucd-theme-header site-name="A UC Davis Website">
|
|
@@ -35,8 +39,7 @@ import { Mixin, MutationObserverElement, BreakPoints, Wait } from "../../utils/i
|
|
|
35
39
|
* </ucd-theme-header>
|
|
36
40
|
*
|
|
37
41
|
*/
|
|
38
|
-
export default class UcdThemeHeader extends
|
|
39
|
-
.with(MutationObserverElement, BreakPoints, Wait) {
|
|
42
|
+
export default class UcdThemeHeader extends LitElement {
|
|
40
43
|
|
|
41
44
|
static get properties() {
|
|
42
45
|
return {
|
|
@@ -45,11 +48,13 @@ export default class UcdThemeHeader extends Mixin(LitElement)
|
|
|
45
48
|
figureSrc: {type: String, attribute: "figure-src"},
|
|
46
49
|
siteUrl: {type: String, attribute: "site-url"},
|
|
47
50
|
opened: {type: Boolean},
|
|
51
|
+
preventFixed: {type: Boolean, attribute: "prevent-fixed"},
|
|
48
52
|
isDemo: {type: Boolean, attribute: "is-demo"},
|
|
49
53
|
_transitioning: {type: Boolean, state: true},
|
|
50
54
|
_hasSlottedBranding: {type: Boolean, state: true},
|
|
51
55
|
_hasQuickLinks: {type: Boolean, state: true},
|
|
52
|
-
_hasSearch: {type: Boolean, state: true}
|
|
56
|
+
_hasSearch: {type: Boolean, state: true},
|
|
57
|
+
_brandingBarInView: {type: Boolean, state: true}
|
|
53
58
|
};
|
|
54
59
|
}
|
|
55
60
|
|
|
@@ -61,6 +66,9 @@ export default class UcdThemeHeader extends Mixin(LitElement)
|
|
|
61
66
|
super();
|
|
62
67
|
this.render = render.bind(this);
|
|
63
68
|
|
|
69
|
+
this.mutationObserver = new MutationObserverController(this);
|
|
70
|
+
this.wait = new WaitController(this);
|
|
71
|
+
|
|
64
72
|
this.siteName = "";
|
|
65
73
|
this.siteUrl = "/";
|
|
66
74
|
this.slogan = "";
|
|
@@ -73,7 +81,38 @@ export default class UcdThemeHeader extends Mixin(LitElement)
|
|
|
73
81
|
this._hasQuickLinks = false;
|
|
74
82
|
this._hasSearch = false;
|
|
75
83
|
this._animationDuration = 500;
|
|
84
|
+
this._brandingBarInView = false;
|
|
85
|
+
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
connectedCallback(){
|
|
89
|
+
super.connectedCallback();
|
|
90
|
+
if ( !this.preventFixed ) {
|
|
91
|
+
this.intersectionObserver = new IntersectionObserverController(this, {}, "_onBrandingBarIntersection", false);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
76
94
|
|
|
95
|
+
firstUpdated(){
|
|
96
|
+
if ( !this.preventFixed ) {
|
|
97
|
+
let aboveNav = this.renderRoot.getElementById('branding-bar-container');
|
|
98
|
+
this.intersectionObserver.observer.observe(aboveNav);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
_onBrandingBarIntersection(entries){
|
|
103
|
+
let offSetValue = 0;
|
|
104
|
+
try {
|
|
105
|
+
offSetValue = this.renderRoot.getElementById('nav-bar').getBoundingClientRect().height;
|
|
106
|
+
} catch (error) {}
|
|
107
|
+
if ( offSetValue > 150 ) offSetValue = 0;
|
|
108
|
+
entries.forEach(entry => {
|
|
109
|
+
this._brandingBarInView = entry.isIntersecting;
|
|
110
|
+
if (this._brandingBarInView) {
|
|
111
|
+
this.style.marginBottom = '0px';
|
|
112
|
+
} else {
|
|
113
|
+
this.style.marginBottom = offSetValue + "px";
|
|
114
|
+
}
|
|
115
|
+
})
|
|
77
116
|
}
|
|
78
117
|
|
|
79
118
|
/**
|
|
@@ -86,7 +125,7 @@ export default class UcdThemeHeader extends Mixin(LitElement)
|
|
|
86
125
|
|
|
87
126
|
this.opened = true;
|
|
88
127
|
this._transitioning = true;
|
|
89
|
-
await this.
|
|
128
|
+
await this.wait.wait(this._animationDuration);
|
|
90
129
|
this._transitioning = false;
|
|
91
130
|
return true;
|
|
92
131
|
|
|
@@ -102,7 +141,7 @@ export default class UcdThemeHeader extends Mixin(LitElement)
|
|
|
102
141
|
|
|
103
142
|
this.opened = false;
|
|
104
143
|
this._transitioning = true;
|
|
105
|
-
await this.
|
|
144
|
+
await this.wait.wait(this._animationDuration);
|
|
106
145
|
this._transitioning = false;
|
|
107
146
|
return true;
|
|
108
147
|
|
|
@@ -149,6 +188,24 @@ export default class UcdThemeHeader extends Mixin(LitElement)
|
|
|
149
188
|
return classes;
|
|
150
189
|
}
|
|
151
190
|
|
|
191
|
+
/**
|
|
192
|
+
* @method _getHeaderClasses
|
|
193
|
+
* @description Get classes to be assigned to the header element
|
|
194
|
+
* @private
|
|
195
|
+
* @returns {Object}
|
|
196
|
+
*/
|
|
197
|
+
_getHeaderClasses(){
|
|
198
|
+
let classes = {
|
|
199
|
+
"l-header": true,
|
|
200
|
+
"header": true
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
classes['fixed-mobile'] = !this.preventFixed;
|
|
204
|
+
classes['fixed-desktop'] = !this.preventFixed && !this._brandingBarInView;
|
|
205
|
+
|
|
206
|
+
return classes;
|
|
207
|
+
}
|
|
208
|
+
|
|
152
209
|
/**
|
|
153
210
|
* @method _ucdLogo
|
|
154
211
|
* @description Returns URI-encoded svg string of UC Davis logo
|
|
@@ -23,6 +23,36 @@ export function styles() {
|
|
|
23
23
|
::slotted(ucdlib-branding-bar){
|
|
24
24
|
width: 100%;
|
|
25
25
|
}
|
|
26
|
+
|
|
27
|
+
@media (max-width: 991px) {
|
|
28
|
+
.fixed-mobile .mobile-bar {
|
|
29
|
+
position: fixed;
|
|
30
|
+
width: 100%;
|
|
31
|
+
z-index: 1000;
|
|
32
|
+
top: 0;
|
|
33
|
+
}
|
|
34
|
+
.fixed-mobile .off-canvas {
|
|
35
|
+
position: fixed;
|
|
36
|
+
overflow: auto;
|
|
37
|
+
z-index: 1000;
|
|
38
|
+
top: 55px;
|
|
39
|
+
}
|
|
40
|
+
.fixed-mobile .l-header__branding {
|
|
41
|
+
margin-top: 55px;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
@media (min-width: 992px) {
|
|
46
|
+
.fixed-desktop .l-navbar {
|
|
47
|
+
position: fixed;
|
|
48
|
+
z-index: 1000;
|
|
49
|
+
top: 0;
|
|
50
|
+
right: 0;
|
|
51
|
+
left: 0;
|
|
52
|
+
width: 100%;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
26
56
|
`;
|
|
27
57
|
|
|
28
58
|
return [
|
|
@@ -44,7 +74,7 @@ ${this.isDemo ? html`
|
|
|
44
74
|
.l-navbar { top: auto !important}
|
|
45
75
|
</style>
|
|
46
76
|
` : html``}
|
|
47
|
-
<header class
|
|
77
|
+
<header class=${classMap(this._getHeaderClasses())}>
|
|
48
78
|
<div class="mobile-bar">
|
|
49
79
|
<div class="mobile-bar__nav-toggle">
|
|
50
80
|
<button
|
|
@@ -64,32 +94,34 @@ ${this.isDemo ? html`
|
|
|
64
94
|
</div>
|
|
65
95
|
</div>
|
|
66
96
|
|
|
67
|
-
<div
|
|
68
|
-
|
|
69
|
-
<
|
|
70
|
-
<
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
</div>
|
|
74
|
-
<div class="l-header__branding">
|
|
75
|
-
${this._hasSlottedBranding ? html`
|
|
76
|
-
<slot name="branding-bar"></slot>
|
|
77
|
-
` : html`
|
|
78
|
-
<div class="site-branding">
|
|
79
|
-
<div class="site-branding__figure" ?hidden=${!this.figureSrc}>
|
|
80
|
-
<a href="${this.siteUrl}" class=""><img src=${this.figureSrc} class="site-logo" alt="Site Logo" /></a>
|
|
97
|
+
<div id="branding-bar-container">
|
|
98
|
+
<div class="header__bar">
|
|
99
|
+
<div class="header__university">
|
|
100
|
+
<a href="https://www.ucdavis.edu/">
|
|
101
|
+
<img class="ucd-logo" src='data:image/svg+xml;utf8,${this._ucdLogo()}'>
|
|
102
|
+
</a>
|
|
81
103
|
</div>
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
104
|
+
</div>
|
|
105
|
+
<div class="l-header__branding">
|
|
106
|
+
${this._hasSlottedBranding ? html`
|
|
107
|
+
<slot name="branding-bar"></slot>
|
|
108
|
+
` : html`
|
|
109
|
+
<div class="site-branding">
|
|
110
|
+
<div class="site-branding__figure" ?hidden=${!this.figureSrc}>
|
|
111
|
+
<a href="${this.siteUrl}" class=""><img src=${this.figureSrc} class="site-logo" alt="Site Logo" /></a>
|
|
112
|
+
</div>
|
|
113
|
+
<div class="site-branding__body">
|
|
114
|
+
<h1 class="site-branding__site-name" ?hidden=${!this.siteName}>
|
|
115
|
+
<a href=${this.siteUrl}>${this.siteName}</a>
|
|
116
|
+
</h1>
|
|
117
|
+
<div class="site-branding__slogan" ?hidden=${!this.slogan}>${this.slogan}</div>
|
|
118
|
+
</div>
|
|
87
119
|
</div>
|
|
88
|
-
|
|
89
|
-
|
|
120
|
+
`}
|
|
121
|
+
</div>
|
|
90
122
|
</div>
|
|
91
123
|
|
|
92
|
-
<div class="${classMap(this._getNavbarClasses())}">
|
|
124
|
+
<div class="${classMap(this._getNavbarClasses())}" id="nav-bar">
|
|
93
125
|
<div class="l-container--navigation off-canvas off-canvas--left">
|
|
94
126
|
<div class="off-canvas__container l-nav-horizontal">
|
|
95
127
|
${this._hasSearch ? html`
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { LitElement, html } from 'lit';
|
|
2
2
|
//import { Page } from 'puppeteer';
|
|
3
3
|
import {render, styles} from "./ucd-theme-pagination.tpl.js";
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
import { BreakPointsController } from '../../utils/controllers';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* @class UcdThemePagination
|
|
@@ -11,6 +12,7 @@ import { Mixin, BreakPoints } from "../../utils/index.js";
|
|
|
11
12
|
* - http://dev.webstyleguide.ucdavis.edu/redesign/?p=molecules-pagination
|
|
12
13
|
*
|
|
13
14
|
* @property {String} base-path - for anchor tag href
|
|
15
|
+
* @property {String} queryParams - Append query parameters if constructing an anchor tag
|
|
14
16
|
* @property {String} current-page - Page to show and highlight
|
|
15
17
|
* @property {String} max-pages - Max number of total pages
|
|
16
18
|
* @property {String} visible-link-count - How many page links to show
|
|
@@ -33,8 +35,7 @@ import { Mixin, BreakPoints } from "../../utils/index.js";
|
|
|
33
35
|
* </ucd-theme-pagination>
|
|
34
36
|
*
|
|
35
37
|
*/
|
|
36
|
-
export default class UcdThemePagination extends
|
|
37
|
-
.with(BreakPoints) {
|
|
38
|
+
export default class UcdThemePagination extends LitElement {
|
|
38
39
|
|
|
39
40
|
static get properties() {
|
|
40
41
|
return {
|
|
@@ -42,6 +43,10 @@ export default class UcdThemePagination extends Mixin(LitElement)
|
|
|
42
43
|
type: String,
|
|
43
44
|
attribute: 'base-path'
|
|
44
45
|
},
|
|
46
|
+
queryParams: {
|
|
47
|
+
type: String,
|
|
48
|
+
attribute: 'query-params'
|
|
49
|
+
},
|
|
45
50
|
useHash : {
|
|
46
51
|
type: Boolean,
|
|
47
52
|
attribute: 'use-hash'
|
|
@@ -89,11 +94,14 @@ export default class UcdThemePagination extends Mixin(LitElement)
|
|
|
89
94
|
constructor() {
|
|
90
95
|
super();
|
|
91
96
|
|
|
97
|
+
this.breakPoints = new BreakPointsController(this);
|
|
98
|
+
|
|
92
99
|
this._pages = [];
|
|
93
100
|
this.useHash = false;
|
|
94
101
|
this.disableLabel = false;
|
|
95
102
|
this.type = 'virtual';
|
|
96
103
|
this.basePath = '';
|
|
104
|
+
this.queryParams = '';
|
|
97
105
|
this.visibleLinkCount = 7;
|
|
98
106
|
this.currentPage = 1;
|
|
99
107
|
this.maxPages = 1;
|
|
@@ -101,8 +109,7 @@ export default class UcdThemePagination extends Mixin(LitElement)
|
|
|
101
109
|
this.xs_screen = false;
|
|
102
110
|
this.size = '';
|
|
103
111
|
|
|
104
|
-
this.screen_check = (window.innerWidth <= this.
|
|
105
|
-
console.log(this.screen_check);
|
|
112
|
+
this.screen_check = (window.innerWidth <= this.breakPoints.mobileBreakPoint) ? true : false;
|
|
106
113
|
|
|
107
114
|
this.render = render.bind(this);
|
|
108
115
|
}
|
|
@@ -190,7 +197,7 @@ export default class UcdThemePagination extends Mixin(LitElement)
|
|
|
190
197
|
</li>`;
|
|
191
198
|
}
|
|
192
199
|
|
|
193
|
-
let href = (this.useHash ? '#' : '') + (this.basePath || '/') + page;
|
|
200
|
+
let href = (this.useHash ? '#' : '') + (this.basePath || '/') + page + (this.queryParams ? '?' + this.queryParams : '');
|
|
194
201
|
return html`<li class="pager__item ${args.class || ''}">
|
|
195
202
|
${((this.currentPage == 1 && args.label == "Prev") || (this.currentPage == this.maxPages && args.label == "Next") ) ?
|
|
196
203
|
html` <a style="pointer-events: none; cursor: default; color:#999999; background:white;" href="${href}">${args.label || page}</a>`:
|
|
@@ -4,7 +4,8 @@ import { styleMap } from 'lit/directives/style-map.js';
|
|
|
4
4
|
import { classMap } from 'lit/directives/class-map.js';
|
|
5
5
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
6
6
|
|
|
7
|
-
import { Mixin,
|
|
7
|
+
import { Mixin, NavElement } from "../../utils/mixins";
|
|
8
|
+
import { MutationObserverController, BreakPointsController } from '../../utils/controllers';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* @class UcdThemePrimaryNav
|
|
@@ -33,7 +34,7 @@ import { Mixin, MutationObserverElement, BreakPoints, NavElement } from "../../u
|
|
|
33
34
|
* </ucd-theme-primary-nav>
|
|
34
35
|
*/
|
|
35
36
|
export default class UcdThemePrimaryNav extends Mixin(LitElement)
|
|
36
|
-
.with(NavElement
|
|
37
|
+
.with(NavElement) {
|
|
37
38
|
|
|
38
39
|
static get properties() {
|
|
39
40
|
return {
|
|
@@ -54,6 +55,9 @@ export default class UcdThemePrimaryNav extends Mixin(LitElement)
|
|
|
54
55
|
constructor() {
|
|
55
56
|
super();
|
|
56
57
|
this.render = render.bind(this);
|
|
58
|
+
this.mutationObserver = new MutationObserverController(this, {subtree: true, childList: true});
|
|
59
|
+
this.breakPoints = new BreakPointsController(this);
|
|
60
|
+
|
|
57
61
|
this.navType = "superfish";
|
|
58
62
|
this.styleModifiers = "";
|
|
59
63
|
this.hoverDelay = 300;
|
|
@@ -97,7 +101,7 @@ export default class UcdThemePrimaryNav extends Mixin(LitElement)
|
|
|
97
101
|
if ( !navItem ) return;
|
|
98
102
|
|
|
99
103
|
// Open on mobile
|
|
100
|
-
if ( this.isMobile() ) {
|
|
104
|
+
if ( this.breakPoints.isMobile() ) {
|
|
101
105
|
let nav = this.renderRoot.getElementById(`nav--${navLocation.join("-")}`);
|
|
102
106
|
if ( !nav ) return;
|
|
103
107
|
let ul = nav.querySelector('ul');
|
|
@@ -160,7 +164,7 @@ export default class UcdThemePrimaryNav extends Mixin(LitElement)
|
|
|
160
164
|
if ( !navItem ) return;
|
|
161
165
|
|
|
162
166
|
// close on mobile
|
|
163
|
-
if ( this.isMobile() ) {
|
|
167
|
+
if ( this.breakPoints.isMobile() ) {
|
|
164
168
|
let nav = this.renderRoot.getElementById(`nav--${navLocation.join("-")}`);
|
|
165
169
|
if ( !nav ) return;
|
|
166
170
|
let ul = nav.querySelector('ul');
|
|
@@ -263,7 +267,7 @@ export default class UcdThemePrimaryNav extends Mixin(LitElement)
|
|
|
263
267
|
/**
|
|
264
268
|
* @method _onChildListMutation
|
|
265
269
|
* @private
|
|
266
|
-
* @description Fires when light dom child list changes. Injected by
|
|
270
|
+
* @description Fires when light dom child list changes. Injected by MutationObserverController.
|
|
267
271
|
* Sets the 'navItems' property.
|
|
268
272
|
*/
|
|
269
273
|
_onChildListMutation(){
|
|
@@ -345,7 +349,7 @@ export default class UcdThemePrimaryNav extends Mixin(LitElement)
|
|
|
345
349
|
this.isMegaMenu() &&
|
|
346
350
|
depth > 0 &&
|
|
347
351
|
!this._megaIsOpen &&
|
|
348
|
-
this.isDesktop()
|
|
352
|
+
this.breakPoints.isDesktop()
|
|
349
353
|
) i = -1;
|
|
350
354
|
|
|
351
355
|
return i;
|
|
@@ -375,7 +379,7 @@ export default class UcdThemePrimaryNav extends Mixin(LitElement)
|
|
|
375
379
|
* @param {Array} navLocation - Array coordinates of corresponding nav item
|
|
376
380
|
*/
|
|
377
381
|
async _toggleMobileMenu(navLocation){
|
|
378
|
-
if ( this.isDesktop() ) return;
|
|
382
|
+
if ( this.breakPoints.isDesktop() ) return;
|
|
379
383
|
let navItem = this.getNavItem(navLocation);
|
|
380
384
|
if ( navItem.isOpen ) {
|
|
381
385
|
this.closeSubNav(navLocation);
|
|
@@ -391,7 +395,7 @@ export default class UcdThemePrimaryNav extends Mixin(LitElement)
|
|
|
391
395
|
*/
|
|
392
396
|
_onNavMouseenter(){
|
|
393
397
|
if (
|
|
394
|
-
this.isMobile() ||
|
|
398
|
+
this.breakPoints.isMobile() ||
|
|
395
399
|
!this.isMegaMenu() )
|
|
396
400
|
return;
|
|
397
401
|
|
|
@@ -408,7 +412,7 @@ export default class UcdThemePrimaryNav extends Mixin(LitElement)
|
|
|
408
412
|
*/
|
|
409
413
|
_onNavMouseleave(){
|
|
410
414
|
if (
|
|
411
|
-
this.isMobile() ||
|
|
415
|
+
this.breakPoints.isMobile() ||
|
|
412
416
|
!this.isMegaMenu() )
|
|
413
417
|
return;
|
|
414
418
|
|
|
@@ -426,7 +430,7 @@ export default class UcdThemePrimaryNav extends Mixin(LitElement)
|
|
|
426
430
|
*/
|
|
427
431
|
_onNavFocusin(){
|
|
428
432
|
if (
|
|
429
|
-
this.isMobile() ||
|
|
433
|
+
this.breakPoints.isMobile() ||
|
|
430
434
|
!this.isMegaMenu() )
|
|
431
435
|
return;
|
|
432
436
|
|
|
@@ -447,7 +451,7 @@ export default class UcdThemePrimaryNav extends Mixin(LitElement)
|
|
|
447
451
|
* @param {Event} e
|
|
448
452
|
*/
|
|
449
453
|
_onItemMouseenter(e){
|
|
450
|
-
if ( this.isMobile() ) return;
|
|
454
|
+
if ( this.breakPoints.isMobile() ) return;
|
|
451
455
|
this.openSubNav(e.target.key);
|
|
452
456
|
}
|
|
453
457
|
|
|
@@ -458,7 +462,7 @@ export default class UcdThemePrimaryNav extends Mixin(LitElement)
|
|
|
458
462
|
* @param {Event} e
|
|
459
463
|
*/
|
|
460
464
|
_onItemFocus(e){
|
|
461
|
-
if ( this.isMobile() ) return;
|
|
465
|
+
if ( this.breakPoints.isMobile() ) return;
|
|
462
466
|
const LI = e.target.parentElement.parentElement;
|
|
463
467
|
|
|
464
468
|
if (LI.hasnav) {
|
|
@@ -511,7 +515,7 @@ export default class UcdThemePrimaryNav extends Mixin(LitElement)
|
|
|
511
515
|
* @param {Event} e
|
|
512
516
|
*/
|
|
513
517
|
_onItemMouseleave(e){
|
|
514
|
-
if ( this.isMobile() || this.isMegaMenu() ) return;
|
|
518
|
+
if ( this.breakPoints.isMobile() || this.isMegaMenu() ) return;
|
|
515
519
|
this.closeSubNav(e.target.key);
|
|
516
520
|
}
|
|
517
521
|
|
|
@@ -521,7 +525,7 @@ export default class UcdThemePrimaryNav extends Mixin(LitElement)
|
|
|
521
525
|
* @description Attached to the top-level nav element. Closes subnav if it doesn't contain focused link.
|
|
522
526
|
*/
|
|
523
527
|
_onNavFocusout(){
|
|
524
|
-
if ( this.isMobile() ) return;
|
|
528
|
+
if ( this.breakPoints.isMobile() ) return;
|
|
525
529
|
if ( this.isMegaMenu() ) {
|
|
526
530
|
if ( this._megaTimeout ) clearTimeout(this._megaTimeout);
|
|
527
531
|
requestAnimationFrame(() => {
|
|
@@ -574,7 +578,7 @@ export default class UcdThemePrimaryNav extends Mixin(LitElement)
|
|
|
574
578
|
* @returns {Object} - Style map
|
|
575
579
|
*/
|
|
576
580
|
_getItemMobileStyles(location) {
|
|
577
|
-
if ( this.isDesktop() ) return {};
|
|
581
|
+
if ( this.breakPoints.isDesktop() ) return {};
|
|
578
582
|
let navItem = this.getNavItem(location);
|
|
579
583
|
if ( !navItem.inlineStyles ) return {};
|
|
580
584
|
return navItem.inlineStyles;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { LitElement, html } from 'lit';
|
|
2
2
|
import {render, styles} from "./ucd-theme-quick-links.tpl.js";
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { MutationObserverController, WaitController } from '../../utils/controllers';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* @class UcdThemeQuickLinks
|
|
@@ -17,8 +17,7 @@ import { Mixin, MutationObserverElement, BreakPoints, Wait } from "../../utils/i
|
|
|
17
17
|
* @property {Boolean} opened - Menu is open
|
|
18
18
|
* @property {Number} animationDuration - Length of animation when opening/closing menu
|
|
19
19
|
*/
|
|
20
|
-
export default class UcdThemeQuickLinks extends
|
|
21
|
-
.with(MutationObserverElement, BreakPoints, Wait) {
|
|
20
|
+
export default class UcdThemeQuickLinks extends LitElement {
|
|
22
21
|
|
|
23
22
|
static get properties() {
|
|
24
23
|
return {
|
|
@@ -40,6 +39,8 @@ export default class UcdThemeQuickLinks extends Mixin(LitElement)
|
|
|
40
39
|
constructor() {
|
|
41
40
|
super();
|
|
42
41
|
this.render = render.bind(this);
|
|
42
|
+
this.mutationObserver = new MutationObserverController(this);
|
|
43
|
+
this.wait = new WaitController(this);
|
|
43
44
|
|
|
44
45
|
this.title = "Quick Links";
|
|
45
46
|
this.styleModifiers = "";
|
|
@@ -67,7 +68,7 @@ export default class UcdThemeQuickLinks extends Mixin(LitElement)
|
|
|
67
68
|
this._openedHeight = this.renderRoot.getElementById('menu').scrollHeight + "px";
|
|
68
69
|
await this.updateComplete;
|
|
69
70
|
|
|
70
|
-
await this.
|
|
71
|
+
await this.wait.wait(this.animationDuration);
|
|
71
72
|
this._transitioning = false;
|
|
72
73
|
this.opened = true;
|
|
73
74
|
return true;
|
|
@@ -84,11 +85,11 @@ export default class UcdThemeQuickLinks extends Mixin(LitElement)
|
|
|
84
85
|
|
|
85
86
|
this._openedHeight = this.renderRoot.getElementById('menu').scrollHeight + "px";
|
|
86
87
|
await this.updateComplete;
|
|
87
|
-
await this.waitForFrames(2);
|
|
88
|
+
await this.wait.waitForFrames(2);
|
|
88
89
|
this._openedHeight = 0;
|
|
89
90
|
await this.updateComplete;
|
|
90
91
|
|
|
91
|
-
await this.
|
|
92
|
+
await this.wait.wait(this.animationDuration);
|
|
92
93
|
|
|
93
94
|
this._transitioning = false;
|
|
94
95
|
this.opened = false;
|
|
@@ -229,7 +230,7 @@ export default class UcdThemeQuickLinks extends Mixin(LitElement)
|
|
|
229
230
|
* @method _onChildListMutation
|
|
230
231
|
* @param {Array} mutationsList - List of mutation records
|
|
231
232
|
* @private
|
|
232
|
-
* @description Fires when light dom child list changes. Injected by
|
|
233
|
+
* @description Fires when light dom child list changes. Injected by MutationObserverController.
|
|
233
234
|
* Sets the '_links' property.
|
|
234
235
|
*/
|
|
235
236
|
_onChildListMutation(mutationsList){
|
|
@@ -84,7 +84,7 @@ return html`
|
|
|
84
84
|
aria-controls="quick-links"
|
|
85
85
|
aria-expanded="${this.opened}"
|
|
86
86
|
aria-label="Toggle ${this.title} Menu">
|
|
87
|
-
${this.title}<span class="submenu-toggle"><span class="submenu-toggle__icon">+</span></span>
|
|
87
|
+
${this.title}<span class="submenu-toggle ${this.opened ? 'submenu-toggle--open' : ''}"><span class="submenu-toggle__icon">+</span></span>
|
|
88
88
|
</button>
|
|
89
89
|
<nav
|
|
90
90
|
id="quick-links"
|
|
@@ -11,6 +11,8 @@ import {render, styles } from "./ucd-theme-search-form.tpl.js";
|
|
|
11
11
|
* @property {String} value - The search string
|
|
12
12
|
* @property {String} placeholder - The input placeholder
|
|
13
13
|
* @property {String} formAction - The action to be taken on form submit (optional)
|
|
14
|
+
* @property {String} formMethod - The http method used on submit (default=POST)
|
|
15
|
+
* @property {String} queryParam - The URL query parameter to use (default=searchterm)
|
|
14
16
|
*
|
|
15
17
|
* @example
|
|
16
18
|
* <ucd-theme-form-search form-action="/url/to/post/to"></ucd-theme-form-search>
|
|
@@ -23,9 +25,11 @@ export default class UcdThemeSearchForm extends LitElement {
|
|
|
23
25
|
value: {type: String},
|
|
24
26
|
placeholder: {type: String, attribute: "placeholder"},
|
|
25
27
|
formAction: {type: String, attribute: "form-action"},
|
|
28
|
+
formMethod: {type: String, attribute: "form-method"},
|
|
26
29
|
formClass: {type: String, attribute: "form-class"},
|
|
27
30
|
labelText: {type: String, attribute: "label-text"},
|
|
28
|
-
inputClass: {type: String, attribute: "input-class"}
|
|
31
|
+
inputClass: {type: String, attribute: "input-class"},
|
|
32
|
+
queryParam: {type: String, attribute: "query-param"}
|
|
29
33
|
};
|
|
30
34
|
}
|
|
31
35
|
|
|
@@ -37,11 +41,13 @@ export default class UcdThemeSearchForm extends LitElement {
|
|
|
37
41
|
super();
|
|
38
42
|
this.render = render.bind(this);
|
|
39
43
|
this.formAction = "";
|
|
44
|
+
this.formMethod = "POST";
|
|
40
45
|
this.formClass = "";
|
|
41
46
|
this.labelText = "Search";
|
|
42
47
|
this.placeholder = "Search...";
|
|
43
48
|
this.inputClass = "";
|
|
44
49
|
this.value = "";
|
|
50
|
+
this.queryParam = "searchterm";
|
|
45
51
|
}
|
|
46
52
|
|
|
47
53
|
/**
|
|
@@ -14,6 +14,10 @@ export function styles() {
|
|
|
14
14
|
[hidden] {
|
|
15
15
|
display: none !important;
|
|
16
16
|
}
|
|
17
|
+
.search-form__submit {
|
|
18
|
+
line-height: 1.9;
|
|
19
|
+
text-indent: .2em;
|
|
20
|
+
}
|
|
17
21
|
`;
|
|
18
22
|
return [
|
|
19
23
|
normalizeCss,
|
|
@@ -29,7 +33,7 @@ return html`
|
|
|
29
33
|
<form
|
|
30
34
|
@submit="${this._onSubmit}"
|
|
31
35
|
action="${this.formAction}"
|
|
32
|
-
method
|
|
36
|
+
method=${this.formMethod}
|
|
33
37
|
class="search-form ${this.formClass}">
|
|
34
38
|
|
|
35
39
|
<label for="search" class="u-hidden--visually">${this.labelText}</label>
|
|
@@ -38,10 +42,11 @@ return html`
|
|
|
38
42
|
placeholder="${this.placeholder}"
|
|
39
43
|
id="search"
|
|
40
44
|
class="search-form__input ${this.inputClass}"
|
|
41
|
-
name
|
|
45
|
+
name=${this.queryParam}
|
|
42
46
|
@input="${this._onInput}"
|
|
43
47
|
value="${this.value}">
|
|
44
|
-
<
|
|
48
|
+
<button type="submit" class="search-form__submit"> Submit
|
|
49
|
+
</button>
|
|
45
50
|
|
|
46
51
|
</form>
|
|
47
52
|
`;}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { LitElement } from 'lit';
|
|
2
2
|
import {render, styles} from "./ucd-theme-search-popup.tpl.js";
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { MutationObserverController } from '../../utils/controllers';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* @class UcdThemeSearchPopup
|
|
@@ -24,8 +24,7 @@ import { Mixin, MutationObserverElement } from "../../utils/index.js";
|
|
|
24
24
|
* <input placeholder="A custom search element">
|
|
25
25
|
* </ucd-theme-search-popup>
|
|
26
26
|
*/
|
|
27
|
-
export default class UcdThemeSearchPopup extends
|
|
28
|
-
.with(MutationObserverElement) {
|
|
27
|
+
export default class UcdThemeSearchPopup extends LitElement {
|
|
29
28
|
|
|
30
29
|
static get properties() {
|
|
31
30
|
return {
|
|
@@ -42,6 +41,7 @@ export default class UcdThemeSearchPopup extends Mixin(LitElement)
|
|
|
42
41
|
constructor() {
|
|
43
42
|
super();
|
|
44
43
|
this.render = render.bind(this);
|
|
44
|
+
this.mutationObserver = new MutationObserverController(this);
|
|
45
45
|
this.buttonText = "Toggle Search";
|
|
46
46
|
this.opened = false;
|
|
47
47
|
this._defaultForm = false;
|
|
@@ -3,7 +3,7 @@ import {render, styles} from "./ucd-theme-slim-select.tpl.js";
|
|
|
3
3
|
|
|
4
4
|
import SlimSelect from 'slim-select';
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { MutationObserverController } from '../../utils/controllers';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* @class UcdThemeSlimSelect
|
|
@@ -12,8 +12,7 @@ import { Mixin, MutationObserverElement } from "../../utils/index.js";
|
|
|
12
12
|
* Patternlab URL:
|
|
13
13
|
* - http://dev.webstyleguide.ucdavis.edu/redesign/?p=atoms-select-menu
|
|
14
14
|
*/
|
|
15
|
-
export default class UcdThemeSlimSelect extends
|
|
16
|
-
.with(MutationObserverElement) {
|
|
15
|
+
export default class UcdThemeSlimSelect extends LitElement {
|
|
17
16
|
|
|
18
17
|
static get properties() {
|
|
19
18
|
return {
|
|
@@ -28,28 +27,27 @@ export default class UcdThemeSlimSelect extends Mixin(LitElement)
|
|
|
28
27
|
constructor() {
|
|
29
28
|
super();
|
|
30
29
|
this.render = render.bind(this);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
*/
|
|
37
|
-
connectedCallback(){
|
|
38
|
-
super.connectedCallback();
|
|
39
|
-
this._childListObserver.disconnect();
|
|
40
|
-
this._childListObserver.observe(this, {subtree: true, childList: true, attributes: true, characterData: true});
|
|
30
|
+
this.mutationObserver = new MutationObserverController(
|
|
31
|
+
this,
|
|
32
|
+
{subtree: true, childList: true, attributes: true, characterData: true},
|
|
33
|
+
"_onLightDomMutation"
|
|
34
|
+
);
|
|
41
35
|
}
|
|
42
36
|
|
|
43
37
|
/**
|
|
44
|
-
* @method
|
|
38
|
+
* @method _onLightDomMutation
|
|
45
39
|
* @private
|
|
46
|
-
* @description Fires when light dom child list changes.
|
|
40
|
+
* @description Fires when light dom child list changes. Called by MutationObserverController.
|
|
47
41
|
*/
|
|
48
|
-
|
|
42
|
+
_onLightDomMutation(){
|
|
49
43
|
const children = Array.from(this.children);
|
|
50
44
|
if (children.length == 0 || children[0].tagName != "SELECT") return;
|
|
51
45
|
const select = children[0].cloneNode(true);
|
|
52
|
-
this.
|
|
46
|
+
if ( this.slimSelect ){
|
|
47
|
+
this.slimSelect.destroy();
|
|
48
|
+
this.renderRoot.querySelector('.ss-main').remove();
|
|
49
|
+
this.renderRoot.querySelector('select').remove();
|
|
50
|
+
}
|
|
53
51
|
this.renderRoot.appendChild(select);
|
|
54
52
|
|
|
55
53
|
this.slimSelect = new SlimSelect({
|