@internetarchive/collection-browser 0.4.19 → 0.4.20

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.
Files changed (60) hide show
  1. package/dist/src/collection-browser.d.ts +8 -1
  2. package/dist/src/collection-browser.js +319 -291
  3. package/dist/src/collection-browser.js.map +1 -1
  4. package/dist/src/collection-facets/facets-template.js +2 -0
  5. package/dist/src/collection-facets/facets-template.js.map +1 -1
  6. package/dist/src/collection-facets/more-facets-content.js +63 -70
  7. package/dist/src/collection-facets/more-facets-content.js.map +1 -1
  8. package/dist/src/collection-facets/more-facets-pagination.js +49 -55
  9. package/dist/src/collection-facets/more-facets-pagination.js.map +1 -1
  10. package/dist/src/collection-facets/toggle-switch.js +46 -56
  11. package/dist/src/collection-facets/toggle-switch.js.map +1 -1
  12. package/dist/src/collection-facets.d.ts +1 -1
  13. package/dist/src/collection-facets.js +94 -84
  14. package/dist/src/collection-facets.js.map +1 -1
  15. package/dist/src/sort-filter-bar/alpha-bar.d.ts +2 -1
  16. package/dist/src/sort-filter-bar/alpha-bar.js +33 -25
  17. package/dist/src/sort-filter-bar/alpha-bar.js.map +1 -1
  18. package/dist/src/sort-filter-bar/sort-filter-bar.d.ts +1 -1
  19. package/dist/src/sort-filter-bar/sort-filter-bar.js +198 -186
  20. package/dist/src/sort-filter-bar/sort-filter-bar.js.map +1 -1
  21. package/dist/src/styles/sr-only.d.ts +1 -0
  22. package/dist/src/styles/sr-only.js +18 -0
  23. package/dist/src/styles/sr-only.js.map +1 -0
  24. package/dist/src/tiles/grid/account-tile.js +1 -1
  25. package/dist/src/tiles/grid/account-tile.js.map +1 -1
  26. package/dist/src/tiles/grid/collection-tile.js +2 -2
  27. package/dist/src/tiles/grid/collection-tile.js.map +1 -1
  28. package/dist/src/tiles/grid/item-tile.js +2 -2
  29. package/dist/src/tiles/grid/item-tile.js.map +1 -1
  30. package/dist/src/tiles/grid/styles/tile-grid-shared-styles.js +5 -15
  31. package/dist/src/tiles/grid/styles/tile-grid-shared-styles.js.map +1 -1
  32. package/dist/src/tiles/grid/tile-stats.js +58 -65
  33. package/dist/src/tiles/grid/tile-stats.js.map +1 -1
  34. package/dist/src/tiles/tile-dispatcher.js +3 -2
  35. package/dist/src/tiles/tile-dispatcher.js.map +1 -1
  36. package/dist/test/collection-facets.test.js +8 -5
  37. package/dist/test/collection-facets.test.js.map +1 -1
  38. package/dist/test/sort-filter-bar/alpha-bar.test.js +12 -12
  39. package/dist/test/sort-filter-bar/alpha-bar.test.js.map +1 -1
  40. package/dist/test/sort-filter-bar/sort-filter-bar.test.js +2 -2
  41. package/dist/test/sort-filter-bar/sort-filter-bar.test.js.map +1 -1
  42. package/package.json +3 -3
  43. package/src/collection-browser.ts +322 -293
  44. package/src/collection-facets/facets-template.ts +2 -0
  45. package/src/collection-facets/more-facets-content.ts +63 -70
  46. package/src/collection-facets/more-facets-pagination.ts +49 -55
  47. package/src/collection-facets/toggle-switch.ts +51 -61
  48. package/src/collection-facets.ts +96 -85
  49. package/src/sort-filter-bar/alpha-bar.ts +26 -18
  50. package/src/sort-filter-bar/sort-filter-bar.ts +200 -186
  51. package/src/styles/sr-only.ts +18 -0
  52. package/src/tiles/grid/account-tile.ts +1 -1
  53. package/src/tiles/grid/collection-tile.ts +2 -2
  54. package/src/tiles/grid/item-tile.ts +2 -2
  55. package/src/tiles/grid/styles/tile-grid-shared-styles.ts +5 -15
  56. package/src/tiles/grid/tile-stats.ts +66 -73
  57. package/src/tiles/tile-dispatcher.ts +1 -0
  58. package/test/collection-facets.test.ts +10 -2
  59. package/test/sort-filter-bar/alpha-bar.test.ts +16 -12
  60. package/test/sort-filter-bar/sort-filter-bar.test.ts +2 -2
@@ -5,6 +5,7 @@ import { favoriteFilledIcon } from '../../assets/img/icons/favorite-filled';
5
5
  import { reviewsIcon } from '../../assets/img/icons/reviews';
6
6
  import { uploadIcon } from '../../assets/img/icons/upload';
7
7
  import { viewsIcon } from '../../assets/img/icons/views';
8
+ import { srOnlyStyle } from '../../styles/sr-only';
8
9
 
9
10
  import { formatCount } from '../../utils/format-count';
10
11
 
@@ -78,78 +79,70 @@ export class TileStats extends LitElement {
78
79
  }
79
80
 
80
81
  static get styles(): CSSResultGroup {
81
- return css`
82
- mediatype-icon {
83
- --iconHeight: 25px;
84
- --iconWidth: 25px;
85
- }
86
-
87
- ul {
88
- all: unset; // unset all property values
89
- list-style-type: none; // remove default list-style
90
- }
91
-
92
- li {
93
- list-style-type: none; // remove default list-style
94
- }
95
-
96
- svg {
97
- height: 13px;
98
- width: 13px;
99
- display: block;
100
- margin: auto;
101
- pointer-events: none;
102
- }
103
-
104
- /* Make the reviews icon slightly smaller/lower, for even visual weight */
105
- .reviews svg {
106
- height: 11px;
107
- width: 11px;
108
- margin-top: 2px;
109
- }
110
-
111
- .item-stats {
112
- height: 30px;
113
- padding-left: 5px;
114
- padding-right: 5px;
115
- font-family: 'Helvetica Neue', ui-sans-serif, system-ui, sans-serif;
116
- text-align: center;
117
- }
118
-
119
- #stats-row {
120
- display: flex;
121
- justify-content: space-between;
122
- flex-wrap: wrap;
123
- width: 100%;
124
- padding-bottom: 5px;
125
- }
126
-
127
- .sr-only {
128
- position: absolute;
129
- width: 1px;
130
- height: 1px;
131
- padding: 0;
132
- margin: -1px;
133
- overflow: hidden;
134
- clip: rect(0, 0, 0, 0);
135
- border: 0;
136
- }
137
-
138
- .col {
139
- min-width: 15px;
140
- max-width: 25%;
141
- height: 25px;
142
- }
143
-
144
- .status-text {
145
- font-size: 14px;
146
- height: 15px;
147
- color: #2c2c2c;
148
- line-height: 17px;
149
- margin: auto;
150
- display: block;
151
- text-align: center;
152
- }
153
- `;
82
+ return [
83
+ srOnlyStyle,
84
+ css`
85
+ mediatype-icon {
86
+ --iconHeight: 25px;
87
+ --iconWidth: 25px;
88
+ }
89
+
90
+ ul {
91
+ all: unset; // unset all property values
92
+ list-style-type: none; // remove default list-style
93
+ }
94
+
95
+ li {
96
+ list-style-type: none; // remove default list-style
97
+ }
98
+
99
+ svg {
100
+ height: 13px;
101
+ width: 13px;
102
+ display: block;
103
+ margin: auto;
104
+ pointer-events: none;
105
+ }
106
+
107
+ /* Make the reviews icon slightly smaller/lower, for even visual weight */
108
+ .reviews svg {
109
+ height: 11px;
110
+ width: 11px;
111
+ margin-top: 2px;
112
+ }
113
+
114
+ .item-stats {
115
+ height: 30px;
116
+ padding-left: 5px;
117
+ padding-right: 5px;
118
+ font-family: 'Helvetica Neue', ui-sans-serif, system-ui, sans-serif;
119
+ text-align: center;
120
+ }
121
+
122
+ #stats-row {
123
+ display: flex;
124
+ justify-content: space-between;
125
+ flex-wrap: wrap;
126
+ width: 100%;
127
+ padding-bottom: 5px;
128
+ }
129
+
130
+ .col {
131
+ min-width: 15px;
132
+ max-width: 25%;
133
+ height: 25px;
134
+ }
135
+
136
+ .status-text {
137
+ font-size: 14px;
138
+ height: 15px;
139
+ color: #2c2c2c;
140
+ line-height: 17px;
141
+ margin: auto;
142
+ display: block;
143
+ text-align: center;
144
+ }
145
+ `,
146
+ ];
154
147
  }
155
148
  }
@@ -123,6 +123,7 @@ export class TileDispatcher
123
123
  return html`
124
124
  <a
125
125
  href="${this.linkTileHref}"
126
+ aria-label=${this.model?.title ?? 'Untitled item'}
126
127
  title=${this.shouldPrepareHoverPane
127
128
  ? nothing // Don't show title tooltips when we have the tile info popups
128
129
  : ifDefined(this.model?.title)}
@@ -119,8 +119,16 @@ describe('Collection Facets', () => {
119
119
  expect(facetGroups?.length).to.equal(1);
120
120
 
121
121
  const titleFacetGroup = facetGroups?.[0];
122
- const facetGroupHeader = titleFacetGroup?.querySelector('h1');
123
- expect(facetGroupHeader?.textContent?.trim()).to.equal('Subject');
122
+ const facetGroupHeader = titleFacetGroup?.querySelector('h3');
123
+ // Every facet group header has an invisible " filters" suffix for screen-readers
124
+ expect(
125
+ facetGroupHeader?.querySelector('span.sr-only')?.textContent?.trim()
126
+ ).to.equal('filters');
127
+ // Ignoring the screen-reader suffix, we should be left with only the readable, capitalized title
128
+ expect(
129
+ facetGroupHeader?.textContent?.trim().replace(/\s*filters$/, '')
130
+ ).to.equal('Subject');
131
+
124
132
  const titleFacetRow = titleFacetGroup
125
133
  ?.querySelector('facets-template')
126
134
  ?.shadowRoot?.querySelector('.facet-row');
@@ -14,30 +14,34 @@ describe('Alphabetical Filter Bar', () => {
14
14
  expect(letters?.length).to.equal(26);
15
15
  });
16
16
 
17
- it('renders letters with items as links', async () => {
17
+ it('renders letters with items as buttons', async () => {
18
18
  const el = await fixture<AlphaBar>(html`<alpha-bar></alpha-bar>`);
19
19
 
20
20
  el.letterCounts = { U: 10, X: 10 };
21
21
  await el.updateComplete;
22
22
 
23
- // Should have exactly two letter links
24
- const letterLinks = el.shadowRoot?.querySelectorAll('li > a[href]');
25
- expect(letterLinks?.length).to.equal(2);
26
- expect(letterLinks?.item(0).textContent?.trim()).to.equal('U');
27
- expect(letterLinks?.item(1).textContent?.trim()).to.equal('X');
23
+ // Should have exactly two letter buttons
24
+ const letterButtons = el.shadowRoot?.querySelectorAll(
25
+ 'li > button:not(:disabled)'
26
+ );
27
+ expect(letterButtons?.length).to.equal(2);
28
+ expect(letterButtons?.item(0).textContent?.trim()).to.equal('U');
29
+ expect(letterButtons?.item(1).textContent?.trim()).to.equal('X');
28
30
  });
29
31
 
30
- it('renders letters without items as uninteractive text', async () => {
32
+ it('renders letters without items as disabled buttons', async () => {
31
33
  const el = await fixture<AlphaBar>(html`<alpha-bar></alpha-bar>`);
32
34
 
33
35
  el.letterCounts = { U: 10, X: 10 };
34
36
  await el.updateComplete;
35
37
 
36
- // All but the two letters above should just be inert spans, not links
37
- const letterNonLinks = el.shadowRoot?.querySelectorAll('li > span');
38
- expect(letterNonLinks?.length).to.equal(24);
39
- expect(letterNonLinks?.item(0).textContent?.trim()).to.equal('A');
40
- expect(letterNonLinks?.item(23).textContent?.trim()).to.equal('Z');
38
+ // All but the two letters above should be disabled
39
+ const letterButtons = el.shadowRoot?.querySelectorAll(
40
+ 'li > button:disabled'
41
+ );
42
+ expect(letterButtons?.length).to.equal(24);
43
+ expect(letterButtons?.item(0).textContent?.trim()).to.equal('A');
44
+ expect(letterButtons?.item(23).textContent?.trim()).to.equal('Z');
41
45
  });
42
46
 
43
47
  it('renders the selected letter with the "selected" class', async () => {
@@ -456,7 +456,7 @@ describe('Sort/filter bar letter behavior', () => {
456
456
 
457
457
  const alphaBar = el.shadowRoot?.querySelector('alpha-bar');
458
458
  const letterLink = alphaBar?.shadowRoot?.querySelector(
459
- 'li > a[href]'
459
+ 'li > button:not(:disabled)'
460
460
  ) as HTMLAnchorElement;
461
461
  expect(letterLink?.textContent?.trim()).to.equal('T');
462
462
 
@@ -477,7 +477,7 @@ describe('Sort/filter bar letter behavior', () => {
477
477
 
478
478
  const alphaBar = el.shadowRoot?.querySelector('alpha-bar');
479
479
  const letterLink = alphaBar?.shadowRoot?.querySelector(
480
- 'li > a[href]'
480
+ 'li > button:not(:disabled)'
481
481
  ) as HTMLAnchorElement;
482
482
  expect(letterLink?.textContent?.trim()).to.equal('C');
483
483