@ucd-lib/theme-elements 2.0.1 → 2.1.1

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.
@@ -140,6 +140,11 @@ export default class UcdThemePagination extends LitElement {
140
140
  * @returns {HTML}
141
141
  */
142
142
  _renderLink(page, args={}) {
143
+ if( this.ellipses && typeof page === 'object' ) {
144
+ args.label = args.label || page.label || '';
145
+ page = page.page || 1;
146
+ }
147
+
143
148
  if( page < 1 ) page = 1;
144
149
  if( page > this.maxPages ) page = this.maxPages;
145
150
 
@@ -211,11 +216,11 @@ export default class UcdThemePagination extends LitElement {
211
216
  if ((this.currentPage <= endIndex - 4) && (this.currentPage >= startIndex + 4)){
212
217
  for( let i = startIndex; i < endIndex; i++ ) {
213
218
  if(i == 0) pages.push(i+1);
214
- else if (i == (startIndex + 1)) pages.push("...");
219
+ else if (i == (startIndex + 1)) pages.push({ page: this.currentPage - 3, label: '...' });
215
220
  else if (i > (startIndex + 1) && i < this.currentPage - 3) continue;
216
221
  else if (i >= (this.currentPage - 3) && i < (this.currentPage + 2)) pages.push(i+1);
217
222
  else if (i < 4 && i < this.currentPage + 2) continue;
218
- else if (i == (endIndex - 2)) pages.push("...");
223
+ else if (i == (endIndex - 2)) pages.push({ page: this.currentPage + 3, label: '...' });
219
224
  else if (i == endIndex - 1) pages.push(i+1);
220
225
  }
221
226
  } //Middle ellipses
@@ -223,14 +228,14 @@ export default class UcdThemePagination extends LitElement {
223
228
  for( let i = startIndex; i < endIndex; i++ ) {
224
229
  if (i == 0) pages.push(i+1);
225
230
  else if(i > 0 && i < (endIndex - 6)) continue;
226
- else if (i == (endIndex - 6)) pages.push("...");
231
+ else if (i == (endIndex - 6)) pages.push({ page: i+1, label: '...' });
227
232
  else pages.push(i+1);
228
233
  }
229
234
  } //Left ellipses
230
235
  else if(this.currentPage <= endIndex - 4){
231
236
  for( let i = startIndex; i < endIndex; i++ ) {
232
237
  if(i < 6) pages.push(i+1);
233
- else if (i == 6) pages.push("...");
238
+ else if (i == 6) pages.push({ page: i+1, label: '...' });
234
239
  else if (i > 6 && i < (endIndex - 2)) continue;
235
240
  else if (i == endIndex - 1) pages.push(i+1);
236
241
  }
@@ -6,7 +6,7 @@ import { MutationObserverController, WaitController } from '../../utils/controll
6
6
  /**
7
7
  * @class UcdThemeQuickLinks
8
8
  * @classdesc Component class for displaying a quick links nav
9
- *
9
+ *
10
10
  * Patternlab Url:
11
11
  * - http://dev.webstyleguide.ucdavis.edu/redesign/?p=molecules-quick-links
12
12
  * - http://dev.webstyleguide.ucdavis.edu/redesign/?p=molecules-quick-links-2-columns
@@ -16,6 +16,7 @@ import { MutationObserverController, WaitController } from '../../utils/controll
16
16
  * @property {String} styleModifiers - Apply alternate styles with a space-separated list.
17
17
  * @property {Boolean} opened - Menu is open
18
18
  * @property {Number} animationDuration - Length of animation when opening/closing menu
19
+ * @property {Boolean} useIcon - Show a custom icon next to the title
19
20
  */
20
21
  export default class UcdThemeQuickLinks extends LitElement {
21
22
 
@@ -25,6 +26,7 @@ export default class UcdThemeQuickLinks extends LitElement {
25
26
  styleModifiers: {type: String, attribute: "style-modifiers"},
26
27
  opened: {type: Boolean},
27
28
  animationDuration: {type: Number, attribute: "animation-duration"},
29
+ useIcon: {type: Boolean, attribute: "use-icon"},
28
30
  _links: {type: Array, state: true},
29
31
  _hasCustomIcons: {type: Boolean, state: true},
30
32
  _transitioning: {type: Boolean, state: true},
@@ -46,6 +48,7 @@ export default class UcdThemeQuickLinks extends LitElement {
46
48
  this.styleModifiers = "";
47
49
  this.opened = false;
48
50
  this.animationDuration = 300;
51
+ this.useIcon = false;
49
52
 
50
53
  this._links = [];
51
54
  this._classPrefix = "quick-links";
@@ -102,7 +105,7 @@ export default class UcdThemeQuickLinks extends LitElement {
102
105
  */
103
106
  ingestChildren(){
104
107
  // remove any slotted icons created from a previous render
105
- this.querySelectorAll('[slot]').forEach(ele => ele.remove());
108
+ this.querySelectorAll('slot:not([name="custom-icon"])').forEach(ele => ele.remove());
106
109
  this._hasCustomIcons = false;
107
110
 
108
111
  let links = [];
@@ -111,8 +114,8 @@ export default class UcdThemeQuickLinks extends LitElement {
111
114
  let link = {};
112
115
 
113
116
  // if first child exists, we assume it is an icon
114
- if (
115
- child.childElementCount > 0 &&
117
+ if (
118
+ child.childElementCount > 0 &&
116
119
  index < 3 &&
117
120
  child.children[0].tagName !== 'A'
118
121
  ){
@@ -157,7 +160,7 @@ export default class UcdThemeQuickLinks extends LitElement {
157
160
  * @method _onItemClick
158
161
  * @private
159
162
  * @description Attached to menu item links without an href
160
- * @param {Event} e
163
+ * @param {Event} e
161
164
  */
162
165
  _onItemClick(e){
163
166
  this._dispatchItemClick(e.target.index);
@@ -167,7 +170,7 @@ export default class UcdThemeQuickLinks extends LitElement {
167
170
  * @method _onItemKeyup
168
171
  * @private
169
172
  * @description Attached to menu item links without an href
170
- * @param {Event} e
173
+ * @param {Event} e
171
174
  */
172
175
  _onItemKeyup(e){
173
176
  if( e.which !== 13 ) return;
@@ -199,7 +202,7 @@ export default class UcdThemeQuickLinks extends LitElement {
199
202
  _getNavClasses(){
200
203
  let classes = {};
201
204
  classes[`${this._classPrefix}__menu`] = true;
202
-
205
+
203
206
  if ( this.styleModifiers ) {
204
207
  this.styleModifiers.split(" ").forEach(mod => {
205
208
  if (mod) classes[`${this._classPrefix}--${mod}`] = true;
@@ -265,4 +268,4 @@ export default class UcdThemeQuickLinks extends LitElement {
265
268
 
266
269
  }
267
270
 
268
- customElements.define('ucd-theme-quick-links', UcdThemeQuickLinks);
271
+ customElements.define('ucd-theme-quick-links', UcdThemeQuickLinks);
@@ -13,6 +13,9 @@ export function styles() {
13
13
  :host {
14
14
  display: block;
15
15
  }
16
+ [hidden] {
17
+ display: none !important;
18
+ }
16
19
  .slot-parent {
17
20
  display: none;
18
21
  }
@@ -43,8 +46,44 @@ export function styles() {
43
46
  margin-right: .75rem;
44
47
  color: #13639e;
45
48
  font-size: .875em;
49
+ }
50
+
51
+ .quick-links__title.show-icon:after {
52
+ content: "";
53
+ }
54
+
55
+ .quick-links__title.show-icon .custom-icon {
56
+ display: flex;
57
+ align-items: center;
58
+ flex-wrap: wrap;
59
+ overflow: hidden;
60
+ width: 2.4375rem;
61
+ height: 2.4375rem;
62
+ padding: 0px;
63
+ border: 0px;
64
+ border-radius: 50%;
65
+ background-color: #ffbf00;
66
+ background-size: 50%;
67
+ color: rgb(255, 255, 255);
68
+ text-indent: inherit;
69
+ margin-left: .75rem;
70
+ }
71
+
72
+ .quick-links__title.show-icon .custom-icon ::slotted(svg) {
73
+ fill: white;
74
+ height: 65%;
75
+ width: 65%;
76
+ margin: 0 auto;
77
+ }
78
+
79
+ .quick-links__title.show-icon:hover .custom-icon, .quick-links__title.show-icon:focus .custom-icon {
80
+ background-color: #13639e;
81
+ }
82
+
83
+ .quick-links__title.show-icon {
84
+ padding-right: 0;
85
+ }
46
86
  }
47
- }
48
87
  `;
49
88
 
50
89
  return [
@@ -57,7 +96,7 @@ export function styles() {
57
96
  ];
58
97
  }
59
98
 
60
- export function render() {
99
+ export function render() {
61
100
  return html`
62
101
  ${this._hasCustomIcons ? html`
63
102
  <style>
@@ -81,17 +120,20 @@ return html`
81
120
  }
82
121
  </style>
83
122
  <div class="quick-links">
84
- <button
85
- class="quick-links__title"
123
+ <button
124
+ class="quick-links__title ${this.useIcon ? 'show-icon' : ''}"
86
125
  @click=${this._onBtnClick}
87
- aria-controls="quick-links"
88
- aria-expanded="${this.opened}"
126
+ aria-controls="quick-links"
127
+ aria-expanded="${this.opened}"
89
128
  aria-label="Toggle ${this.title} Menu">
90
129
  ${this.title}<span class="submenu-toggle ${this.opened ? 'submenu-toggle--open' : ''}"><span class="submenu-toggle__icon">+</span></span>
130
+ <div class="custom-icon" ?hidden="${!this.useIcon}">
131
+ <slot name="custom-icon"></slot>
132
+ </div>
91
133
  </button>
92
- <nav
93
- id="quick-links"
94
- class=${classMap(this._getNavClasses())}
134
+ <nav
135
+ id="quick-links"
136
+ class=${classMap(this._getNavClasses())}
95
137
  style=${styleMap(this._getNavStyles())}
96
138
  aria-label="Quick Links Menu">
97
139
  <ul class="menu" id="menu">
@@ -100,8 +142,8 @@ return html`
100
142
  ${link.href ? html`
101
143
  <a href="${link.href}">${this._renderSlot(link)}${link.text}</a>
102
144
  ` : html`
103
- <a
104
- class="click-attached"
145
+ <a
146
+ class="click-attached"
105
147
  tabindex="0"
106
148
  @click=${this._onItemClick}
107
149
  @keyup=${this._onItemKeyup}
@@ -111,7 +153,7 @@ return html`
111
153
  `)}
112
154
  </ul>
113
155
  </nav>
114
-
156
+
115
157
  </div>
116
158
 
117
- `;}
159
+ `;}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ucd-lib/theme-elements",
3
- "version": "2.0.1",
3
+ "version": "2.1.1",
4
4
  "description": "Custom elements for the UCD brand theme",
5
5
  "main": "index.js",
6
6
  "scripts": {