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