@internetarchive/collection-browser 0.4.3-alpha.4 → 0.4.3-alpha.6
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/src/collection-browser.d.ts +4 -4
- package/dist/src/collection-browser.js +23 -43
- package/dist/src/collection-browser.js.map +1 -1
- package/dist/src/restoration-state-handler.d.ts +0 -1
- package/dist/src/restoration-state-handler.js +12 -50
- package/dist/src/restoration-state-handler.js.map +1 -1
- package/dist/src/sort-filter-bar/sort-filter-bar.js +0 -1
- package/dist/src/sort-filter-bar/sort-filter-bar.js.map +1 -1
- package/dist/src/styles/item-image-styles.js +5 -0
- package/dist/src/styles/item-image-styles.js.map +1 -1
- package/dist/src/tiles/grid/account-tile.d.ts +12 -3
- package/dist/src/tiles/grid/account-tile.js +54 -103
- package/dist/src/tiles/grid/account-tile.js.map +1 -1
- package/dist/src/tiles/grid/item-tile.d.ts +7 -2
- package/dist/src/tiles/grid/item-tile.js +79 -119
- package/dist/src/tiles/grid/item-tile.js.map +1 -1
- package/dist/src/tiles/grid/styles/tile-grid-shared-styles.d.ts +1 -0
- package/dist/src/tiles/grid/styles/tile-grid-shared-styles.js +97 -0
- package/dist/src/tiles/grid/styles/tile-grid-shared-styles.js.map +1 -0
- package/dist/src/tiles/grid/tile-stats.js +11 -13
- package/dist/src/tiles/grid/tile-stats.js.map +1 -1
- package/dist/src/tiles/image-block.js +5 -0
- package/dist/src/tiles/image-block.js.map +1 -1
- package/dist/src/tiles/item-image.d.ts +4 -0
- package/dist/src/tiles/item-image.js +10 -0
- package/dist/src/tiles/item-image.js.map +1 -1
- package/dist/src/tiles/list/tile-list.d.ts +5 -2
- package/dist/src/tiles/list/tile-list.js +32 -29
- package/dist/src/tiles/list/tile-list.js.map +1 -1
- package/dist/src/tiles/text-snippet-block.d.ts +0 -2
- package/dist/src/tiles/text-snippet-block.js +22 -24
- package/dist/src/tiles/text-snippet-block.js.map +1 -1
- package/dist/src/tiles/tile-dispatcher.js +1 -0
- package/dist/src/tiles/tile-dispatcher.js.map +1 -1
- package/dist/test/collection-browser.test.js +7 -7
- package/dist/test/collection-browser.test.js.map +1 -1
- package/dist/test/text-snippet-block.test.js +4 -4
- package/dist/test/text-snippet-block.test.js.map +1 -1
- package/dist/test/tiles/grid/account-tile.test.d.ts +1 -0
- package/dist/test/tiles/grid/account-tile.test.js +76 -0
- package/dist/test/tiles/grid/account-tile.test.js.map +1 -0
- package/dist/test/tiles/grid/item-tile.test.js +34 -10
- package/dist/test/tiles/grid/item-tile.test.js.map +1 -1
- package/package.json +2 -2
- package/src/collection-browser.ts +26 -70
- package/src/restoration-state-handler.ts +14 -68
- package/src/sort-filter-bar/sort-filter-bar.ts +0 -1
- package/src/styles/item-image-styles.ts +5 -0
- package/src/tiles/grid/account-tile.ts +52 -100
- package/src/tiles/grid/item-tile.ts +84 -125
- package/src/tiles/grid/styles/tile-grid-shared-styles.ts +99 -0
- package/src/tiles/grid/tile-stats.ts +11 -13
- package/src/tiles/image-block.ts +6 -0
- package/src/tiles/item-image.ts +12 -0
- package/src/tiles/list/tile-list.ts +41 -38
- package/src/tiles/text-snippet-block.ts +22 -26
- package/src/tiles/tile-dispatcher.ts +1 -0
- package/test/collection-browser.test.ts +7 -7
- package/test/text-snippet-block.test.ts +4 -4
- package/test/tiles/grid/account-tile.test.ts +95 -0
- package/test/tiles/grid/item-tile.test.ts +34 -2
- package/dist/src/utils/array-equals.d.ts +0 -4
- package/dist/src/utils/array-equals.js +0 -11
- package/dist/src/utils/array-equals.js.map +0 -1
- package/dist/test/utils/array-equals.test.d.ts +0 -1
- package/dist/test/utils/array-equals.test.js +0 -27
- package/dist/test/utils/array-equals.test.js.map +0 -1
- package/src/utils/array-equals.ts +0 -8
- package/test/utils/array-equals.test.ts +0 -31
|
@@ -14,6 +14,7 @@ import type { SortParam } from '@internetarchive/search-service';
|
|
|
14
14
|
import { formatDate } from '../../utils/format-date';
|
|
15
15
|
import type { TileModel } from '../../models';
|
|
16
16
|
|
|
17
|
+
import { baseTileStyles } from './styles/tile-grid-shared-styles';
|
|
17
18
|
import '../image-block';
|
|
18
19
|
import '../text-snippet-block';
|
|
19
20
|
import '../item-image';
|
|
@@ -35,38 +36,30 @@ export class ItemTile extends LitElement {
|
|
|
35
36
|
|
|
36
37
|
return html`
|
|
37
38
|
<div class="container">
|
|
38
|
-
<div class="
|
|
39
|
-
<div
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
.isCompactTile=${false}
|
|
51
|
-
.isListTile=${false}
|
|
52
|
-
.viewSize=${'grid'}>
|
|
53
|
-
</image-block>
|
|
54
|
-
|
|
55
|
-
${this.textSnippetsTemplate}
|
|
56
|
-
|
|
57
|
-
${
|
|
58
|
-
this.doesSortedByDate
|
|
39
|
+
<div class="tile-details">
|
|
40
|
+
<div class="item-info">
|
|
41
|
+
${this.imageBlockTemplate}
|
|
42
|
+
|
|
43
|
+
<div id="title">
|
|
44
|
+
<h1 class="truncated" title=${ifDefined(itemTitle)}>
|
|
45
|
+
${itemTitle}
|
|
46
|
+
</h1>
|
|
47
|
+
</div>
|
|
48
|
+
|
|
49
|
+
${this.volumeIssueTemplate}
|
|
50
|
+
${this.doesSortedByDate
|
|
59
51
|
? this.sortedDateInfoTemplate
|
|
60
|
-
: this.creatorTemplate
|
|
61
|
-
|
|
62
|
-
|
|
52
|
+
: this.creatorTemplate}
|
|
53
|
+
${this.textSnippetsTemplate}
|
|
54
|
+
</div>
|
|
63
55
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
56
|
+
<tile-stats
|
|
57
|
+
.mediatype=${this.model?.mediatype}
|
|
58
|
+
.viewCount=${this.model?.viewCount}
|
|
59
|
+
.favCount=${this.model?.favCount}
|
|
60
|
+
.commentCount=${this.model?.commentCount}
|
|
61
|
+
>
|
|
62
|
+
</tile-stats>
|
|
70
63
|
</div>
|
|
71
64
|
</div>
|
|
72
65
|
`;
|
|
@@ -75,10 +68,31 @@ export class ItemTile extends LitElement {
|
|
|
75
68
|
/**
|
|
76
69
|
* Templates
|
|
77
70
|
*/
|
|
78
|
-
private get
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
71
|
+
private get creatorTemplate(): TemplateResult | typeof nothing {
|
|
72
|
+
if (!this.model?.creator) return nothing;
|
|
73
|
+
|
|
74
|
+
return html`
|
|
75
|
+
<div class="created-by">
|
|
76
|
+
<span class="truncated" title=${ifDefined(this.model?.creator)}>
|
|
77
|
+
by ${this.model?.creator}
|
|
78
|
+
</span>
|
|
79
|
+
</div>
|
|
80
|
+
`;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
private get imageBlockTemplate(): TemplateResult {
|
|
84
|
+
return html`
|
|
85
|
+
<image-block
|
|
86
|
+
class=${this.hasSnippets ? 'has-snippets' : nothing}
|
|
87
|
+
.model=${this.model}
|
|
88
|
+
.baseImageUrl=${this.baseImageUrl}
|
|
89
|
+
.loggedIn=${this.loggedIn}
|
|
90
|
+
.isCompactTile=${false}
|
|
91
|
+
.isListTile=${false}
|
|
92
|
+
.viewSize=${'grid'}
|
|
93
|
+
>
|
|
94
|
+
</image-block>
|
|
95
|
+
`;
|
|
82
96
|
}
|
|
83
97
|
|
|
84
98
|
private get sortedDateInfoTemplate() {
|
|
@@ -110,108 +124,53 @@ export class ItemTile extends LitElement {
|
|
|
110
124
|
`;
|
|
111
125
|
}
|
|
112
126
|
|
|
113
|
-
private get
|
|
127
|
+
private get textSnippetsTemplate(): TemplateResult | typeof nothing {
|
|
128
|
+
if (!this.hasSnippets) return nothing;
|
|
129
|
+
|
|
114
130
|
return html`
|
|
115
|
-
<
|
|
116
|
-
|
|
117
|
-
? html`<span>by ${this.model?.creator}</span>`
|
|
118
|
-
: nothing}
|
|
119
|
-
</div>
|
|
131
|
+
<text-snippet-block viewsize="grid" .snippets=${this.model?.snippets}>
|
|
132
|
+
</text-snippet-block>
|
|
120
133
|
`;
|
|
121
134
|
}
|
|
122
135
|
|
|
123
|
-
private get
|
|
124
|
-
if (!this.
|
|
136
|
+
private get volumeIssueTemplate(): TemplateResult | typeof nothing {
|
|
137
|
+
if (!this.model?.volume || !this.model?.issue) return nothing;
|
|
125
138
|
|
|
126
|
-
return html
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
139
|
+
return html`
|
|
140
|
+
<div class="volume-issue">
|
|
141
|
+
<span class="truncated" title="volume|issue">
|
|
142
|
+
Volume ${this.model?.volume}, Issue ${this.model?.issue}
|
|
143
|
+
</span>
|
|
144
|
+
</div>
|
|
145
|
+
`;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
private get doesSortedByDate() {
|
|
149
|
+
return ['date', 'reviewdate', 'addeddate', 'publicdate'].includes(
|
|
150
|
+
this.sortParam?.field as string
|
|
151
|
+
);
|
|
130
152
|
}
|
|
131
153
|
|
|
132
154
|
private get hasSnippets(): boolean {
|
|
133
155
|
return !!this.model?.snippets?.length;
|
|
134
156
|
}
|
|
135
157
|
|
|
158
|
+
/**
|
|
159
|
+
* CSS
|
|
160
|
+
*/
|
|
136
161
|
static get styles(): CSSResultGroup {
|
|
137
|
-
return
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
#title {
|
|
153
|
-
flex-shrink: 0;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
.hidden {
|
|
157
|
-
display: none;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
.container:hover > .item-info > #title > .truncated {
|
|
161
|
-
text-decoration: underline;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
/** this is a workaround for Safari 15 where the hover effects are not working */
|
|
165
|
-
#title:hover > .truncated {
|
|
166
|
-
text-decoration: underline;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
image-block {
|
|
170
|
-
display: block;
|
|
171
|
-
margin-bottom: 5px;
|
|
172
|
-
position: relative;
|
|
173
|
-
text-align: center;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
image-block.has-snippets {
|
|
177
|
-
/* If there is a text snippet block present, the image block needs to shrink */
|
|
178
|
-
--imgBlockHeight: 11rem;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
.created-by,
|
|
182
|
-
.date-sorted-by {
|
|
183
|
-
display: flex;
|
|
184
|
-
justify-content: center;
|
|
185
|
-
align-items: flex-end; /* Important to start text from bottom */
|
|
186
|
-
height: 3rem;
|
|
187
|
-
padding-top: 1rem;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
.truncated {
|
|
191
|
-
flex: 1;
|
|
192
|
-
color: #2c2c2c;
|
|
193
|
-
min-width: 0; /* Important for long words! */
|
|
194
|
-
text-align: center;
|
|
195
|
-
line-height: 2rem;
|
|
196
|
-
text-overflow: ellipsis;
|
|
197
|
-
overflow: hidden;
|
|
198
|
-
word-wrap: break-word;
|
|
199
|
-
-webkit-line-clamp: 2;
|
|
200
|
-
-webkit-box-orient: vertical;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
.truncated span {
|
|
204
|
-
font-size: 1.4rem;
|
|
205
|
-
display: -webkit-box;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
h1.truncated {
|
|
209
|
-
margin-top: 0rem;
|
|
210
|
-
margin-bottom: 0.5rem;
|
|
211
|
-
font-size: 1.6rem;
|
|
212
|
-
height: 4rem;
|
|
213
|
-
display: -webkit-box;
|
|
214
|
-
}
|
|
215
|
-
`;
|
|
162
|
+
return [
|
|
163
|
+
baseTileStyles,
|
|
164
|
+
css`
|
|
165
|
+
image-block {
|
|
166
|
+
--imageBlockBackgroundColor: #f1f1f4;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
text-snippet-block {
|
|
170
|
+
--containerLeftMargin: 5px;
|
|
171
|
+
--containerTopMargin: 10px;
|
|
172
|
+
}
|
|
173
|
+
`,
|
|
174
|
+
];
|
|
216
175
|
}
|
|
217
176
|
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Base tile styles
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const tileCornerRadius = css`var(--collectionTileCornerRadius, 4px)`;
|
|
8
|
+
const tileBackgroundColor = css`var(--tileBackgroundColor, #ffffff)`;
|
|
9
|
+
|
|
10
|
+
export const baseTileStyles = css`
|
|
11
|
+
.container {
|
|
12
|
+
background-color: ${tileBackgroundColor};
|
|
13
|
+
border: 1px #2c2c2c;
|
|
14
|
+
border-radius: ${tileCornerRadius};
|
|
15
|
+
box-shadow: 1px 1px 2px 0;
|
|
16
|
+
height: 100%;
|
|
17
|
+
display: flex;
|
|
18
|
+
flex-direction: column;
|
|
19
|
+
width: 100%;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
image-block {
|
|
23
|
+
display: block;
|
|
24
|
+
margin-bottom: 5px;
|
|
25
|
+
position: relative;
|
|
26
|
+
text-align: center;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.tile-details {
|
|
30
|
+
display: flex;
|
|
31
|
+
flex-direction: column;
|
|
32
|
+
height: 100%;
|
|
33
|
+
row-gap: 10px;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.item-info {
|
|
37
|
+
flex-grow: 1;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
#title {
|
|
41
|
+
flex-shrink: 0;
|
|
42
|
+
padding-left: 5px;
|
|
43
|
+
padding-right: 5px;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.created-by,
|
|
47
|
+
.date-sorted-by,
|
|
48
|
+
.volume-issue,
|
|
49
|
+
.archivist-since {
|
|
50
|
+
display: flex;
|
|
51
|
+
justify-content: left;
|
|
52
|
+
align-items: flex-end; /* Important to start text from bottom */
|
|
53
|
+
padding: 10px 5px 0px 5px;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.truncated {
|
|
57
|
+
flex: 1;
|
|
58
|
+
color: #2c2c2c;
|
|
59
|
+
min-width: 0; /* Important for long words! */
|
|
60
|
+
text-align: left;
|
|
61
|
+
line-height: 15px;
|
|
62
|
+
text-overflow: ellipsis;
|
|
63
|
+
overflow: hidden;
|
|
64
|
+
word-wrap: break-word;
|
|
65
|
+
-webkit-line-clamp: 3;
|
|
66
|
+
-webkit-box-orient: vertical;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
h1.truncated {
|
|
70
|
+
display: -webkit-box;
|
|
71
|
+
margin: 0px;
|
|
72
|
+
line-height: 15px;
|
|
73
|
+
font-size: 14px;
|
|
74
|
+
font-weight: 500;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
span {
|
|
78
|
+
display: -webkit-box;
|
|
79
|
+
font-size: 1.4rem;
|
|
80
|
+
line-height: 15px;
|
|
81
|
+
overflow: hidden;
|
|
82
|
+
word-wrap: break-word;
|
|
83
|
+
-webkit-line-clamp: 1;
|
|
84
|
+
-webkit-box-orient: vertical;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.container:hover > .tile-details > .item-info > #title > .truncated {
|
|
88
|
+
text-decoration: underline;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** this is a workaround for Safari 15 where the hover effects are not working */
|
|
92
|
+
#title:hover > .truncated {
|
|
93
|
+
text-decoration: underline;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.hidden {
|
|
97
|
+
display: none;
|
|
98
|
+
}
|
|
99
|
+
`;
|
|
@@ -91,17 +91,23 @@ export class TileStats extends LitElement {
|
|
|
91
91
|
list-style-type: none; // remove default list-style
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
+
svg {
|
|
95
|
+
height: 10px;
|
|
96
|
+
width: 10px;
|
|
97
|
+
display: block;
|
|
98
|
+
margin: auto;
|
|
99
|
+
pointer-events: none;
|
|
100
|
+
}
|
|
101
|
+
|
|
94
102
|
.item-stats {
|
|
95
103
|
height: 35px;
|
|
104
|
+
padding-left: 5px;
|
|
105
|
+
padding-right: 5px;
|
|
96
106
|
}
|
|
97
107
|
|
|
98
108
|
#stats-row {
|
|
99
|
-
border-top: 1px solid #bbb;
|
|
100
|
-
align-items: center;
|
|
101
109
|
display: flex;
|
|
102
|
-
flex:
|
|
103
|
-
justify-content: space-evenly;
|
|
104
|
-
text-align: center;
|
|
110
|
+
flex-wrap: wrap;
|
|
105
111
|
width: 100%;
|
|
106
112
|
padding-top: 5px;
|
|
107
113
|
padding-bottom: 5px;
|
|
@@ -123,14 +129,6 @@ export class TileStats extends LitElement {
|
|
|
123
129
|
height: 25px;
|
|
124
130
|
}
|
|
125
131
|
|
|
126
|
-
svg {
|
|
127
|
-
height: 10px;
|
|
128
|
-
width: 10px;
|
|
129
|
-
display: block;
|
|
130
|
-
margin: auto;
|
|
131
|
-
pointer-events: none;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
132
|
.status-text {
|
|
135
133
|
font-size: 14px;
|
|
136
134
|
height: 15px;
|
package/src/tiles/image-block.ts
CHANGED
|
@@ -81,17 +81,23 @@ export class ImageBlock extends LitElement {
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
static get styles(): CSSResultGroup {
|
|
84
|
+
const imageBlockBackgroundColor = css`var(--imageBlockBackgroundColor, #f1f1f4)`;
|
|
85
|
+
const imageBlockBorderColor = css`var(--imageBlockBorderColor, #dddddd)`;
|
|
86
|
+
|
|
84
87
|
return css`
|
|
85
88
|
div {
|
|
86
89
|
display: flex;
|
|
87
90
|
justify-content: center;
|
|
88
91
|
position: relative;
|
|
92
|
+
background-color: ${imageBlockBackgroundColor};
|
|
93
|
+
border: 1px solid ${imageBlockBorderColor};
|
|
89
94
|
}
|
|
90
95
|
|
|
91
96
|
.grid {
|
|
92
97
|
height: var(--imgBlockHeight, 16rem);
|
|
93
98
|
flex: 1;
|
|
94
99
|
position: initial;
|
|
100
|
+
padding: 5px;
|
|
95
101
|
}
|
|
96
102
|
|
|
97
103
|
/** tile-list view */
|
package/src/tiles/item-image.ts
CHANGED
|
@@ -81,9 +81,21 @@ export class ItemImage extends LitElement {
|
|
|
81
81
|
cover: this.isCompactTile,
|
|
82
82
|
blur: toBlur || false,
|
|
83
83
|
waveform: this.isWaveform,
|
|
84
|
+
radius50: this.itemImageRadius,
|
|
84
85
|
};
|
|
85
86
|
}
|
|
86
87
|
|
|
88
|
+
/**
|
|
89
|
+
* Helper function to determine if border radius is needed
|
|
90
|
+
*/
|
|
91
|
+
private get itemImageRadius() {
|
|
92
|
+
return (
|
|
93
|
+
this.model?.mediatype === 'account' &&
|
|
94
|
+
!this.isCompactTile &&
|
|
95
|
+
!this.isListTile
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
|
|
87
99
|
/**
|
|
88
100
|
* Event listener sets isWaveform true if image is waveform
|
|
89
101
|
*/
|
|
@@ -48,44 +48,6 @@ export class TileList extends LitElement {
|
|
|
48
48
|
|
|
49
49
|
@property({ type: Boolean }) loggedIn = false;
|
|
50
50
|
|
|
51
|
-
protected updated(changed: PropertyValues): void {
|
|
52
|
-
if (changed.has('model')) {
|
|
53
|
-
this.fetchCollectionNames();
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
private async fetchCollectionNames() {
|
|
58
|
-
if (
|
|
59
|
-
!this.model?.collections ||
|
|
60
|
-
this.model.collections.length === 0 ||
|
|
61
|
-
!this.collectionNameCache
|
|
62
|
-
) {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
// Note: quirk of Lit: need to replace collectionLinks array,
|
|
66
|
-
// otherwise it will not re-render. Can't simply alter the array.
|
|
67
|
-
this.collectionLinks = [];
|
|
68
|
-
const newCollectionLinks: TemplateResult[] = [];
|
|
69
|
-
const promises: Promise<void>[] = [];
|
|
70
|
-
for (const collection of this.model.collections) {
|
|
71
|
-
// Don't include favorites or collections that are meant to be suppressed
|
|
72
|
-
if (
|
|
73
|
-
!suppressedCollections[collection] &&
|
|
74
|
-
!collection.startsWith('fav-')
|
|
75
|
-
) {
|
|
76
|
-
promises.push(
|
|
77
|
-
this.collectionNameCache?.collectionNameFor(collection).then(name => {
|
|
78
|
-
newCollectionLinks.push(
|
|
79
|
-
this.detailsLink(collection, name ?? collection)
|
|
80
|
-
);
|
|
81
|
-
})
|
|
82
|
-
);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
await Promise.all(promises);
|
|
86
|
-
this.collectionLinks = newCollectionLinks;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
51
|
render() {
|
|
90
52
|
return html`
|
|
91
53
|
<div id="list-line" class="${this.classSize}">
|
|
@@ -96,6 +58,9 @@ export class TileList extends LitElement {
|
|
|
96
58
|
`;
|
|
97
59
|
}
|
|
98
60
|
|
|
61
|
+
/**
|
|
62
|
+
* Templates
|
|
63
|
+
*/
|
|
99
64
|
private get mobileTemplate() {
|
|
100
65
|
return html`
|
|
101
66
|
<div id="list-line-top">
|
|
@@ -366,6 +331,44 @@ export class TileList extends LitElement {
|
|
|
366
331
|
>`;
|
|
367
332
|
}
|
|
368
333
|
|
|
334
|
+
protected updated(changed: PropertyValues): void {
|
|
335
|
+
if (changed.has('model')) {
|
|
336
|
+
this.fetchCollectionNames();
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
private async fetchCollectionNames() {
|
|
341
|
+
if (
|
|
342
|
+
!this.model?.collections ||
|
|
343
|
+
this.model.collections.length === 0 ||
|
|
344
|
+
!this.collectionNameCache
|
|
345
|
+
) {
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
// Note: quirk of Lit: need to replace collectionLinks array,
|
|
349
|
+
// otherwise it will not re-render. Can't simply alter the array.
|
|
350
|
+
this.collectionLinks = [];
|
|
351
|
+
const newCollectionLinks: TemplateResult[] = [];
|
|
352
|
+
const promises: Promise<void>[] = [];
|
|
353
|
+
for (const collection of this.model.collections) {
|
|
354
|
+
// Don't include favorites or collections that are meant to be suppressed
|
|
355
|
+
if (
|
|
356
|
+
!suppressedCollections[collection] &&
|
|
357
|
+
!collection.startsWith('fav-')
|
|
358
|
+
) {
|
|
359
|
+
promises.push(
|
|
360
|
+
this.collectionNameCache?.collectionNameFor(collection).then(name => {
|
|
361
|
+
newCollectionLinks.push(
|
|
362
|
+
this.detailsLink(collection, name ?? collection)
|
|
363
|
+
);
|
|
364
|
+
})
|
|
365
|
+
);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
await Promise.all(promises);
|
|
369
|
+
this.collectionLinks = newCollectionLinks;
|
|
370
|
+
}
|
|
371
|
+
|
|
369
372
|
/*
|
|
370
373
|
* TODO: fix field names to match model in src/collection-browser.ts
|
|
371
374
|
* private get dateSortSelector()
|
|
@@ -19,22 +19,14 @@ export class TextSnippetBlock extends LitElement {
|
|
|
19
19
|
if (!this.snippets?.length) return html`${nothing}`;
|
|
20
20
|
|
|
21
21
|
return html`
|
|
22
|
-
<div class="
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
<div class="container">
|
|
23
|
+
<div class="snippet-view ${this.viewSize}">
|
|
24
|
+
${this.ellipsisJoinedSnippets}
|
|
25
|
+
</div>
|
|
26
|
+
</div>
|
|
27
27
|
`;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
private get viewSizeClass() {
|
|
31
|
-
return this.viewSize === 'grid' ? 'grid' : 'list';
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
private get containerClasses() {
|
|
35
|
-
return `container ${this.viewSizeClass}`;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
30
|
/**
|
|
39
31
|
* An array of HTML templates derived from the snippets, with ellipses inserted
|
|
40
32
|
* at the beginning, end, and between each pair of snippets.
|
|
@@ -90,32 +82,36 @@ export class TextSnippetBlock extends LitElement {
|
|
|
90
82
|
static get styles(): CSSResultGroup {
|
|
91
83
|
return css`
|
|
92
84
|
.container {
|
|
85
|
+
display: flex;
|
|
86
|
+
flex-direction: row;
|
|
87
|
+
flex-wrap: wrap;
|
|
88
|
+
width: 100%;
|
|
89
|
+
border-left: 5px solid #194880;
|
|
90
|
+
margin-top: var(--containerTopMargin, 10px);
|
|
91
|
+
margin-left: var(--containerLeftMargin, 0px);
|
|
92
|
+
border-radius: 3px;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.snippet-view {
|
|
93
96
|
display: -webkit-box;
|
|
94
|
-
font-family: '
|
|
97
|
+
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
|
|
98
|
+
font-size: 14px;
|
|
95
99
|
overflow: hidden;
|
|
96
100
|
overflow-wrap: break-word;
|
|
97
101
|
-webkit-line-clamp: var(--maxLines, 3);
|
|
98
102
|
-webkit-box-orient: vertical;
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
.separator {
|
|
102
|
-
/* Border line should extend to the edges of the tile */
|
|
103
|
-
margin: 0 -5px;
|
|
104
|
-
border-bottom: 1px solid #bbb;
|
|
103
|
+
margin-left: 5px;
|
|
104
|
+
margin-right: 10px;
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
.grid {
|
|
108
|
-
|
|
109
|
-
margin: 0.5rem 0 0.4rem;
|
|
108
|
+
margin: 0px 15px 0px 5px;
|
|
110
109
|
font-size: 1.2rem;
|
|
111
110
|
line-height: 1.5rem;
|
|
112
111
|
}
|
|
113
112
|
|
|
114
113
|
.list {
|
|
115
|
-
|
|
116
|
-
padding: 0 0 0 1.5rem;
|
|
117
|
-
border-left: 0.5rem solid #194880;
|
|
118
|
-
border-radius: 3px;
|
|
114
|
+
padding-left: 20px;
|
|
119
115
|
font-size: 1.4rem;
|
|
120
116
|
line-height: 2rem;
|
|
121
117
|
}
|
|
@@ -61,10 +61,10 @@ describe('Collection Browser', () => {
|
|
|
61
61
|
|
|
62
62
|
expect(el.selectedFacets).to.equal(defaultSelectedFacets);
|
|
63
63
|
expect(el.selectedSort).to.equal('relevance');
|
|
64
|
-
expect(el.sortDirection).to.
|
|
65
|
-
expect(el.sortParam).to.
|
|
66
|
-
expect(el.selectedCreatorFilter).to.
|
|
67
|
-
expect(el.selectedTitleFilter).to.
|
|
64
|
+
expect(el.sortDirection).to.null;
|
|
65
|
+
expect(el.sortParam).to.null;
|
|
66
|
+
expect(el.selectedCreatorFilter).to.null;
|
|
67
|
+
expect(el.selectedTitleFilter).to.null;
|
|
68
68
|
});
|
|
69
69
|
|
|
70
70
|
it('filterBy creator with analytics', async () => {
|
|
@@ -87,7 +87,7 @@ describe('Collection Browser', () => {
|
|
|
87
87
|
el.clearFilters();
|
|
88
88
|
await el.updateComplete;
|
|
89
89
|
|
|
90
|
-
expect(el.selectedTitleFilter).to.
|
|
90
|
+
expect(el.selectedTitleFilter).to.null;
|
|
91
91
|
expect(mockAnalyticsHandler.callCategory).to.equal('betaSearchService');
|
|
92
92
|
expect(mockAnalyticsHandler.callAction).to.equal('filterByCreator');
|
|
93
93
|
expect(mockAnalyticsHandler.callLabel).to.equal('clear-A');
|
|
@@ -113,7 +113,7 @@ describe('Collection Browser', () => {
|
|
|
113
113
|
el.clearFilters();
|
|
114
114
|
await el.updateComplete;
|
|
115
115
|
|
|
116
|
-
expect(el.selectedTitleFilter).to.
|
|
116
|
+
expect(el.selectedTitleFilter).to.null;
|
|
117
117
|
expect(mockAnalyticsHandler.callCategory).to.equal('beta-search-service');
|
|
118
118
|
expect(mockAnalyticsHandler.callAction).to.equal('filterByTitle');
|
|
119
119
|
expect(mockAnalyticsHandler.callLabel).to.equal('clear-A');
|
|
@@ -660,7 +660,7 @@ describe('Collection Browser', () => {
|
|
|
660
660
|
await el.updateComplete;
|
|
661
661
|
|
|
662
662
|
const fetchPromise = el.fetchPage(2);
|
|
663
|
-
el.sortParam =
|
|
663
|
+
el.sortParam = null;
|
|
664
664
|
await fetchPromise;
|
|
665
665
|
|
|
666
666
|
// If the different sort param causes the results to be discarded,
|