@ucd-lib/theme-elements 0.0.11 → 0.0.12

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.
@@ -17,6 +17,12 @@ export function styles() {
17
17
  .brand-textbox--collapsible .brand-textbox__button {
18
18
  display: block;
19
19
  }
20
+ ::slotted(*:last-child) {
21
+ margin-bottom: 0 !important;
22
+ }
23
+ ::slotted(blockquote) {
24
+ --category-brand-contrast-color: #fff !important;
25
+ }
20
26
  `;
21
27
 
22
28
  return [
@@ -17,6 +17,7 @@ import { MutationObserverController, WaitController } from '../../utils/controll
17
17
  *
18
18
  * @property {String} navTitle - Subnav header text
19
19
  * @property {String} titleHref - Link for subnav header (optional)
20
+ * @property {Boolean} titleClickEvent - If navTitle, will fire an event when clicked.
20
21
  *
21
22
  * @example
22
23
  * <ucd-theme-subnav nav-title="A subnav">
@@ -36,6 +37,7 @@ export default class UcdThemeSubnav extends Mixin(LitElement)
36
37
  return {
37
38
  navTitle: {type: String, attribute: "nav-title"},
38
39
  titleHref: {type: String, attribute: "title-href"},
40
+ titleClickEvent: {type: Boolean, attribute: 'title-click-event'},
39
41
  navItems: {type: Array},
40
42
  animationDuration: {type: Number, attribute: "animation-duration"}
41
43
  };
@@ -53,6 +55,7 @@ export default class UcdThemeSubnav extends Mixin(LitElement)
53
55
 
54
56
  this.navTitle = "";
55
57
  this.titleHref = "";
58
+ this.titleClickEvent = false;
56
59
  this.animationDuration = 300;
57
60
  }
58
61
 
@@ -140,6 +143,41 @@ export default class UcdThemeSubnav extends Mixin(LitElement)
140
143
  if ( navItems.length ) this.navItems = navItems;
141
144
  }
142
145
 
146
+ /**
147
+ * @method _dispatchItemClick
148
+ * @private
149
+ * @description Fires an 'item-click' event
150
+ * @param {Object} item - The link item
151
+ * @param {Array} location - The link location in links array
152
+ * @returns
153
+ */
154
+ _dispatchItemClick(item, location){
155
+ if (item.href) return;
156
+ const options = {
157
+ detail: {
158
+ linkText: item.linkText,
159
+ location
160
+ },
161
+ bubbles: true,
162
+ composed: true,
163
+ };
164
+ this.dispatchEvent(new CustomEvent('item-click', options));
165
+ }
166
+
167
+ /**
168
+ * @method _dispatchTitleClick
169
+ * @private
170
+ * @description fires a 'title-click' ecent
171
+ */
172
+ _dispatchTitleClick(){
173
+ if ( !this.titleClickEvent ) return;
174
+ const options = {
175
+ bubbles: true,
176
+ composed: true,
177
+ };
178
+ this.dispatchEvent(new CustomEvent('title-click', options));
179
+ }
180
+
143
181
  /**
144
182
  * @method _renderNavItem
145
183
  * @private
@@ -155,7 +193,7 @@ export default class UcdThemeSubnav extends Mixin(LitElement)
155
193
  return html`
156
194
  <li id="nav--${location.join("-")}">
157
195
  <div class="submenu-toggle__wrapper">
158
- <a href=${ifDefined(item.href ? item.href : null)}>${item.linkText}</a>
196
+ <a href=${ifDefined(item.href ? item.href : undefined)} @click=${() => this._dispatchItemClick(item, location)}>${item.linkText}</a>
159
197
  <button
160
198
  @click=${() => this._toggleItemMenu(location)}
161
199
  class="submenu-toggle ${item.isOpen ? "submenu-toggle--open" : ""}"
@@ -171,7 +209,7 @@ export default class UcdThemeSubnav extends Mixin(LitElement)
171
209
  `;
172
210
  }
173
211
  return html`
174
- <li id="nav--${location.join("-")}"><a href=${item.href}>${item.linkText}</a></li>
212
+ <li id="nav--${location.join("-")}"><a href=${ifDefined(item.href ? item.href : undefined)} @click=${() => this._dispatchItemClick(item, location)}>${item.linkText}</a></li>
175
213
  `;
176
214
  }
177
215
 
@@ -1,4 +1,5 @@
1
1
  import { html, css } from 'lit';
2
+ import { ifDefined } from 'lit/directives/if-defined.js';
2
3
 
3
4
  import normalizeStyles from "@ucd-lib/theme-sass/normalize.css.js";
4
5
  import headerStyles from "@ucd-lib/theme-sass/1_base_html/_headings.css.js";
@@ -25,6 +26,9 @@ export function styles() {
25
26
  ul.sub-nav__menu ul.is-open {
26
27
  display: block;
27
28
  }
29
+ a {
30
+ cursor: pointer;
31
+ }
28
32
  `;
29
33
 
30
34
  return [
@@ -48,8 +52,8 @@ export function render() {
48
52
  </style>
49
53
  <nav class="sub-nav">
50
54
  ${this.navTitle ? html`
51
- <h2 class="sub-nav__title${this.titleHref ? "-linked" : ""}">
52
- ${this.titleHref ? html`<a href=${this.titleHref}>${this.navTitle}</a>` : this.navTitle}
55
+ <h2 class="sub-nav__title${this.titleHref || this.titleClickEvent ? "-linked" : ""}">
56
+ ${this.titleHref || this.titleClickEvent ? html`<a href=${ifDefined(this.titleHref ? this.titleHref : undefined)} @click=${() => this._dispatchTitleClick()}>${this.navTitle}</a>` : this.navTitle}
53
57
  </h2>
54
58
  ` : html``}
55
59
  <ul class="sub-nav__menu">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ucd-lib/theme-elements",
3
- "version": "0.0.11",
3
+ "version": "0.0.12",
4
4
  "description": "Custom elements for the UCD brand theme",
5
5
  "main": "index.js",
6
6
  "scripts": {