@internetarchive/collection-browser 0.2.11 → 0.2.14-a1
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/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/src/assets/img/icons/login-required.d.ts +1 -0
- package/dist/src/assets/img/icons/login-required.js +30 -0
- package/dist/src/assets/img/icons/login-required.js.map +1 -0
- package/dist/src/collection-browser.d.ts +1 -1
- package/dist/src/collection-browser.js +15 -10
- package/dist/src/collection-browser.js.map +1 -1
- package/dist/src/collection-facets.d.ts +3 -3
- package/dist/src/collection-facets.js.map +1 -1
- package/dist/src/restoration-state-handler.d.ts +1 -1
- package/dist/src/restoration-state-handler.js.map +1 -1
- package/dist/src/sort-filter-bar/sort-filter-bar.d.ts +1 -1
- package/dist/src/sort-filter-bar/sort-filter-bar.js.map +1 -1
- package/dist/src/styles/item-image-styles.js +4 -3
- package/dist/src/styles/item-image-styles.js.map +1 -1
- package/dist/src/tiles/grid/account-tile.d.ts +1 -1
- package/dist/src/tiles/grid/account-tile.js.map +1 -1
- package/dist/src/tiles/grid/collection-tile.d.ts +1 -1
- package/dist/src/tiles/grid/collection-tile.js.map +1 -1
- package/dist/src/tiles/grid/item-tile.d.ts +9 -4
- package/dist/src/tiles/grid/item-tile.js +27 -18
- package/dist/src/tiles/grid/item-tile.js.map +1 -1
- package/dist/src/tiles/image-block.d.ts +17 -0
- package/dist/src/tiles/image-block.js +136 -0
- package/dist/src/tiles/image-block.js.map +1 -0
- package/dist/src/tiles/item-image.d.ts +1 -1
- package/dist/src/tiles/item-image.js +3 -2
- package/dist/src/tiles/item-image.js.map +1 -1
- package/dist/src/tiles/list/tile-list-compact-header.d.ts +2 -2
- package/dist/src/tiles/list/tile-list-compact-header.js.map +1 -1
- package/dist/src/tiles/list/tile-list-compact.d.ts +4 -4
- package/dist/src/tiles/list/tile-list-compact.js +29 -64
- package/dist/src/tiles/list/tile-list-compact.js.map +1 -1
- package/dist/src/tiles/list/tile-list.d.ts +6 -5
- package/dist/src/tiles/list/tile-list.js +19 -56
- package/dist/src/tiles/list/tile-list.js.map +1 -1
- package/dist/src/tiles/overlay/icon-overlay.d.ts +7 -0
- package/dist/src/tiles/overlay/icon-overlay.js +43 -0
- package/dist/src/tiles/overlay/icon-overlay.js.map +1 -0
- package/dist/src/tiles/overlay/text-overlay.d.ts +8 -0
- package/dist/src/tiles/overlay/text-overlay.js +57 -0
- package/dist/src/tiles/overlay/text-overlay.js.map +1 -0
- package/dist/src/tiles/tile-dispatcher.d.ts +3 -2
- package/dist/src/tiles/tile-dispatcher.js +15 -4
- package/dist/src/tiles/tile-dispatcher.js.map +1 -1
- package/dist/test/collection-browser.test.js.map +1 -1
- package/dist/test/empty-placeholder.test.js.map +1 -1
- package/dist/test/icon-overlay.test.d.ts +1 -0
- package/dist/test/icon-overlay.test.js +31 -0
- package/dist/test/icon-overlay.test.js.map +1 -0
- package/dist/test/item-image.test.d.ts +1 -0
- package/dist/test/item-image.test.js +73 -0
- package/dist/test/item-image.test.js.map +1 -0
- package/dist/test/mocks/mock-collection-name-cache.d.ts +1 -1
- package/dist/test/mocks/mock-collection-name-cache.js.map +1 -1
- package/dist/test/mocks/mock-search-responses.d.ts +1 -1
- package/dist/test/mocks/mock-search-responses.js.map +1 -1
- package/dist/test/mocks/mock-search-service.d.ts +2 -2
- package/dist/test/mocks/mock-search-service.js.map +1 -1
- package/dist/test/text-overlay.test.d.ts +1 -0
- package/dist/test/text-overlay.test.js +48 -0
- package/dist/test/text-overlay.test.js.map +1 -0
- package/dist/test/tile-stats.test.js.map +1 -1
- package/dist/test/tiles/grid/item-tile.test.js +3 -3
- package/dist/test/tiles/grid/item-tile.test.js.map +1 -1
- package/package.json +4 -3
- package/renovate.json +6 -0
- package/src/assets/img/icons/login-required.ts +30 -0
- package/src/collection-browser.ts +17 -12
- package/src/collection-facets.ts +3 -3
- package/src/restoration-state-handler.ts +1 -1
- package/src/sort-filter-bar/sort-filter-bar.ts +1 -1
- package/src/styles/item-image-styles.ts +4 -3
- package/src/tiles/grid/account-tile.ts +1 -1
- package/src/tiles/grid/collection-tile.ts +1 -1
- package/src/tiles/grid/item-tile.ts +24 -21
- package/src/tiles/image-block.ts +124 -0
- package/src/tiles/item-image.ts +4 -2
- package/src/tiles/list/tile-list-compact-header.ts +2 -2
- package/src/tiles/list/tile-list-compact.ts +21 -58
- package/src/tiles/list/tile-list.ts +22 -58
- package/src/tiles/overlay/icon-overlay.ts +34 -0
- package/src/tiles/overlay/text-overlay.ts +48 -0
- package/src/tiles/tile-dispatcher.ts +15 -6
- package/test/collection-browser.test.ts +1 -1
- package/test/empty-placeholder.test.ts +2 -1
- package/test/icon-overlay.test.ts +41 -0
- package/test/item-image.test.ts +82 -0
- package/test/mocks/mock-collection-name-cache.ts +1 -1
- package/test/mocks/mock-search-responses.ts +1 -1
- package/test/mocks/mock-search-service.ts +2 -2
- package/test/text-overlay.test.ts +57 -0
- package/test/tile-stats.test.ts +1 -1
- package/test/tiles/grid/item-tile.test.ts +3 -3
- package/tsconfig.json +3 -2
- package/types/dompurify.d.ts +1 -0
- package/dist/src/tiles/item-tile-image.d.ts +0 -15
- package/dist/src/tiles/item-tile-image.js +0 -68
- package/dist/src/tiles/item-tile-image.js.map +0 -1
- package/src/tiles/item-tile-image.ts +0 -61
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import { css, html, LitElement
|
|
2
|
-
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
1
|
+
import { css, html, LitElement } from 'lit';
|
|
3
2
|
import { customElement, property } from 'lit/decorators.js';
|
|
4
|
-
import { SortParam } from '@internetarchive/search-service';
|
|
5
3
|
import DOMPurify from 'dompurify';
|
|
4
|
+
import type { SortParam } from '@internetarchive/search-service';
|
|
5
|
+
import type { TileModel } from '../../models';
|
|
6
6
|
|
|
7
|
-
import { TileModel } from '../../models';
|
|
8
7
|
import { formatCount, NumberFormat } from '../../utils/format-count';
|
|
9
8
|
import { formatDate, DateFormat } from '../../utils/format-date';
|
|
10
9
|
import { accountLabel } from './account-label';
|
|
11
10
|
|
|
12
|
-
import '../
|
|
11
|
+
import '../image-block';
|
|
13
12
|
import '../mediatype-icon';
|
|
14
13
|
|
|
15
14
|
@customElement('tile-list-compact')
|
|
@@ -28,12 +27,19 @@ export class TileListCompact extends LitElement {
|
|
|
28
27
|
|
|
29
28
|
@property({ type: String }) baseImageUrl?: string;
|
|
30
29
|
|
|
30
|
+
@property({ type: Boolean }) loggedIn = false;
|
|
31
|
+
|
|
31
32
|
render() {
|
|
32
33
|
return html`
|
|
33
34
|
<div id="list-line" class="${this.classSize}">
|
|
34
|
-
<
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
<image-block
|
|
36
|
+
.model=${this.model}
|
|
37
|
+
.baseImageUrl=${this.baseImageUrl}
|
|
38
|
+
.isCompactTile=${true}
|
|
39
|
+
.isListTile=${true}
|
|
40
|
+
.viewSize=${this.classSize}
|
|
41
|
+
>
|
|
42
|
+
</image-block>
|
|
37
43
|
<div id="title">${DOMPurify.sanitize(this.model?.title ?? '')}</div>
|
|
38
44
|
<div id="creator">
|
|
39
45
|
${this.model?.mediatype === 'account'
|
|
@@ -55,22 +61,6 @@ export class TileListCompact extends LitElement {
|
|
|
55
61
|
`;
|
|
56
62
|
}
|
|
57
63
|
|
|
58
|
-
private get imageTemplate() {
|
|
59
|
-
if (!this.model?.identifier) {
|
|
60
|
-
return nothing;
|
|
61
|
-
}
|
|
62
|
-
return html`
|
|
63
|
-
<item-image
|
|
64
|
-
.model=${this.model}
|
|
65
|
-
.baseImageUrl=${this.baseImageUrl}
|
|
66
|
-
.isListTile=${true}
|
|
67
|
-
.isCompactTile=${true}
|
|
68
|
-
style="--imgHeight: 100%; --imgWidth: 100%"
|
|
69
|
-
>
|
|
70
|
-
</item-image>
|
|
71
|
-
`;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
64
|
/*
|
|
75
65
|
* TODO: fix field names to match model in src/collection-browser.ts
|
|
76
66
|
* private get dateSortSelector()
|
|
@@ -127,6 +117,8 @@ export class TileListCompact extends LitElement {
|
|
|
127
117
|
border-top: 1px solid #ddd;
|
|
128
118
|
align-items: center;
|
|
129
119
|
line-height: 20px;
|
|
120
|
+
padding-top: 5px;
|
|
121
|
+
padding-bottom: 5px;
|
|
130
122
|
}
|
|
131
123
|
|
|
132
124
|
#list-line.mobile {
|
|
@@ -141,40 +133,6 @@ export class TileListCompact extends LitElement {
|
|
|
141
133
|
text-decoration: underline;
|
|
142
134
|
}
|
|
143
135
|
|
|
144
|
-
/* fields */
|
|
145
|
-
#thumb {
|
|
146
|
-
object-fit: cover;
|
|
147
|
-
display: block;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
.mobile #thumb {
|
|
151
|
-
width: 30px;
|
|
152
|
-
height: 30px;
|
|
153
|
-
padding-top: 2px;
|
|
154
|
-
padding-bottom: 2px;
|
|
155
|
-
padding-left: 4px;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
.desktop #thumb {
|
|
159
|
-
width: 45px;
|
|
160
|
-
height: 45px;
|
|
161
|
-
padding-top: 5px;
|
|
162
|
-
padding-bottom: 5px;
|
|
163
|
-
padding-left: 6px;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
#thumb.collection {
|
|
167
|
-
--border-radius: 8px;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
.mobile #thumb.account {
|
|
171
|
-
--border-radius: 15px;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
.desktop #thumb.account {
|
|
175
|
-
--border-radius: 22.5px;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
136
|
#title {
|
|
179
137
|
color: #4b64ff;
|
|
180
138
|
text-decoration: none;
|
|
@@ -205,6 +163,11 @@ export class TileListCompact extends LitElement {
|
|
|
205
163
|
--iconHeight: 20px;
|
|
206
164
|
--iconWidth: 20px;
|
|
207
165
|
}
|
|
166
|
+
|
|
167
|
+
item-image {
|
|
168
|
+
--imgHeight: 100%;
|
|
169
|
+
--imgWidth: 100%;
|
|
170
|
+
}
|
|
208
171
|
`;
|
|
209
172
|
}
|
|
210
173
|
}
|
|
@@ -10,18 +10,18 @@ import { ifDefined } from 'lit/directives/if-defined.js';
|
|
|
10
10
|
import { join } from 'lit/directives/join.js';
|
|
11
11
|
import { map } from 'lit/directives/map.js';
|
|
12
12
|
import { customElement, property, state } from 'lit/decorators.js';
|
|
13
|
-
|
|
14
|
-
import { CollectionNameCacheInterface } from '@internetarchive/collection-name-cache';
|
|
15
|
-
import { SortParam } from '@internetarchive/search-service';
|
|
16
13
|
import DOMPurify from 'dompurify';
|
|
17
14
|
|
|
15
|
+
import type { CollectionNameCacheInterface } from '@internetarchive/collection-name-cache';
|
|
16
|
+
import type { SortParam } from '@internetarchive/search-service';
|
|
17
|
+
import type { TileModel } from '../../models';
|
|
18
|
+
|
|
18
19
|
import { dateLabel } from './date-label';
|
|
19
20
|
import { accountLabel } from './account-label';
|
|
20
|
-
import { TileModel } from '../../models';
|
|
21
21
|
import { formatCount, NumberFormat } from '../../utils/format-count';
|
|
22
22
|
import { formatDate, DateFormat } from '../../utils/format-date';
|
|
23
23
|
|
|
24
|
-
import '../
|
|
24
|
+
import '../image-block';
|
|
25
25
|
import '../mediatype-icon';
|
|
26
26
|
|
|
27
27
|
@customElement('tile-list')
|
|
@@ -45,6 +45,8 @@ export class TileList extends LitElement {
|
|
|
45
45
|
|
|
46
46
|
@property({ type: String }) baseImageUrl?: string;
|
|
47
47
|
|
|
48
|
+
@property({ type: Boolean }) loggedIn = false;
|
|
49
|
+
|
|
48
50
|
protected updated(changed: PropertyValues): void {
|
|
49
51
|
if (changed.has('model')) {
|
|
50
52
|
this.fetchCollectionNames();
|
|
@@ -90,11 +92,7 @@ export class TileList extends LitElement {
|
|
|
90
92
|
private get mobileTemplate() {
|
|
91
93
|
return html`
|
|
92
94
|
<div id="list-line-top">
|
|
93
|
-
<div id="list-line-left">
|
|
94
|
-
<div id="thumb" class="${ifDefined(this.model?.mediatype)}">
|
|
95
|
-
${this.imgTemplate}
|
|
96
|
-
</div>
|
|
97
|
-
</div>
|
|
95
|
+
<div id="list-line-left">${this.imageBlockTemplate}</div>
|
|
98
96
|
<div id="list-line-right">
|
|
99
97
|
<div id="title-line">
|
|
100
98
|
<div id="title">${this.titleTemplate}</div>
|
|
@@ -108,11 +106,7 @@ export class TileList extends LitElement {
|
|
|
108
106
|
|
|
109
107
|
private get desktopTemplate() {
|
|
110
108
|
return html`
|
|
111
|
-
<div id="list-line-left">
|
|
112
|
-
<div id="thumb" class="${ifDefined(this.model?.mediatype)}">
|
|
113
|
-
${this.imgTemplate}
|
|
114
|
-
</div>
|
|
115
|
-
</div>
|
|
109
|
+
<div id="list-line-left">${this.imageBlockTemplate}</div>
|
|
116
110
|
<div id="list-line-right">
|
|
117
111
|
<div id="title-line">
|
|
118
112
|
<div id="title">${this.titleTemplate}</div>
|
|
@@ -123,6 +117,19 @@ export class TileList extends LitElement {
|
|
|
123
117
|
`;
|
|
124
118
|
}
|
|
125
119
|
|
|
120
|
+
private get imageBlockTemplate() {
|
|
121
|
+
return html`
|
|
122
|
+
<image-block
|
|
123
|
+
.model=${this.model}
|
|
124
|
+
.baseImageUrl=${this.baseImageUrl}
|
|
125
|
+
.isCompactTile=${false}
|
|
126
|
+
.isListTile=${true}
|
|
127
|
+
.viewSize=${this.classSize}
|
|
128
|
+
>
|
|
129
|
+
</image-block>
|
|
130
|
+
`;
|
|
131
|
+
}
|
|
132
|
+
|
|
126
133
|
private get detailsTemplate() {
|
|
127
134
|
return html`
|
|
128
135
|
${this.itemLineTemplate} ${this.creatorTemplate}
|
|
@@ -138,21 +145,6 @@ export class TileList extends LitElement {
|
|
|
138
145
|
}
|
|
139
146
|
|
|
140
147
|
// Data templates
|
|
141
|
-
private get imgTemplate() {
|
|
142
|
-
if (!this.model?.identifier) {
|
|
143
|
-
return nothing;
|
|
144
|
-
}
|
|
145
|
-
return html`
|
|
146
|
-
<item-image
|
|
147
|
-
.model=${this.model}
|
|
148
|
-
.baseImageUrl=${this.baseImageUrl}
|
|
149
|
-
.isListTile=${true}
|
|
150
|
-
style="--imgHeight: 100%; --imgWidth: 100%"
|
|
151
|
-
>
|
|
152
|
-
</item-image>
|
|
153
|
-
`;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
148
|
private get iconRightTemplate() {
|
|
157
149
|
return html`
|
|
158
150
|
<div id="icon-right">
|
|
@@ -409,34 +401,6 @@ export class TileList extends LitElement {
|
|
|
409
401
|
}
|
|
410
402
|
|
|
411
403
|
/* fields */
|
|
412
|
-
|
|
413
|
-
#thumb img {
|
|
414
|
-
object-fit: cover;
|
|
415
|
-
display: block;
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
.mobile #thumb {
|
|
419
|
-
width: 90px;
|
|
420
|
-
height: 90px;
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
.desktop #thumb {
|
|
424
|
-
width: 100px;
|
|
425
|
-
height: 100px;
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
#thumb.collection {
|
|
429
|
-
--border-radius: 8px;
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
.mobile #thumb.account {
|
|
433
|
-
--border-radius: 45px;
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
.desktop #thumb.account {
|
|
437
|
-
--border-radius: 50px;
|
|
438
|
-
}
|
|
439
|
-
|
|
440
404
|
#icon-right {
|
|
441
405
|
width: 20px;
|
|
442
406
|
padding-top: 5px;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { css, CSSResultGroup, html, LitElement } from 'lit';
|
|
2
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
3
|
+
|
|
4
|
+
import { restrictedIcon } from '../../assets/img/icons/restricted';
|
|
5
|
+
import { loginRequiredIcon } from '../../assets/img/icons/login-required';
|
|
6
|
+
|
|
7
|
+
@customElement('icon-overlay')
|
|
8
|
+
export class IconOverlay extends LitElement {
|
|
9
|
+
@property({ type: Boolean }) loggedIn = false;
|
|
10
|
+
|
|
11
|
+
@property({ type: Boolean }) loginRequired = false;
|
|
12
|
+
|
|
13
|
+
render() {
|
|
14
|
+
if (this.loginRequired && !this.loggedIn) {
|
|
15
|
+
return html`${loginRequiredIcon} `;
|
|
16
|
+
}
|
|
17
|
+
return html`${restrictedIcon}`;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
static get styles(): CSSResultGroup {
|
|
21
|
+
return css`
|
|
22
|
+
:host {
|
|
23
|
+
position: absolute;
|
|
24
|
+
top: 50%;
|
|
25
|
+
left: 50%;
|
|
26
|
+
transform: translate(-50%, -50%);
|
|
27
|
+
-ms-transform: translate(-50%, -50%);
|
|
28
|
+
width: 50%;
|
|
29
|
+
height: 50%;
|
|
30
|
+
z-index: 2;
|
|
31
|
+
}
|
|
32
|
+
`;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { css, CSSResultGroup, html, LitElement } from 'lit';
|
|
2
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
3
|
+
|
|
4
|
+
@customElement('text-overlay')
|
|
5
|
+
export class TextOverlay extends LitElement {
|
|
6
|
+
@property({ type: Boolean }) loggedIn = false;
|
|
7
|
+
|
|
8
|
+
@property({ type: Boolean }) loginRequired = false;
|
|
9
|
+
|
|
10
|
+
render() {
|
|
11
|
+
return html` <div class="overlay no-preview">${this.textDisplay}</div> `;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
private get textDisplay() {
|
|
15
|
+
return this.loginRequired && !this.loggedIn
|
|
16
|
+
? 'Log in\nto view this item'
|
|
17
|
+
: 'Content may be inappropriate';
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
static get styles(): CSSResultGroup {
|
|
21
|
+
return css`
|
|
22
|
+
:host {
|
|
23
|
+
align-items: center;
|
|
24
|
+
display: flex;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.overlay {
|
|
28
|
+
border: 1px solid #2c2c2c;
|
|
29
|
+
border-radius: 1px;
|
|
30
|
+
position: absolute;
|
|
31
|
+
right: 0;
|
|
32
|
+
left: 0;
|
|
33
|
+
width: auto;
|
|
34
|
+
height: auto;
|
|
35
|
+
padding: 5px;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.no-preview {
|
|
39
|
+
background-color: #fffecb;
|
|
40
|
+
color: #2c2c2c;
|
|
41
|
+
font-size: 1.4rem;
|
|
42
|
+
line-height: 2rem;
|
|
43
|
+
text-align: center;
|
|
44
|
+
white-space: pre-wrap; // for the newline character
|
|
45
|
+
}
|
|
46
|
+
`;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { css, html, LitElement, nothing, PropertyValues } from 'lit';
|
|
2
2
|
import { customElement, property, query } from 'lit/decorators.js';
|
|
3
3
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
4
|
-
import {
|
|
4
|
+
import type {
|
|
5
5
|
SharedResizeObserverInterface,
|
|
6
6
|
SharedResizeObserverResizeHandlerInterface,
|
|
7
7
|
} from '@internetarchive/shared-resize-observer';
|
|
8
8
|
import type { CollectionNameCacheInterface } from '@internetarchive/collection-name-cache';
|
|
9
|
-
import { SortParam } from '@internetarchive/search-service';
|
|
9
|
+
import type { SortParam } from '@internetarchive/search-service';
|
|
10
10
|
import type { TileDisplayMode, TileModel } from '../models';
|
|
11
11
|
import './grid/collection-tile';
|
|
12
12
|
import './grid/item-tile';
|
|
@@ -43,6 +43,8 @@ export class TileDispatcher
|
|
|
43
43
|
|
|
44
44
|
@property({ type: String }) baseImageUrl?: string;
|
|
45
45
|
|
|
46
|
+
@property({ type: Boolean }) loggedIn = false;
|
|
47
|
+
|
|
46
48
|
render() {
|
|
47
49
|
return html`
|
|
48
50
|
<div id="container">
|
|
@@ -146,7 +148,8 @@ export class TileDispatcher
|
|
|
146
148
|
.model=${model}
|
|
147
149
|
.currentWidth=${currentWidth}
|
|
148
150
|
.currentHeight=${currentHeight}
|
|
149
|
-
|
|
151
|
+
>
|
|
152
|
+
</account-tile>`;
|
|
150
153
|
default:
|
|
151
154
|
return html`<item-tile
|
|
152
155
|
.model=${model}
|
|
@@ -155,7 +158,9 @@ export class TileDispatcher
|
|
|
155
158
|
.collectionNameCache=${this.collectionNameCache}
|
|
156
159
|
.baseImageUrl=${this.baseImageUrl}
|
|
157
160
|
.sortParam=${sortParam}
|
|
158
|
-
|
|
161
|
+
.loggedIn=${this.loggedIn}
|
|
162
|
+
>
|
|
163
|
+
</item-tile>`;
|
|
159
164
|
}
|
|
160
165
|
case 'list-compact':
|
|
161
166
|
return html`<tile-list-compact
|
|
@@ -166,7 +171,9 @@ export class TileDispatcher
|
|
|
166
171
|
.sortParam=${sortParam}
|
|
167
172
|
.mobileBreakpoint=${mobileBreakpoint}
|
|
168
173
|
.baseImageUrl=${this.baseImageUrl}
|
|
169
|
-
|
|
174
|
+
.loggedIn=${this.loggedIn}
|
|
175
|
+
>
|
|
176
|
+
</tile-list-compact>`;
|
|
170
177
|
case 'list-detail':
|
|
171
178
|
return html`<tile-list
|
|
172
179
|
.model=${model}
|
|
@@ -177,7 +184,9 @@ export class TileDispatcher
|
|
|
177
184
|
.sortParam=${sortParam}
|
|
178
185
|
.mobileBreakpoint=${mobileBreakpoint}
|
|
179
186
|
.baseImageUrl=${this.baseImageUrl}
|
|
180
|
-
|
|
187
|
+
.loggedIn=${this.loggedIn}
|
|
188
|
+
>
|
|
189
|
+
</tile-list>`;
|
|
181
190
|
default:
|
|
182
191
|
return nothing;
|
|
183
192
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable import/no-duplicates */
|
|
2
2
|
import { expect, fixture } from '@open-wc/testing';
|
|
3
3
|
import { html } from 'lit';
|
|
4
|
-
import { CollectionBrowser } from '../src/collection-browser';
|
|
4
|
+
import type { CollectionBrowser } from '../src/collection-browser';
|
|
5
5
|
import '../src/collection-browser';
|
|
6
6
|
import { MockSearchService } from './mocks/mock-search-service';
|
|
7
7
|
import { MockCollectionNameCache } from './mocks/mock-collection-name-cache';
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/* eslint-disable import/no-duplicates */
|
|
2
2
|
import { expect, fixture } from '@open-wc/testing';
|
|
3
3
|
import { html } from 'lit';
|
|
4
|
-
import { EmptyPlaceholder } from '../src/empty-placeholder';
|
|
5
4
|
import '../src/empty-placeholder';
|
|
6
5
|
|
|
6
|
+
import type { EmptyPlaceholder } from '../src/empty-placeholder';
|
|
7
|
+
|
|
7
8
|
describe('Empty Placeholder', () => {
|
|
8
9
|
it('should render with empty-query placeholder', async () => {
|
|
9
10
|
const el = await fixture<EmptyPlaceholder>(
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/* eslint-disable import/no-duplicates */
|
|
2
|
+
import { expect, fixture } from '@open-wc/testing';
|
|
3
|
+
import { html } from 'lit';
|
|
4
|
+
import type { IconOverlay } from '../src/tiles/overlay/icon-overlay';
|
|
5
|
+
|
|
6
|
+
import '../src/tiles/overlay/icon-overlay';
|
|
7
|
+
|
|
8
|
+
describe('Icon Overlay component', () => {
|
|
9
|
+
it('should render component if loggedIn required', async () => {
|
|
10
|
+
const el = await fixture<IconOverlay>(html`
|
|
11
|
+
<icon-overlay .loggedIn=${false} .loginRequired=${true}> </icon-overlay>
|
|
12
|
+
`);
|
|
13
|
+
|
|
14
|
+
const svgTitle = el.shadowRoot
|
|
15
|
+
?.querySelector('svg')
|
|
16
|
+
?.querySelector('title')?.textContent;
|
|
17
|
+
expect(svgTitle).to.equal('Log in to view this item');
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('should render component if content warning', async () => {
|
|
21
|
+
const el = await fixture<IconOverlay>(html`
|
|
22
|
+
<icon-overlay .loggedIn=${false} .loginRequired=${false}> </icon-overlay>
|
|
23
|
+
`);
|
|
24
|
+
|
|
25
|
+
const svgTitle = el.shadowRoot
|
|
26
|
+
?.querySelector('svg')
|
|
27
|
+
?.querySelector('title')?.textContent;
|
|
28
|
+
expect(svgTitle).to.equal('Content may be inappropriate');
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('should render component if content warning', async () => {
|
|
32
|
+
const el = await fixture<IconOverlay>(html`
|
|
33
|
+
<icon-overlay .loggedIn=${true} .loginRequired=${true}> </icon-overlay>
|
|
34
|
+
`);
|
|
35
|
+
|
|
36
|
+
const svgTitle = el.shadowRoot
|
|
37
|
+
?.querySelector('svg')
|
|
38
|
+
?.querySelector('title')?.textContent;
|
|
39
|
+
expect(svgTitle).to.equal('Content may be inappropriate');
|
|
40
|
+
});
|
|
41
|
+
});
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/* eslint-disable import/no-duplicates */
|
|
2
|
+
import { expect, fixture } from '@open-wc/testing';
|
|
3
|
+
import { html } from 'lit';
|
|
4
|
+
|
|
5
|
+
import type { TileModel } from '../src/models';
|
|
6
|
+
import type { ItemImage } from '../src/tiles/item-image';
|
|
7
|
+
|
|
8
|
+
import '../src/tiles/item-image';
|
|
9
|
+
|
|
10
|
+
const baseImageUrl = 'https://archive.org';
|
|
11
|
+
const testBookModel: TileModel = {
|
|
12
|
+
collections: [],
|
|
13
|
+
commentCount: 0,
|
|
14
|
+
creators: [],
|
|
15
|
+
favCount: 0,
|
|
16
|
+
identifier: '18730130BloomfieldRecordCompleteIssue',
|
|
17
|
+
itemCount: 0,
|
|
18
|
+
mediatype: 'texts',
|
|
19
|
+
subjects: [],
|
|
20
|
+
title: 'Sample Waveform',
|
|
21
|
+
viewCount: 0,
|
|
22
|
+
loginRequired: false,
|
|
23
|
+
contentWarning: false,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const testAudioModel: TileModel = {
|
|
27
|
+
collections: [],
|
|
28
|
+
commentCount: 0,
|
|
29
|
+
creators: [],
|
|
30
|
+
favCount: 0,
|
|
31
|
+
identifier: 'dwd2015-01-24',
|
|
32
|
+
itemCount: 0,
|
|
33
|
+
mediatype: 'audio',
|
|
34
|
+
subjects: [],
|
|
35
|
+
title: 'Sample Waveform',
|
|
36
|
+
viewCount: 0,
|
|
37
|
+
loginRequired: false,
|
|
38
|
+
contentWarning: false,
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
describe('ItemImage component', () => {
|
|
42
|
+
it('should render initial component', async () => {
|
|
43
|
+
const el = await fixture<ItemImage>(html`
|
|
44
|
+
<item-image
|
|
45
|
+
.isListTile=${false}
|
|
46
|
+
.isCompactTile=${false}
|
|
47
|
+
.model=${testBookModel}
|
|
48
|
+
.baseImageUrl=${baseImageUrl}
|
|
49
|
+
>
|
|
50
|
+
</item-image>
|
|
51
|
+
`);
|
|
52
|
+
|
|
53
|
+
const dropShadow = el.shadowRoot?.querySelector('.drop-shadow');
|
|
54
|
+
const imgClassName = dropShadow?.querySelector('img')?.className;
|
|
55
|
+
|
|
56
|
+
expect(dropShadow).to.exist;
|
|
57
|
+
expect(imgClassName).to.eql(' contain ');
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('should render component if mediatype is waveform', async () => {
|
|
61
|
+
const el = await fixture<ItemImage>(html`
|
|
62
|
+
<item-image
|
|
63
|
+
.isListTile=${false}
|
|
64
|
+
.isCompactTile=${false}
|
|
65
|
+
.model=${testAudioModel}
|
|
66
|
+
.baseImageUrl=${baseImageUrl}
|
|
67
|
+
>
|
|
68
|
+
</item-image>
|
|
69
|
+
`);
|
|
70
|
+
|
|
71
|
+
const dropShadow = el.shadowRoot?.querySelector('.drop-shadow');
|
|
72
|
+
const image = dropShadow?.querySelector('img');
|
|
73
|
+
expect(dropShadow).to.exist;
|
|
74
|
+
expect(image).to.exist;
|
|
75
|
+
|
|
76
|
+
// simulate image onLoad event check if image className is waveform
|
|
77
|
+
setTimeout(() => {
|
|
78
|
+
const imgClassName = image?.className;
|
|
79
|
+
expect(imgClassName).to.eql(' waveform ');
|
|
80
|
+
}, 1000);
|
|
81
|
+
});
|
|
82
|
+
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CollectionNameCacheInterface } from '@internetarchive/collection-name-cache';
|
|
1
|
+
import type { CollectionNameCacheInterface } from '@internetarchive/collection-name-cache';
|
|
2
2
|
|
|
3
3
|
export class MockCollectionNameCache implements CollectionNameCacheInterface {
|
|
4
4
|
collectionNamesRequested: string[] = [];
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/* eslint-disable import/no-duplicates */
|
|
2
|
+
import { expect, fixture } from '@open-wc/testing';
|
|
3
|
+
import { html } from 'lit';
|
|
4
|
+
import type { TextOverlay } from '../src/tiles/overlay/text-overlay';
|
|
5
|
+
|
|
6
|
+
import '../src/tiles/overlay/text-overlay';
|
|
7
|
+
|
|
8
|
+
describe('Text Overlay component', () => {
|
|
9
|
+
it('should render initial component', async () => {
|
|
10
|
+
const el = await fixture<TextOverlay>(html`<text-overlay></text-overlay>`);
|
|
11
|
+
|
|
12
|
+
const overlay = el.shadowRoot?.querySelector('.overlay');
|
|
13
|
+
const noPreview = el.shadowRoot?.querySelector('.no-preview');
|
|
14
|
+
|
|
15
|
+
expect(overlay).to.exist;
|
|
16
|
+
expect(noPreview).to.exist;
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('should render component if loggedIn required', async () => {
|
|
20
|
+
const el = await fixture<TextOverlay>(html`
|
|
21
|
+
<text-overlay .loggedIn=${false} .loginRequired=${true}> </text-overlay>
|
|
22
|
+
`);
|
|
23
|
+
|
|
24
|
+
const overlay = el.shadowRoot?.querySelector('.overlay');
|
|
25
|
+
const noPreview = el.shadowRoot?.querySelector('.no-preview');
|
|
26
|
+
|
|
27
|
+
expect(overlay).to.exist;
|
|
28
|
+
expect(noPreview).to.exist;
|
|
29
|
+
expect(noPreview?.textContent).to.equal('Log in\nto view this item');
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('should render component if content warning', async () => {
|
|
33
|
+
const el = await fixture<TextOverlay>(html`
|
|
34
|
+
<text-overlay .loggedIn=${false} .loginRequired=${false}> </text-overlay>
|
|
35
|
+
`);
|
|
36
|
+
|
|
37
|
+
const overlay = el.shadowRoot?.querySelector('.overlay');
|
|
38
|
+
const noPreview = el.shadowRoot?.querySelector('.no-preview');
|
|
39
|
+
|
|
40
|
+
expect(overlay).to.exist;
|
|
41
|
+
expect(noPreview).to.exist;
|
|
42
|
+
expect(noPreview?.textContent).to.equal('Content may be inappropriate');
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('should render component if content warning', async () => {
|
|
46
|
+
const el = await fixture<TextOverlay>(html`
|
|
47
|
+
<text-overlay .loggedIn=${true} .loginRequired=${true}> </text-overlay>
|
|
48
|
+
`);
|
|
49
|
+
|
|
50
|
+
const overlay = el.shadowRoot?.querySelector('.overlay');
|
|
51
|
+
const noPreview = el.shadowRoot?.querySelector('.no-preview');
|
|
52
|
+
|
|
53
|
+
expect(overlay).to.exist;
|
|
54
|
+
expect(noPreview).to.exist;
|
|
55
|
+
expect(noPreview?.textContent).to.equal('Content may be inappropriate');
|
|
56
|
+
});
|
|
57
|
+
});
|
package/test/tile-stats.test.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable import/no-duplicates */
|
|
2
2
|
import { expect, fixture } from '@open-wc/testing';
|
|
3
3
|
import { html } from 'lit';
|
|
4
|
-
import { TileStats } from '../src/tiles/grid/tile-stats';
|
|
4
|
+
import type { TileStats } from '../src/tiles/grid/tile-stats';
|
|
5
5
|
|
|
6
6
|
import '../src/tiles/grid/tile-stats';
|
|
7
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable import/no-duplicates */
|
|
2
2
|
import { expect, fixture } from '@open-wc/testing';
|
|
3
3
|
import { html } from 'lit';
|
|
4
|
-
import { ItemTile } from '../../../src/tiles/grid/item-tile';
|
|
4
|
+
import type { ItemTile } from '../../../src/tiles/grid/item-tile';
|
|
5
5
|
|
|
6
6
|
import '../../../src/tiles/grid/item-tile';
|
|
7
7
|
|
|
@@ -10,11 +10,11 @@ describe('Item Tile', () => {
|
|
|
10
10
|
const el = await fixture<ItemTile>(html`<item-tile></item-tile>`);
|
|
11
11
|
|
|
12
12
|
const itemInfo = el.shadowRoot?.querySelector('.item-info');
|
|
13
|
-
const itemImage = el.shadowRoot?.querySelector('item-image');
|
|
14
13
|
const itemTitle = el.shadowRoot?.querySelector('#title');
|
|
14
|
+
const imageBlock = el.shadowRoot?.querySelector('image-block');
|
|
15
15
|
|
|
16
16
|
expect(itemInfo).to.exist;
|
|
17
|
-
expect(
|
|
17
|
+
expect(imageBlock).to.exist;
|
|
18
18
|
expect(itemTitle).to.exist;
|
|
19
19
|
});
|
|
20
20
|
|
package/tsconfig.json
CHANGED
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
"sourceMap": true,
|
|
15
15
|
"inlineSources": true,
|
|
16
16
|
"rootDir": "./",
|
|
17
|
-
"declaration": true
|
|
17
|
+
"declaration": true,
|
|
18
|
+
"importsNotUsedAsValues": "error"
|
|
18
19
|
},
|
|
19
|
-
"include": ["src", "test", "index.ts"],
|
|
20
|
+
"include": ["src", "test", "index.ts", "types"],
|
|
20
21
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
declare module 'dompurify';
|