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