@internetarchive/collection-browser 2.22.1 → 3.0.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.
Files changed (71) 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.d.ts +1 -2
  11. package/dist/src/collection-browser.js +681 -687
  12. package/dist/src/collection-browser.js.map +1 -1
  13. package/dist/src/collection-facets/facet-row.js +130 -130
  14. package/dist/src/collection-facets/facet-row.js.map +1 -1
  15. package/dist/src/collection-facets/smart-facets/smart-facet-bar.js +75 -75
  16. package/dist/src/collection-facets/smart-facets/smart-facet-bar.js.map +1 -1
  17. package/dist/src/collection-facets.js +263 -263
  18. package/dist/src/collection-facets.js.map +1 -1
  19. package/dist/src/data-source/collection-browser-data-source.js.map +1 -1
  20. package/dist/src/data-source/collection-browser-query-state.js.map +1 -1
  21. package/dist/src/data-source/models.js.map +1 -1
  22. package/dist/src/models.js.map +1 -1
  23. package/dist/src/restoration-state-handler.js.map +1 -1
  24. package/dist/src/tiles/base-tile-component.js.map +1 -1
  25. package/dist/src/tiles/grid/item-tile.js +139 -139
  26. package/dist/src/tiles/grid/item-tile.js.map +1 -1
  27. package/dist/src/tiles/hover/hover-pane-controller.js +21 -21
  28. package/dist/src/tiles/hover/hover-pane-controller.js.map +1 -1
  29. package/dist/src/tiles/hover/tile-hover-pane.js +108 -108
  30. package/dist/src/tiles/hover/tile-hover-pane.js.map +1 -1
  31. package/dist/src/tiles/list/tile-list-compact-header.js +45 -45
  32. package/dist/src/tiles/list/tile-list-compact-header.js.map +1 -1
  33. package/dist/src/tiles/list/tile-list-compact.js +97 -97
  34. package/dist/src/tiles/list/tile-list-compact.js.map +1 -1
  35. package/dist/src/tiles/list/tile-list.js +289 -289
  36. package/dist/src/tiles/list/tile-list.js.map +1 -1
  37. package/dist/src/tiles/tile-dispatcher.js +200 -200
  38. package/dist/src/tiles/tile-dispatcher.js.map +1 -1
  39. package/dist/src/tiles/tile-display-value-provider.js.map +1 -1
  40. package/dist/test/collection-browser.test.js +183 -197
  41. package/dist/test/collection-browser.test.js.map +1 -1
  42. package/dist/test/restoration-state-handler.test.js.map +1 -1
  43. package/eslint.config.mjs +53 -53
  44. package/index.html +24 -24
  45. package/local.archive.org.cert +86 -86
  46. package/local.archive.org.key +27 -27
  47. package/package.json +117 -117
  48. package/renovate.json +6 -6
  49. package/src/collection-browser.ts +2775 -2779
  50. package/src/collection-facets/facet-row.ts +282 -282
  51. package/src/collection-facets/smart-facets/smart-facet-bar.ts +437 -437
  52. package/src/collection-facets.ts +990 -990
  53. package/src/data-source/collection-browser-data-source.ts +1390 -1390
  54. package/src/data-source/collection-browser-query-state.ts +63 -63
  55. package/src/data-source/models.ts +43 -43
  56. package/src/models.ts +870 -870
  57. package/src/restoration-state-handler.ts +544 -544
  58. package/src/tiles/base-tile-component.ts +53 -53
  59. package/src/tiles/grid/item-tile.ts +339 -339
  60. package/src/tiles/hover/hover-pane-controller.ts +517 -517
  61. package/src/tiles/hover/tile-hover-pane.ts +180 -180
  62. package/src/tiles/list/tile-list-compact-header.ts +86 -86
  63. package/src/tiles/list/tile-list-compact.ts +236 -236
  64. package/src/tiles/list/tile-list.ts +688 -688
  65. package/src/tiles/tile-dispatcher.ts +486 -486
  66. package/src/tiles/tile-display-value-provider.ts +124 -124
  67. package/test/collection-browser.test.ts +2340 -2359
  68. package/test/restoration-state-handler.test.ts +510 -510
  69. package/tsconfig.json +20 -20
  70. package/web-dev-server.config.mjs +30 -30
  71. package/web-test-runner.config.mjs +41 -41
@@ -1,339 +1,339 @@
1
- import { css, CSSResultGroup, html, nothing, TemplateResult } from 'lit';
2
- import { customElement, property } from 'lit/decorators.js';
3
- import { ifDefined } from 'lit/directives/if-defined.js';
4
- import { map } from 'lit/directives/map.js';
5
- import { classMap } from 'lit/directives/class-map.js';
6
- import { msg } from '@lit/localize';
7
-
8
- import type { SortParam } from '@internetarchive/search-service';
9
- import { DateFormat, formatDate } from '../../utils/format-date';
10
- import { isFirstMillisecondOfUTCYear } from '../../utils/local-date-from-utc';
11
- import { BaseTileComponent } from '../base-tile-component';
12
- import { baseTileStyles } from './styles/tile-grid-shared-styles';
13
-
14
- import '../image-block';
15
- import '../review-block';
16
- import '../text-snippet-block';
17
- import '../item-image';
18
- import '../tile-mediatype-icon';
19
- import './tile-stats';
20
- import { SimpleLayoutType } from '../models';
21
-
22
- @customElement('item-tile')
23
- export class ItemTile extends BaseTileComponent {
24
- /*
25
- * Reactive properties inherited from BaseTileComponent:
26
- * - model?: TileModel;
27
- * - currentWidth?: number;
28
- * - currentHeight?: number;
29
- * - baseNavigationUrl?: string;
30
- * - baseImageUrl?: string;
31
- * - collectionPagePath?: string;
32
- * - sortParam: SortParam | null = null;
33
- * - defaultSortParam: SortParam | null = null;
34
- * - creatorFilter?: string;
35
- * - mobileBreakpoint?: number;
36
- * - loggedIn = false;
37
- * - suppressBlurring = false;
38
- */
39
-
40
- @property({ type: Boolean }) showInfoButton = false;
41
-
42
- @property({ type: Boolean }) showTvClips = false;
43
-
44
- @property({ type: String }) simpleLayoutType: SimpleLayoutType = 'none';
45
-
46
- render() {
47
- const itemTitle = this.model?.title;
48
- const containerClasses = classMap({
49
- container: true,
50
- simple: this.simpleLayoutType !== 'none',
51
- 'stats-only': this.simpleLayoutType === 'stats-only',
52
- 'snippets-only': this.simpleLayoutType === 'snippets-only',
53
- });
54
-
55
- return html`
56
- <div class=${containerClasses}>
57
- ${this.infoButtonTemplate}
58
- <div class="tile-details">
59
- <div class="item-info">
60
- ${this.imageBlockTemplate}
61
-
62
- <div id="title">
63
- <h4 class="truncated" title=${ifDefined(itemTitle)}>
64
- ${itemTitle}
65
- </h4>
66
- </div>
67
-
68
- ${this.volumeIssueTemplate}
69
- ${this.isSortedByDate
70
- ? this.sortedDateInfoTemplate
71
- : this.creatorTemplate}
72
- ${this.webArchivesCaptureDatesTemplate} ${this.textSnippetsTemplate}
73
- ${this.reviewBlockTemplate}
74
- </div>
75
-
76
- ${this.tileStatsTemplate}
77
- </div>
78
- </div>
79
- `;
80
- }
81
-
82
- /**
83
- * Templates
84
- */
85
- private get creatorTemplate(): TemplateResult | typeof nothing {
86
- const displayedCreator =
87
- this.displayValueProvider.firstCreatorMatchingFilter;
88
- if (!displayedCreator) return nothing;
89
-
90
- return html`
91
- <div class="created-by">
92
- <span class="truncated" title=${displayedCreator}>
93
- by&nbsp;${displayedCreator}
94
- </span>
95
- </div>
96
- `;
97
- }
98
-
99
- private get imageBlockTemplate(): TemplateResult {
100
- return html`
101
- <image-block
102
- .model=${this.model}
103
- .baseImageUrl=${this.baseImageUrl}
104
- .loggedIn=${this.loggedIn}
105
- .suppressBlurring=${this.suppressBlurring}
106
- .isCompactTile=${false}
107
- .isListTile=${false}
108
- .viewSize=${'grid'}
109
- >
110
- </image-block>
111
- `;
112
- }
113
-
114
- private get sortedDateInfoTemplate() {
115
- let sortedValue;
116
- let format: DateFormat = 'long';
117
- switch (this.effectiveSort?.field) {
118
- case 'date': {
119
- const datePublished = this.model?.datePublished;
120
- sortedValue = { field: 'published', value: datePublished };
121
- if (isFirstMillisecondOfUTCYear(datePublished)) {
122
- format = 'year-only';
123
- }
124
- break;
125
- }
126
- case 'reviewdate':
127
- sortedValue = { field: 'reviewed', value: this.model?.dateReviewed };
128
- break;
129
- case 'addeddate':
130
- sortedValue = { field: 'added', value: this.model?.dateAdded };
131
- break;
132
- case 'publicdate':
133
- sortedValue = { field: 'archived', value: this.model?.dateArchived };
134
- break;
135
- default:
136
- break;
137
- }
138
-
139
- if (!sortedValue?.value) {
140
- return nothing;
141
- }
142
- return html`
143
- <div class="date-sorted-by truncated">
144
- <span>
145
- ${sortedValue?.field} ${formatDate(sortedValue?.value, format)}
146
- </span>
147
- </div>
148
- `;
149
- }
150
-
151
- private get infoButtonTemplate(): TemplateResult | typeof nothing {
152
- // &#9432; is an information icon
153
- return this.showInfoButton
154
- ? html`<button class="info-button" @click=${this.infoButtonPressed}>
155
- &#9432;
156
- <span class="sr-only">${msg('More info')}</span>
157
- </button>`
158
- : nothing;
159
- }
160
-
161
- private get reviewBlockTemplate(): TemplateResult | typeof nothing {
162
- if (!this.model?.review) return nothing;
163
-
164
- const { reviewtitle, reviewbody, stars } = this.model.review;
165
- return html`
166
- <review-block
167
- viewsize="grid"
168
- title=${ifDefined(reviewtitle)}
169
- body=${ifDefined(reviewbody)}
170
- starRating=${ifDefined(stars)}
171
- >
172
- </review-block>
173
- `;
174
- }
175
-
176
- private get textSnippetsTemplate(): TemplateResult | typeof nothing {
177
- if (!this.hasSnippets || this.simpleLayoutType === 'stats-only')
178
- return nothing;
179
-
180
- return html`
181
- <text-snippet-block viewsize="grid" .snippets=${this.model?.snippets}>
182
- </text-snippet-block>
183
- `;
184
- }
185
-
186
- private get volumeIssueTemplate(): TemplateResult | typeof nothing {
187
- if (!this.model?.volume || !this.model?.issue) return nothing;
188
-
189
- return html`
190
- <div class="volume-issue">
191
- <span class="truncated" title="volume|issue">
192
- Volume&nbsp;${this.model?.volume}, Issue&nbsp;${this.model?.issue}
193
- </span>
194
- </div>
195
- `;
196
- }
197
-
198
- private get webArchivesCaptureDatesTemplate():
199
- | TemplateResult
200
- | typeof nothing {
201
- if (!this.model?.captureDates || !this.model.title) return nothing;
202
-
203
- return html`
204
- <ul class="capture-dates">
205
- ${map(
206
- this.model.captureDates,
207
- date =>
208
- html`<li>
209
- ${this.displayValueProvider.webArchivesCaptureLink(
210
- this.model!.title,
211
- date,
212
- )}
213
- </li>`,
214
- )}
215
- </ul>
216
- `;
217
- }
218
-
219
- /**
220
- * Template for the stats row along the bottom of the tile.
221
- */
222
- private get tileStatsTemplate(): TemplateResult | typeof nothing {
223
- if (this.simpleLayoutType === 'snippets-only') return nothing;
224
-
225
- const effectiveSort = this.sortParam ?? this.defaultSortParam;
226
- const [viewCount, viewLabel] =
227
- effectiveSort?.field === 'week'
228
- ? [this.model?.weeklyViewCount, 'weekly views']
229
- : [this.model?.viewCount, 'all-time views'];
230
-
231
- return html`
232
- <tile-stats
233
- .model=${this.model}
234
- .mediatype=${this.model?.mediatype}
235
- .viewCount=${viewCount}
236
- .viewLabel=${viewLabel}
237
- .favCount=${this.model?.favCount}
238
- .commentCount=${this.model?.commentCount}
239
- .tvClipCount=${this.model?.tvClipCount}
240
- .showTvClips=${this.showTvClips}
241
- >
242
- </tile-stats>
243
- `;
244
- }
245
-
246
- private get isSortedByDate(): boolean {
247
- return ['date', 'reviewdate', 'addeddate', 'publicdate'].includes(
248
- this.effectiveSort?.field as string,
249
- );
250
- }
251
-
252
- /**
253
- * Returns the active sort param if one is set, or the default sort param otherwise.
254
- */
255
- private get effectiveSort(): SortParam | null {
256
- return this.sortParam ?? this.defaultSortParam;
257
- }
258
-
259
- private get hasSnippets(): boolean {
260
- return !!this.model?.snippets?.length;
261
- }
262
-
263
- private infoButtonPressed(e: PointerEvent): void {
264
- e.preventDefault();
265
- const event = new CustomEvent<{ x: number; y: number }>(
266
- 'infoButtonPressed',
267
- { detail: { x: e.clientX, y: e.clientY } },
268
- );
269
- this.dispatchEvent(event);
270
- }
271
-
272
- /**
273
- * CSS
274
- */
275
- static get styles(): CSSResultGroup {
276
- const tileBorderColor = css`var(--tileBorderColor, #dddddd)`;
277
-
278
- return [
279
- baseTileStyles,
280
- css`
281
- a:link {
282
- text-decoration: none;
283
- color: var(--ia-theme-link-color, #4b64ff);
284
- }
285
- a:hover {
286
- text-decoration: underline;
287
- }
288
-
289
- .container {
290
- border: 1px solid ${tileBorderColor};
291
- }
292
-
293
- .simple #title > .truncated {
294
- -webkit-line-clamp: 2;
295
- }
296
-
297
- .simple .created-by > .truncated,
298
- .simple .date-sorted-by > .truncated,
299
- .simple .volume-issue > .truncated {
300
- -webkit-line-clamp: 1;
301
- }
302
-
303
- .simple.snippets-only .item-info {
304
- padding-bottom: 5px;
305
- }
306
-
307
- .simple.snippets-only text-snippet-block {
308
- margin-top: auto; /* Force the snippets to the bottom of the tile */
309
- }
310
-
311
- .capture-dates {
312
- margin: 0;
313
- padding: 0 5px;
314
- list-style-type: none;
315
- }
316
-
317
- review-block,
318
- text-snippet-block {
319
- --containerLeftMargin: 5px;
320
- --containerTopMargin: 5px;
321
- }
322
-
323
- /**
324
- * iOS Safari long-press on tiles (to bring up hover pane)
325
- * gets messy without this
326
- */
327
- @media screen and (pointer: coarse) and (hover: none) {
328
- .container {
329
- -webkit-touch-callout: none;
330
- }
331
-
332
- .truncated {
333
- -webkit-touch-callout: default;
334
- }
335
- }
336
- `,
337
- ];
338
- }
339
- }
1
+ import { css, CSSResultGroup, html, nothing, TemplateResult } from 'lit';
2
+ import { customElement, property } from 'lit/decorators.js';
3
+ import { ifDefined } from 'lit/directives/if-defined.js';
4
+ import { map } from 'lit/directives/map.js';
5
+ import { classMap } from 'lit/directives/class-map.js';
6
+ import { msg } from '@lit/localize';
7
+
8
+ import type { SortParam } from '@internetarchive/search-service';
9
+ import { DateFormat, formatDate } from '../../utils/format-date';
10
+ import { isFirstMillisecondOfUTCYear } from '../../utils/local-date-from-utc';
11
+ import { BaseTileComponent } from '../base-tile-component';
12
+ import { baseTileStyles } from './styles/tile-grid-shared-styles';
13
+
14
+ import '../image-block';
15
+ import '../review-block';
16
+ import '../text-snippet-block';
17
+ import '../item-image';
18
+ import '../tile-mediatype-icon';
19
+ import './tile-stats';
20
+ import { SimpleLayoutType } from '../models';
21
+
22
+ @customElement('item-tile')
23
+ export class ItemTile extends BaseTileComponent {
24
+ /*
25
+ * Reactive properties inherited from BaseTileComponent:
26
+ * - model?: TileModel;
27
+ * - currentWidth?: number;
28
+ * - currentHeight?: number;
29
+ * - baseNavigationUrl?: string;
30
+ * - baseImageUrl?: string;
31
+ * - collectionPagePath?: string;
32
+ * - sortParam: SortParam | null = null;
33
+ * - defaultSortParam: SortParam | null = null;
34
+ * - creatorFilter?: string;
35
+ * - mobileBreakpoint?: number;
36
+ * - loggedIn = false;
37
+ * - suppressBlurring = false;
38
+ */
39
+
40
+ @property({ type: Boolean }) showInfoButton = false;
41
+
42
+ @property({ type: Boolean }) showTvClips = false;
43
+
44
+ @property({ type: String }) simpleLayoutType: SimpleLayoutType = 'none';
45
+
46
+ render() {
47
+ const itemTitle = this.model?.title;
48
+ const containerClasses = classMap({
49
+ container: true,
50
+ simple: this.simpleLayoutType !== 'none',
51
+ 'stats-only': this.simpleLayoutType === 'stats-only',
52
+ 'snippets-only': this.simpleLayoutType === 'snippets-only',
53
+ });
54
+
55
+ return html`
56
+ <div class=${containerClasses}>
57
+ ${this.infoButtonTemplate}
58
+ <div class="tile-details">
59
+ <div class="item-info">
60
+ ${this.imageBlockTemplate}
61
+
62
+ <div id="title">
63
+ <h4 class="truncated" title=${ifDefined(itemTitle)}>
64
+ ${itemTitle}
65
+ </h4>
66
+ </div>
67
+
68
+ ${this.volumeIssueTemplate}
69
+ ${this.isSortedByDate
70
+ ? this.sortedDateInfoTemplate
71
+ : this.creatorTemplate}
72
+ ${this.webArchivesCaptureDatesTemplate} ${this.textSnippetsTemplate}
73
+ ${this.reviewBlockTemplate}
74
+ </div>
75
+
76
+ ${this.tileStatsTemplate}
77
+ </div>
78
+ </div>
79
+ `;
80
+ }
81
+
82
+ /**
83
+ * Templates
84
+ */
85
+ private get creatorTemplate(): TemplateResult | typeof nothing {
86
+ const displayedCreator =
87
+ this.displayValueProvider.firstCreatorMatchingFilter;
88
+ if (!displayedCreator) return nothing;
89
+
90
+ return html`
91
+ <div class="created-by">
92
+ <span class="truncated" title=${displayedCreator}>
93
+ by&nbsp;${displayedCreator}
94
+ </span>
95
+ </div>
96
+ `;
97
+ }
98
+
99
+ private get imageBlockTemplate(): TemplateResult {
100
+ return html`
101
+ <image-block
102
+ .model=${this.model}
103
+ .baseImageUrl=${this.baseImageUrl}
104
+ .loggedIn=${this.loggedIn}
105
+ .suppressBlurring=${this.suppressBlurring}
106
+ .isCompactTile=${false}
107
+ .isListTile=${false}
108
+ .viewSize=${'grid'}
109
+ >
110
+ </image-block>
111
+ `;
112
+ }
113
+
114
+ private get sortedDateInfoTemplate() {
115
+ let sortedValue;
116
+ let format: DateFormat = 'long';
117
+ switch (this.effectiveSort?.field) {
118
+ case 'date': {
119
+ const datePublished = this.model?.datePublished;
120
+ sortedValue = { field: 'published', value: datePublished };
121
+ if (isFirstMillisecondOfUTCYear(datePublished)) {
122
+ format = 'year-only';
123
+ }
124
+ break;
125
+ }
126
+ case 'reviewdate':
127
+ sortedValue = { field: 'reviewed', value: this.model?.dateReviewed };
128
+ break;
129
+ case 'addeddate':
130
+ sortedValue = { field: 'added', value: this.model?.dateAdded };
131
+ break;
132
+ case 'publicdate':
133
+ sortedValue = { field: 'archived', value: this.model?.dateArchived };
134
+ break;
135
+ default:
136
+ break;
137
+ }
138
+
139
+ if (!sortedValue?.value) {
140
+ return nothing;
141
+ }
142
+ return html`
143
+ <div class="date-sorted-by truncated">
144
+ <span>
145
+ ${sortedValue?.field} ${formatDate(sortedValue?.value, format)}
146
+ </span>
147
+ </div>
148
+ `;
149
+ }
150
+
151
+ private get infoButtonTemplate(): TemplateResult | typeof nothing {
152
+ // &#9432; is an information icon
153
+ return this.showInfoButton
154
+ ? html`<button class="info-button" @click=${this.infoButtonPressed}>
155
+ &#9432;
156
+ <span class="sr-only">${msg('More info')}</span>
157
+ </button>`
158
+ : nothing;
159
+ }
160
+
161
+ private get reviewBlockTemplate(): TemplateResult | typeof nothing {
162
+ if (!this.model?.review) return nothing;
163
+
164
+ const { reviewtitle, reviewbody, stars } = this.model.review;
165
+ return html`
166
+ <review-block
167
+ viewsize="grid"
168
+ title=${ifDefined(reviewtitle)}
169
+ body=${ifDefined(reviewbody)}
170
+ starRating=${ifDefined(stars)}
171
+ >
172
+ </review-block>
173
+ `;
174
+ }
175
+
176
+ private get textSnippetsTemplate(): TemplateResult | typeof nothing {
177
+ if (!this.hasSnippets || this.simpleLayoutType === 'stats-only')
178
+ return nothing;
179
+
180
+ return html`
181
+ <text-snippet-block viewsize="grid" .snippets=${this.model?.snippets}>
182
+ </text-snippet-block>
183
+ `;
184
+ }
185
+
186
+ private get volumeIssueTemplate(): TemplateResult | typeof nothing {
187
+ if (!this.model?.volume || !this.model?.issue) return nothing;
188
+
189
+ return html`
190
+ <div class="volume-issue">
191
+ <span class="truncated" title="volume|issue">
192
+ Volume&nbsp;${this.model?.volume}, Issue&nbsp;${this.model?.issue}
193
+ </span>
194
+ </div>
195
+ `;
196
+ }
197
+
198
+ private get webArchivesCaptureDatesTemplate():
199
+ | TemplateResult
200
+ | typeof nothing {
201
+ if (!this.model?.captureDates || !this.model.title) return nothing;
202
+
203
+ return html`
204
+ <ul class="capture-dates">
205
+ ${map(
206
+ this.model.captureDates,
207
+ date =>
208
+ html`<li>
209
+ ${this.displayValueProvider.webArchivesCaptureLink(
210
+ this.model!.title,
211
+ date,
212
+ )}
213
+ </li>`,
214
+ )}
215
+ </ul>
216
+ `;
217
+ }
218
+
219
+ /**
220
+ * Template for the stats row along the bottom of the tile.
221
+ */
222
+ private get tileStatsTemplate(): TemplateResult | typeof nothing {
223
+ if (this.simpleLayoutType === 'snippets-only') return nothing;
224
+
225
+ const effectiveSort = this.sortParam ?? this.defaultSortParam;
226
+ const [viewCount, viewLabel] =
227
+ effectiveSort?.field === 'week'
228
+ ? [this.model?.weeklyViewCount, 'weekly views']
229
+ : [this.model?.viewCount, 'all-time views'];
230
+
231
+ return html`
232
+ <tile-stats
233
+ .model=${this.model}
234
+ .mediatype=${this.model?.mediatype}
235
+ .viewCount=${viewCount}
236
+ .viewLabel=${viewLabel}
237
+ .favCount=${this.model?.favCount}
238
+ .commentCount=${this.model?.commentCount}
239
+ .tvClipCount=${this.model?.tvClipCount}
240
+ .showTvClips=${this.showTvClips}
241
+ >
242
+ </tile-stats>
243
+ `;
244
+ }
245
+
246
+ private get isSortedByDate(): boolean {
247
+ return ['date', 'reviewdate', 'addeddate', 'publicdate'].includes(
248
+ this.effectiveSort?.field as string,
249
+ );
250
+ }
251
+
252
+ /**
253
+ * Returns the active sort param if one is set, or the default sort param otherwise.
254
+ */
255
+ private get effectiveSort(): SortParam | null {
256
+ return this.sortParam ?? this.defaultSortParam;
257
+ }
258
+
259
+ private get hasSnippets(): boolean {
260
+ return !!this.model?.snippets?.length;
261
+ }
262
+
263
+ private infoButtonPressed(e: PointerEvent): void {
264
+ e.preventDefault();
265
+ const event = new CustomEvent<{ x: number; y: number }>(
266
+ 'infoButtonPressed',
267
+ { detail: { x: e.clientX, y: e.clientY } },
268
+ );
269
+ this.dispatchEvent(event);
270
+ }
271
+
272
+ /**
273
+ * CSS
274
+ */
275
+ static get styles(): CSSResultGroup {
276
+ const tileBorderColor = css`var(--tileBorderColor, #dddddd)`;
277
+
278
+ return [
279
+ baseTileStyles,
280
+ css`
281
+ a:link {
282
+ text-decoration: none;
283
+ color: var(--ia-theme-link-color, #4b64ff);
284
+ }
285
+ a:hover {
286
+ text-decoration: underline;
287
+ }
288
+
289
+ .container {
290
+ border: 1px solid ${tileBorderColor};
291
+ }
292
+
293
+ .simple #title > .truncated {
294
+ -webkit-line-clamp: 2;
295
+ }
296
+
297
+ .simple .created-by > .truncated,
298
+ .simple .date-sorted-by > .truncated,
299
+ .simple .volume-issue > .truncated {
300
+ -webkit-line-clamp: 1;
301
+ }
302
+
303
+ .simple.snippets-only .item-info {
304
+ padding-bottom: 5px;
305
+ }
306
+
307
+ .simple.snippets-only text-snippet-block {
308
+ margin-top: auto; /* Force the snippets to the bottom of the tile */
309
+ }
310
+
311
+ .capture-dates {
312
+ margin: 0;
313
+ padding: 0 5px;
314
+ list-style-type: none;
315
+ }
316
+
317
+ review-block,
318
+ text-snippet-block {
319
+ --containerLeftMargin: 5px;
320
+ --containerTopMargin: 5px;
321
+ }
322
+
323
+ /**
324
+ * iOS Safari long-press on tiles (to bring up hover pane)
325
+ * gets messy without this
326
+ */
327
+ @media screen and (pointer: coarse) and (hover: none) {
328
+ .container {
329
+ -webkit-touch-callout: none;
330
+ }
331
+
332
+ .truncated {
333
+ -webkit-touch-callout: default;
334
+ }
335
+ }
336
+ `,
337
+ ];
338
+ }
339
+ }