@internetarchive/collection-browser 4.1.0-alpha-webdev8186.4 → 4.1.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.
@@ -62,35 +62,35 @@ let SortFilterBar = class SortFilterBar extends LitElement {
62
62
  };
63
63
  }
64
64
  render() {
65
- return html `
66
- <div id="container">
67
- <section id="sort-bar" aria-label="Sorting options">
68
- <slot name="sort-options-left"></slot>
69
- <div id="sort-options">
65
+ return html `
66
+ <div id="container">
67
+ <section id="sort-bar" aria-label="Sorting options">
68
+ <slot name="sort-options-left"></slot>
69
+ <div id="sort-options">
70
70
  ${!this.enableSortOptionsSlot
71
- ? html `
72
- <div class="sort-direction-container">
73
- ${this.sortDirectionSelectorTemplate}
74
- </div>
75
- <span class="sort-by-text">${msg('Sort by:')}</span>
76
- <div id="sort-selector-container">
77
- ${this.sortSelectorTemplate}
78
- </div>
71
+ ? html `
72
+ <div class="sort-direction-container">
73
+ ${this.sortDirectionSelectorTemplate}
74
+ </div>
75
+ <span class="sort-by-text">${msg('Sort by:')}</span>
76
+ <div id="sort-selector-container">
77
+ ${this.sortSelectorTemplate}
78
+ </div>
79
79
  `
80
- : html `<slot name="sort-options"></slot>`}
81
- </div>
82
- <slot name="sort-options-right"></slot>
83
-
80
+ : html `<slot name="sort-options"></slot>`}
81
+ </div>
82
+ <slot name="sort-options-right"></slot>
83
+
84
84
  ${this.suppressDisplayModes
85
85
  ? nothing
86
- : html `<div id="display-style-selector">
87
- ${this.displayOptionTemplate}
88
- </div>`}
89
- </section>
90
-
91
- ${this.dropdownBackdropVisible ? this.dropdownBackdrop : nothing}
92
- ${this.alphaBarTemplate}
93
- </div>
86
+ : html `<div id="display-style-selector">
87
+ ${this.displayOptionTemplate}
88
+ </div>`}
89
+ </section>
90
+
91
+ ${this.dropdownBackdropVisible ? this.dropdownBackdrop : nothing}
92
+ ${this.alphaBarTemplate}
93
+ </div>
94
94
  `;
95
95
  }
96
96
  willUpdate(changed) {
@@ -153,16 +153,16 @@ let SortFilterBar = class SortFilterBar extends LitElement {
153
153
  const buttonLabel = this.canChangeSortDirection
154
154
  ? msg(str `Change to ${oppositeSortDirectionReadable} sort`)
155
155
  : msg('Directions are not available for the current sort option');
156
- return html `
157
- <button
158
- class="sort-direction-selector"
159
- title=${buttonLabel}
160
- ?disabled=${!this.canChangeSortDirection}
161
- @click=${this.handleSortDirectionClicked}
162
- >
163
- <span class="sr-only">${buttonLabel}</span>
164
- ${this.sortDirectionIcon}
165
- </button>
156
+ return html `
157
+ <button
158
+ class="sort-direction-selector"
159
+ title=${buttonLabel}
160
+ ?disabled=${!this.canChangeSortDirection}
161
+ @click=${this.handleSortDirectionClicked}
162
+ >
163
+ <span class="sr-only">${buttonLabel}</span>
164
+ ${this.sortDirectionIcon}
165
+ </button>
166
166
  `;
167
167
  }
168
168
  /** Template to render the sort direction button's icon in the correct current state */
@@ -172,17 +172,17 @@ let SortFilterBar = class SortFilterBar extends LitElement {
172
172
  return html `<div class="sort-direction-icon">${sortDisabledIcon}</div>`;
173
173
  }
174
174
  // For all other sorts, show the ascending/descending direction
175
- return html `
176
- <div class="sort-direction-icon">
177
- ${this.finalizedSortDirection === 'asc' ? sortUpIcon : sortDownIcon}
178
- </div>
175
+ return html `
176
+ <div class="sort-direction-icon">
177
+ ${this.finalizedSortDirection === 'asc' ? sortUpIcon : sortDownIcon}
178
+ </div>
179
179
  `;
180
180
  }
181
181
  /** The template to render all the sort options in a single dropdown */
182
182
  get sortSelectorTemplate() {
183
183
  const displayedOptions = Object.values(SORT_OPTIONS).filter(opt => opt.shownInSortBar && this.sortFieldAvailability[opt.field]);
184
- return html `
185
- <div id="sort-dropdown-container">
184
+ return html `
185
+ <div id="sort-dropdown-container">
186
186
  ${this.getSortDropdown({
187
187
  displayName: SORT_OPTIONS[this.finalizedSortField].displayName,
188
188
  id: 'sort-dropdown',
@@ -194,8 +194,8 @@ let SortFilterBar = class SortFilterBar extends LitElement {
194
194
  this.dropdownBackdropVisible = this.sortOptionsDropdown.open;
195
195
  this.sortOptionsDropdown.classList.toggle('open', this.sortOptionsDropdown.open);
196
196
  },
197
- })}
198
- </div>
197
+ })}
198
+ </div>
199
199
  `;
200
200
  }
201
201
  /**
@@ -211,40 +211,37 @@ let SortFilterBar = class SortFilterBar extends LitElement {
211
211
  * @param options.onDropdownClick A handler for click events on the dropdown
212
212
  */
213
213
  getSortDropdown(options) {
214
- return html `
215
- <ia-dropdown
216
- id=${options.id}
217
- class=${options.selected ? 'selected' : ''}
218
- displayCaret
219
- closeOnSelect
220
- includeSelectedOption
221
- .openViaButton=${options.selected}
222
- .options=${options.dropdownOptions}
223
- .selectedOption=${options.selectedOption ?? ''}
224
- @optionSelected=${options.onOptionSelected ?? nothing}
225
- @click=${options.onDropdownClick ?? nothing}
226
- >
227
- <span
228
- class="dropdown-label"
229
- slot="dropdown-label"
230
- data-title=${options.displayName}
231
- >
232
- ${options.displayName}
233
- </span>
234
- </ia-dropdown>
214
+ return html `
215
+ <ia-dropdown
216
+ id=${options.id}
217
+ class=${options.selected ? 'selected' : ''}
218
+ displayCaret
219
+ closeOnSelect
220
+ includeSelectedOption
221
+ .openViaButton=${options.selected}
222
+ .options=${options.dropdownOptions}
223
+ .selectedOption=${options.selectedOption ?? ''}
224
+ @optionSelected=${options.onOptionSelected ?? nothing}
225
+ @click=${options.onDropdownClick ?? nothing}
226
+ >
227
+ <span
228
+ class="dropdown-label"
229
+ slot="dropdown-label"
230
+ data-title=${options.displayName}
231
+ >
232
+ ${options.displayName}
233
+ </span>
234
+ </ia-dropdown>
235
235
  `;
236
236
  }
237
237
  /** Generates a single dropdown option object for the given sort field */
238
238
  getDropdownOption(sortField) {
239
239
  return {
240
240
  id: sortField,
241
- selectedHandler: () => {
242
- this.selectDropdownSortField(sortField);
243
- },
244
- label: html `
245
- <span class="dropdown-option-label">
246
- ${SORT_OPTIONS[sortField].displayName}
247
- </span>
241
+ label: html `
242
+ <span class="dropdown-option-label">
243
+ ${SORT_OPTIONS[sortField].displayName}
244
+ </span>
248
245
  `,
249
246
  };
250
247
  }
@@ -266,48 +263,48 @@ let SortFilterBar = class SortFilterBar extends LitElement {
266
263
  /** Template for rendering the three display mode options */
267
264
  /** Added data-testid for Playwright testing * */
268
265
  get displayOptionTemplate() {
269
- return html `
270
- <ul>
271
- <li>
272
- <button
273
- id="grid-button"
266
+ return html `
267
+ <ul>
268
+ <li>
269
+ <button
270
+ id="grid-button"
274
271
  @click=${() => {
275
272
  this.displayMode = 'grid';
276
- }}
277
- class=${this.displayMode === 'grid' ? 'active' : ''}
278
- title="Tile view"
279
- data-testid="grid-button"
280
- >
281
- ${tileIcon}
282
- </button>
283
- </li>
284
- <li>
285
- <button
286
- id="list-detail-button"
273
+ }}
274
+ class=${this.displayMode === 'grid' ? 'active' : ''}
275
+ title="Tile view"
276
+ data-testid="grid-button"
277
+ >
278
+ ${tileIcon}
279
+ </button>
280
+ </li>
281
+ <li>
282
+ <button
283
+ id="list-detail-button"
287
284
  @click=${() => {
288
285
  this.displayMode = 'list-detail';
289
- }}
290
- class=${this.displayMode === 'list-detail' ? 'active' : ''}
291
- title="List view"
292
- data-testid="list-detail-button"
293
- >
294
- ${listIcon}
295
- </button>
296
- </li>
297
- <li>
298
- <button
299
- id="list-compact-button"
286
+ }}
287
+ class=${this.displayMode === 'list-detail' ? 'active' : ''}
288
+ title="List view"
289
+ data-testid="list-detail-button"
290
+ >
291
+ ${listIcon}
292
+ </button>
293
+ </li>
294
+ <li>
295
+ <button
296
+ id="list-compact-button"
300
297
  @click=${() => {
301
298
  this.displayMode = 'list-compact';
302
- }}
303
- class=${this.displayMode === 'list-compact' ? 'active' : ''}
304
- title="Compact list view"
305
- data-testid="list-compact-button"
306
- >
307
- ${compactIcon}
308
- </button>
309
- </li>
310
- </ul>
299
+ }}
300
+ class=${this.displayMode === 'list-compact' ? 'active' : ''}
301
+ title="Compact list view"
302
+ data-testid="list-compact-button"
303
+ >
304
+ ${compactIcon}
305
+ </button>
306
+ </li>
307
+ </ul>
311
308
  `;
312
309
  }
313
310
  /**
@@ -315,12 +312,12 @@ let SortFilterBar = class SortFilterBar extends LitElement {
315
312
  * dropdown menu while it is open.
316
313
  */
317
314
  get dropdownBackdrop() {
318
- return html `
319
- <div
320
- id="sort-selector-backdrop"
321
- @keyup=${this.closeDropdown}
322
- @click=${this.closeDropdown}
323
- ></div>
315
+ return html `
316
+ <div
317
+ id="sort-selector-backdrop"
318
+ @keyup=${this.closeDropdown}
319
+ @click=${this.closeDropdown}
320
+ ></div>
324
321
  `;
325
322
  }
326
323
  /** Closes the sorting dropdown component's menus */
@@ -331,11 +328,6 @@ let SortFilterBar = class SortFilterBar extends LitElement {
331
328
  this.sortOptionsDropdown.open = false;
332
329
  this.sortOptionsDropdown.classList.remove('open');
333
330
  }
334
- selectDropdownSortField(sortField) {
335
- // When a dropdown sort option is selected, we additionally need to clear the backdrop
336
- this.dropdownBackdropVisible = false;
337
- this.setSelectedSort(sortField);
338
- }
339
331
  setSortDirection(sortDirection) {
340
332
  this.sortDirection = sortDirection;
341
333
  this.emitSortChangedEvent();
@@ -389,19 +381,19 @@ let SortFilterBar = class SortFilterBar extends LitElement {
389
381
  return SORT_OPTIONS[this.finalizedSortField].canSetDirection;
390
382
  }
391
383
  get titleSelectorBar() {
392
- return html ` <alpha-bar
393
- .selectedLetter=${this.selectedTitleFilter}
394
- .letterCounts=${this.prefixFilterCountMap?.title}
395
- ariaLandmarkLabel="Filter by title letter"
396
- @letterChanged=${this.titleLetterChanged}
384
+ return html ` <alpha-bar
385
+ .selectedLetter=${this.selectedTitleFilter}
386
+ .letterCounts=${this.prefixFilterCountMap?.title}
387
+ ariaLandmarkLabel="Filter by title letter"
388
+ @letterChanged=${this.titleLetterChanged}
397
389
  ></alpha-bar>`;
398
390
  }
399
391
  get creatorSelectorBar() {
400
- return html ` <alpha-bar
401
- .selectedLetter=${this.selectedCreatorFilter}
402
- .letterCounts=${this.prefixFilterCountMap?.creator}
403
- ariaLandmarkLabel="Filter by creator letter"
404
- @letterChanged=${this.creatorLetterChanged}
392
+ return html ` <alpha-bar
393
+ .selectedLetter=${this.selectedCreatorFilter}
394
+ .letterCounts=${this.prefixFilterCountMap?.creator}
395
+ ariaLandmarkLabel="Filter by creator letter"
396
+ @letterChanged=${this.creatorLetterChanged}
405
397
  ></alpha-bar>`;
406
398
  }
407
399
  titleLetterChanged(e) {
@@ -443,166 +435,166 @@ let SortFilterBar = class SortFilterBar extends LitElement {
443
435
  const disabledIconColor = css `#bbbbbb`;
444
436
  return [
445
437
  srOnlyStyle,
446
- css `
447
- #container {
448
- position: relative;
449
- }
450
-
451
- #sort-bar {
452
- display: flex;
453
- justify-content: flex-start;
454
- align-items: center;
455
- padding-bottom: 1px;
456
- border-bottom: 1px solid #2c2c2c;
457
- font-size: 1.4rem;
458
- }
459
-
460
- #sort-options {
461
- display: flex;
462
- align-items: center;
463
- flex-grow: 1;
464
- }
465
-
466
- ul {
467
- list-style: none;
468
- display: flex;
469
- align-items: center;
470
- margin: 0;
471
- padding: 0;
472
- }
473
-
474
- li {
475
- padding: 0;
476
- }
477
-
478
- .sort-by-text {
479
- margin-right: 5px;
480
- font-weight: bold;
481
- white-space: nowrap;
482
- }
483
-
484
- .sort-direction-container {
485
- display: flex;
486
- align-self: stretch;
487
- flex: 0;
488
- margin: 0 3px;
489
- }
490
-
491
- .sort-direction-selector {
492
- display: flex;
493
- justify-content: center;
494
- width: 30px;
495
- margin: 0 5px 0 0;
496
- padding: 7px 8px;
497
- max-height: fit-content;
498
- border-radius: 5px;
499
- background: white;
500
- border: 1px solid rgb(25, 72, 128);
501
- appearance: none;
502
- cursor: pointer;
503
- }
504
-
505
- .sort-direction-selector:disabled {
506
- cursor: not-allowed;
507
- border-color: ${disabledIconColor};
508
- }
509
-
510
- .sort-direction-icon {
511
- display: flex;
512
- align-items: center;
513
- background: none;
514
- color: inherit;
515
- border: none;
516
- padding: 0;
517
- outline: inherit;
518
- width: 12px;
519
- height: 12px;
520
- }
521
-
522
- .sort-direction-icon > svg {
523
- flex: 1;
524
- }
525
-
526
- #sort-selector-container {
527
- flex: 1;
528
- display: flex;
529
- justify-content: flex-start;
530
- align-items: center;
531
- }
532
-
533
- #sort-dropdown-container {
534
- display: flex;
535
- justify-content: flex-start;
536
- align-items: center;
537
- }
538
-
539
- #sort-selector-backdrop {
540
- position: fixed;
541
- top: 0;
542
- left: 0;
543
- width: 100vw;
544
- height: 100vh;
545
- z-index: 1;
546
- background-color: transparent;
547
- }
548
-
549
- #display-style-selector {
550
- flex: 0;
551
- }
552
-
553
- #display-style-selector button {
554
- background: none;
555
- color: inherit;
556
- border: none;
557
- appearance: none;
558
- cursor: pointer;
559
- -webkit-appearance: none;
560
- fill: ${disabledIconColor};
561
- }
562
-
563
- #display-style-selector button.active {
564
- fill: var(--ia-theme-primary-text-color, #2c2c2c);
565
- }
566
-
567
- #display-style-selector button svg {
568
- width: 24px;
569
- height: 24px;
570
- }
571
-
572
- ia-dropdown {
573
- --dropdownTextColor: white;
574
- --dropdownOffsetTop: 0;
575
- --dropdownBorderTopWidth: 0;
576
- --dropdownBorderTopLeftRadius: 0;
577
- --dropdownBorderTopRightRadius: 0;
578
- --dropdownWhiteSpace: nowrap;
579
- --dropdownListZIndex: 2;
580
- --dropdownCaretColor: var(--ia-theme-primary-text-color, #2c2c2c);
581
- --dropdownSelectedTextColor: white;
582
- --dropdownSelectedBgColor: rgba(255, 255, 255, 0.3);
583
- --dropdownHoverBgColor: rgba(255, 255, 255, 0.3);
584
- --caretHeight: 9px;
585
- --caretWidth: 12px;
586
- --caretPadding: 0 5px 0 0;
587
- }
588
- ia-dropdown.selected .dropdown-label {
589
- font-weight: bold;
590
- }
591
- ia-dropdown.open {
592
- z-index: 2;
593
- }
594
-
595
- .dropdown-label {
596
- display: inline-block;
597
- height: 100%;
598
- padding-left: 5px;
599
- font-size: 1.4rem;
600
- font-family: var(--ia-theme-base-font-family);
601
- line-height: 2;
602
- color: var(--ia-theme-primary-text-color, #2c2c2c);
603
- white-space: nowrap;
604
- user-select: none;
605
- }
438
+ css `
439
+ #container {
440
+ position: relative;
441
+ }
442
+
443
+ #sort-bar {
444
+ display: flex;
445
+ justify-content: flex-start;
446
+ align-items: center;
447
+ padding-bottom: 1px;
448
+ border-bottom: 1px solid #2c2c2c;
449
+ font-size: 1.4rem;
450
+ }
451
+
452
+ #sort-options {
453
+ display: flex;
454
+ align-items: center;
455
+ flex-grow: 1;
456
+ }
457
+
458
+ ul {
459
+ list-style: none;
460
+ display: flex;
461
+ align-items: center;
462
+ margin: 0;
463
+ padding: 0;
464
+ }
465
+
466
+ li {
467
+ padding: 0;
468
+ }
469
+
470
+ .sort-by-text {
471
+ margin-right: 5px;
472
+ font-weight: bold;
473
+ white-space: nowrap;
474
+ }
475
+
476
+ .sort-direction-container {
477
+ display: flex;
478
+ align-self: stretch;
479
+ flex: 0;
480
+ margin: 0 3px;
481
+ }
482
+
483
+ .sort-direction-selector {
484
+ display: flex;
485
+ justify-content: center;
486
+ width: 30px;
487
+ margin: 0 5px 0 0;
488
+ padding: 7px 8px;
489
+ max-height: fit-content;
490
+ border-radius: 5px;
491
+ background: white;
492
+ border: 1px solid rgb(25, 72, 128);
493
+ appearance: none;
494
+ cursor: pointer;
495
+ }
496
+
497
+ .sort-direction-selector:disabled {
498
+ cursor: not-allowed;
499
+ border-color: ${disabledIconColor};
500
+ }
501
+
502
+ .sort-direction-icon {
503
+ display: flex;
504
+ align-items: center;
505
+ background: none;
506
+ color: inherit;
507
+ border: none;
508
+ padding: 0;
509
+ outline: inherit;
510
+ width: 12px;
511
+ height: 12px;
512
+ }
513
+
514
+ .sort-direction-icon > svg {
515
+ flex: 1;
516
+ }
517
+
518
+ #sort-selector-container {
519
+ flex: 1;
520
+ display: flex;
521
+ justify-content: flex-start;
522
+ align-items: center;
523
+ }
524
+
525
+ #sort-dropdown-container {
526
+ display: flex;
527
+ justify-content: flex-start;
528
+ align-items: center;
529
+ }
530
+
531
+ #sort-selector-backdrop {
532
+ position: fixed;
533
+ top: 0;
534
+ left: 0;
535
+ width: 100vw;
536
+ height: 100vh;
537
+ z-index: 1;
538
+ background-color: transparent;
539
+ }
540
+
541
+ #display-style-selector {
542
+ flex: 0;
543
+ }
544
+
545
+ #display-style-selector button {
546
+ background: none;
547
+ color: inherit;
548
+ border: none;
549
+ appearance: none;
550
+ cursor: pointer;
551
+ -webkit-appearance: none;
552
+ fill: ${disabledIconColor};
553
+ }
554
+
555
+ #display-style-selector button.active {
556
+ fill: var(--ia-theme-primary-text-color, #2c2c2c);
557
+ }
558
+
559
+ #display-style-selector button svg {
560
+ width: 24px;
561
+ height: 24px;
562
+ }
563
+
564
+ ia-dropdown {
565
+ --dropdownTextColor: white;
566
+ --dropdownOffsetTop: 0;
567
+ --dropdownBorderTopWidth: 0;
568
+ --dropdownBorderTopLeftRadius: 0;
569
+ --dropdownBorderTopRightRadius: 0;
570
+ --dropdownWhiteSpace: nowrap;
571
+ --dropdownListZIndex: 2;
572
+ --dropdownCaretColor: var(--ia-theme-primary-text-color, #2c2c2c);
573
+ --dropdownSelectedTextColor: white;
574
+ --dropdownSelectedBgColor: rgba(255, 255, 255, 0.3);
575
+ --dropdownHoverBgColor: rgba(255, 255, 255, 0.3);
576
+ --caretHeight: 9px;
577
+ --caretWidth: 12px;
578
+ --caretPadding: 0 5px 0 0;
579
+ }
580
+ ia-dropdown.selected .dropdown-label {
581
+ font-weight: bold;
582
+ }
583
+ ia-dropdown.open {
584
+ z-index: 2;
585
+ }
586
+
587
+ .dropdown-label {
588
+ display: inline-block;
589
+ height: 100%;
590
+ padding-left: 5px;
591
+ font-size: 1.4rem;
592
+ font-family: var(--ia-theme-base-font-family);
593
+ line-height: 2;
594
+ color: var(--ia-theme-primary-text-color, #2c2c2c);
595
+ white-space: nowrap;
596
+ user-select: none;
597
+ }
606
598
  `,
607
599
  ];
608
600
  }