@internetarchive/collection-browser 0.2.10 → 0.2.13
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/package.json +4 -3
- package/renovate.json +6 -0
- package/src/assets/img/icons/empty-query.ts +5 -0
- package/src/assets/img/icons/login-required.ts +30 -0
- package/src/assets/img/icons/null-result.ts +5 -0
- package/src/collection-browser.ts +107 -72
- package/src/collection-facets.ts +3 -3
- package/src/empty-placeholder.ts +79 -0
- 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 +4 -1
- package/test/empty-placeholder.test.ts +47 -0
- 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 +2 -1
- package/src/tiles/item-tile-image.ts +0 -61
|
@@ -2,7 +2,7 @@ import { msg } from '@lit/localize';
|
|
|
2
2
|
import { css, CSSResultGroup, html, LitElement } from 'lit';
|
|
3
3
|
import { customElement, property } from 'lit/decorators.js';
|
|
4
4
|
import { collectionIcon } from '../../assets/img/icons/mediatype/collection';
|
|
5
|
-
import { TileModel } from '../../models';
|
|
5
|
+
import type { TileModel } from '../../models';
|
|
6
6
|
|
|
7
7
|
@customElement('collection-tile')
|
|
8
8
|
export class CollectionTile extends LitElement {
|
|
@@ -2,40 +2,47 @@
|
|
|
2
2
|
import { css, CSSResultGroup, html, LitElement, nothing } from 'lit';
|
|
3
3
|
import { customElement, property } from 'lit/decorators.js';
|
|
4
4
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
5
|
-
import { SortParam } from '@internetarchive/search-service';
|
|
5
|
+
import type { SortParam } from '@internetarchive/search-service';
|
|
6
6
|
|
|
7
7
|
import { formatDate } from '../../utils/format-date';
|
|
8
|
-
import { TileModel } from '../../models';
|
|
8
|
+
import type { TileModel } from '../../models';
|
|
9
9
|
|
|
10
|
-
import '../
|
|
10
|
+
import '../image-block';
|
|
11
11
|
import '../item-image';
|
|
12
|
+
import '../mediatype-icon';
|
|
12
13
|
import './tile-stats';
|
|
13
14
|
|
|
14
15
|
@customElement('item-tile')
|
|
15
16
|
export class ItemTile extends LitElement {
|
|
16
|
-
@property({ type: Object }) model?: TileModel;
|
|
17
|
-
|
|
18
17
|
@property({ type: String }) baseImageUrl?: string;
|
|
19
18
|
|
|
19
|
+
@property({ type: Boolean }) loggedIn = false;
|
|
20
|
+
|
|
21
|
+
@property({ type: Object }) model?: TileModel;
|
|
22
|
+
|
|
20
23
|
@property({ type: Object }) sortParam?: SortParam;
|
|
21
24
|
|
|
22
25
|
render() {
|
|
23
26
|
const itemTitle = this.model?.title;
|
|
27
|
+
|
|
24
28
|
return html`
|
|
25
29
|
<div class="container">
|
|
26
30
|
<div class="item-info">
|
|
27
31
|
<div id="title">
|
|
28
|
-
<h1 class="truncated" title=${ifDefined(
|
|
29
|
-
itemTitle
|
|
30
|
-
|
|
32
|
+
<h1 class="truncated" title=${ifDefined(itemTitle)}>
|
|
33
|
+
${itemTitle}
|
|
34
|
+
</h1>
|
|
31
35
|
</div>
|
|
32
36
|
|
|
33
|
-
<
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
<image-block
|
|
38
|
+
.model=${this.model}
|
|
39
|
+
.baseImageUrl=${this.baseImageUrl}
|
|
40
|
+
.loggedIn=${this.loggedIn}
|
|
41
|
+
.isCompactTile=${false}
|
|
42
|
+
.isListTile=${false}
|
|
43
|
+
.viewSize=${'grid'}>
|
|
44
|
+
</image-block>
|
|
45
|
+
|
|
39
46
|
${
|
|
40
47
|
this.doesSortedByDate
|
|
41
48
|
? this.sortedDateInfoTemplate
|
|
@@ -54,6 +61,9 @@ export class ItemTile extends LitElement {
|
|
|
54
61
|
`;
|
|
55
62
|
}
|
|
56
63
|
|
|
64
|
+
/**
|
|
65
|
+
* Templates
|
|
66
|
+
*/
|
|
57
67
|
private get doesSortedByDate() {
|
|
58
68
|
return ['date', 'reviewdate', 'addeddate', 'publicdate'].includes(
|
|
59
69
|
this.sortParam?.field as string
|
|
@@ -119,13 +129,6 @@ export class ItemTile extends LitElement {
|
|
|
119
129
|
flex-shrink: 0;
|
|
120
130
|
}
|
|
121
131
|
|
|
122
|
-
#image {
|
|
123
|
-
display: flex;
|
|
124
|
-
justify-content: center;
|
|
125
|
-
flex: 1;
|
|
126
|
-
height: 16rem;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
132
|
.hidden {
|
|
130
133
|
display: none;
|
|
131
134
|
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { css, CSSResultGroup, html, LitElement, nothing } from 'lit';
|
|
2
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
3
|
+
import { ClassInfo, classMap } from 'lit/directives/class-map.js';
|
|
4
|
+
|
|
5
|
+
import type { TileModel } from '../models';
|
|
6
|
+
|
|
7
|
+
import './overlay/icon-overlay';
|
|
8
|
+
import './overlay/text-overlay';
|
|
9
|
+
|
|
10
|
+
@customElement('image-block')
|
|
11
|
+
export class ImageBlock extends LitElement {
|
|
12
|
+
@property({ type: String }) baseImageUrl?: string;
|
|
13
|
+
|
|
14
|
+
@property({ type: Boolean }) isCompactTile = false;
|
|
15
|
+
|
|
16
|
+
@property({ type: Boolean }) isListTile = false;
|
|
17
|
+
|
|
18
|
+
@property({ type: Boolean }) loggedIn = false;
|
|
19
|
+
|
|
20
|
+
@property({ type: Object }) model?: TileModel;
|
|
21
|
+
|
|
22
|
+
@property({ type: String }) viewSize: string = 'desktop';
|
|
23
|
+
|
|
24
|
+
render() {
|
|
25
|
+
if (!this.model?.identifier) {
|
|
26
|
+
return nothing;
|
|
27
|
+
}
|
|
28
|
+
return html`
|
|
29
|
+
<div class=${classMap(this.baseClass)}>
|
|
30
|
+
<item-image
|
|
31
|
+
.model=${this.model}
|
|
32
|
+
.baseImageUrl=${this.baseImageUrl}
|
|
33
|
+
.isListTile=${this.isListTile}
|
|
34
|
+
.isCompactTile=${this.isCompactTile}
|
|
35
|
+
.loggedIn=${this.loggedIn}
|
|
36
|
+
style="--imgHeight: 100%; --imgWidth: 100%"
|
|
37
|
+
>
|
|
38
|
+
</item-image>
|
|
39
|
+
${this.textOverlayTemplate} ${this.iconOverlayTemplate}
|
|
40
|
+
</div>
|
|
41
|
+
`;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
private get baseClass(): ClassInfo {
|
|
45
|
+
return {
|
|
46
|
+
list: this.isListTile && !this.isCompactTile,
|
|
47
|
+
'list-compact': this.isListTile && this.isCompactTile,
|
|
48
|
+
[this.viewSize]: true,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
private get iconOverlayTemplate() {
|
|
53
|
+
if (!this.isListTile) return nothing;
|
|
54
|
+
|
|
55
|
+
if (!this.model?.loginRequired && !this.model?.contentWarning) {
|
|
56
|
+
return nothing;
|
|
57
|
+
}
|
|
58
|
+
return html`
|
|
59
|
+
<icon-overlay
|
|
60
|
+
.loggedIn=${this.loggedIn}
|
|
61
|
+
.loginRequired=${this.model?.loginRequired}
|
|
62
|
+
>
|
|
63
|
+
</icon-overlay>
|
|
64
|
+
`;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
private get textOverlayTemplate() {
|
|
68
|
+
if (this.isListTile) {
|
|
69
|
+
return nothing;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (!this.model?.loginRequired && !this.model?.contentWarning) {
|
|
73
|
+
return nothing;
|
|
74
|
+
}
|
|
75
|
+
return html`
|
|
76
|
+
<text-overlay
|
|
77
|
+
.loggedIn=${this.loggedIn}
|
|
78
|
+
.loginRequired=${this.model?.loginRequired}
|
|
79
|
+
>
|
|
80
|
+
</text-overlay>
|
|
81
|
+
`;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
static get styles(): CSSResultGroup {
|
|
85
|
+
return css`
|
|
86
|
+
div {
|
|
87
|
+
display: flex;
|
|
88
|
+
justify-content: center;
|
|
89
|
+
position: relative;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.grid {
|
|
93
|
+
height: 16rem;
|
|
94
|
+
flex: 1;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** tile-list view */
|
|
98
|
+
.list.desktop {
|
|
99
|
+
width: 100px;
|
|
100
|
+
height: 100px;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.list.mobile {
|
|
104
|
+
width: 90px;
|
|
105
|
+
height: 90px;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/** tile-list-compact view */
|
|
109
|
+
.list-compact {
|
|
110
|
+
display: block;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.list-compact.desktop {
|
|
114
|
+
width: 45px;
|
|
115
|
+
height: 45px;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.list-compact.mobile {
|
|
119
|
+
width: 30px;
|
|
120
|
+
height: 30px;
|
|
121
|
+
}
|
|
122
|
+
`;
|
|
123
|
+
}
|
|
124
|
+
}
|
package/src/tiles/item-image.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { css, CSSResultGroup, html, LitElement } from 'lit';
|
|
|
2
2
|
import { customElement, property, query, state } from 'lit/decorators.js';
|
|
3
3
|
import { ClassInfo, classMap } from 'lit/directives/class-map.js';
|
|
4
4
|
|
|
5
|
-
import { TileModel } from '../models';
|
|
5
|
+
import type { TileModel } from '../models';
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
8
|
baseItemImageStyles,
|
|
@@ -71,10 +71,12 @@ export class ItemImage extends LitElement {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
private get itemImageClass(): ClassInfo {
|
|
74
|
+
const toBlur = this.model?.contentWarning || this.model?.loginRequired;
|
|
75
|
+
|
|
74
76
|
return {
|
|
75
77
|
contain: !this.isCompactTile && !this.isWaveform,
|
|
76
78
|
cover: this.isCompactTile,
|
|
77
|
-
blur:
|
|
79
|
+
blur: toBlur || false,
|
|
78
80
|
waveform: this.isWaveform,
|
|
79
81
|
};
|
|
80
82
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { css, html, LitElement } from 'lit';
|
|
2
2
|
import { customElement, property } from 'lit/decorators.js';
|
|
3
|
-
import { SortParam } from '@internetarchive/search-service';
|
|
3
|
+
import type { SortParam } from '@internetarchive/search-service';
|
|
4
4
|
import { dateLabel } from './date-label';
|
|
5
|
-
import { TileModel } from '../../models';
|
|
5
|
+
import type { TileModel } from '../../models';
|
|
6
6
|
|
|
7
7
|
@customElement('tile-list-compact-header')
|
|
8
8
|
export class TileListCompactHeader extends LitElement {
|
|
@@ -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';
|
|
@@ -12,6 +12,9 @@ describe('Collection Browser', () => {
|
|
|
12
12
|
html`<collection-browser></collection-browser>`
|
|
13
13
|
);
|
|
14
14
|
|
|
15
|
+
el.baseQuery = 'hello';
|
|
16
|
+
await el.updateComplete;
|
|
17
|
+
|
|
15
18
|
const facets = el.shadowRoot?.querySelector('collection-facets');
|
|
16
19
|
const sortBar = el.shadowRoot?.querySelector('sort-filter-bar');
|
|
17
20
|
const infiniteScroller = el.shadowRoot?.querySelector('infinite-scroller');
|