@ucd-lib/theme-elements 3.3.1 → 3.4.0

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.
@@ -1,5 +1,5 @@
1
1
  import { LitElement, html } from 'lit';
2
- //import { Page } from 'puppeteer';
2
+ import {ifDefined} from 'lit/directives/if-defined.js';
3
3
  import {render, styles} from "./ucd-theme-pagination.tpl.js";
4
4
 
5
5
  import { BreakPointsController } from '../../utils/controllers';
@@ -160,8 +160,8 @@ export default class UcdThemePagination extends LitElement {
160
160
  if( !this.basePath && !this.useHash ) {
161
161
  return html `<li class="pager__item ${args.class || ''}">
162
162
  ${((this.currentPage == 1 && args.label == "Prev") || (this.currentPage == this.maxPages && args.label == "Next") ) ?
163
- html`<a style="pointer-events: none; cursor: default; color: ${this.darkmode ? '#cccccc' : '#999999'}; background: ${this.darkmode ? 'transparent' : 'white'}" tabindex="1" @click="${this._onPageClicked}" page="${page}">${args.label || page}</a>`:
164
- html`<a style="cursor:pointer;" tabindex="1" @click="${this._onPageClicked}" page="${page}">${args.label || page}</a>`
163
+ html`<button disabled style="cursor: default; color: ${this.darkmode ? '#cccccc' : '#999999'}; background: ${this.darkmode ? 'transparent' : 'white'}" page="${page}">${args.label || page}</button>`:
164
+ html`<a style="cursor:pointer;" tabindex="1" @click="${this._onPageClicked}" page="${page}" aria-label="${ifDefined(args.label === '...' ? 'More pages' : undefined)}">${args.label || page}</a>`
165
165
  }
166
166
  </li>`;
167
167
  }
@@ -169,8 +169,8 @@ export default class UcdThemePagination extends LitElement {
169
169
  let href = (this.useHash ? '#' : '') + (this.basePath || '/') + page + (this.queryParams ? '?' + this.queryParams : '');
170
170
  return html`<li class="pager__item ${args.class || ''}">
171
171
  ${((this.currentPage == 1 && args.label == "Prev") || (this.currentPage == this.maxPages && args.label == "Next") ) ?
172
- html` <a style="pointer-events: none; cursor: default; color: ${this.darkmode ? '#cccccc' : '#999999'}; background: ${this.darkmode ? 'transparent' : 'white'};" href="${href}">${args.label || page}</a>`:
173
- html` <a href="${href}">${args.label || page}</a>`
172
+ html` <button disabled style="cursor: default; color: ${this.darkmode ? '#cccccc' : '#999999'}; background: ${this.darkmode ? 'transparent' : 'white'};" href="${href}">${args.label || page}</button>`:
173
+ html` <a href="${href}" aria-label="${ifDefined(args.label === '...' ? 'More pages' : undefined)}">${args.label || page}</a>`
174
174
  }
175
175
  </li>`;
176
176
  }
@@ -62,6 +62,30 @@ export function styles() {
62
62
  .pager__item--next.pager__item--current.darkmode:hover a {
63
63
  color: #cccccc !important;
64
64
  }
65
+ .pager__item button {
66
+ all: unset;
67
+ cursor: pointer;
68
+ display: inline-flex;
69
+ align-items: center;
70
+ justify-content: center;
71
+ min-width: 2rem;
72
+ padding: 0.25rem 0.5rem;
73
+ color: rgb(76, 76, 76);
74
+ text-decoration: none;
75
+ transition: 0.2s ease-in-out;
76
+ }
77
+ .pager__item--previous button::before {
78
+ margin-right: 0.5rem;
79
+ content: '\\f30a';
80
+ font-family: "Font Awesome 5 Free";
81
+ font-weight: 900;
82
+ }
83
+ .pager__item--next button::after {
84
+ margin-left: 0.5rem;
85
+ content: '\\f30b';
86
+ font-family: "Font Awesome 5 Free";
87
+ font-weight: 900;
88
+ }
65
89
  `;
66
90
 
67
91
  return [normalizeCss, resetCss, paginationCss, elementStyles];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ucd-lib/theme-elements",
3
- "version": "3.3.1",
3
+ "version": "3.4.0",
4
4
  "description": "Custom elements for the UCD brand theme",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -38,7 +38,9 @@ export default class UcdlibRangeSlider extends LitElement {
38
38
  // colors for histogram
39
39
  lightColor: { type: String, attribute: 'light-color' },
40
40
  mediumColor: { type: String, attribute: 'medium-color' },
41
- darkColor: { type: String, attribute: 'dark-color' }
41
+ darkColor: { type: String, attribute: 'dark-color' },
42
+ initialMin: { type: Number },
43
+ initialMax: { type: Number }
42
44
  };
43
45
  }
44
46
 
@@ -71,6 +73,8 @@ export default class UcdlibRangeSlider extends LitElement {
71
73
  this.lightColor = '#CCE0F3';
72
74
  this.mediumColor = '#73ABDD';
73
75
  this.darkColor = '#13639E';
76
+ this.initialMin = null;
77
+ this.initialMax = null;
74
78
 
75
79
  // consts to build histogram
76
80
  this.gapPx = 2;
@@ -163,6 +167,12 @@ export default class UcdlibRangeSlider extends LitElement {
163
167
  if( !this.merged ) {
164
168
  this.min = this.absMin;
165
169
  this.max = this.absMax;
170
+ if( Number.isFinite(this.initialMin) ) {
171
+ this.min = Math.max(this.absMin, Math.min(this.initialMin, this.absMax));
172
+ }
173
+ if( Number.isFinite(this.initialMax) ) {
174
+ this.max = Math.max(this.min, Math.min(this.initialMax, this.absMax));
175
+ }
166
176
  }
167
177
 
168
178
  if( this.data?.length < 5 ) return this.hideHistogram = true;
@@ -236,6 +246,9 @@ export default class UcdlibRangeSlider extends LitElement {
236
246
  this.numBins = (this.mergedData.length || this.data.length);
237
247
 
238
248
  this._updateHistogramColors();
249
+
250
+ this.initialMin = null;
251
+ this.initialMax = null;
239
252
  }
240
253
 
241
254
  /**
@@ -461,6 +474,22 @@ export default class UcdlibRangeSlider extends LitElement {
461
474
  );
462
475
  }
463
476
 
477
+ /**
478
+ * @method refresh
479
+ * @description public method to refresh histogram bins and layout after data/size changes
480
+ * @param {Boolean} forceRecalc force recalculation of merged bins
481
+ */
482
+ refresh(forceRecalc = false) {
483
+ // Reset render guard to allow full recalculation
484
+ this.hasRendered = false;
485
+
486
+ // Trigger resize logic to recalculate dimensions and bins
487
+ this._onResize(null, forceRecalc);
488
+
489
+ // Request update and wait for render
490
+ this.requestUpdate();
491
+ }
492
+
464
493
  /**
465
494
  * @method reset
466
495
  * @description reset range filter