@internetarchive/collection-browser 3.3.1 → 3.3.3

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 (84) hide show
  1. package/.editorconfig +29 -29
  2. package/.github/workflows/ci.yml +27 -27
  3. package/.github/workflows/gh-pages-main.yml +39 -39
  4. package/.github/workflows/npm-publish.yml +39 -39
  5. package/.github/workflows/pr-preview.yml +38 -38
  6. package/.husky/pre-commit +4 -4
  7. package/.prettierignore +1 -1
  8. package/LICENSE +661 -661
  9. package/README.md +83 -83
  10. package/dist/src/collection-browser.js +683 -683
  11. package/dist/src/collection-browser.js.map +1 -1
  12. package/dist/src/collection-facets/more-facets-content.js +118 -118
  13. package/dist/src/collection-facets/more-facets-content.js.map +1 -1
  14. package/dist/src/collection-facets.js +265 -266
  15. package/dist/src/collection-facets.js.map +1 -1
  16. package/dist/src/data-source/collection-browser-data-source.js.map +1 -1
  17. package/dist/src/data-source/collection-browser-query-state.js.map +1 -1
  18. package/dist/src/data-source/models.js.map +1 -1
  19. package/dist/src/tiles/base-tile-component.js.map +1 -1
  20. package/dist/src/tiles/grid/account-tile.js +36 -36
  21. package/dist/src/tiles/grid/account-tile.js.map +1 -1
  22. package/dist/src/tiles/grid/collection-tile.js +77 -77
  23. package/dist/src/tiles/grid/collection-tile.js.map +1 -1
  24. package/dist/src/tiles/grid/item-tile.js +137 -137
  25. package/dist/src/tiles/grid/item-tile.js.map +1 -1
  26. package/dist/src/tiles/hover/hover-pane-controller.d.ts +9 -1
  27. package/dist/src/tiles/hover/hover-pane-controller.js +105 -37
  28. package/dist/src/tiles/hover/hover-pane-controller.js.map +1 -1
  29. package/dist/src/tiles/hover/tile-hover-pane.d.ts +1 -0
  30. package/dist/src/tiles/hover/tile-hover-pane.js +115 -112
  31. package/dist/src/tiles/hover/tile-hover-pane.js.map +1 -1
  32. package/dist/src/tiles/list/tile-list-compact.js +99 -99
  33. package/dist/src/tiles/list/tile-list-compact.js.map +1 -1
  34. package/dist/src/tiles/list/tile-list.js +297 -297
  35. package/dist/src/tiles/list/tile-list.js.map +1 -1
  36. package/dist/src/tiles/tile-dispatcher.d.ts +4 -1
  37. package/dist/src/tiles/tile-dispatcher.js +231 -204
  38. package/dist/src/tiles/tile-dispatcher.js.map +1 -1
  39. package/dist/src/utils/format-date.js.map +1 -1
  40. package/dist/test/collection-browser.test.js +189 -189
  41. package/dist/test/collection-browser.test.js.map +1 -1
  42. package/dist/test/tiles/grid/item-tile.test.js +77 -77
  43. package/dist/test/tiles/grid/item-tile.test.js.map +1 -1
  44. package/dist/test/tiles/hover/hover-pane-controller.test.js +68 -21
  45. package/dist/test/tiles/hover/hover-pane-controller.test.js.map +1 -1
  46. package/dist/test/tiles/list/tile-list-compact.test.js +70 -70
  47. package/dist/test/tiles/list/tile-list-compact.test.js.map +1 -1
  48. package/dist/test/tiles/list/tile-list.test.js +126 -126
  49. package/dist/test/tiles/list/tile-list.test.js.map +1 -1
  50. package/dist/test/tiles/tile-dispatcher.test.js +130 -52
  51. package/dist/test/tiles/tile-dispatcher.test.js.map +1 -1
  52. package/dist/test/utils/format-date.test.js.map +1 -1
  53. package/eslint.config.mjs +53 -53
  54. package/index.html +24 -24
  55. package/local.archive.org.cert +86 -86
  56. package/local.archive.org.key +27 -27
  57. package/package.json +118 -117
  58. package/renovate.json +6 -6
  59. package/src/collection-browser.ts +2829 -2829
  60. package/src/collection-facets/more-facets-content.ts +639 -639
  61. package/src/collection-facets.ts +994 -995
  62. package/src/data-source/collection-browser-data-source.ts +1401 -1401
  63. package/src/data-source/collection-browser-query-state.ts +65 -65
  64. package/src/data-source/models.ts +43 -43
  65. package/src/tiles/base-tile-component.ts +65 -65
  66. package/src/tiles/grid/account-tile.ts +113 -113
  67. package/src/tiles/grid/collection-tile.ts +163 -163
  68. package/src/tiles/grid/item-tile.ts +340 -340
  69. package/src/tiles/hover/hover-pane-controller.ts +613 -517
  70. package/src/tiles/hover/tile-hover-pane.ts +184 -180
  71. package/src/tiles/list/tile-list-compact.ts +239 -239
  72. package/src/tiles/list/tile-list.ts +700 -700
  73. package/src/tiles/tile-dispatcher.ts +517 -490
  74. package/src/utils/format-date.ts +62 -62
  75. package/test/collection-browser.test.ts +2403 -2403
  76. package/test/tiles/grid/item-tile.test.ts +520 -520
  77. package/test/tiles/hover/hover-pane-controller.test.ts +418 -353
  78. package/test/tiles/list/tile-list-compact.test.ts +282 -282
  79. package/test/tiles/list/tile-list.test.ts +552 -552
  80. package/test/tiles/tile-dispatcher.test.ts +283 -187
  81. package/test/utils/format-date.test.ts +89 -89
  82. package/tsconfig.json +20 -20
  83. package/web-dev-server.config.mjs +30 -30
  84. package/web-test-runner.config.mjs +41 -41
@@ -1,180 +1,184 @@
1
- import type { SortParam } from '@internetarchive/search-service';
2
- import {
3
- css,
4
- CSSResultGroup,
5
- html,
6
- LitElement,
7
- nothing,
8
- TemplateResult,
9
- } from 'lit';
10
- import { customElement, property } from 'lit/decorators.js';
11
- import { suppressedCollections, type TileModel } from '../../models';
12
- import type { CollectionTitles } from '../../data-source/models';
13
- import '../list/tile-list';
14
-
15
- @customElement('tile-hover-pane')
16
- export class TileHoverPane extends LitElement {
17
- @property({ type: Object }) model?: TileModel;
18
-
19
- @property({ type: String }) baseNavigationUrl?: string;
20
-
21
- @property({ type: String }) baseImageUrl?: string;
22
-
23
- @property({ type: Boolean }) loggedIn: boolean = false;
24
-
25
- @property({ type: Boolean }) suppressBlurring: boolean = false;
26
-
27
- @property({ type: Object }) sortParam?: SortParam;
28
-
29
- @property({ type: Number }) mobileBreakpoint?: number;
30
-
31
- @property({ type: Number }) currentWidth?: number;
32
-
33
- @property({ type: Object })
34
- collectionTitles?: CollectionTitles;
35
-
36
- protected render(): TemplateResult {
37
- return html`
38
- <div id="container">
39
- ${this.headerTemplate}
40
- <div id="hover-tile-list">
41
- <tile-list
42
- .model=${this.model}
43
- .baseNavigationUrl=${this.baseNavigationUrl}
44
- .baseImageUrl=${this.baseImageUrl}
45
- .loggedIn=${this.loggedIn}
46
- .suppressBlurring=${this.suppressBlurring}
47
- .sortParam=${this.sortParam}
48
- .collectionTitles=${this.collectionTitles}
49
- .mobileBreakpoint=${this.mobileBreakpoint}
50
- .currentWidth=${this.currentWidth}
51
- ></tile-list>
52
- </div>
53
- </div>
54
- `;
55
- }
56
-
57
- private get headerTemplate(): TemplateResult | typeof nothing {
58
- // early return if item does't have parent collection
59
- if (this.model?.collections.length === 0) return nothing;
60
-
61
- let collectionTitle = '';
62
- let collectionIdentifier = '';
63
-
64
- for (const collection of this.model?.collections || []) {
65
- if (
66
- !suppressedCollections[collection] &&
67
- !collection.startsWith('fav-')
68
- ) {
69
- collectionTitle = this.collectionTitles?.get(collection) ?? collection;
70
- collectionIdentifier = collection;
71
- break;
72
- }
73
- }
74
-
75
- // sometimes item does have collections but they are in suppressed or favorite list,
76
- // let's not render that
77
- if (!collectionIdentifier) return nothing;
78
-
79
- return html`
80
- <div id="list-line-header">
81
- <a href="${this.baseNavigationUrl}/details/${collectionIdentifier}">
82
- <img
83
- src="${this.baseImageUrl}/services/img/${collectionIdentifier}"
84
- alt=""
85
- /><span>${collectionTitle}</span>
86
- </a>
87
- </div>
88
- `;
89
- }
90
-
91
- static get styles(): CSSResultGroup {
92
- const hoverPaneHeaderBGColor = css`var(--hoverPaneHeaderBGColor, #edf0ff)`;
93
- const iaLinkColor = css`var(--ia-theme-link-color, #4b64ff)`;
94
- const iaFontFamily = css`var(--ia-theme-base-font-family, "Helvetica Neue", Helvetica, Arial, sans-serif);`;
95
-
96
- return css`
97
- :host {
98
- margin: 0;
99
- border: 0;
100
- padding: 0;
101
- overflow: visible;
102
- color: inherit;
103
- background: none;
104
- visibility: hidden;
105
- opacity: 0;
106
- transform: translateY(8px);
107
- transition:
108
- opacity 0.1s ease-in,
109
- transform 0.1s ease-in;
110
- --image-width: auto;
111
- }
112
-
113
- :host(.visible) {
114
- visibility: visible;
115
- }
116
-
117
- :host(.fade-in) {
118
- opacity: 1;
119
- transform: translateY(0);
120
- }
121
-
122
- @media (prefers-reduced-motion: reduce) {
123
- :host {
124
- transition-duration: 0.001s !important; /* Imperceptibly fast */
125
- }
126
- }
127
-
128
- #container {
129
- width: max-content;
130
- max-width: min(45vw, 600px);
131
- border: 1px solid #ddd;
132
- border-radius: 4px;
133
- box-shadow: 4px 4px 8px 0 rgba(0, 0, 0, 0.8);
134
- background: white;
135
- }
136
-
137
- @media screen and (max-width: 600px) {
138
- #container {
139
- max-width: 80vw;
140
- }
141
- }
142
-
143
- /* main tile-list container */
144
- #hover-tile-list {
145
- padding: 10px;
146
- }
147
-
148
- /* header on hover panel to show collection icon and title */
149
- #list-line-header {
150
- background: ${hoverPaneHeaderBGColor};
151
- }
152
- #list-line-header a {
153
- display: flex;
154
- align-items: center;
155
- column-gap: 5px;
156
- height: 3.4rem;
157
- padding: 0 10px;
158
- border-radius: 4px 4px 0 0;
159
- width: fit-content;
160
- font-size: 1.4rem;
161
- color: ${iaLinkColor};
162
- font-family: ${iaFontFamily};
163
- text-decoration: none;
164
- width: auto;
165
- }
166
- #list-line-header a span {
167
- white-space: nowrap;
168
- overflow: hidden;
169
- text-overflow: ellipsis;
170
- }
171
- #list-line-header a:hover {
172
- text-decoration: underline;
173
- }
174
- #list-line-header a img {
175
- width: 30px;
176
- max-height: 30px;
177
- }
178
- `;
179
- }
180
- }
1
+ import type { SortParam } from '@internetarchive/search-service';
2
+ import {
3
+ css,
4
+ CSSResultGroup,
5
+ html,
6
+ LitElement,
7
+ nothing,
8
+ TemplateResult,
9
+ } from 'lit';
10
+ import { customElement, property } from 'lit/decorators.js';
11
+ import '@a11y/focus-trap';
12
+
13
+ import { suppressedCollections, type TileModel } from '../../models';
14
+ import type { CollectionTitles } from '../../data-source/models';
15
+ import '../list/tile-list';
16
+
17
+ @customElement('tile-hover-pane')
18
+ export class TileHoverPane extends LitElement {
19
+ @property({ type: Object }) model?: TileModel;
20
+
21
+ @property({ type: String }) baseNavigationUrl?: string;
22
+
23
+ @property({ type: String }) baseImageUrl?: string;
24
+
25
+ @property({ type: Boolean }) loggedIn: boolean = false;
26
+
27
+ @property({ type: Boolean }) suppressBlurring: boolean = false;
28
+
29
+ @property({ type: Object }) sortParam?: SortParam;
30
+
31
+ @property({ type: Number }) mobileBreakpoint?: number;
32
+
33
+ @property({ type: Number }) currentWidth?: number;
34
+
35
+ @property({ type: Object })
36
+ collectionTitles?: CollectionTitles;
37
+
38
+ protected render(): TemplateResult {
39
+ return html`
40
+ <div id="container">
41
+ <focus-trap>
42
+ ${this.headerTemplate}
43
+ <div id="hover-tile-list">
44
+ <tile-list
45
+ .model=${this.model}
46
+ .baseNavigationUrl=${this.baseNavigationUrl}
47
+ .baseImageUrl=${this.baseImageUrl}
48
+ .loggedIn=${this.loggedIn}
49
+ .suppressBlurring=${this.suppressBlurring}
50
+ .sortParam=${this.sortParam}
51
+ .collectionTitles=${this.collectionTitles}
52
+ .mobileBreakpoint=${this.mobileBreakpoint}
53
+ .currentWidth=${this.currentWidth}
54
+ ></tile-list>
55
+ </div>
56
+ </focus-trap>
57
+ </div>
58
+ `;
59
+ }
60
+
61
+ private get headerTemplate(): TemplateResult | typeof nothing {
62
+ // early return if item does't have parent collection
63
+ if (this.model?.collections?.length === 0) return nothing;
64
+
65
+ let collectionTitle = '';
66
+ let collectionIdentifier = '';
67
+
68
+ for (const collection of this.model?.collections || []) {
69
+ if (
70
+ !suppressedCollections[collection] &&
71
+ !collection.startsWith('fav-')
72
+ ) {
73
+ collectionTitle = this.collectionTitles?.get(collection) ?? collection;
74
+ collectionIdentifier = collection;
75
+ break;
76
+ }
77
+ }
78
+
79
+ // sometimes item does have collections but they are in suppressed or favorite list,
80
+ // let's not render that
81
+ if (!collectionIdentifier) return nothing;
82
+
83
+ return html`
84
+ <div id="list-line-header">
85
+ <a href="${this.baseNavigationUrl}/details/${collectionIdentifier}">
86
+ <img
87
+ src="${this.baseImageUrl}/services/img/${collectionIdentifier}"
88
+ alt=""
89
+ /><span>${collectionTitle}</span>
90
+ </a>
91
+ </div>
92
+ `;
93
+ }
94
+
95
+ static get styles(): CSSResultGroup {
96
+ const hoverPaneHeaderBGColor = css`var(--hoverPaneHeaderBGColor, #edf0ff)`;
97
+ const iaLinkColor = css`var(--ia-theme-link-color, #4b64ff)`;
98
+ const iaFontFamily = css`var(--ia-theme-base-font-family, "Helvetica Neue", Helvetica, Arial, sans-serif);`;
99
+
100
+ return css`
101
+ :host {
102
+ margin: 0;
103
+ border: 0;
104
+ padding: 0;
105
+ overflow: visible;
106
+ color: inherit;
107
+ background: none;
108
+ visibility: hidden;
109
+ opacity: 0;
110
+ transform: translateY(8px);
111
+ transition:
112
+ opacity 0.1s ease-in,
113
+ transform 0.1s ease-in;
114
+ --image-width: auto;
115
+ }
116
+
117
+ :host(.visible) {
118
+ visibility: visible;
119
+ }
120
+
121
+ :host(.fade-in) {
122
+ opacity: 1;
123
+ transform: translateY(0);
124
+ }
125
+
126
+ @media (prefers-reduced-motion: reduce) {
127
+ :host {
128
+ transition-duration: 0.001s !important; /* Imperceptibly fast */
129
+ }
130
+ }
131
+
132
+ #container {
133
+ width: max-content;
134
+ max-width: min(45vw, 600px);
135
+ border: 1px solid #ddd;
136
+ border-radius: 4px;
137
+ box-shadow: 4px 4px 8px 0 rgba(0, 0, 0, 0.8);
138
+ background: white;
139
+ }
140
+
141
+ @media screen and (max-width: 600px) {
142
+ #container {
143
+ max-width: 80vw;
144
+ }
145
+ }
146
+
147
+ /* main tile-list container */
148
+ #hover-tile-list {
149
+ padding: 10px;
150
+ }
151
+
152
+ /* header on hover panel to show collection icon and title */
153
+ #list-line-header {
154
+ background: ${hoverPaneHeaderBGColor};
155
+ }
156
+ #list-line-header a {
157
+ display: flex;
158
+ align-items: center;
159
+ column-gap: 5px;
160
+ height: 3.4rem;
161
+ padding: 0 10px;
162
+ border-radius: 4px 4px 0 0;
163
+ width: fit-content;
164
+ font-size: 1.4rem;
165
+ color: ${iaLinkColor};
166
+ font-family: ${iaFontFamily};
167
+ text-decoration: none;
168
+ width: auto;
169
+ }
170
+ #list-line-header a span {
171
+ white-space: nowrap;
172
+ overflow: hidden;
173
+ text-overflow: ellipsis;
174
+ }
175
+ #list-line-header a:hover {
176
+ text-decoration: underline;
177
+ }
178
+ #list-line-header a img {
179
+ width: 30px;
180
+ max-height: 30px;
181
+ }
182
+ `;
183
+ }
184
+ }