@ucd-lib/theme-elements 1.0.3 → 1.1.2

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.
@@ -18,6 +18,7 @@ import {
18
18
  * @property {String} slogan - Optional text to display below site name
19
19
  * @property {String} figureSrc - Site logo/icon to display next to site name
20
20
  * @property {String} siteUrl - Url to use for links around site name and figure
21
+ * @property {Boolean} silenceWarnings - Console warnings will be silences
21
22
  * @property {Boolean} opened - Whether header is open in the mobile view
22
23
  * @property {Boolean} preventFixed - Navbar will not be fixed to top of screen in desktop view
23
24
  *
@@ -49,6 +50,7 @@ export default class UcdThemeHeader extends LitElement {
49
50
  figureSrc: {type: String, attribute: "figure-src"},
50
51
  siteUrl: {type: String, attribute: "site-url"},
51
52
  opened: {type: Boolean},
53
+ silenceWarnings: {type: Boolean, attribute: 'silence-warnings'},
52
54
  preventFixed: {type: Boolean, attribute: "prevent-fixed"},
53
55
  isDemo: {type: Boolean, attribute: "is-demo"},
54
56
  _transitioning: {type: Boolean, state: true},
@@ -57,6 +59,8 @@ export default class UcdThemeHeader extends LitElement {
57
59
  _hasQuickLinks: {type: Boolean, state: true},
58
60
  _hasSearch: {type: Boolean, state: true},
59
61
  _brandingBarInView: {type: Boolean, state: true},
62
+ _brandingBarLinks: {type: Array, state: true},
63
+ _brandingBarListener: {type: Boolean, state: true},
60
64
  _components: {type: Object, state: true}
61
65
  };
62
66
  }
@@ -79,6 +83,7 @@ export default class UcdThemeHeader extends LitElement {
79
83
  this.figureSrc = "";
80
84
  this.opened = false;
81
85
  this.isDemo = false;
86
+ this.silenceWarnings = false;
82
87
 
83
88
  this._transitioning = false;
84
89
  this._hasPrimaryNav = false;
@@ -87,6 +92,8 @@ export default class UcdThemeHeader extends LitElement {
87
92
  this._hasSearch = false;
88
93
  this._animationDuration = 500;
89
94
  this._brandingBarInView = false;
95
+ this._brandingBarLinks = [];
96
+ this._brandingBarListener = false;
90
97
  this._slottedComponents = {};
91
98
 
92
99
  }
@@ -261,6 +268,20 @@ export default class UcdThemeHeader extends LitElement {
261
268
 
262
269
  }
263
270
 
271
+ /**
272
+ * @method _onBrandingBarUpdate
273
+ * @description Listens to nav item changes to the ucdlib-branding-bar element (if applicable)
274
+ * @private
275
+ * @param {Element} ele - ucdlib-branding-bar element
276
+ */
277
+ _onBrandingBarUpdate(ele) {
278
+ if ( ele.navItems ) {
279
+ this._brandingBarLinks = ele.navItems;
280
+ } else {
281
+ this._brandingBarLinks = [];
282
+ }
283
+ }
284
+
264
285
  /**
265
286
  * @method _onChildListMutation
266
287
  * @description Fires when there are changes to this element's non-shadow DOM children
@@ -273,7 +294,9 @@ export default class UcdThemeHeader extends LitElement {
273
294
  this._hasPrimaryNav = true;
274
295
  this._slottedComponents.primaryNav = primaryNav;
275
296
  } else {
276
- console.warn("No 'ucd-theme-primary-nav' child element found!");
297
+ if ( !this.silenceWarnings ) {
298
+ console.warn("No 'ucd-theme-primary-nav' child element found!");
299
+ }
277
300
  this._hasPrimaryNav = false;
278
301
  }
279
302
 
@@ -300,10 +323,18 @@ export default class UcdThemeHeader extends LitElement {
300
323
  UcdlibBrandingBar.setAttribute('slot', 'branding-bar');
301
324
  this._hasSlottedBranding = true;
302
325
  this._slottedComponents.brandingBar = UcdlibBrandingBar;
326
+ if ( !this._brandingBarListener ){
327
+ this._onBrandingBarUpdate(UcdlibBrandingBar);
328
+ UcdlibBrandingBar.addEventListener('nav-update', (e) => {this._onBrandingBarUpdate(e.target);});
329
+ this._brandingBarListener = true;
330
+ }
331
+
303
332
  } else if ( this.querySelector("*[slot='branding-bar']") ){
304
333
  this._hasSlottedBranding = true;
334
+ this._brandingBarLinks = [];
305
335
  } else {
306
336
  this._hasSlottedBranding = false;
337
+ this._brandingBarLinks = [];
307
338
  }
308
339
  }
309
340
 
@@ -1,5 +1,6 @@
1
1
  import { html, css } from 'lit';
2
2
  import { classMap } from 'lit/directives/class-map.js';
3
+ import { ifDefined } from 'lit/directives/if-defined.js';
3
4
 
4
5
  import headingStyles from "@ucd-lib/theme-sass/1_base_html/_headings.css.js";
5
6
  import headerStyles from "@ucd-lib/theme-sass/4_component/_header.css.js";
@@ -40,6 +41,9 @@ export function styles() {
40
41
  .fixed-mobile .l-header__branding {
41
42
  margin-top: 55px;
42
43
  }
44
+ .branding-bar-mobile-links {
45
+ display: block;
46
+ }
43
47
  }
44
48
 
45
49
  @media (min-width: 992px) {
@@ -51,6 +55,36 @@ export function styles() {
51
55
  left: 0;
52
56
  width: 100%;
53
57
  }
58
+ .branding-bar-mobile-links {
59
+ display: none;
60
+ }
61
+ }
62
+ .branding-bar-mobile-links ul {
63
+ margin: 0px;
64
+ padding: 0px;
65
+ list-style: none;
66
+ }
67
+ .branding-bar-mobile-links li {
68
+ margin: 0px;
69
+ padding: 0px;
70
+ list-style: none;
71
+ }
72
+ .branding-bar-mobile-links a {
73
+ display: flex;
74
+ align-items: center;
75
+ padding: 0.75rem;
76
+ border-bottom: 0.15rem solid rgb(219, 234, 247);
77
+ background-color: #fff;
78
+ color: rgb(2, 40, 81);
79
+ font-weight: 700;
80
+ line-height: 1.5rem;
81
+ text-decoration: none;
82
+ }
83
+ .branding-bar-mobile-links a:hover {
84
+ background-color: rgb(255, 191, 0);
85
+ }
86
+ .branding-bar-mobile-links li:last-child a {
87
+ border-bottom: none;
54
88
  }
55
89
 
56
90
  `;
@@ -137,6 +171,19 @@ ${this.isDemo ? html`
137
171
  <div class="l-nav-horizontal__primary-nav">
138
172
  <slot name="primary-nav"></slot>
139
173
  </div>
174
+ ${this._brandingBarLinks.length ? html`
175
+ <div class='branding-bar-mobile-links'>
176
+ <ul>
177
+ ${this._brandingBarLinks.map(link => html`
178
+ <li><a
179
+ href=${ifDefined(link.href ? link.href : null)}
180
+ target=${ifDefined(link.newTab ? "_blank": null)}
181
+ >${link.linkText}</a></li>
182
+ `)}
183
+ </ul>
184
+
185
+ </div>
186
+ ` : html``}
140
187
  </div>
141
188
  </div>
142
189
  </div>
@@ -17,6 +17,9 @@ export function styles() {
17
17
  button[disabled] {
18
18
  pointer-events: none;
19
19
  }
20
+ .submenu-toggle__icon {
21
+ min-width: 40%;
22
+ }
20
23
  @media (min-width: 992px) {
21
24
  nav.primary-nav--mega li.depth-0 > ul.menu {
22
25
  opacity: 1;
@@ -29,6 +29,9 @@ export function styles() {
29
29
  .click-attached {
30
30
  cursor: pointer;
31
31
  }
32
+ .submenu-toggle__icon {
33
+ min-width: 40%;
34
+ }
32
35
  @media (min-width: 992px) {
33
36
  .slot-parent {
34
37
  display: block;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ucd-lib/theme-elements",
3
- "version": "1.0.3",
3
+ "version": "1.1.2",
4
4
  "description": "Custom elements for the UCD brand theme",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,14 +1,14 @@
1
1
  import {html, LitElement} from 'lit';
2
- import {render, styles} from "./ucd-theme-author-profile.tpl.js";
2
+ import {render, styles} from "./ucdlib-author-profile.tpl.js";
3
3
  import {TaskController} from '../../utils/controllers/task.js';
4
4
 
5
5
  /**
6
6
  * @class AuthorProfile
7
7
  * @description This author profile hydrates with the website wordpress api and goes into a profile block.
8
8
  * @property {String} email - Email to reference person
9
- * @property {String} domain - Specify the domain to choose from
9
+ * @property {String} host - Specify the host to choose from
10
10
  *
11
- * <ucdlib-theme-author-profile domain="sandbox" email='sabaggett@ucdavis.edu></ucdlib-theme-author-profile>
11
+ * <ucdlib-theme-author-profile host="sandbox" email='sabaggett@ucdavis.edu></ucdlib-theme-author-profile>
12
12
  */
13
13
  export default class UcdlibAuthorProfile extends LitElement {
14
14
  static get properties() {
@@ -16,20 +16,22 @@ export default class UcdlibAuthorProfile extends LitElement {
16
16
  results : {type: Object, attribute:false},
17
17
  email : {type: String},
18
18
  id: {type: Number},
19
- nameLast: {type: String},
20
- nameFirst: {type: String},
19
+ nameLast: {type: String, attribute: 'name-last'},
20
+ nameFirst: {type: String, attribute: 'name-first'},
21
21
  link: {type: String},
22
- contactWebsite: {type: String},
23
- contactEmail: {type: String},
24
- contactPhone: {type: String},
25
- contactWebsiteLabel: {type: String},
26
- contactEmailLabel: {type: String},
27
- contactPhoneLabel: {type: String},
28
- contactAppointmentUrl: {type: String},
29
- positionTitle: {type: String},
22
+ contactWebsite: {type: String, attribute: 'contact-website'},
23
+ contactEmail: {type: String, attribute: 'contact-email'},
24
+ contactPhone: {type: String, attribute: 'contact-phone'},
25
+ contactWebsiteLabel: {type: String, attribute: 'contact-website-label'},
26
+ contactEmailLabel: {type: String, attribute: 'contact-email-label'},
27
+ contactPhoneLabel: {type: String, attribute: 'contact-phone-label'},
28
+ contactAppointmentUrl: {type: String, attribute: 'contact-appointment-url'},
29
+ positionTitle: {type: String, attribute: 'position-title'},
30
30
  photo: {type: Object},
31
31
  department: {type: String},
32
- domain: {type: String}
32
+ host: {type: String},
33
+ apiPath: {type: String, attribute: 'api-path'},
34
+ sidebar: {type: Boolean}
33
35
  };
34
36
  }
35
37
 
@@ -45,7 +47,10 @@ export default class UcdlibAuthorProfile extends LitElement {
45
47
  this.ERROR = false;
46
48
  this.results = {};
47
49
  this.email = '';
48
- this.domain = '';
50
+ this.host = window.location.origin;
51
+ this.apiPath = '/wp-json/ucdlib-directory/person/';
52
+
53
+
49
54
  this.errorMessage = 'This is not an email.';
50
55
 
51
56
  this.svgIcon = {
@@ -75,13 +80,13 @@ export default class UcdlibAuthorProfile extends LitElement {
75
80
  /**
76
81
  * @method updated
77
82
  *
78
- * @description request user data when email or domain changes
83
+ * @description request user data when email or host changes
79
84
  *
80
85
  * @param {Object} props
81
86
  *
82
87
  */
83
88
  updated(props){
84
- if( props.has('email') || props.has('domain') ){
89
+ if( props.has('email') || props.has('host') || props.has('apiPath')){
85
90
  if( !this.email ) return;
86
91
  this.eController = new TaskController(this, this._requestUrl());
87
92
  }
@@ -149,7 +154,6 @@ export default class UcdlibAuthorProfile extends LitElement {
149
154
  this.PENDING = false;
150
155
  this.LOADING = false;
151
156
 
152
-
153
157
  this.id = this.results.id;
154
158
 
155
159
  this.nameLast = this.results.nameLast;
@@ -193,11 +197,9 @@ export default class UcdlibAuthorProfile extends LitElement {
193
197
  let email =this.email;
194
198
  let validate = this.validationLink(email);
195
199
  if(!validate) console.error(email);
196
- let url;
197
200
 
198
- url = "https://library.ucdavis.edu/wp-json/ucdlib-directory/person/" + String(email);
199
- if (this.domain != "")
200
- url = "https://" + this.domain + ".library.ucdavis.edu/wp-json/ucdlib-directory/person/" + String(email);
201
+ let url = (this.host || window.location.origin) + this.apiPath + String(email);
202
+
201
203
  this.requestUpdate();
202
204
 
203
205
  return url;
@@ -217,4 +219,4 @@ export default class UcdlibAuthorProfile extends LitElement {
217
219
 
218
220
  }
219
221
 
220
- customElements.define('ucdlib-theme-author-profile', UcdlibAuthorProfile);
222
+ customElements.define('ucdlib-author-profile', UcdlibAuthorProfile);
@@ -40,6 +40,11 @@ export function render() {
40
40
  width: 33.3%;
41
41
  height:18px;
42
42
  }
43
+ .side-bar{
44
+ display: inline-grid;
45
+ grid-template-columns: 15% 85%;
46
+ width:100%;
47
+ }
43
48
  .container {
44
49
  display: inline-grid;
45
50
  grid-template-columns: 15% 85%;
@@ -75,14 +80,14 @@ export function render() {
75
80
  display:inline-block;
76
81
  }
77
82
  .name {
78
- color:var(--ucd-blue-80);
83
+ color: #13639e;
79
84
  margin-bottom:0;
80
85
  }
81
86
  .title {
82
87
  margin-bottom:0;
83
88
  }
84
89
  .info {
85
- color:var(--ucd-blue-80);
90
+ color: #13639e;
86
91
  margin-bottom:0;
87
92
  }
88
93
  .svg-icon {
@@ -106,6 +111,12 @@ export function render() {
106
111
  display:none;
107
112
  }
108
113
 
114
+ @media (min-width:992px) {
115
+ .container{
116
+ grid-template-columns: 25% 75%;
117
+ }
118
+ }
119
+
109
120
  @media (max-width: 800px) {
110
121
 
111
122
  .contact-list {
@@ -127,6 +138,7 @@ export function render() {
127
138
  .container {
128
139
  grid-template-columns: 35% 65%;
129
140
  }
141
+
130
142
  .photo {
131
143
  width:80%;
132
144
  height:80%;
@@ -151,16 +163,16 @@ ${this.eController ? html`
151
163
  ${!this.LOADING ? html`
152
164
  ${this.photo != "Empty" && this.photo != undefined ?
153
165
  html`
154
- <div class="container">
155
- <div class="photo"><img src="${this.photo.link}" alt="${this.photoAlt}"></div>
156
- <div class="text_container">
157
- <h3 class="name"><a class="name" href="${this.link}">${this.nameFirst} ${this.nameLast}</a></h3>
158
- <p class="title">${this.positionTitle} <span class="pipe">&#124;</span> ${this.department}</p>
159
- <p class="contact-list">${this.contactPhone ? html`${this.svgIcon.phone} <a class="info" href="tel:${this.contactPhone}">${this.contactPhone}</a> <span class="pipe">&#124;</span>`: html``}</p>
160
- <p class="contact-list">${this.contactEmail ? html`${this.svgIcon.email} <a class="info" href="mailto:${this.contactEmail}">${this.contactEmail}</a> ${this.contactAppointmentUrl ? html`<span class="pipe">&#124;</span>`:html`<span class="noApp-pipe">&#124;</span>`}`: html``}</p>
161
- <p class="contact-list">${this.contactAppointmentUrl ? html`${this.svgIcon.calendar} <a class="info" href="${this.contactAppointmentUrl ? this.contactAppointmentUrl:"#"}">Book an Appointment</a>`: html``}</p>
166
+ <div class="${this.sidebar ? 'side-bar':'container'}">
167
+ <div class="photo"><img src="${this.photo.link}" alt="${this.photoAlt}"></div>
168
+ <div class="text_container">
169
+ <h3 class="name"><a class="name" href="${this.link}">${this.nameFirst} ${this.nameLast}</a></h3>
170
+ <p class="title">${this.positionTitle} <span class="pipe">&#124;</span> ${this.department}</p>
171
+ <p class="contact-list">${this.contactPhone ? html`${this.svgIcon.phone} <a class="info" href="tel:${this.contactPhone}">${this.contactPhone}</a> <span class="pipe">&#124;</span>`: html``}</p>
172
+ <p class="contact-list">${this.contactEmail ? html`${this.svgIcon.email} <a class="info" href="mailto:${this.contactEmail}">${this.contactEmail}</a> ${this.contactAppointmentUrl ? html`<span class="pipe">&#124;</span>`:html`<span class="noApp-pipe">&#124;</span>`}`: html``}</p>
173
+ <p class="contact-list">${this.contactAppointmentUrl ? html`${this.svgIcon.calendar} <a class="info" href="${this.contactAppointmentUrl ? this.contactAppointmentUrl:"#"}">Book an Appointment</a>`: html``}</p>
174
+ </div>
162
175
  </div>
163
- </div>
164
176
  `
165
177
  :html`
166
178
  <div class="container-no-image">
@@ -92,7 +92,12 @@ export default class UcdlibBrandingBar extends Mixin(LitElement)
92
92
  */
93
93
  _onChildListMutation(){
94
94
  let navItems = this.parseNavChildren();
95
- if ( navItems.length ) this.navItems = navItems;
95
+ if ( navItems.length ) {
96
+ this.navItems = navItems;
97
+ } else {
98
+ this.navItems = [];
99
+ }
100
+ this.dispatchEvent(new CustomEvent('nav-update', {bubbles: true, composed: false}));
96
101
  }
97
102
 
98
103
  }
@@ -13,7 +13,7 @@ export function styles() {
13
13
  const elementStyles = css`
14
14
  :host {
15
15
  display: block;
16
- max-width: 500px;
16
+ max-width: 33rem;
17
17
  margin: auto;
18
18
  }
19
19
  h2 {
@@ -44,8 +44,9 @@ export function styles() {
44
44
  justify-content: space-between;
45
45
  }
46
46
  .search-options label {
47
- color: ${unsafeCSS(categoryBrands.primary.hex)};
47
+ font-weight: 700;
48
48
  padding-bottom: 0;
49
+ color: ${unsafeCSS(categoryBrands.primary.hex)};
49
50
  }
50
51
  input[type=checkbox] {
51
52
  margin-right: 0;
@@ -53,13 +54,15 @@ export function styles() {
53
54
  .search-options button {
54
55
  border: none;
55
56
  background-color: inherit;
56
- color: ${unsafeCSS(categoryBrands.primary.hex)};
57
+ font-weight: 700;
57
58
  text-decoration: underline;
58
59
  padding: 0;
59
60
  font-family: inherit;
61
+ color: ${unsafeCSS(categoryBrands.primary.hex)};
60
62
  }
61
63
  .checkbox label::before {
62
64
  background-color: white;
65
+ border: 1px solid rgb(153, 153, 153);
63
66
  }
64
67
  .dark h2 {
65
68
  color: ${unsafeCSS(categoryBrands.secondary.hex)}