@internetarchive/collection-browser 2.0.0 → 2.0.1-alpha.1
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/app-root.d.ts +1 -0
- package/dist/src/app-root.js +38 -1
- package/dist/src/app-root.js.map +1 -1
- package/dist/src/assets/img/icons/favorite-filled.d.ts +1 -1
- package/dist/src/assets/img/icons/favorite-filled.js +2 -3
- package/dist/src/assets/img/icons/favorite-filled.js.map +1 -1
- package/dist/src/assets/img/icons/favorite-unfilled.d.ts +1 -0
- package/dist/src/assets/img/icons/favorite-unfilled.js +9 -0
- package/dist/src/assets/img/icons/favorite-unfilled.js.map +1 -0
- package/dist/src/models.d.ts +2 -1
- package/dist/src/models.js +12 -11
- package/dist/src/models.js.map +1 -1
- package/dist/src/tiles/grid/item-tile.d.ts +2 -0
- package/dist/src/tiles/grid/item-tile.js +18 -0
- package/dist/src/tiles/grid/item-tile.js.map +1 -1
- package/dist/src/tiles/list/tile-list.d.ts +3 -0
- package/dist/src/tiles/list/tile-list.js +18 -0
- package/dist/src/tiles/list/tile-list.js.map +1 -1
- package/dist/src/tiles/review-block.d.ts +12 -0
- package/dist/src/tiles/review-block.js +134 -0
- package/dist/src/tiles/review-block.js.map +1 -0
- package/package.json +2 -2
- package/src/app-root.ts +41 -1
- package/src/assets/img/icons/favorite-filled.ts +2 -3
- package/src/assets/img/icons/favorite-unfilled.ts +9 -0
- package/src/models.ts +7 -1
- package/src/tiles/grid/item-tile.ts +18 -0
- package/src/tiles/list/tile-list.ts +18 -0
- package/src/tiles/review-block.ts +130 -0
|
@@ -11,6 +11,7 @@ import { BaseTileComponent } from '../base-tile-component';
|
|
|
11
11
|
|
|
12
12
|
import { baseTileStyles } from './styles/tile-grid-shared-styles';
|
|
13
13
|
import '../image-block';
|
|
14
|
+
import '../review-block';
|
|
14
15
|
import '../text-snippet-block';
|
|
15
16
|
import '../item-image';
|
|
16
17
|
import '../mediatype-icon';
|
|
@@ -59,6 +60,7 @@ export class ItemTile extends BaseTileComponent {
|
|
|
59
60
|
? this.sortedDateInfoTemplate
|
|
60
61
|
: this.creatorTemplate}
|
|
61
62
|
${this.webArchivesCaptureDatesTemplate} ${this.textSnippetsTemplate}
|
|
63
|
+
${this.reviewBlockTemplate}
|
|
62
64
|
</div>
|
|
63
65
|
|
|
64
66
|
<tile-stats
|
|
@@ -152,6 +154,21 @@ export class ItemTile extends BaseTileComponent {
|
|
|
152
154
|
: nothing;
|
|
153
155
|
}
|
|
154
156
|
|
|
157
|
+
private get reviewBlockTemplate(): TemplateResult | typeof nothing {
|
|
158
|
+
if (!this.model?.review) return nothing;
|
|
159
|
+
|
|
160
|
+
const { title, body, stars } = this.model.review;
|
|
161
|
+
return html`
|
|
162
|
+
<review-block
|
|
163
|
+
viewsize="grid"
|
|
164
|
+
.title=${title}
|
|
165
|
+
.body=${body}
|
|
166
|
+
.starRating=${stars}
|
|
167
|
+
>
|
|
168
|
+
</review-block>
|
|
169
|
+
`;
|
|
170
|
+
}
|
|
171
|
+
|
|
155
172
|
private get textSnippetsTemplate(): TemplateResult | typeof nothing {
|
|
156
173
|
if (!this.hasSnippets) return nothing;
|
|
157
174
|
|
|
@@ -239,6 +256,7 @@ export class ItemTile extends BaseTileComponent {
|
|
|
239
256
|
list-style-type: none;
|
|
240
257
|
}
|
|
241
258
|
|
|
259
|
+
review-block,
|
|
242
260
|
text-snippet-block {
|
|
243
261
|
--containerLeftMargin: 5px;
|
|
244
262
|
--containerTopMargin: 5px;
|
|
@@ -16,6 +16,8 @@ import { formatDate, DateFormat } from '../../utils/format-date';
|
|
|
16
16
|
import { isFirstMillisecondOfUTCYear } from '../../utils/local-date-from-utc';
|
|
17
17
|
|
|
18
18
|
import '../image-block';
|
|
19
|
+
import '../review-block';
|
|
20
|
+
import '../text-snippet-block';
|
|
19
21
|
import '../mediatype-icon';
|
|
20
22
|
|
|
21
23
|
@customElement('tile-list')
|
|
@@ -114,6 +116,7 @@ export class TileList extends BaseTileComponent {
|
|
|
114
116
|
</div>
|
|
115
117
|
${this.topicsTemplate} ${this.collectionsTemplate}
|
|
116
118
|
${this.descriptionTemplate} ${this.textSnippetsTemplate}
|
|
119
|
+
${this.reviewBlockTemplate}
|
|
117
120
|
`;
|
|
118
121
|
}
|
|
119
122
|
|
|
@@ -298,6 +301,21 @@ export class TileList extends BaseTileComponent {
|
|
|
298
301
|
);
|
|
299
302
|
}
|
|
300
303
|
|
|
304
|
+
private get reviewBlockTemplate(): TemplateResult | typeof nothing {
|
|
305
|
+
if (!this.model?.review) return nothing;
|
|
306
|
+
|
|
307
|
+
const { title, body, stars } = this.model.review;
|
|
308
|
+
return html`
|
|
309
|
+
<review-block
|
|
310
|
+
viewsize="list"
|
|
311
|
+
.title=${title}
|
|
312
|
+
.body=${body}
|
|
313
|
+
.starRating=${stars}
|
|
314
|
+
>
|
|
315
|
+
</review-block>
|
|
316
|
+
`;
|
|
317
|
+
}
|
|
318
|
+
|
|
301
319
|
private get textSnippetsTemplate(): TemplateResult | typeof nothing {
|
|
302
320
|
if (!this.hasSnippets) return nothing;
|
|
303
321
|
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import {
|
|
2
|
+
css,
|
|
3
|
+
CSSResultGroup,
|
|
4
|
+
html,
|
|
5
|
+
LitElement,
|
|
6
|
+
nothing,
|
|
7
|
+
TemplateResult,
|
|
8
|
+
} from 'lit';
|
|
9
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
10
|
+
import { msg } from '@lit/localize';
|
|
11
|
+
import { favoriteFilledIcon } from '../assets/img/icons/favorite-filled';
|
|
12
|
+
import { favoriteUnfilledIcon } from '../assets/img/icons/favorite-unfilled';
|
|
13
|
+
import { srOnlyStyle } from '../styles/sr-only';
|
|
14
|
+
|
|
15
|
+
@customElement('review-block')
|
|
16
|
+
export class ReviewBlock extends LitElement {
|
|
17
|
+
@property({ type: String }) title = '';
|
|
18
|
+
|
|
19
|
+
@property({ type: String }) body = '';
|
|
20
|
+
|
|
21
|
+
@property({ type: Number }) starRating = 0;
|
|
22
|
+
|
|
23
|
+
@property({ type: String }) viewSize = 'desktop';
|
|
24
|
+
|
|
25
|
+
render() {
|
|
26
|
+
if (!this.title && !this.body && !this.starRating) return nothing;
|
|
27
|
+
|
|
28
|
+
return html`
|
|
29
|
+
<div class="review-container">
|
|
30
|
+
<div class="snippet-view ${this.viewSize}">
|
|
31
|
+
${this.starsTemplate}
|
|
32
|
+
<p class="review-title">${this.title}</p>
|
|
33
|
+
<p class="review-body">${this.body}</p>
|
|
34
|
+
</div>
|
|
35
|
+
</div>
|
|
36
|
+
`;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
private get starsTemplate(): TemplateResult | typeof nothing {
|
|
40
|
+
if (this.starRating <= 0) return nothing;
|
|
41
|
+
|
|
42
|
+
const numFilledStars = Math.min(5, this.starRating);
|
|
43
|
+
const numUnfilledStars = Math.min(5, 5 - this.starRating);
|
|
44
|
+
return html`
|
|
45
|
+
<div class="star-rating">
|
|
46
|
+
<span class="sr-only">${this.starRating} ${msg('out of 5 stars')}</span>
|
|
47
|
+
${Array(numFilledStars).fill(this.filledStarTemplate)}
|
|
48
|
+
${Array(numUnfilledStars).fill(this.unfilledStarTemplate)}
|
|
49
|
+
</div>
|
|
50
|
+
`;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
private get filledStarTemplate(): TemplateResult {
|
|
54
|
+
return html`<span aria-hidden="true">${favoriteFilledIcon}</span>`;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
private get unfilledStarTemplate(): TemplateResult {
|
|
58
|
+
return html`
|
|
59
|
+
<span class="unfilled-star" aria-hidden="true">
|
|
60
|
+
${favoriteUnfilledIcon}
|
|
61
|
+
</span>
|
|
62
|
+
`;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
static get styles(): CSSResultGroup {
|
|
66
|
+
return [
|
|
67
|
+
srOnlyStyle,
|
|
68
|
+
css`
|
|
69
|
+
.review-container {
|
|
70
|
+
display: flex;
|
|
71
|
+
flex-direction: row;
|
|
72
|
+
flex-wrap: wrap;
|
|
73
|
+
width: calc(100% - 10px);
|
|
74
|
+
border: 1px solid #ccc;
|
|
75
|
+
margin-top: var(--containerTopMargin, 10px);
|
|
76
|
+
margin-left: var(--containerLeftMargin, 0px);
|
|
77
|
+
padding: 5px;
|
|
78
|
+
box-sizing: border-box;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.review-title,
|
|
82
|
+
.review-body {
|
|
83
|
+
display: -webkit-box;
|
|
84
|
+
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
|
|
85
|
+
overflow: hidden;
|
|
86
|
+
overflow-wrap: break-word;
|
|
87
|
+
word-break: break-word;
|
|
88
|
+
-webkit-line-clamp: var(--maxLines, 3);
|
|
89
|
+
-webkit-box-orient: vertical;
|
|
90
|
+
margin: 0;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.review-title {
|
|
94
|
+
font-size: 1.4rem;
|
|
95
|
+
line-height: 2rem;
|
|
96
|
+
max-height: 6rem;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.review-title > a[href] {
|
|
100
|
+
color: inherit;
|
|
101
|
+
text-decoration: none;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.review-title > a[href]:hover {
|
|
105
|
+
text-decoration: underline;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.review-body {
|
|
109
|
+
font-size: 1rem;
|
|
110
|
+
line-height: 1.4rem;
|
|
111
|
+
max-height: 4.2rem;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.star-rating svg {
|
|
115
|
+
width: 10px;
|
|
116
|
+
height: 10px;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.unfilled-star {
|
|
120
|
+
fill: #ccc;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.list {
|
|
124
|
+
margin: 0;
|
|
125
|
+
padding-left: 5px;
|
|
126
|
+
}
|
|
127
|
+
`,
|
|
128
|
+
];
|
|
129
|
+
}
|
|
130
|
+
}
|