@ucd-lib/theme-elements 0.0.5 → 0.0.9
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 +50 -6
- package/brand/ucd-theme-pagination/ucd-theme-pagination.js +9 -2
- package/brand/ucd-theme-primary-nav/ucd-theme-primary-nav.js +3 -3
- package/brand/ucd-theme-quick-links/ucd-theme-quick-links.js +2 -3
- 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 +1 -1
- package/brand/ucd-theme-slim-select/ucd-theme-slim-select.js +10 -6
- package/brand/ucd-theme-subnav/ucd-theme-subnav.js +2 -3
- package/package.json +2 -2
- package/ucdlib/ucdlib-branding-bar/ucdlib-branding-bar.js +4 -5
- 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 +5 -4
- package/ucdlib/ucdlib-iconset/ucdlib-iconset.js +15 -1
- package/ucdlib/ucdlib-pages/ucdlib-pages.js +1 -1
- package/ucdlib/ucdlib-sils-search-redirect/ucdlib-sils-search-redirect.js +138 -0
- package/ucdlib/ucdlib-sils-search-redirect/ucdlib-sils-search-redirect.tpl.js +108 -0
- package/utils/controllers/break-points.js +2 -2
- package/utils/controllers/index.js +5 -0
- package/utils/controllers/intersection-observer.js +0 -5
- package/utils/controllers/mutation-observer.js +0 -5
- package/utils/controllers/popstate-observer.js +51 -0
- package/utils/controllers/sils-primo.js +124 -0
- package/utils/controllers/wait.js +0 -1
|
@@ -4,6 +4,7 @@ import {render, styles} from "./ucd-theme-header.tpl.js";
|
|
|
4
4
|
import {
|
|
5
5
|
IntersectionObserverController,
|
|
6
6
|
MutationObserverController,
|
|
7
|
+
PopStateObserverController,
|
|
7
8
|
WaitController } from '../../utils/controllers';
|
|
8
9
|
|
|
9
10
|
/**
|
|
@@ -40,9 +41,6 @@ import {
|
|
|
40
41
|
*
|
|
41
42
|
*/
|
|
42
43
|
export default class UcdThemeHeader extends LitElement {
|
|
43
|
-
|
|
44
|
-
mutationObserver = new MutationObserverController(this);
|
|
45
|
-
wait = new WaitController(this);
|
|
46
44
|
|
|
47
45
|
static get properties() {
|
|
48
46
|
return {
|
|
@@ -54,10 +52,12 @@ export default class UcdThemeHeader extends LitElement {
|
|
|
54
52
|
preventFixed: {type: Boolean, attribute: "prevent-fixed"},
|
|
55
53
|
isDemo: {type: Boolean, attribute: "is-demo"},
|
|
56
54
|
_transitioning: {type: Boolean, state: true},
|
|
55
|
+
_hasPrimaryNav: {type: Boolean, state: true},
|
|
57
56
|
_hasSlottedBranding: {type: Boolean, state: true},
|
|
58
57
|
_hasQuickLinks: {type: Boolean, state: true},
|
|
59
58
|
_hasSearch: {type: Boolean, state: true},
|
|
60
|
-
_brandingBarInView: {type: Boolean, state: true}
|
|
59
|
+
_brandingBarInView: {type: Boolean, state: true},
|
|
60
|
+
_components: {type: Object, state: true}
|
|
61
61
|
};
|
|
62
62
|
}
|
|
63
63
|
|
|
@@ -69,6 +69,10 @@ export default class UcdThemeHeader extends LitElement {
|
|
|
69
69
|
super();
|
|
70
70
|
this.render = render.bind(this);
|
|
71
71
|
|
|
72
|
+
this.mutationObserver = new MutationObserverController(this);
|
|
73
|
+
this.wait = new WaitController(this);
|
|
74
|
+
new PopStateObserverController(this, "_onLocationChange");
|
|
75
|
+
|
|
72
76
|
this.siteName = "";
|
|
73
77
|
this.siteUrl = "/";
|
|
74
78
|
this.slogan = "";
|
|
@@ -77,14 +81,21 @@ export default class UcdThemeHeader extends LitElement {
|
|
|
77
81
|
this.isDemo = false;
|
|
78
82
|
|
|
79
83
|
this._transitioning = false;
|
|
84
|
+
this._hasPrimaryNav = false;
|
|
80
85
|
this._hasSlottedBranding = false;
|
|
81
86
|
this._hasQuickLinks = false;
|
|
82
87
|
this._hasSearch = false;
|
|
83
88
|
this._animationDuration = 500;
|
|
84
89
|
this._brandingBarInView = false;
|
|
90
|
+
this._slottedComponents = {};
|
|
85
91
|
|
|
86
92
|
}
|
|
87
93
|
|
|
94
|
+
/**
|
|
95
|
+
* @method connectedCallback
|
|
96
|
+
* @private
|
|
97
|
+
* @description Custom element lifecycle method
|
|
98
|
+
*/
|
|
88
99
|
connectedCallback(){
|
|
89
100
|
super.connectedCallback();
|
|
90
101
|
if ( !this.preventFixed ) {
|
|
@@ -92,6 +103,11 @@ export default class UcdThemeHeader extends LitElement {
|
|
|
92
103
|
}
|
|
93
104
|
}
|
|
94
105
|
|
|
106
|
+
/**
|
|
107
|
+
* @method firstUpdated
|
|
108
|
+
* @private
|
|
109
|
+
* @description Lit lifecycle hook
|
|
110
|
+
*/
|
|
95
111
|
firstUpdated(){
|
|
96
112
|
if ( !this.preventFixed ) {
|
|
97
113
|
let aboveNav = this.renderRoot.getElementById('branding-bar-container');
|
|
@@ -99,11 +115,33 @@ export default class UcdThemeHeader extends LitElement {
|
|
|
99
115
|
}
|
|
100
116
|
}
|
|
101
117
|
|
|
118
|
+
/**
|
|
119
|
+
* @method _onLocationChange
|
|
120
|
+
* @description Called when url changes by popstate controller
|
|
121
|
+
*/
|
|
122
|
+
_onLocationChange(){
|
|
123
|
+
this.close();
|
|
124
|
+
if ( this._hasQuickLinks ){
|
|
125
|
+
this._slottedComponents.quickLinks.close();
|
|
126
|
+
}
|
|
127
|
+
if ( this._hasSearch ){
|
|
128
|
+
this._slottedComponents.search.close();
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* @method _onBrandingBarIntersection
|
|
134
|
+
* @private
|
|
135
|
+
* @description Called by intersection observer when branding bar enters/exits screen
|
|
136
|
+
* @param {*} entries
|
|
137
|
+
*/
|
|
102
138
|
_onBrandingBarIntersection(entries){
|
|
103
139
|
let offSetValue = 0;
|
|
104
140
|
try {
|
|
105
141
|
offSetValue = this.renderRoot.getElementById('nav-bar').getBoundingClientRect().height;
|
|
106
|
-
} catch (error) {
|
|
142
|
+
} catch (error) {
|
|
143
|
+
//
|
|
144
|
+
}
|
|
107
145
|
if ( offSetValue > 150 ) offSetValue = 0;
|
|
108
146
|
entries.forEach(entry => {
|
|
109
147
|
this._brandingBarInView = entry.isIntersecting;
|
|
@@ -112,7 +150,7 @@ export default class UcdThemeHeader extends LitElement {
|
|
|
112
150
|
} else {
|
|
113
151
|
this.style.marginBottom = offSetValue + "px";
|
|
114
152
|
}
|
|
115
|
-
})
|
|
153
|
+
});
|
|
116
154
|
}
|
|
117
155
|
|
|
118
156
|
/**
|
|
@@ -232,14 +270,18 @@ export default class UcdThemeHeader extends LitElement {
|
|
|
232
270
|
let primaryNav = this.querySelector('ucd-theme-primary-nav');
|
|
233
271
|
if ( primaryNav ) {
|
|
234
272
|
primaryNav.setAttribute('slot', 'primary-nav');
|
|
273
|
+
this._hasPrimaryNav = true;
|
|
274
|
+
this._slottedComponents.primaryNav = primaryNav;
|
|
235
275
|
} else {
|
|
236
276
|
console.warn("No 'ucd-theme-primary-nav' child element found!");
|
|
277
|
+
this._hasPrimaryNav = false;
|
|
237
278
|
}
|
|
238
279
|
|
|
239
280
|
let quickLinks = this.querySelector('ucd-theme-quick-links');
|
|
240
281
|
if ( quickLinks ) {
|
|
241
282
|
quickLinks.setAttribute('slot', 'quick-links');
|
|
242
283
|
this._hasQuickLinks = true;
|
|
284
|
+
this._slottedComponents.quickLinks = quickLinks;
|
|
243
285
|
} else {
|
|
244
286
|
this._hasQuickLinks = false;
|
|
245
287
|
}
|
|
@@ -248,6 +290,7 @@ export default class UcdThemeHeader extends LitElement {
|
|
|
248
290
|
if ( search ) {
|
|
249
291
|
search.setAttribute('slot', 'search');
|
|
250
292
|
this._hasSearch = true;
|
|
293
|
+
this._slottedComponents.search = search;
|
|
251
294
|
} else {
|
|
252
295
|
this._hasSearch = false;
|
|
253
296
|
}
|
|
@@ -256,6 +299,7 @@ export default class UcdThemeHeader extends LitElement {
|
|
|
256
299
|
if ( UcdlibBrandingBar ) {
|
|
257
300
|
UcdlibBrandingBar.setAttribute('slot', 'branding-bar');
|
|
258
301
|
this._hasSlottedBranding = true;
|
|
302
|
+
this._slottedComponents.brandingBar = UcdlibBrandingBar;
|
|
259
303
|
} else if ( this.querySelector("*[slot='branding-bar']") ){
|
|
260
304
|
this._hasSlottedBranding = true;
|
|
261
305
|
} else {
|
|
@@ -12,6 +12,7 @@ import { BreakPointsController } from '../../utils/controllers';
|
|
|
12
12
|
* - http://dev.webstyleguide.ucdavis.edu/redesign/?p=molecules-pagination
|
|
13
13
|
*
|
|
14
14
|
* @property {String} base-path - for anchor tag href
|
|
15
|
+
* @property {String} queryParams - Append query parameters if constructing an anchor tag
|
|
15
16
|
* @property {String} current-page - Page to show and highlight
|
|
16
17
|
* @property {String} max-pages - Max number of total pages
|
|
17
18
|
* @property {String} visible-link-count - How many page links to show
|
|
@@ -35,7 +36,6 @@ import { BreakPointsController } from '../../utils/controllers';
|
|
|
35
36
|
*
|
|
36
37
|
*/
|
|
37
38
|
export default class UcdThemePagination extends LitElement {
|
|
38
|
-
breakPoints = new BreakPointsController(this);
|
|
39
39
|
|
|
40
40
|
static get properties() {
|
|
41
41
|
return {
|
|
@@ -43,6 +43,10 @@ export default class UcdThemePagination extends LitElement {
|
|
|
43
43
|
type: String,
|
|
44
44
|
attribute: 'base-path'
|
|
45
45
|
},
|
|
46
|
+
queryParams: {
|
|
47
|
+
type: String,
|
|
48
|
+
attribute: 'query-params'
|
|
49
|
+
},
|
|
46
50
|
useHash : {
|
|
47
51
|
type: Boolean,
|
|
48
52
|
attribute: 'use-hash'
|
|
@@ -90,11 +94,14 @@ export default class UcdThemePagination extends LitElement {
|
|
|
90
94
|
constructor() {
|
|
91
95
|
super();
|
|
92
96
|
|
|
97
|
+
this.breakPoints = new BreakPointsController(this);
|
|
98
|
+
|
|
93
99
|
this._pages = [];
|
|
94
100
|
this.useHash = false;
|
|
95
101
|
this.disableLabel = false;
|
|
96
102
|
this.type = 'virtual';
|
|
97
103
|
this.basePath = '';
|
|
104
|
+
this.queryParams = '';
|
|
98
105
|
this.visibleLinkCount = 7;
|
|
99
106
|
this.currentPage = 1;
|
|
100
107
|
this.maxPages = 1;
|
|
@@ -190,7 +197,7 @@ export default class UcdThemePagination extends 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>`:
|
|
@@ -36,9 +36,6 @@ import { MutationObserverController, BreakPointsController } from '../../utils/c
|
|
|
36
36
|
export default class UcdThemePrimaryNav extends Mixin(LitElement)
|
|
37
37
|
.with(NavElement) {
|
|
38
38
|
|
|
39
|
-
mutationObserver = new MutationObserverController(this, {subtree: true, childList: true});
|
|
40
|
-
breakPoints = new BreakPointsController(this);
|
|
41
|
-
|
|
42
39
|
static get properties() {
|
|
43
40
|
return {
|
|
44
41
|
navType: {type: String, attribute: "nav-type"},
|
|
@@ -58,6 +55,9 @@ export default class UcdThemePrimaryNav extends Mixin(LitElement)
|
|
|
58
55
|
constructor() {
|
|
59
56
|
super();
|
|
60
57
|
this.render = render.bind(this);
|
|
58
|
+
this.mutationObserver = new MutationObserverController(this, {subtree: true, childList: true});
|
|
59
|
+
this.breakPoints = new BreakPointsController(this);
|
|
60
|
+
|
|
61
61
|
this.navType = "superfish";
|
|
62
62
|
this.styleModifiers = "";
|
|
63
63
|
this.hoverDelay = 300;
|
|
@@ -19,9 +19,6 @@ import { MutationObserverController, WaitController } from '../../utils/controll
|
|
|
19
19
|
*/
|
|
20
20
|
export default class UcdThemeQuickLinks extends LitElement {
|
|
21
21
|
|
|
22
|
-
mutationObserver = new MutationObserverController(this);
|
|
23
|
-
wait = new WaitController(this);
|
|
24
|
-
|
|
25
22
|
static get properties() {
|
|
26
23
|
return {
|
|
27
24
|
title: {type: String},
|
|
@@ -42,6 +39,8 @@ export default class UcdThemeQuickLinks extends LitElement {
|
|
|
42
39
|
constructor() {
|
|
43
40
|
super();
|
|
44
41
|
this.render = render.bind(this);
|
|
42
|
+
this.mutationObserver = new MutationObserverController(this);
|
|
43
|
+
this.wait = new WaitController(this);
|
|
45
44
|
|
|
46
45
|
this.title = "Quick Links";
|
|
47
46
|
this.styleModifiers = "";
|
|
@@ -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
|
`;}
|
|
@@ -25,7 +25,6 @@ import { MutationObserverController } from '../../utils/controllers';
|
|
|
25
25
|
* </ucd-theme-search-popup>
|
|
26
26
|
*/
|
|
27
27
|
export default class UcdThemeSearchPopup extends LitElement {
|
|
28
|
-
mutationObserver = new MutationObserverController(this);
|
|
29
28
|
|
|
30
29
|
static get properties() {
|
|
31
30
|
return {
|
|
@@ -42,6 +41,7 @@ export default class UcdThemeSearchPopup extends 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;
|
|
@@ -13,11 +13,6 @@ import { MutationObserverController } from '../../utils/controllers';
|
|
|
13
13
|
* - http://dev.webstyleguide.ucdavis.edu/redesign/?p=atoms-select-menu
|
|
14
14
|
*/
|
|
15
15
|
export default class UcdThemeSlimSelect extends LitElement {
|
|
16
|
-
mutationObserver = new MutationObserverController(
|
|
17
|
-
this,
|
|
18
|
-
{subtree: true, childList: true, attributes: true, characterData: true},
|
|
19
|
-
"_onLightDomMutation"
|
|
20
|
-
);
|
|
21
16
|
|
|
22
17
|
static get properties() {
|
|
23
18
|
return {
|
|
@@ -32,6 +27,11 @@ export default class UcdThemeSlimSelect extends LitElement {
|
|
|
32
27
|
constructor() {
|
|
33
28
|
super();
|
|
34
29
|
this.render = render.bind(this);
|
|
30
|
+
this.mutationObserver = new MutationObserverController(
|
|
31
|
+
this,
|
|
32
|
+
{subtree: true, childList: true, attributes: true, characterData: true},
|
|
33
|
+
"_onLightDomMutation"
|
|
34
|
+
);
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
/**
|
|
@@ -43,7 +43,11 @@ export default class UcdThemeSlimSelect extends LitElement {
|
|
|
43
43
|
const children = Array.from(this.children);
|
|
44
44
|
if (children.length == 0 || children[0].tagName != "SELECT") return;
|
|
45
45
|
const select = children[0].cloneNode(true);
|
|
46
|
-
this.
|
|
46
|
+
if ( this.slimSelect ){
|
|
47
|
+
this.slimSelect.destroy();
|
|
48
|
+
this.renderRoot.querySelector('.ss-main').remove();
|
|
49
|
+
this.renderRoot.querySelector('select').remove();
|
|
50
|
+
}
|
|
47
51
|
this.renderRoot.appendChild(select);
|
|
48
52
|
|
|
49
53
|
this.slimSelect = new SlimSelect({
|
|
@@ -31,9 +31,6 @@ import { MutationObserverController, WaitController } from '../../utils/controll
|
|
|
31
31
|
*/
|
|
32
32
|
export default class UcdThemeSubnav extends Mixin(LitElement)
|
|
33
33
|
.with(NavElement) {
|
|
34
|
-
|
|
35
|
-
mutationObserver = new MutationObserverController(this, {subtree: true, childList: true});
|
|
36
|
-
wait = new WaitController(this);
|
|
37
34
|
|
|
38
35
|
static get properties() {
|
|
39
36
|
return {
|
|
@@ -51,6 +48,8 @@ export default class UcdThemeSubnav extends Mixin(LitElement)
|
|
|
51
48
|
constructor() {
|
|
52
49
|
super();
|
|
53
50
|
this.render = render.bind(this);
|
|
51
|
+
this.mutationObserver = new MutationObserverController(this, {subtree: true, childList: true});
|
|
52
|
+
this.wait = new WaitController(this);
|
|
54
53
|
|
|
55
54
|
this.navTitle = "";
|
|
56
55
|
this.titleHref = "";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ucd-lib/theme-elements",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
4
4
|
"description": "Custom elements for the UCD brand theme",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"author": "jrmerz@ucdavis.edu",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@ucd-lib/theme-sass": "^5.0.
|
|
12
|
+
"@ucd-lib/theme-sass": "^5.0.15",
|
|
13
13
|
"lit": "^2.0.2",
|
|
14
14
|
"photoswipe": "^4.1.3",
|
|
15
15
|
"slim-select": "^1.26.2"
|
|
@@ -25,11 +25,6 @@ import bookLogo from "./book.js";
|
|
|
25
25
|
export default class UcdlibBrandingBar extends Mixin(LitElement)
|
|
26
26
|
.with(NavElement) {
|
|
27
27
|
|
|
28
|
-
mutationObserver = new MutationObserverController(
|
|
29
|
-
this,
|
|
30
|
-
{childList: true, characterData: true, attributes: true}
|
|
31
|
-
);
|
|
32
|
-
|
|
33
28
|
static get properties() {
|
|
34
29
|
return {
|
|
35
30
|
figure: {type: String},
|
|
@@ -47,6 +42,10 @@ export default class UcdlibBrandingBar extends Mixin(LitElement)
|
|
|
47
42
|
constructor() {
|
|
48
43
|
super();
|
|
49
44
|
this.render = render.bind(this);
|
|
45
|
+
this.mutationObserver = new MutationObserverController(
|
|
46
|
+
this,
|
|
47
|
+
{childList: true, characterData: true, attributes: true}
|
|
48
|
+
);
|
|
50
49
|
|
|
51
50
|
this.figure = "book";
|
|
52
51
|
this.siteName = "UC Davis Library";
|
|
@@ -9,6 +9,8 @@ export function styles() {
|
|
|
9
9
|
stroke: var(--ucdlib-icon-stroke-color, none);
|
|
10
10
|
width: var(--ucdlib-icon-width, 24px);
|
|
11
11
|
height: var(--ucdlib-icon-height, 24px);
|
|
12
|
+
min-width: var(--ucdlib-icon-width, 24px);
|
|
13
|
+
min-height: var(--ucdlib-icon-height, 24px);
|
|
12
14
|
}
|
|
13
15
|
`;
|
|
14
16
|
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { html } from "lit";
|
|
2
|
+
import { renderIconSet } from "@ucd-lib/theme-elements/ucdlib/ucdlib-icons/utils.js";
|
|
3
|
+
|
|
4
|
+
const template = html`
|
|
5
|
+
<!-- All icons prefixed with 'fa' by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (CC BY 4.0) -->
|
|
6
|
+
<svg><defs>
|
|
7
|
+
<g id="fa-chevron-right" viewBox="0 0 320 512">
|
|
8
|
+
<path d="M285.476 272.971L91.132 467.314c-9.373 9.373-24.569 9.373-33.941 0l-22.667-22.667c-9.357-9.357-9.375-24.522-.04-33.901L188.505 256 34.484 101.255c-9.335-9.379-9.317-24.544.04-33.901l22.667-22.667c9.373-9.373 24.569-9.373 33.941 0L285.475 239.03c9.373 9.372 9.373 24.568.001 33.941z"/>
|
|
9
|
+
</g>
|
|
10
|
+
<g id="fa-angle-double-right" viewBox="0 0 448 512">
|
|
11
|
+
<path d="M224.3 273l-136 136c-9.4 9.4-24.6 9.4-33.9 0l-22.6-22.6c-9.4-9.4-9.4-24.6 0-33.9l96.4-96.4-96.4-96.4c-9.4-9.4-9.4-24.6 0-33.9L54.3 103c9.4-9.4 24.6-9.4 33.9 0l136 136c9.5 9.4 9.5 24.6.1 34zm192-34l-136-136c-9.4-9.4-24.6-9.4-33.9 0l-22.6 22.6c-9.4 9.4-9.4 24.6 0 33.9l96.4 96.4-96.4 96.4c-9.4 9.4-9.4 24.6 0 33.9l22.6 22.6c9.4 9.4 24.6 9.4 33.9 0l136-136c9.4-9.2 9.4-24.4 0-33.8z"/>
|
|
12
|
+
</g>
|
|
13
|
+
<g id="fa-chevron-circle-right" viewBox="0 0 512 512">
|
|
14
|
+
<path d="M256 8c137 0 248 111 248 248S393 504 256 504 8 393 8 256 119 8 256 8zm113.9 231L234.4 103.5c-9.4-9.4-24.6-9.4-33.9 0l-17 17c-9.4 9.4-9.4 24.6 0 33.9L285.1 256 183.5 357.6c-9.4 9.4-9.4 24.6 0 33.9l17 17c9.4 9.4 24.6 9.4 33.9 0L369.9 273c9.4-9.4 9.4-24.6 0-34z"/>
|
|
15
|
+
</g>
|
|
16
|
+
<g id="fa-times" viewBox="0 0 352 512">
|
|
17
|
+
<path d="M242.72 256l100.07-100.07c12.28-12.28 12.28-32.19 0-44.48l-22.24-22.24c-12.28-12.28-32.19-12.28-44.48 0L176 189.28 75.93 89.21c-12.28-12.28-32.19-12.28-44.48 0L9.21 111.45c-12.28 12.28-12.28 32.19 0 44.48L109.28 256 9.21 356.07c-12.28 12.28-12.28 32.19 0 44.48l22.24 22.24c12.28 12.28 32.2 12.28 44.48 0L176 322.72l100.07 100.07c12.28 12.28 32.2 12.28 44.48 0l22.24-22.24c12.28-12.28 12.28-32.19 0-44.48L242.72 256z"/>
|
|
18
|
+
</g>
|
|
19
|
+
<g id="fa-chevron-down" viewBox="0 0 448 512">
|
|
20
|
+
<path d="M207.029 381.476L12.686 187.132c-9.373-9.373-9.373-24.569 0-33.941l22.667-22.667c9.357-9.357 24.522-9.375 33.901-.04L224 284.505l154.745-154.021c9.379-9.335 24.544-9.317 33.901.04l22.667 22.667c9.373 9.373 9.373 24.569 0 33.941L240.971 381.476c-9.373 9.372-24.569 9.372-33.942 0z"/>
|
|
21
|
+
</g>
|
|
22
|
+
<g id="fa-plus" viewBox="0 0 448 512">
|
|
23
|
+
<path d="M416 208H272V64c0-17.67-14.33-32-32-32h-32c-17.67 0-32 14.33-32 32v144H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h144v144c0 17.67 14.33 32 32 32h32c17.67 0 32-14.33 32-32V304h144c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z"/>
|
|
24
|
+
</g>
|
|
25
|
+
<g id="fa-calendar" viewBox="0 0 448 512">
|
|
26
|
+
<path d="M12 192h424c6.6 0 12 5.4 12 12v260c0 26.5-21.5 48-48 48H48c-26.5 0-48-21.5-48-48V204c0-6.6 5.4-12 12-12zm436-44v-36c0-26.5-21.5-48-48-48h-48V12c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v52H160V12c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v52H48C21.5 64 0 85.5 0 112v36c0 6.6 5.4 12 12 12h424c6.6 0 12-5.4 12-12z"/>
|
|
27
|
+
</g>
|
|
28
|
+
<g id="fa-map-marker-alt" viewBox="0 0 384 512">
|
|
29
|
+
<path d="M172.268 501.67C26.97 291.031 0 269.413 0 192 0 85.961 85.961 0 192 0s192 85.961 192 192c0 77.413-26.97 99.031-172.268 309.67-9.535 13.774-29.93 13.773-39.464 0zM192 272c44.183 0 80-35.817 80-80s-35.817-80-80-80-80 35.817-80 80 35.817 80 80 80z"/>
|
|
30
|
+
</g>
|
|
31
|
+
<g id="fa-phone-alt" viewBox="0 0 512 512">
|
|
32
|
+
<path d="M497.39 361.8l-112-48a24 24 0 0 0-28 6.9l-49.6 60.6A370.66 370.66 0 0 1 130.6 204.11l60.6-49.6a23.94 23.94 0 0 0 6.9-28l-48-112A24.16 24.16 0 0 0 122.6.61l-104 24A24 24 0 0 0 0 48c0 256.5 207.9 464 464 464a24 24 0 0 0 23.4-18.6l24-104a24.29 24.29 0 0 0-14.01-27.6z"/>
|
|
33
|
+
</g>
|
|
34
|
+
<g id="fa-envelope" viewBox="0 0 512 512">
|
|
35
|
+
<path d="M502.3 190.8c3.9-3.1 9.7-.2 9.7 4.7V400c0 26.5-21.5 48-48 48H48c-26.5 0-48-21.5-48-48V195.6c0-5 5.7-7.8 9.7-4.7 22.4 17.4 52.1 39.5 154.1 113.6 21.1 15.4 56.7 47.8 92.2 47.6 35.7.3 72-32.8 92.3-47.6 102-74.1 131.6-96.3 154-113.7zM256 320c23.2.4 56.6-29.2 73.4-41.4 132.7-96.3 142.8-104.7 173.4-128.7 5.8-4.5 9.2-11.5 9.2-18.9v-19c0-26.5-21.5-48-48-48H48C21.5 64 0 85.5 0 112v19c0 7.4 3.4 14.3 9.2 18.9 30.6 23.9 40.7 32.4 173.4 128.7 16.8 12.2 50.2 41.8 73.4 41.4z"/>
|
|
36
|
+
</g>
|
|
37
|
+
<g id="fa-network-wired" viewBox="0 0 640 512">
|
|
38
|
+
<path d="M640 264v-16c0-8.84-7.16-16-16-16H344v-40h72c17.67 0 32-14.33 32-32V32c0-17.67-14.33-32-32-32H224c-17.67 0-32 14.33-32 32v128c0 17.67 14.33 32 32 32h72v40H16c-8.84 0-16 7.16-16 16v16c0 8.84 7.16 16 16 16h104v40H64c-17.67 0-32 14.33-32 32v128c0 17.67 14.33 32 32 32h160c17.67 0 32-14.33 32-32V352c0-17.67-14.33-32-32-32h-56v-40h304v40h-56c-17.67 0-32 14.33-32 32v128c0 17.67 14.33 32 32 32h160c17.67 0 32-14.33 32-32V352c0-17.67-14.33-32-32-32h-56v-40h104c8.84 0 16-7.16 16-16zM256 128V64h128v64H256zm-64 320H96v-64h96v64zm352 0h-96v-64h96v64z"/>
|
|
39
|
+
</g>
|
|
40
|
+
<g id="fa-map" viewBox="0 0 576 512">
|
|
41
|
+
<path d="M0 117.66v346.32c0 11.32 11.43 19.06 21.94 14.86L160 416V32L20.12 87.95A32.006 32.006 0 0 0 0 117.66zM192 416l192 64V96L192 32v384zM554.06 33.16L416 96v384l139.88-55.95A31.996 31.996 0 0 0 576 394.34V48.02c0-11.32-11.43-19.06-21.94-14.86z"/>
|
|
42
|
+
</g>
|
|
43
|
+
<g id="fa-cloud-download-alt" viewBox="0 0 640 512">
|
|
44
|
+
<path d="M537.6 226.6c4.1-10.7 6.4-22.4 6.4-34.6 0-53-43-96-96-96-19.7 0-38.1 6-53.3 16.2C367 64.2 315.3 32 256 32c-88.4 0-160 71.6-160 160 0 2.7.1 5.4.2 8.1C40.2 219.8 0 273.2 0 336c0 79.5 64.5 144 144 144h368c70.7 0 128-57.3 128-128 0-61.9-44-113.6-102.4-125.4zm-132.9 88.7L299.3 420.7c-6.2 6.2-16.4 6.2-22.6 0L171.3 315.3c-10.1-10.1-2.9-27.3 11.3-27.3H248V176c0-8.8 7.2-16 16-16h48c8.8 0 16 7.2 16 16v112h65.4c14.2 0 21.4 17.2 11.3 27.3z"/>
|
|
45
|
+
</g>
|
|
46
|
+
<g id="fa-clock" viewBox="0 0 512 512">
|
|
47
|
+
<path d="M256,8C119,8,8,119,8,256S119,504,256,504,504,393,504,256,393,8,256,8Zm92.49,313h0l-20,25a16,16,0,0,1-22.49,2.5h0l-67-49.72a40,40,0,0,1-15-31.23V112a16,16,0,0,1,16-16h32a16,16,0,0,1,16,16V256l58,42.5A16,16,0,0,1,348.49,321Z"/>
|
|
48
|
+
</g>
|
|
49
|
+
<g id="fa-plus-circle" viewBox="0 0 512 512">
|
|
50
|
+
<path d="M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm144 276c0 6.6-5.4 12-12 12h-92v92c0 6.6-5.4 12-12 12h-56c-6.6 0-12-5.4-12-12v-92h-92c-6.6 0-12-5.4-12-12v-56c0-6.6 5.4-12 12-12h92v-92c0-6.6 5.4-12 12-12h56c6.6 0 12 5.4 12 12v92h92c6.6 0 12 5.4 12 12v56z"/>
|
|
51
|
+
</g>
|
|
52
|
+
<g id="fa-arrow-circle-right" viewBox="0 0 512 512">
|
|
53
|
+
<path d="M256 8c137 0 248 111 248 248S393 504 256 504 8 393 8 256 119 8 256 8zm-28.9 143.6l75.5 72.4H120c-13.3 0-24 10.7-24 24v16c0 13.3 10.7 24 24 24h182.6l-75.5 72.4c-9.7 9.3-9.9 24.8-.4 34.3l11 10.9c9.4 9.4 24.6 9.4 33.9 0L404.3 273c9.4-9.4 9.4-24.6 0-33.9L271.6 106.3c-9.4-9.4-24.6-9.4-33.9 0l-11 10.9c-9.5 9.6-9.3 25.1.4 34.4z"/>
|
|
54
|
+
</g>
|
|
55
|
+
<g id="fa-user-alt" viewBox="0 0 512 512">
|
|
56
|
+
<path d="M256 288c79.5 0 144-64.5 144-144S335.5 0 256 0 112 64.5 112 144s64.5 144 144 144zm128 32h-55.1c-22.2 10.2-46.9 16-72.9 16s-50.6-5.8-72.9-16H128C57.3 320 0 377.3 0 448v16c0 26.5 21.5 48 48 48h416c26.5 0 48-21.5 48-48v-16c0-70.7-57.3-128-128-128z"/>
|
|
57
|
+
</g>
|
|
58
|
+
<g id="fa-check-circle" viewBox="0 0 512 512">
|
|
59
|
+
<path d="M504 256c0 136.967-111.033 248-248 248S8 392.967 8 256 119.033 8 256 8s248 111.033 248 248zM227.314 387.314l184-184c6.248-6.248 6.248-16.379 0-22.627l-22.627-22.627c-6.248-6.249-16.379-6.249-22.628 0L216 308.118l-70.059-70.059c-6.248-6.248-16.379-6.248-22.628 0l-22.627 22.627c-6.248 6.248-6.248 16.379 0 22.627l104 104c6.249 6.249 16.379 6.249 22.628.001z"/>
|
|
60
|
+
</g>
|
|
61
|
+
<g id="fa-gift" viewBox="0 0 512 512">
|
|
62
|
+
<path d="M32 448c0 17.7 14.3 32 32 32h160V320H32v128zm256 32h160c17.7 0 32-14.3 32-32V320H288v160zm192-320h-42.1c6.2-12.1 10.1-25.5 10.1-40 0-48.5-39.5-88-88-88-41.6 0-68.5 21.3-103 68.3-34.5-47-61.4-68.3-103-68.3-48.5 0-88 39.5-88 88 0 14.5 3.8 27.9 10.1 40H32c-17.7 0-32 14.3-32 32v80c0 8.8 7.2 16 16 16h480c8.8 0 16-7.2 16-16v-80c0-17.7-14.3-32-32-32zm-326.1 0c-22.1 0-40-17.9-40-40s17.9-40 40-40c19.9 0 34.6 3.3 86.1 80h-86.1zm206.1 0h-86.1c51.4-76.5 65.7-80 86.1-80 22.1 0 40 17.9 40 40s-17.9 40-40 40z"/>
|
|
63
|
+
</g>
|
|
64
|
+
<g id="fa-chevron-left" viewBox="0 0 320 512">
|
|
65
|
+
<path d="M34.52 239.03L228.87 44.69c9.37-9.37 24.57-9.37 33.94 0l22.67 22.67c9.36 9.36 9.37 24.52.04 33.9L131.49 256l154.02 154.75c9.34 9.38 9.32 24.54-.04 33.9l-22.67 22.67c-9.37 9.37-24.57 9.37-33.94 0L34.52 272.97c-9.37-9.37-9.37-24.57 0-33.94z"/>
|
|
66
|
+
</g>
|
|
67
|
+
<g id="fa-long-arrow-alt-left" viewBox="0 0 448 512">
|
|
68
|
+
<path d="M134.059 296H436c6.627 0 12-5.373 12-12v-56c0-6.627-5.373-12-12-12H134.059v-46.059c0-21.382-25.851-32.09-40.971-16.971L7.029 239.029c-9.373 9.373-9.373 24.569 0 33.941l86.059 86.059c15.119 15.119 40.971 4.411 40.971-16.971V296z"/>
|
|
69
|
+
</g>
|
|
70
|
+
<g id="fa-long-arrow-alt-right" viewBox="0 0 448 512">
|
|
71
|
+
<path d="M313.941 216H12c-6.627 0-12 5.373-12 12v56c0 6.627 5.373 12 12 12h301.941v46.059c0 21.382 25.851 32.09 40.971 16.971l86.059-86.059c9.373-9.373 9.373-24.569 0-33.941l-86.059-86.059c-15.119-15.119-40.971-4.411-40.971 16.971V216z"/>
|
|
72
|
+
</g>
|
|
73
|
+
<g id="fa-flask" viewBox="0 0 448 512">
|
|
74
|
+
<path d="M437.2 403.5L320 215V64h8c13.3 0 24-10.7 24-24V24c0-13.3-10.7-24-24-24H120c-13.3 0-24 10.7-24 24v16c0 13.3 10.7 24 24 24h8v151L10.8 403.5C-18.5 450.6 15.3 512 70.9 512h306.2c55.7 0 89.4-61.5 60.1-108.5zM137.9 320l48.2-77.6c3.7-5.2 5.8-11.6 5.8-18.4V64h64v160c0 6.9 2.2 13.2 5.8 18.4l48.2 77.6h-172z"/>
|
|
75
|
+
</g>
|
|
76
|
+
<g id="fa-bullhorn" viewBox="0 0 576 512">
|
|
77
|
+
<path d="M576 240c0-23.63-12.95-44.04-32-55.12V32.01C544 23.26 537.02 0 512 0c-7.12 0-14.19 2.38-19.98 7.02l-85.03 68.03C364.28 109.19 310.66 128 256 128H64c-35.35 0-64 28.65-64 64v96c0 35.35 28.65 64 64 64h33.7c-1.39 10.48-2.18 21.14-2.18 32 0 39.77 9.26 77.35 25.56 110.94 5.19 10.69 16.52 17.06 28.4 17.06h74.28c26.05 0 41.69-29.84 25.9-50.56-16.4-21.52-26.15-48.36-26.15-77.44 0-11.11 1.62-21.79 4.41-32H256c54.66 0 108.28 18.81 150.98 52.95l85.03 68.03a32.023 32.023 0 0 0 19.98 7.02c24.92 0 32-22.78 32-32V295.13C563.05 284.04 576 263.63 576 240zm-96 141.42l-33.05-26.44C392.95 311.78 325.12 288 256 288v-96c69.12 0 136.95-23.78 190.95-66.98L480 98.58v282.84z"/>
|
|
78
|
+
</g>
|
|
79
|
+
<g id="fa-rss" viewBox="0 0 448 512">
|
|
80
|
+
<path d="M128.081 415.959c0 35.369-28.672 64.041-64.041 64.041S0 451.328 0 415.959s28.672-64.041 64.041-64.041 64.04 28.673 64.04 64.041zm175.66 47.25c-8.354-154.6-132.185-278.587-286.95-286.95C7.656 175.765 0 183.105 0 192.253v48.069c0 8.415 6.49 15.472 14.887 16.018 111.832 7.284 201.473 96.702 208.772 208.772.547 8.397 7.604 14.887 16.018 14.887h48.069c9.149.001 16.489-7.655 15.995-16.79zm144.249.288C439.596 229.677 251.465 40.445 16.503 32.01 7.473 31.686 0 38.981 0 48.016v48.068c0 8.625 6.835 15.645 15.453 15.999 191.179 7.839 344.627 161.316 352.465 352.465.353 8.618 7.373 15.453 15.999 15.453h48.068c9.034-.001 16.329-7.474 16.005-16.504z"/>
|
|
81
|
+
</g>
|
|
82
|
+
<g id="fa-twitter" viewBox="0 0 512 512">
|
|
83
|
+
<path d="M459.37 151.716c.325 4.548.325 9.097.325 13.645 0 138.72-105.583 298.558-298.558 298.558-59.452 0-114.68-17.219-161.137-47.106 8.447.974 16.568 1.299 25.34 1.299 49.055 0 94.213-16.568 130.274-44.832-46.132-.975-84.792-31.188-98.112-72.772 6.498.974 12.995 1.624 19.818 1.624 9.421 0 18.843-1.3 27.614-3.573-48.081-9.747-84.143-51.98-84.143-102.985v-1.299c13.969 7.797 30.214 12.67 47.431 13.319-28.264-18.843-46.781-51.005-46.781-87.391 0-19.492 5.197-37.36 14.294-52.954 51.655 63.675 129.3 105.258 216.365 109.807-1.624-7.797-2.599-15.918-2.599-24.04 0-57.828 46.782-104.934 104.934-104.934 30.213 0 57.502 12.67 76.67 33.137 23.715-4.548 46.456-13.32 66.599-25.34-7.798 24.366-24.366 44.833-46.132 57.827 21.117-2.273 41.584-8.122 60.426-16.243-14.292 20.791-32.161 39.308-52.628 54.253z"/>
|
|
84
|
+
</g>
|
|
85
|
+
<g id="fa-horse-head" viewBox="0 0 512 512">
|
|
86
|
+
<path d="M509.8 332.5l-69.9-164.3c-14.9-41.2-50.4-71-93-79.2 18-10.6 46.3-35.9 34.2-82.3-1.3-5-7.1-7.9-12-6.1L166.9 76.3C35.9 123.4 0 238.9 0 398.8V480c0 17.7 14.3 32 32 32h236.2c23.8 0 39.3-25 28.6-46.3L256 384v-.7c-45.6-3.5-84.6-30.7-104.3-69.6-1.6-3.1-.9-6.9 1.6-9.3l12.1-12.1c3.9-3.9 10.6-2.7 12.9 2.4 14.8 33.7 48.2 57.4 87.4 57.4 17.2 0 33-5.1 46.8-13.2l46 63.9c6 8.4 15.7 13.3 26 13.3h50.3c8.5 0 16.6-3.4 22.6-9.4l45.3-39.8c8.9-9.1 11.7-22.6 7.1-34.4zM328 224c-13.3 0-24-10.7-24-24s10.7-24 24-24 24 10.7 24 24-10.7 24-24 24z"/>
|
|
87
|
+
</g>
|
|
88
|
+
<g id="fa-chart-line" viewBox="0 0 512 512">
|
|
89
|
+
<path d="M496 384H64V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-32c0-8.84-7.16-16-16-16zM464 96H345.94c-21.38 0-32.09 25.85-16.97 40.97l32.4 32.4L288 242.75l-73.37-73.37c-12.5-12.5-32.76-12.5-45.25 0l-68.69 68.69c-6.25 6.25-6.25 16.38 0 22.63l22.62 22.62c6.25 6.25 16.38 6.25 22.63 0L192 237.25l73.37 73.37c12.5 12.5 32.76 12.5 45.25 0l96-96 32.4 32.4c15.12 15.12 40.97 4.41 40.97-16.97V112c.01-8.84-7.15-16-15.99-16z"/>
|
|
90
|
+
</g>
|
|
91
|
+
<g id="fa-instagram" viewBox="0 0 448 512">
|
|
92
|
+
<path d="M224.1 141c-63.6 0-114.9 51.3-114.9 114.9s51.3 114.9 114.9 114.9S339 319.5 339 255.9 287.7 141 224.1 141zm0 189.6c-41.1 0-74.7-33.5-74.7-74.7s33.5-74.7 74.7-74.7 74.7 33.5 74.7 74.7-33.6 74.7-74.7 74.7zm146.4-194.3c0 14.9-12 26.8-26.8 26.8-14.9 0-26.8-12-26.8-26.8s12-26.8 26.8-26.8 26.8 12 26.8 26.8zm76.1 27.2c-1.7-35.9-9.9-67.7-36.2-93.9-26.2-26.2-58-34.4-93.9-36.2-37-2.1-147.9-2.1-184.9 0-35.8 1.7-67.6 9.9-93.9 36.1s-34.4 58-36.2 93.9c-2.1 37-2.1 147.9 0 184.9 1.7 35.9 9.9 67.7 36.2 93.9s58 34.4 93.9 36.2c37 2.1 147.9 2.1 184.9 0 35.9-1.7 67.7-9.9 93.9-36.2 26.2-26.2 34.4-58 36.2-93.9 2.1-37 2.1-147.8 0-184.8zM398.8 388c-7.8 19.6-22.9 34.7-42.6 42.6-29.5 11.7-99.5 9-132.1 9s-102.7 2.6-132.1-9c-19.6-7.8-34.7-22.9-42.6-42.6-11.7-29.5-9-99.5-9-132.1s-2.6-102.7 9-132.1c7.8-19.6 22.9-34.7 42.6-42.6 29.5-11.7 99.5-9 132.1-9s102.7-2.6 132.1 9c19.6 7.8 34.7 22.9 42.6 42.6 11.7 29.5 9 99.5 9 132.1s2.7 102.7-9 132.1z"/>
|
|
93
|
+
</g>
|
|
94
|
+
<g id="fa-lightbulb" viewBox="0 0 352 512">
|
|
95
|
+
<path d="M96.06 454.35c.01 6.29 1.87 12.45 5.36 17.69l17.09 25.69a31.99 31.99 0 0 0 26.64 14.28h61.71a31.99 31.99 0 0 0 26.64-14.28l17.09-25.69a31.989 31.989 0 0 0 5.36-17.69l.04-38.35H96.01l.05 38.35zM0 176c0 44.37 16.45 84.85 43.56 115.78 16.52 18.85 42.36 58.23 52.21 91.45.04.26.07.52.11.78h160.24c.04-.26.07-.51.11-.78 9.85-33.22 35.69-72.6 52.21-91.45C335.55 260.85 352 220.37 352 176 352 78.61 272.91-.3 175.45 0 73.44.31 0 82.97 0 176zm176-80c-44.11 0-80 35.89-80 80 0 8.84-7.16 16-16 16s-16-7.16-16-16c0-61.76 50.24-112 112-112 8.84 0 16 7.16 16 16s-7.16 16-16 16z"/>
|
|
96
|
+
</g>
|
|
97
|
+
<g id="fa-exclamation-triangle" viewBox="0 0 576 512">
|
|
98
|
+
<path d="M569.517 440.013C587.975 472.007 564.806 512 527.94 512H48.054c-36.937 0-59.999-40.055-41.577-71.987L246.423 23.985c18.467-32.009 64.72-31.951 83.154 0l239.94 416.028zM288 354c-25.405 0-46 20.595-46 46s20.595 46 46 46 46-20.595 46-46-20.595-46-46-46zm-43.673-165.346l7.418 136c.347 6.364 5.609 11.346 11.982 11.346h48.546c6.373 0 11.635-4.982 11.982-11.346l7.418-136c.375-6.874-5.098-12.654-11.982-12.654h-63.383c-6.884 0-12.356 5.78-11.981 12.654z"/>
|
|
99
|
+
</g>
|
|
100
|
+
<g id="fa-search" viewBox="0 0 512 512">
|
|
101
|
+
<path d="M505 442.7L405.3 343c-4.5-4.5-10.6-7-17-7H372c27.6-35.3 44-79.7 44-128C416 93.1 322.9 0 208 0S0 93.1 0 208s93.1 208 208 208c48.3 0 92.7-16.4 128-44v16.3c0 6.4 2.5 12.5 7 17l99.7 99.7c9.4 9.4 24.6 9.4 33.9 0l28.3-28.3c9.4-9.4 9.4-24.6.1-34zM208 336c-70.7 0-128-57.2-128-128 0-70.7 57.2-128 128-128 70.7 0 128 57.2 128 128 0 70.7-57.2 128-128 128z"/>
|
|
102
|
+
</g>
|
|
103
|
+
<g id="fa-arrow-alt-circle-right" viewBox="0 0 512 512">
|
|
104
|
+
<path d="M256 8c137 0 248 111 248 248S393 504 256 504 8 393 8 256 119 8 256 8zM140 300h116v70.9c0 10.7 13 16.1 20.5 8.5l114.3-114.9c4.7-4.7 4.7-12.2 0-16.9l-114.3-115c-7.6-7.6-20.5-2.2-20.5 8.5V212H140c-6.6 0-12 5.4-12 12v64c0 6.6 5.4 12 12 12z"/>
|
|
105
|
+
</g>
|
|
106
|
+
</defs></svg>`;
|
|
107
|
+
|
|
108
|
+
renderIconSet(template, "sitefarm", 24);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "
|
|
2
|
-
import "
|
|
1
|
+
import "@ucd-lib/theme-elements/ucdlib/ucdlib-iconset/ucdlib-iconset";
|
|
2
|
+
import "@ucd-lib/theme-elements/ucdlib/ucdlib-icon/ucdlib-icon";
|
|
3
3
|
|
|
4
4
|
import { html, render } from "lit-html";
|
|
5
5
|
|
|
@@ -8,8 +8,9 @@ import { html, render } from "lit-html";
|
|
|
8
8
|
* @param {TemplateResult} icons - SVG html string of icons
|
|
9
9
|
* @param {String} name - name of iconset.
|
|
10
10
|
* @param {Number} size - size of icons
|
|
11
|
+
* @param {String} label - Friendly name of iconset
|
|
11
12
|
*/
|
|
12
|
-
function renderIconSet(icons, name, size=24){
|
|
13
|
+
function renderIconSet(icons, name, size=24, label=""){
|
|
13
14
|
const containerId = `ucdlib-icons--${name}`;
|
|
14
15
|
let container = document.getElementById(containerId);
|
|
15
16
|
if ( !container ){
|
|
@@ -19,7 +20,7 @@ function renderIconSet(icons, name, size=24){
|
|
|
19
20
|
document.head.appendChild(container);
|
|
20
21
|
}
|
|
21
22
|
const template = html`
|
|
22
|
-
<ucdlib-iconset name=${name} size=${size}>
|
|
23
|
+
<ucdlib-iconset name=${name} size=${size} label=${label}>
|
|
23
24
|
${icons}
|
|
24
25
|
</ucdlib-iconset>
|
|
25
26
|
`;
|
|
@@ -9,6 +9,7 @@ import { MutationObserverController } from '../../utils/controllers';
|
|
|
9
9
|
*
|
|
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
|
+
* @property {String} label - Optional friendly label for iconset.
|
|
12
13
|
* @example
|
|
13
14
|
* <ucdlib-iconset name="arrows">
|
|
14
15
|
<svg>
|
|
@@ -21,20 +22,22 @@ import { MutationObserverController } from '../../utils/controllers';
|
|
|
21
22
|
*/
|
|
22
23
|
export default class UcdlibIconset extends Mixin(LitElement)
|
|
23
24
|
.with(MainDomElement) {
|
|
24
|
-
mutationObserver = new MutationObserverController(this, {subtree: true, childList: true});
|
|
25
25
|
|
|
26
26
|
static get properties() {
|
|
27
27
|
return {
|
|
28
28
|
name: {type: String},
|
|
29
29
|
size: {type: Number},
|
|
30
|
+
label: {type: String},
|
|
30
31
|
_iconMap: {type: Object, state: true}
|
|
31
32
|
};
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
constructor() {
|
|
35
36
|
super();
|
|
37
|
+
this.mutationObserver = new MutationObserverController(this, {subtree: true, childList: true});
|
|
36
38
|
|
|
37
39
|
this.name = "";
|
|
40
|
+
this.label = "";
|
|
38
41
|
this.size = 24;
|
|
39
42
|
this._iconMap = {};
|
|
40
43
|
this.style.display = "none";
|
|
@@ -63,6 +66,17 @@ export default class UcdlibIconset extends Mixin(LitElement)
|
|
|
63
66
|
return Object.keys(this._iconMap);
|
|
64
67
|
}
|
|
65
68
|
|
|
69
|
+
/**
|
|
70
|
+
* @method getLabel
|
|
71
|
+
* @description Returns a friendly label of iconset
|
|
72
|
+
* @returns {String}
|
|
73
|
+
*/
|
|
74
|
+
getLabel(){
|
|
75
|
+
if ( this.label ) return this.label;
|
|
76
|
+
|
|
77
|
+
return this.name.replace(/-/g, " ");
|
|
78
|
+
}
|
|
79
|
+
|
|
66
80
|
/**
|
|
67
81
|
* @method applyIcon
|
|
68
82
|
* @description Adds icon to ucdlib-icon element from iconset
|
|
@@ -17,7 +17,6 @@ import { MutationObserverController } from '../../utils/controllers';
|
|
|
17
17
|
* </ucdlib-pages>
|
|
18
18
|
*/
|
|
19
19
|
export default class UcdlibPages extends LitElement {
|
|
20
|
-
mutationObserver = new MutationObserverController(this);
|
|
21
20
|
|
|
22
21
|
static get properties() {
|
|
23
22
|
return {
|
|
@@ -35,6 +34,7 @@ export default class UcdlibPages extends LitElement {
|
|
|
35
34
|
|
|
36
35
|
constructor() {
|
|
37
36
|
super();
|
|
37
|
+
this.mutationObserver = new MutationObserverController(this);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
/**
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
import {render, styles} from "./ucdlib-sils-search-redirect.tpl.js";
|
|
3
|
+
|
|
4
|
+
import { SilsPrimoController } from '../../utils/controllers';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @class UcdlibSilsSearchRedirect
|
|
8
|
+
* @classdesc Search widget that redirects a user's query to SILS Primo
|
|
9
|
+
* @property {String} query - The search query
|
|
10
|
+
* @property {Boolean} ucdOnly - Limits search to UC Davis libraries only
|
|
11
|
+
* @property {Boolean} darkBackground - Adjusts colors for display on a dark background
|
|
12
|
+
* @property {Boolean} preventRedirect - Will not send user to Primo on form submission
|
|
13
|
+
* @property {String} headingText - Text to display above main text input
|
|
14
|
+
* @property {String} inputPlaceholder - Placeholder for main text input
|
|
15
|
+
* @property {String} host - Primo host
|
|
16
|
+
*/
|
|
17
|
+
export default class UcdlibSilsSearchRedirect extends LitElement {
|
|
18
|
+
|
|
19
|
+
static get properties() {
|
|
20
|
+
return {
|
|
21
|
+
query: {type: String},
|
|
22
|
+
ucdOnly: {type: Boolean, attribute: "ucd-only"},
|
|
23
|
+
darkBackground: {type: Boolean, attribute: "dark-background"},
|
|
24
|
+
preventRedirect: {type: Boolean, attribute: "prevent-redirect"},
|
|
25
|
+
headingText: {type: String, attribute: "heading-text"},
|
|
26
|
+
inputPlaceholder: {type: String, attribute: "input-placeholder"},
|
|
27
|
+
host: {type: String},
|
|
28
|
+
role: {type: String, reflect: true},
|
|
29
|
+
ariaLabel: {type: String, attribute: "aria-label", reflect: true}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
static get styles() {
|
|
34
|
+
return styles();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
constructor() {
|
|
38
|
+
super();
|
|
39
|
+
this.render = render.bind(this);
|
|
40
|
+
this.query = "";
|
|
41
|
+
this.ucdOnly = false;
|
|
42
|
+
this.darkBackground = false;
|
|
43
|
+
this.headingText = "Search UC Library Materials";
|
|
44
|
+
this.inputPlaceholder = "All UC books, journals, articles + more";
|
|
45
|
+
this.role = "form";
|
|
46
|
+
this.ariaLabel = "Search UC Library Materials";
|
|
47
|
+
this.host = "";
|
|
48
|
+
this._updatePrimoController();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* @method willUpdate
|
|
53
|
+
* @description Lit lifecycle hook
|
|
54
|
+
* @private
|
|
55
|
+
* @param {Map} props - Properties that have changed
|
|
56
|
+
*/
|
|
57
|
+
willUpdate(props){
|
|
58
|
+
this._updatePrimoController(props);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @method _onQueryChange
|
|
63
|
+
* @private
|
|
64
|
+
* @description Attached to primary text input
|
|
65
|
+
* @param {Event} e - Input event
|
|
66
|
+
*/
|
|
67
|
+
_onQueryChange(e){
|
|
68
|
+
let text = e.target.value ? e.target.value : "";
|
|
69
|
+
this.query = text;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* @method _onCorpusChange
|
|
74
|
+
* @private
|
|
75
|
+
* @description Attached to ucd-only checkbox
|
|
76
|
+
* @param {Event} e - Input event
|
|
77
|
+
*/
|
|
78
|
+
_onCorpusChange(e){
|
|
79
|
+
this.ucdOnly = e.target.checked;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* @method _onSubmit
|
|
84
|
+
* @description Called on form submit
|
|
85
|
+
* @private
|
|
86
|
+
* @param {Event} e - submit event
|
|
87
|
+
*/
|
|
88
|
+
_onSubmit(e){
|
|
89
|
+
e.preventDefault();
|
|
90
|
+
let corpus = this.ucdOnly ? "ucd" : "everything";
|
|
91
|
+
let advanced = e.submitter.id == "advanced-search";
|
|
92
|
+
|
|
93
|
+
let url = this.primo.makeSearchUrl(this.query, corpus, advanced);
|
|
94
|
+
if ( this.preventRedirect ) {
|
|
95
|
+
this.dispatchEvent(new CustomEvent('search', {
|
|
96
|
+
detail : {url}
|
|
97
|
+
}));
|
|
98
|
+
} else {
|
|
99
|
+
window.location = url;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* @method _updatePrimoController
|
|
106
|
+
* @description Updates the config values of the Primo controller based on ele attributes
|
|
107
|
+
* @private
|
|
108
|
+
* @param {Map} props - Properties that have changed in current lifecycle
|
|
109
|
+
*/
|
|
110
|
+
_updatePrimoController(props){
|
|
111
|
+
let primoConfig = {};
|
|
112
|
+
|
|
113
|
+
// Get primo config values from ele attributes
|
|
114
|
+
const attrs = [
|
|
115
|
+
{ele: 'host', ctl: 'host'}
|
|
116
|
+
];
|
|
117
|
+
if ( props ){
|
|
118
|
+
attrs.forEach(attr => {
|
|
119
|
+
if ( props.has(attr.ele) && this[attr.ele] ) {
|
|
120
|
+
primoConfig[attr.ctl] = this[attr.ele];
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// instantiate or update controller
|
|
126
|
+
if ( !this.primo ) {
|
|
127
|
+
this.primo = new SilsPrimoController(
|
|
128
|
+
this,
|
|
129
|
+
primoConfig
|
|
130
|
+
);
|
|
131
|
+
} else {
|
|
132
|
+
this.primo.updateConfig(primoConfig);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
customElements.define('ucdlib-sils-search-redirect', UcdlibSilsSearchRedirect);
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { html, css, unsafeCSS } from 'lit';
|
|
2
|
+
|
|
3
|
+
import normalizeCss from "@ucd-lib/theme-sass/normalize.css.js";
|
|
4
|
+
import headingCss from "@ucd-lib/theme-sass/1_base_html/_headings.css";
|
|
5
|
+
import headingClassesCss from "@ucd-lib/theme-sass/2_base_class/_headings.css";
|
|
6
|
+
import formsCss from "@ucd-lib/theme-sass/1_base_html/_forms.css";
|
|
7
|
+
import formsClassesCss from "@ucd-lib/theme-sass/2_base_class/_forms.css";
|
|
8
|
+
import buttonCss from "@ucd-lib/theme-sass/2_base_class/_buttons.css";
|
|
9
|
+
import spacingUtilityCss from "@ucd-lib/theme-sass/6_utility/_u-space.css";
|
|
10
|
+
import { categoryBrands } from "@ucd-lib/theme-sass/colors";
|
|
11
|
+
|
|
12
|
+
export function styles() {
|
|
13
|
+
const elementStyles = css`
|
|
14
|
+
:host {
|
|
15
|
+
display: block;
|
|
16
|
+
max-width: 500px;
|
|
17
|
+
margin: auto;
|
|
18
|
+
}
|
|
19
|
+
h2 {
|
|
20
|
+
text-align: center;
|
|
21
|
+
}
|
|
22
|
+
.search-bar {
|
|
23
|
+
display: flex;
|
|
24
|
+
flex-flow: row nowrap;
|
|
25
|
+
}
|
|
26
|
+
.search-bar button {
|
|
27
|
+
font-family: "Font Awesome 5 Free";
|
|
28
|
+
min-width: unset;
|
|
29
|
+
font-size: 1.2rem;
|
|
30
|
+
padding: 0 .75rem;
|
|
31
|
+
min-height: 0;
|
|
32
|
+
}
|
|
33
|
+
.search-bar button:hover {
|
|
34
|
+
padding-right: .75rem;
|
|
35
|
+
padding-left: .75rem;
|
|
36
|
+
}
|
|
37
|
+
.search-bar input {
|
|
38
|
+
flex-grow: 1;
|
|
39
|
+
}
|
|
40
|
+
.search-options {
|
|
41
|
+
display: flex;
|
|
42
|
+
flex-flow: row wrap;
|
|
43
|
+
align-items: center;
|
|
44
|
+
justify-content: space-between;
|
|
45
|
+
}
|
|
46
|
+
.search-options label {
|
|
47
|
+
color: ${unsafeCSS(categoryBrands.primary.hex)};
|
|
48
|
+
padding-bottom: 0;
|
|
49
|
+
}
|
|
50
|
+
input[type=checkbox] {
|
|
51
|
+
margin-right: 0;
|
|
52
|
+
}
|
|
53
|
+
.search-options button {
|
|
54
|
+
border: none;
|
|
55
|
+
background-color: inherit;
|
|
56
|
+
color: ${unsafeCSS(categoryBrands.primary.hex)};
|
|
57
|
+
text-decoration: underline;
|
|
58
|
+
padding: 0;
|
|
59
|
+
font-family: inherit;
|
|
60
|
+
}
|
|
61
|
+
.dark h2 {
|
|
62
|
+
color: ${unsafeCSS(categoryBrands.secondary.hex)}
|
|
63
|
+
}
|
|
64
|
+
.dark .search-options label {
|
|
65
|
+
color: #fff;
|
|
66
|
+
}
|
|
67
|
+
.dark .search-options button {
|
|
68
|
+
color: #fff;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
`;
|
|
72
|
+
|
|
73
|
+
return [
|
|
74
|
+
normalizeCss,
|
|
75
|
+
headingCss,
|
|
76
|
+
headingClassesCss,
|
|
77
|
+
formsCss,
|
|
78
|
+
formsClassesCss,
|
|
79
|
+
buttonCss,
|
|
80
|
+
spacingUtilityCss,
|
|
81
|
+
elementStyles];
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export function render() {
|
|
85
|
+
return html`
|
|
86
|
+
<form
|
|
87
|
+
@submit=${this._onSubmit}
|
|
88
|
+
aria-label=${this.ariaLabel}
|
|
89
|
+
class="${this.darkBackground ? 'dark' : 'light'}">
|
|
90
|
+
|
|
91
|
+
${this.headingText ? html`
|
|
92
|
+
<h2 class="heading--highlight u-space-mb">${this.headingText}</h2>
|
|
93
|
+
` : html``}
|
|
94
|
+
|
|
95
|
+
<div class="search-bar">
|
|
96
|
+
<input type="text" .value=${this.query} @input=${this._onQueryChange} placeholder=${this.inputPlaceholder}>
|
|
97
|
+
<button id="simple-search" type="submit" class="btn btn--primary-input"> </button>
|
|
98
|
+
</div>
|
|
99
|
+
|
|
100
|
+
<div class="search-options">
|
|
101
|
+
<div class="checkbox u-space-mr--small u-space-mt--small">
|
|
102
|
+
<input id="corpus" type="checkbox" ?checked=${this.ucdOnly} @input=${this._onCorpusChange}><label for="corpus">UC Davis libraries only</label>
|
|
103
|
+
</div>
|
|
104
|
+
<button id="advanced-search" class="u-space-mt--small" type="submit">Advanced Search</button>
|
|
105
|
+
</div>
|
|
106
|
+
</form>
|
|
107
|
+
|
|
108
|
+
`;}
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import { BreakPointsController } from "./break-points";
|
|
2
2
|
import { IntersectionObserverController } from "./intersection-observer";
|
|
3
3
|
import { MutationObserverController } from "./mutation-observer";
|
|
4
|
+
import { PopStateObserverController } from "./popstate-observer";
|
|
5
|
+
import { SilsPrimoController } from "./sils-primo";
|
|
4
6
|
import { WaitController } from "./wait";
|
|
5
7
|
|
|
8
|
+
|
|
6
9
|
export {
|
|
7
10
|
BreakPointsController,
|
|
8
11
|
IntersectionObserverController,
|
|
9
12
|
MutationObserverController,
|
|
13
|
+
PopStateObserverController,
|
|
14
|
+
SilsPrimoController,
|
|
10
15
|
WaitController,
|
|
11
16
|
};
|
|
@@ -20,11 +20,6 @@
|
|
|
20
20
|
*
|
|
21
21
|
*/
|
|
22
22
|
export class IntersectionObserverController{
|
|
23
|
-
host;
|
|
24
|
-
options;
|
|
25
|
-
callback;
|
|
26
|
-
observer;
|
|
27
|
-
observeSelf;
|
|
28
23
|
|
|
29
24
|
constructor(host, options = {}, callback = "_onIntersection", observeSelf = true){
|
|
30
25
|
(this.host = host).addController(this);
|
|
@@ -14,11 +14,6 @@
|
|
|
14
14
|
* mutationObserver = new MutationObserverController(this, {childList: true, attributes: true}, 'aDifferentCallbackMethod');
|
|
15
15
|
*/
|
|
16
16
|
export class MutationObserverController {
|
|
17
|
-
host;
|
|
18
|
-
options;
|
|
19
|
-
callback;
|
|
20
|
-
|
|
21
|
-
_observer;
|
|
22
17
|
|
|
23
18
|
constructor(host, options = {childList: true}, callback = "_onChildListMutation"){
|
|
24
19
|
(this.host = host).addController(this);
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @class PopStateObserverController
|
|
3
|
+
* @classdesc Controller for attaching a popstate event listener to a Lit element.
|
|
4
|
+
*
|
|
5
|
+
* @property {LitElement} host - 'this' from a Lit element
|
|
6
|
+
* @property {String} callback - Name of element method called on popstate. Default: '_onPopstate'
|
|
7
|
+
*
|
|
8
|
+
* @examples
|
|
9
|
+
* // Instantiate this controller in the constructor of your element
|
|
10
|
+
* new PopStateObserverController(this, "_onLocationChange");
|
|
11
|
+
*/
|
|
12
|
+
export class PopStateObserverController{
|
|
13
|
+
|
|
14
|
+
constructor(host, callback="_onPopstate"){
|
|
15
|
+
(this.host = host).addController(this);
|
|
16
|
+
this.callback = callback;
|
|
17
|
+
this._onPopstate = this._onPopstate.bind(this);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
hostConnected(){
|
|
21
|
+
window.addEventListener('popstate', this._onPopstate);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
hostDisconnected(){
|
|
25
|
+
window.removeEventListener('popstate', this._onPopstate);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
_onPopstate(e){
|
|
29
|
+
if ( !this.host[this.callback]){
|
|
30
|
+
console.warn(
|
|
31
|
+
`Element has no '${this.callback}' method.
|
|
32
|
+
Either add this method, or change the 'callback' argument on instantiation.`
|
|
33
|
+
);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
let locationObject = this._getLocationObject();
|
|
37
|
+
this.host[this.callback](locationObject, e);
|
|
38
|
+
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
_getLocationObject(){
|
|
42
|
+
let location = {
|
|
43
|
+
fullpath : window.location.href.replace(window.location.origin, '').replace(/^\/+/, '/'),
|
|
44
|
+
pathname : window.location.pathname.replace(/^\/+/, '/'),
|
|
45
|
+
path : window.location.pathname.replace(/(^\/+|\/+$)/g, '').split('/'),
|
|
46
|
+
query : new URLSearchParams(window.location.search),
|
|
47
|
+
hash : window.location.hash.replace(/^#/, '')
|
|
48
|
+
};
|
|
49
|
+
return location;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @class SilsPrimoController
|
|
3
|
+
* @classdesc Utility for interacting with UC Libraries' discovery tool
|
|
4
|
+
*
|
|
5
|
+
* @property {LitElement} host - 'this' from a Lit element
|
|
6
|
+
* @property {Object} config - Basic Primo configuration values (host, uris, etc)
|
|
7
|
+
*/
|
|
8
|
+
export class SilsPrimoController{
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @method constructor
|
|
12
|
+
* @description Called on instantiation
|
|
13
|
+
* @param {LitElement} host - Element
|
|
14
|
+
* @param {Object} config - Config values
|
|
15
|
+
*/
|
|
16
|
+
constructor(host, config={}){
|
|
17
|
+
(this.host = host).addController(this);
|
|
18
|
+
this.updateConfig(config);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @method updateConfig
|
|
23
|
+
* @description Updates the config property.
|
|
24
|
+
* @param {Object} config - Values to overide the default.
|
|
25
|
+
*/
|
|
26
|
+
updateConfig(config){
|
|
27
|
+
const UCD_TAB = "LibraryCatalog";
|
|
28
|
+
let _config = {
|
|
29
|
+
host: "https://search.library.ucdavis.edu",
|
|
30
|
+
paths: {
|
|
31
|
+
search: "discovery/search",
|
|
32
|
+
browse: "discovery/browse"
|
|
33
|
+
},
|
|
34
|
+
defaultParams: {
|
|
35
|
+
vid: "01UCD_INST:UCD"
|
|
36
|
+
},
|
|
37
|
+
corpora: {
|
|
38
|
+
everything: {
|
|
39
|
+
tab: "UCSILSDefaultSearch",
|
|
40
|
+
scope: "DN_and_CI"
|
|
41
|
+
},
|
|
42
|
+
uc: {
|
|
43
|
+
tab: "UCSDiscoveryNetwork",
|
|
44
|
+
scope: "UCSDiscoveryNetwork"
|
|
45
|
+
},
|
|
46
|
+
ucd: {
|
|
47
|
+
tab: UCD_TAB,
|
|
48
|
+
scope: "MyInstitution",
|
|
49
|
+
},
|
|
50
|
+
specialCollections: {
|
|
51
|
+
tab: UCD_TAB,
|
|
52
|
+
scope: "SSPEC"
|
|
53
|
+
},
|
|
54
|
+
medical: {
|
|
55
|
+
tab: UCD_TAB,
|
|
56
|
+
scope: "BLAISDELL"
|
|
57
|
+
},
|
|
58
|
+
healthSciences: {
|
|
59
|
+
tab: UCD_TAB,
|
|
60
|
+
scope: "CARLSON"
|
|
61
|
+
},
|
|
62
|
+
law: {
|
|
63
|
+
tab: UCD_TAB,
|
|
64
|
+
scope: "Mabie"
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
this.config = Object.assign(_config, config);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* @method makeSearchUrl
|
|
74
|
+
* @description Makes a Primo Search URL
|
|
75
|
+
* @param {String} query - A search term or phrase
|
|
76
|
+
* @param {String} corpus - The bib corpus to search against.
|
|
77
|
+
* Sets 'tab' and 'search_scope' params. Must be a recognized keyword in the corpora config object:
|
|
78
|
+
* everything, uc, ucd, specialCollections, medical, healthSciences, law
|
|
79
|
+
* @param {Boolean} advanced - Expands the advanced search interface
|
|
80
|
+
* @param {Object} additionalParams - Any additional url params. Has the final say.
|
|
81
|
+
* @returns
|
|
82
|
+
*/
|
|
83
|
+
makeSearchUrl( query, corpus="everything", advanced=false, additionalParams={} ){
|
|
84
|
+
let url = `${this._trailingSlashIt(this.config.host)}${this.config.paths.search}`;
|
|
85
|
+
|
|
86
|
+
let params = Object.assign({}, this.config.defaultParams);
|
|
87
|
+
|
|
88
|
+
if ( advanced ) {
|
|
89
|
+
params['mode'] = 'advanced';
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if ( query ) {
|
|
93
|
+
params['query'] = 'any,contains,' + query.replace(/,/g, ' ');
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if ( this.config.corpora[corpus] ) {
|
|
97
|
+
params['tab'] = this.config.corpora[corpus].tab;
|
|
98
|
+
params['search_scope'] = this.config.corpora[corpus].scope;
|
|
99
|
+
} else {
|
|
100
|
+
console.warn(`${corpus} is not a recognized corpus`);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if ( additionalParams ){
|
|
104
|
+
Object.assign(params, additionalParams);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
params = new URLSearchParams(params);
|
|
108
|
+
return `${url}?${params.toString()}`;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* @method _trailingSlashIt
|
|
113
|
+
* @description Adds trailing slash to string if not already present
|
|
114
|
+
* @private
|
|
115
|
+
* @param {String} str
|
|
116
|
+
* @returns
|
|
117
|
+
*/
|
|
118
|
+
_trailingSlashIt(str){
|
|
119
|
+
if ( str.endsWith('/') ){
|
|
120
|
+
return str;
|
|
121
|
+
}
|
|
122
|
+
return str + "/";
|
|
123
|
+
}
|
|
124
|
+
}
|