@internetarchive/collection-browser 0.2.5 → 0.2.6-alpha1
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/{tiles/grid → assets/img}/icons/favorite-filled.d.ts +0 -0
- package/dist/src/{tiles/grid → assets/img}/icons/favorite-filled.js +0 -0
- package/dist/src/{tiles/grid → assets/img}/icons/favorite-filled.js.map +1 -1
- package/dist/src/{tiles/grid → assets/img}/icons/reviews.d.ts +0 -0
- package/dist/src/{tiles/grid → assets/img}/icons/reviews.js +0 -0
- package/dist/src/{tiles/grid → assets/img}/icons/reviews.js.map +1 -1
- package/dist/src/{tiles/grid → assets/img}/icons/upload.d.ts +0 -0
- package/dist/src/{tiles/grid → assets/img}/icons/upload.js +0 -0
- package/dist/src/{tiles/grid → assets/img}/icons/upload.js.map +1 -1
- package/dist/src/assets/img/icons/views.d.ts +1 -0
- package/dist/src/{tiles/grid → assets/img}/icons/views.js +1 -1
- package/dist/src/assets/img/icons/views.js.map +1 -0
- package/dist/src/tiles/grid/account-tile.d.ts +1 -0
- package/dist/src/tiles/grid/account-tile.js +45 -78
- package/dist/src/tiles/grid/account-tile.js.map +1 -1
- package/dist/src/tiles/grid/item-tile.d.ts +6 -0
- package/dist/src/tiles/grid/item-tile.js +96 -124
- package/dist/src/tiles/grid/item-tile.js.map +1 -1
- package/dist/src/tiles/grid/tile-stats.d.ts +10 -0
- package/dist/src/tiles/grid/tile-stats.js +134 -0
- package/dist/src/tiles/grid/tile-stats.js.map +1 -0
- package/dist/src/tiles/mediatype-icon.js +4 -0
- package/dist/src/tiles/mediatype-icon.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/tile-stats.test.d.ts +1 -0
- package/dist/test/tile-stats.test.js +42 -0
- package/dist/test/tile-stats.test.js.map +1 -0
- package/dist/test/tiles/grid/item-tile.test.d.ts +1 -0
- package/dist/test/tiles/grid/item-tile.test.js +96 -0
- package/dist/test/tiles/grid/item-tile.test.js.map +1 -0
- package/package.json +1 -1
- package/src/{tiles/grid → assets/img}/icons/favorite-filled.ts +0 -0
- package/src/{tiles/grid → assets/img}/icons/reviews.ts +0 -0
- package/src/{tiles/grid → assets/img}/icons/upload.ts +0 -0
- package/src/{tiles/grid → assets/img}/icons/views.ts +1 -1
- package/src/tiles/grid/account-tile.ts +44 -77
- package/src/tiles/grid/item-tile.ts +103 -125
- package/src/tiles/grid/tile-stats.ts +132 -0
- package/src/tiles/mediatype-icon.ts +4 -0
- package/src/tiles/tile-dispatcher.ts +1 -0
- package/test/tile-stats.test.ts +57 -0
- package/test/tiles/grid/item-tile.test.ts +116 -0
- package/dist/src/tiles/grid/icons/account.d.ts +0 -1
- package/dist/src/tiles/grid/icons/account.js +0 -12
- package/dist/src/tiles/grid/icons/account.js.map +0 -1
- package/dist/src/tiles/grid/icons/views.d.ts +0 -2
- package/dist/src/tiles/grid/icons/views.js.map +0 -1
- package/src/tiles/grid/icons/account.ts +0 -12
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
/* eslint-disable import/no-duplicates */
|
|
2
2
|
import { css, CSSResultGroup, html, LitElement, nothing } from 'lit';
|
|
3
3
|
import { customElement, property } from 'lit/decorators.js';
|
|
4
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
5
|
+
import { SortParam } from '@internetarchive/search-service';
|
|
4
6
|
|
|
7
|
+
import { formatDate } from '../../utils/format-date';
|
|
5
8
|
import { TileModel } from '../../models';
|
|
6
|
-
import { formatCount } from '../../utils/format-count';
|
|
7
|
-
|
|
8
|
-
import { favoriteFilledIcon } from './icons/favorite-filled';
|
|
9
|
-
import { reviewsIcon } from './icons/reviews';
|
|
10
|
-
import viewsIcon from './icons/views';
|
|
11
9
|
|
|
12
10
|
import '../mediatype-icon';
|
|
13
11
|
import '../item-image';
|
|
12
|
+
import './tile-stats';
|
|
14
13
|
|
|
15
14
|
@customElement('item-tile')
|
|
16
15
|
export class ItemTile extends LitElement {
|
|
@@ -18,183 +17,162 @@ export class ItemTile extends LitElement {
|
|
|
18
17
|
|
|
19
18
|
@property({ type: String }) baseImageUrl?: string;
|
|
20
19
|
|
|
20
|
+
@property({ type: Object }) sortParam?: SortParam;
|
|
21
|
+
|
|
21
22
|
render() {
|
|
22
|
-
const itemTitle = this.model?.title
|
|
23
|
-
const itemCreator = this.model?.creator;
|
|
23
|
+
const itemTitle = this.model?.title;
|
|
24
24
|
return html`
|
|
25
|
-
<div
|
|
26
|
-
<div
|
|
27
|
-
<
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
</
|
|
25
|
+
<div class="container">
|
|
26
|
+
<div class="item-info">
|
|
27
|
+
<div id="title">
|
|
28
|
+
<h1 class="truncated" title=${ifDefined(
|
|
29
|
+
itemTitle
|
|
30
|
+
)}>${itemTitle}</h1>
|
|
31
31
|
</div>
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
</
|
|
32
|
+
|
|
33
|
+
<div id="image">
|
|
34
|
+
<item-image
|
|
35
|
+
.model=${this.model}
|
|
36
|
+
.baseImageUrl=${this.baseImageUrl}>
|
|
37
|
+
</item-image>
|
|
38
38
|
</div>
|
|
39
|
+
${
|
|
40
|
+
this.doesSortedByDate
|
|
41
|
+
? this.sortedDateInfoTemplate
|
|
42
|
+
: this.creatorTemplate
|
|
43
|
+
}
|
|
39
44
|
</div>
|
|
40
45
|
|
|
41
|
-
<
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
.mediatype=${this.model?.mediatype}
|
|
48
|
-
.collection=${this.model?.collections}
|
|
49
|
-
style="--iconHeight:25px; --iconWidth:25px;"
|
|
50
|
-
>
|
|
51
|
-
</mediatype-icon>
|
|
52
|
-
</div>
|
|
53
|
-
<div class="col">
|
|
54
|
-
${viewsIcon}
|
|
55
|
-
<p class="status-text">
|
|
56
|
-
${formatCount(this.model?.viewCount, 'short', 'short')}
|
|
57
|
-
</p>
|
|
58
|
-
</div>
|
|
59
|
-
<div class="col">
|
|
60
|
-
${favoriteFilledIcon}
|
|
61
|
-
<p class="status-text">
|
|
62
|
-
${formatCount(this.model?.itemCount, 'short', 'short')}
|
|
63
|
-
</p>
|
|
64
|
-
</div>
|
|
65
|
-
<div class="col">
|
|
66
|
-
${reviewsIcon}
|
|
67
|
-
<p class="status-text">
|
|
68
|
-
${formatCount(this.model?.favCount, 'short', 'short')}
|
|
69
|
-
</p>
|
|
70
|
-
</div>
|
|
71
|
-
</div>
|
|
46
|
+
<tile-stats
|
|
47
|
+
.mediatype=${this.model?.mediatype}
|
|
48
|
+
.viewCount=${this.model?.viewCount}
|
|
49
|
+
.favCount=${this.model?.favCount}
|
|
50
|
+
.commentCount=${this.model?.commentCount}>
|
|
51
|
+
</tile-stats>
|
|
72
52
|
</div>
|
|
73
53
|
</div>
|
|
74
54
|
`;
|
|
75
55
|
}
|
|
76
56
|
|
|
77
|
-
|
|
78
|
-
|
|
57
|
+
private get doesSortedByDate() {
|
|
58
|
+
return ['date', 'reviewdate', 'addeddate', 'publicdate'].includes(
|
|
59
|
+
this.sortParam?.field as string
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
private get sortedDateInfoTemplate() {
|
|
64
|
+
let sortedValue;
|
|
65
|
+
|
|
66
|
+
switch (this.sortParam?.field) {
|
|
67
|
+
case 'date':
|
|
68
|
+
sortedValue = { field: 'published', value: this.model?.datePublished };
|
|
69
|
+
break;
|
|
70
|
+
case 'reviewdate':
|
|
71
|
+
sortedValue = { field: 'reviewed', value: this.model?.dateReviewed };
|
|
72
|
+
break;
|
|
73
|
+
case 'addeddate':
|
|
74
|
+
sortedValue = { field: 'added', value: this.model?.dateAdded };
|
|
75
|
+
break;
|
|
76
|
+
case 'publicdate':
|
|
77
|
+
sortedValue = { field: 'archived', value: this.model?.dateArchived };
|
|
78
|
+
break;
|
|
79
|
+
default:
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return html`
|
|
84
|
+
<div class="date-sorted-by truncated">
|
|
85
|
+
<span>
|
|
86
|
+
${sortedValue?.field} ${formatDate(sortedValue?.value, 'long')}
|
|
87
|
+
</span>
|
|
88
|
+
</div>
|
|
89
|
+
`;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
private get creatorTemplate() {
|
|
93
|
+
return html`
|
|
94
|
+
<div class="created-by truncated">
|
|
95
|
+
${this.model?.creator
|
|
96
|
+
? html`<span>by ${this.model?.creator}</span>`
|
|
97
|
+
: nothing}
|
|
98
|
+
</div>
|
|
99
|
+
`;
|
|
100
|
+
}
|
|
79
101
|
|
|
102
|
+
static get styles(): CSSResultGroup {
|
|
80
103
|
return css`
|
|
81
|
-
|
|
104
|
+
.container {
|
|
82
105
|
background-color: #ffffff;
|
|
83
|
-
border-radius:
|
|
106
|
+
border-radius: var(--collectionTileCornerRadius, 4px);
|
|
84
107
|
box-shadow: 1px 1px 2px 0px;
|
|
85
108
|
display: flex;
|
|
86
109
|
flex-direction: column;
|
|
87
110
|
height: 100%;
|
|
88
|
-
position: relative;
|
|
89
111
|
}
|
|
90
112
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
flex: 1;
|
|
94
|
-
flex-direction: column;
|
|
95
|
-
padding: 0.5rem 0.5rem 0 0.5rem;
|
|
113
|
+
.item-info {
|
|
114
|
+
padding: 5px 5px 0 5px;
|
|
115
|
+
flex-grow: 1;
|
|
96
116
|
}
|
|
97
117
|
|
|
98
|
-
#
|
|
99
|
-
|
|
100
|
-
font-size: 1.6rem;
|
|
101
|
-
text-align: center;
|
|
102
|
-
margin-top: 0rem;
|
|
103
|
-
margin-bottom: 0.5rem;
|
|
104
|
-
overflow: hidden;
|
|
105
|
-
text-overflow: ellipsis;
|
|
106
|
-
display: -webkit-box;
|
|
107
|
-
-webkit-line-clamp: 2;
|
|
108
|
-
-webkit-box-orient: vertical;
|
|
109
|
-
line-height: 2rem;
|
|
110
|
-
height: 4rem;
|
|
118
|
+
#title {
|
|
119
|
+
flex-shrink: 0;
|
|
111
120
|
}
|
|
112
121
|
|
|
113
|
-
#
|
|
122
|
+
#image {
|
|
114
123
|
display: flex;
|
|
115
124
|
justify-content: center;
|
|
116
125
|
flex: 1;
|
|
126
|
+
height: 16rem;
|
|
117
127
|
}
|
|
118
128
|
|
|
119
129
|
.hidden {
|
|
120
130
|
display: none;
|
|
121
131
|
}
|
|
122
132
|
|
|
123
|
-
|
|
133
|
+
.container:hover > .item-info > #title > .truncated {
|
|
124
134
|
text-decoration: underline;
|
|
125
135
|
}
|
|
126
136
|
|
|
127
137
|
/** this is a workaround for Safari 15 where the hover effects are not working */
|
|
128
|
-
#title
|
|
138
|
+
#title:hover > .truncated {
|
|
129
139
|
text-decoration: underline;
|
|
130
140
|
}
|
|
131
141
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
.item-creator {
|
|
142
|
+
.created-by,
|
|
143
|
+
.date-sorted-by {
|
|
137
144
|
display: flex;
|
|
138
145
|
justify-content: center;
|
|
139
146
|
align-items: flex-end; /* Important to start text from bottom */
|
|
140
147
|
height: 3rem;
|
|
141
148
|
padding-top: 1rem;
|
|
149
|
+
margin-top: 5px;
|
|
142
150
|
}
|
|
143
151
|
|
|
144
152
|
.truncated {
|
|
145
153
|
flex: 1;
|
|
146
|
-
min-width: 0; /* Important for long words! */
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
.truncated span {
|
|
150
|
-
font-size: 1.4rem;
|
|
151
154
|
color: #2c2c2c;
|
|
152
|
-
-
|
|
155
|
+
min-width: 0; /* Important for long words! */
|
|
156
|
+
text-align: center;
|
|
157
|
+
line-height: 2rem;
|
|
153
158
|
text-overflow: ellipsis;
|
|
154
159
|
overflow: hidden;
|
|
155
|
-
display: -webkit-box;
|
|
156
|
-
-webkit-box-orient: vertical;
|
|
157
160
|
word-wrap: break-word;
|
|
158
|
-
line-
|
|
159
|
-
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
.hr {
|
|
163
|
-
border: 0.5px solid #ccc;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
#item-stats-container {
|
|
167
|
-
align-items: center;
|
|
168
|
-
display: flex;
|
|
169
|
-
height: 5.5rem;
|
|
170
|
-
padding-left: 1rem;
|
|
171
|
-
padding-right: 0.5rem;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
#stats-holder {
|
|
175
|
-
align-items: center;
|
|
176
|
-
display: flex;
|
|
177
|
-
flex: 1;
|
|
178
|
-
justify-content: space-evenly;
|
|
179
|
-
text-align: center;
|
|
180
|
-
width: 100%;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
svg {
|
|
184
|
-
height: 10px;
|
|
185
|
-
width: 10px;
|
|
161
|
+
-webkit-line-clamp: 2;
|
|
162
|
+
-webkit-box-orient: vertical;
|
|
186
163
|
}
|
|
187
164
|
|
|
188
|
-
.
|
|
189
|
-
font-size:
|
|
190
|
-
|
|
191
|
-
margin: auto;
|
|
192
|
-
display: block;
|
|
193
|
-
text-align: center;
|
|
165
|
+
.truncated span {
|
|
166
|
+
font-size: 1.4rem;
|
|
167
|
+
display: -webkit-box;
|
|
194
168
|
}
|
|
195
169
|
|
|
196
|
-
.
|
|
197
|
-
|
|
170
|
+
h1.truncated {
|
|
171
|
+
margin-top: 0rem;
|
|
172
|
+
margin-bottom: 0.5rem;
|
|
173
|
+
font-size: 1.6rem;
|
|
174
|
+
height: 4rem;
|
|
175
|
+
display: -webkit-box;
|
|
198
176
|
}
|
|
199
177
|
`;
|
|
200
178
|
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { css, CSSResultGroup, html, LitElement } from 'lit';
|
|
2
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
3
|
+
|
|
4
|
+
import { favoriteFilledIcon } from '../../assets/img/icons/favorite-filled';
|
|
5
|
+
import { reviewsIcon } from '../../assets/img/icons/reviews';
|
|
6
|
+
import { uploadIcon } from '../../assets/img/icons/upload';
|
|
7
|
+
import { viewsIcon } from '../../assets/img/icons/views';
|
|
8
|
+
|
|
9
|
+
import { formatCount } from '../../utils/format-count';
|
|
10
|
+
|
|
11
|
+
@customElement('tile-stats')
|
|
12
|
+
export class TileStats extends LitElement {
|
|
13
|
+
@property({ type: String }) mediatype?: string;
|
|
14
|
+
|
|
15
|
+
@property({ type: Number }) itemCount?: number;
|
|
16
|
+
|
|
17
|
+
@property({ type: Number }) viewCount?: number;
|
|
18
|
+
|
|
19
|
+
@property({ type: Number }) favCount?: number;
|
|
20
|
+
|
|
21
|
+
@property({ type: Number }) commentCount?: number;
|
|
22
|
+
|
|
23
|
+
render() {
|
|
24
|
+
return html`
|
|
25
|
+
<div class="item-stats">
|
|
26
|
+
<p class="sr-only">
|
|
27
|
+
${this.mediatype === 'account' ? 'Account Stats' : 'Item Stats'}
|
|
28
|
+
</p>
|
|
29
|
+
<ul id="stats-row">
|
|
30
|
+
<li class="col">
|
|
31
|
+
<p class="sr-only">Mediatype:</p>
|
|
32
|
+
<mediatype-icon .mediatype=${this.mediatype}></mediatype-icon>
|
|
33
|
+
</li>
|
|
34
|
+
<li class="col">
|
|
35
|
+
${this.mediatype === 'account' ? uploadIcon : viewsIcon}
|
|
36
|
+
<p class="status-text">
|
|
37
|
+
<span class="sr-only">
|
|
38
|
+
${this.mediatype === 'account' ? 'Uploads:' : 'Views:'}
|
|
39
|
+
</span>
|
|
40
|
+
${formatCount(
|
|
41
|
+
this.mediatype === 'account' ? this.itemCount : this.viewCount,
|
|
42
|
+
'short',
|
|
43
|
+
'short'
|
|
44
|
+
)}
|
|
45
|
+
</p>
|
|
46
|
+
</li>
|
|
47
|
+
<li class="col">
|
|
48
|
+
${favoriteFilledIcon}
|
|
49
|
+
<p class="status-text">
|
|
50
|
+
<span class="sr-only">Favorites:</span>
|
|
51
|
+
${formatCount(this.favCount, 'short', 'short')}
|
|
52
|
+
</p>
|
|
53
|
+
</li>
|
|
54
|
+
<li class="col">
|
|
55
|
+
${reviewsIcon}
|
|
56
|
+
<p class="status-text">
|
|
57
|
+
<span class="sr-only">Reviews:</span>
|
|
58
|
+
${formatCount(this.commentCount, 'short', 'short')}
|
|
59
|
+
</p>
|
|
60
|
+
</li>
|
|
61
|
+
</ul>
|
|
62
|
+
</div>
|
|
63
|
+
`;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
static get styles(): CSSResultGroup {
|
|
67
|
+
return css`
|
|
68
|
+
mediatype-icon {
|
|
69
|
+
--iconHeight: 25px;
|
|
70
|
+
--iconWidth: 25px;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
ul {
|
|
74
|
+
all: unset; // unset all property values
|
|
75
|
+
list-style-type: none; // remove default list-style
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
li {
|
|
79
|
+
list-style-type: none; // remove default list-style
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.item-stats {
|
|
83
|
+
height: 35px;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
#stats-row {
|
|
87
|
+
border-top: 1px solid #bbb;
|
|
88
|
+
align-items: center;
|
|
89
|
+
display: flex;
|
|
90
|
+
flex: 1;
|
|
91
|
+
justify-content: space-evenly;
|
|
92
|
+
text-align: center;
|
|
93
|
+
width: 100%;
|
|
94
|
+
padding-top: 5px;
|
|
95
|
+
padding-bottom: 5px;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.sr-only {
|
|
99
|
+
position: absolute;
|
|
100
|
+
width: 1px;
|
|
101
|
+
height: 1px;
|
|
102
|
+
padding: 0;
|
|
103
|
+
margin: -1px;
|
|
104
|
+
overflow: hidden;
|
|
105
|
+
clip: rect(0, 0, 0, 0);
|
|
106
|
+
border: 0;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.col {
|
|
110
|
+
width: 25%;
|
|
111
|
+
height: 25px;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
svg {
|
|
115
|
+
height: 10px;
|
|
116
|
+
width: 10px;
|
|
117
|
+
display: block;
|
|
118
|
+
margin: auto;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.status-text {
|
|
122
|
+
font-size: 14px;
|
|
123
|
+
height: 15px;
|
|
124
|
+
color: #2c2c2c;
|
|
125
|
+
line-height: 20px;
|
|
126
|
+
margin: auto;
|
|
127
|
+
display: block;
|
|
128
|
+
text-align: center;
|
|
129
|
+
}
|
|
130
|
+
`;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
@@ -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 { TileStats } from '../src/tiles/grid/tile-stats';
|
|
5
|
+
|
|
6
|
+
import '../src/tiles/grid/tile-stats';
|
|
7
|
+
|
|
8
|
+
describe('Tile Stats', () => {
|
|
9
|
+
it('should render initial component', async () => {
|
|
10
|
+
const el = await fixture<TileStats>(html`<tile-stats></tile-stats>`);
|
|
11
|
+
|
|
12
|
+
const itemStats = el.shadowRoot?.querySelector('.item-stats');
|
|
13
|
+
const statsRow = el.shadowRoot?.querySelector('#stats-row');
|
|
14
|
+
const statsRowCount = statsRow?.childElementCount;
|
|
15
|
+
|
|
16
|
+
expect(itemStats).to.exist;
|
|
17
|
+
expect(statsRow).to.exist;
|
|
18
|
+
expect(statsRowCount).to.equal(4);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('should render component with value', async () => {
|
|
22
|
+
const el = await fixture<TileStats>(
|
|
23
|
+
html`
|
|
24
|
+
<tile-stats
|
|
25
|
+
.mediatype=${'account'}
|
|
26
|
+
.itemCount=${1}
|
|
27
|
+
.favCount=${2}
|
|
28
|
+
.commentCount=${3}
|
|
29
|
+
>
|
|
30
|
+
</tile-stats>
|
|
31
|
+
`
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
const statsRow = el.shadowRoot?.querySelector('#stats-row');
|
|
35
|
+
|
|
36
|
+
const mediatypeStat = statsRow?.children.item(0);
|
|
37
|
+
// get second column item in stats row
|
|
38
|
+
const itemStatCount = statsRow?.children
|
|
39
|
+
.item(1)
|
|
40
|
+
?.querySelector('.status-text')?.textContent;
|
|
41
|
+
// get third column item in stats row
|
|
42
|
+
const favoritesStatCount = statsRow?.children
|
|
43
|
+
.item(2)
|
|
44
|
+
?.querySelector('.status-text')?.textContent;
|
|
45
|
+
// get fourth column item in stats row
|
|
46
|
+
const reviewsStatCount = statsRow?.children
|
|
47
|
+
.item(3)
|
|
48
|
+
?.querySelector('.status-text')?.textContent;
|
|
49
|
+
|
|
50
|
+
expect(mediatypeStat).to.exist;
|
|
51
|
+
|
|
52
|
+
// Snapshot testing - reference: https://open-wc.org/docs/testing/semantic-dom-diff/#snapshot-testing
|
|
53
|
+
expect(itemStatCount).to.equalSnapshot(1);
|
|
54
|
+
expect(favoritesStatCount).to.equalSnapshot(2);
|
|
55
|
+
expect(reviewsStatCount).to.equalSnapshot(3);
|
|
56
|
+
});
|
|
57
|
+
});
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/* eslint-disable import/no-duplicates */
|
|
2
|
+
import { expect, fixture } from '@open-wc/testing';
|
|
3
|
+
import { html } from 'lit';
|
|
4
|
+
import { ItemTile } from '../../../src/tiles/grid/item-tile';
|
|
5
|
+
|
|
6
|
+
import '../../../src/tiles/grid/item-tile';
|
|
7
|
+
|
|
8
|
+
describe('Item Tile', () => {
|
|
9
|
+
it('should render initial component', async () => {
|
|
10
|
+
const el = await fixture<ItemTile>(html`<item-tile></item-tile>`);
|
|
11
|
+
|
|
12
|
+
const itemInfo = el.shadowRoot?.querySelector('.item-info');
|
|
13
|
+
const itemImage = el.shadowRoot?.querySelector('item-image');
|
|
14
|
+
const itemTitle = el.shadowRoot?.querySelector('#title');
|
|
15
|
+
|
|
16
|
+
expect(itemInfo).to.exist;
|
|
17
|
+
expect(itemImage).to.exist;
|
|
18
|
+
expect(itemTitle).to.exist;
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('should render with created-by element', async () => {
|
|
22
|
+
const el = await fixture<ItemTile>(html`<item-tile></item-tile>`);
|
|
23
|
+
|
|
24
|
+
const itemInfo = el.shadowRoot?.querySelector('.item-info');
|
|
25
|
+
const createdBy = el.shadowRoot?.querySelector('.created-by');
|
|
26
|
+
const dateSortedBy = el.shadowRoot?.querySelector('.date-sorted-by');
|
|
27
|
+
|
|
28
|
+
expect(itemInfo).to.exist;
|
|
29
|
+
expect(createdBy).to.exist;
|
|
30
|
+
expect(dateSortedBy).to.not.exist;
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('should not render with created-by but date element', async () => {
|
|
34
|
+
const el = await fixture<ItemTile>(html`<item-tile></item-tile>`);
|
|
35
|
+
|
|
36
|
+
el.sortParam = {
|
|
37
|
+
field: 'date',
|
|
38
|
+
direction: 'desc',
|
|
39
|
+
};
|
|
40
|
+
await el.updateComplete;
|
|
41
|
+
|
|
42
|
+
const createdBy = el.shadowRoot?.querySelector('.created-by');
|
|
43
|
+
const dateSortedBy = el.shadowRoot?.querySelector('.date-sorted-by');
|
|
44
|
+
|
|
45
|
+
expect(createdBy).to.not.exist;
|
|
46
|
+
expect(dateSortedBy).to.exist;
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('should not render with created-by but reviewdate element', async () => {
|
|
50
|
+
const el = await fixture<ItemTile>(html`<item-tile></item-tile>`);
|
|
51
|
+
|
|
52
|
+
el.sortParam = {
|
|
53
|
+
field: 'reviewdate',
|
|
54
|
+
direction: 'desc',
|
|
55
|
+
};
|
|
56
|
+
await el.updateComplete;
|
|
57
|
+
|
|
58
|
+
const createdBy = el.shadowRoot?.querySelector('.created-by');
|
|
59
|
+
const dateSortedBy = el.shadowRoot?.querySelector('.date-sorted-by');
|
|
60
|
+
|
|
61
|
+
expect(createdBy).to.not.exist;
|
|
62
|
+
expect(dateSortedBy).to.exist;
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('should not render with created-by but publicdate element', async () => {
|
|
66
|
+
const el = await fixture<ItemTile>(html`<item-tile></item-tile>`);
|
|
67
|
+
|
|
68
|
+
el.sortParam = {
|
|
69
|
+
field: 'publicdate',
|
|
70
|
+
direction: 'desc',
|
|
71
|
+
};
|
|
72
|
+
await el.updateComplete;
|
|
73
|
+
|
|
74
|
+
const createdBy = el.shadowRoot?.querySelector('.created-by');
|
|
75
|
+
const dateSortedBy = el.shadowRoot?.querySelector('.date-sorted-by');
|
|
76
|
+
|
|
77
|
+
expect(createdBy).to.not.exist;
|
|
78
|
+
expect(dateSortedBy).to.exist;
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it('should render with created-by when sorting not related to date', async () => {
|
|
82
|
+
const el = await fixture<ItemTile>(html`<item-tile></item-tile>`);
|
|
83
|
+
|
|
84
|
+
el.sortParam = {
|
|
85
|
+
field: 'addeddate',
|
|
86
|
+
direction: 'asc',
|
|
87
|
+
};
|
|
88
|
+
await el.updateComplete;
|
|
89
|
+
|
|
90
|
+
const itemInfo = el.shadowRoot?.querySelector('.item-info');
|
|
91
|
+
const createdBy = el.shadowRoot?.querySelector('.created-by');
|
|
92
|
+
const dateSortedBy = el.shadowRoot?.querySelector('.date-sorted-by');
|
|
93
|
+
|
|
94
|
+
expect(itemInfo).to.exist;
|
|
95
|
+
expect(createdBy).to.not.exist;
|
|
96
|
+
expect(dateSortedBy).to.exist;
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it('should render with created-by when sort field id not like date', async () => {
|
|
100
|
+
const el = await fixture<ItemTile>(html`<item-tile></item-tile>`);
|
|
101
|
+
|
|
102
|
+
el.sortParam = {
|
|
103
|
+
field: 'week',
|
|
104
|
+
direction: 'asc',
|
|
105
|
+
};
|
|
106
|
+
await el.updateComplete;
|
|
107
|
+
|
|
108
|
+
const itemInfo = el.shadowRoot?.querySelector('.item-info');
|
|
109
|
+
const createdBy = el.shadowRoot?.querySelector('.created-by');
|
|
110
|
+
const dateSortedBy = el.shadowRoot?.querySelector('.date-sorted-by');
|
|
111
|
+
|
|
112
|
+
expect(itemInfo).to.exist;
|
|
113
|
+
expect(dateSortedBy).to.not.exist; // it should be exist because this is not related to date sort
|
|
114
|
+
expect(createdBy).to.exist;
|
|
115
|
+
});
|
|
116
|
+
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const accountIcon: import("lit-html").TemplateResult<2>;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { svg } from 'lit';
|
|
2
|
-
export const accountIcon = svg `
|
|
3
|
-
<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
|
|
4
|
-
<path
|
|
5
|
-
d="m89.6854559 79.6500588c1.7300364 6.4823648 2.180423 13.3122689 3.3145441 20.3499412h-86c.5683151-15.8558542 2.98334063-30.7849367 15.1676149-41.6581341 22.9948067-20.518674 59.250299-9.0032844 67.517841 21.3081929zm-40.0998307-79.6500588c10.872402.0493248 19.9700408 9.25722341 19.917959 20.1421788-.0829413 11.042868-8.9616237 19.8492523-20.0602807 19.8578212-11.1181198 0-19.9397193-8.7904706-19.9397193-19.8908727-.0327543-11.11998815 9.0125781-20.17487063 20.082041-20.1091273z"
|
|
6
|
-
fill="#333"
|
|
7
|
-
fill-rule="evenodd"
|
|
8
|
-
/>
|
|
9
|
-
<title>Icon of a person</title>
|
|
10
|
-
</svg>
|
|
11
|
-
`;
|
|
12
|
-
//# sourceMappingURL=account.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"account.js","sourceRoot":"","sources":["../../../../../src/tiles/grid/icons/account.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,CAAA;;;;;;;;;CAS7B,CAAC","sourcesContent":["import { svg } from 'lit';\n\nexport const accountIcon = svg`\n <svg viewBox=\"0 0 100 100\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n d=\"m89.6854559 79.6500588c1.7300364 6.4823648 2.180423 13.3122689 3.3145441 20.3499412h-86c.5683151-15.8558542 2.98334063-30.7849367 15.1676149-41.6581341 22.9948067-20.518674 59.250299-9.0032844 67.517841 21.3081929zm-40.0998307-79.6500588c10.872402.0493248 19.9700408 9.25722341 19.917959 20.1421788-.0829413 11.042868-8.9616237 19.8492523-20.0602807 19.8578212-11.1181198 0-19.9397193-8.7904706-19.9397193-19.8908727-.0327543-11.11998815 9.0125781-20.17487063 20.082041-20.1091273z\"\n fill=\"#333\"\n fill-rule=\"evenodd\"\n />\n <title>Icon of a person</title>\n </svg>\n`;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"views.js","sourceRoot":"","sources":["../../../../../src/tiles/grid/icons/views.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,eAAe,GAAG,CAAA;;;;;;;;CAQjB,CAAC","sourcesContent":["import { svg } from 'lit';\n\nexport default svg`\n <svg viewBox=\"0 0 100 100\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n d=\"m98 50.5704143c-.2830293-.471515-.671154-1.1088947-1.1643742-1.9121392s-1.6003642-2.3617474-3.3214321-4.6755089c-1.7210678-2.3137614-3.522258-4.5325939-5.4035703-6.6564975-1.8813124-2.1239037-4.2828993-4.473133-7.2047606-7.0476881-2.9218612-2.5745551-5.8895067-4.7933876-8.9029363-6.6564976-3.0134295-1.86311-6.4628491-3.4330878-10.3482587-4.7099336-3.8854095-1.2768458-7.7822651-1.9142256-11.6905667-1.9121443-3.9083017.0020914-7.8051573.6154781-11.6905668 1.8401652-3.8854096 1.2246871-7.3702078 2.8301329-10.4543947 4.8163375-3.0841869 1.9862045-6.0278997 4.1695691-8.8311384 6.5500937s-5.2048256 4.7652219-7.2047605 7.1540919c-1.99993501 2.38887-3.75430043 4.5722346-5.26309632 6.5500938s-2.63883199 3.583305-3.39010829 4.8163374l-1.13003609 1.8401602c.2830293.4715149.67115403 1.1088946 1.16437421 1.9121391.49322017.8032445 1.5878776 2.3617475 3.28397229 4.6755089s3.47439274 4.521119 5.3348942 6.6220728c1.8605014 2.1009538 4.2506422 4.4387083 7.1704224 7.0132633 2.9197801 2.5745551 5.8874256 4.7819127 8.9029363 6.6220729 3.0155106 1.8401601 6.4774168 3.398663 10.3857184 4.6755088 3.9083017 1.2768458 7.8176438 1.9142256 11.7280266 1.9121443 3.9103827-.0020914 7.7957922-.6154781 11.6562286-1.8401652s7.3337886-2.818658 10.4200566-4.7819127 6.0299808-4.1351444 8.8311384-6.515669 5.2152311-4.7652219 7.2422203-7.1540919 3.8052873-4.5607597 5.3348942-6.515669c1.5296068-1.9549093 2.6721295-3.5488802 3.427568-4.7819127zm-24.5142913 0c0 6.467683-2.3079374 12.0152859-6.9238123 16.6428087s-10.1495139 6.9412843-16.600917 6.9412843c-6.4992683 0-12.0453939-2.3137615-16.6383767-6.9412843s-6.8894742-10.1751257-6.8894742-16.6428087 2.2964914-12.003811 6.8894742-16.608384 10.1391084-6.9068595 16.6383767-6.9068595c6.4534842 0 11.9871232 2.3022865 16.600917 6.9068595s6.9217312 10.140701 6.9238123 16.608384zm-23.5247293-10.552755c2.8261308 0 5.2870289 1.0619518 7.3826944 3.1858555 2.0956655 2.1239036 3.1434982 4.5795368 3.1434982 7.3668995 0 2.8332624-1.0478327 5.2888956-3.1434982 7.3668995-2.0956655 2.078004-4.5565636 3.1170059-7.3826944 3.1170059-2.873996 0-5.3348941-1.0264838-7.3826944-3.0794516-2.0478002-2.0529677-3.0717003-4.5200758-3.0717003-7.4013243 0-2.8332624 1.0239001-5.3003705 3.0717003-7.4013243 2.0478003-2.1009538 4.5086984-3.1514307 7.3826944-3.1514307z\"\n fill=\"#333\"\n />\n <title>Eye icon</title>\n </svg>\n`;\n"]}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { svg } from 'lit';
|
|
2
|
-
|
|
3
|
-
export const accountIcon = svg`
|
|
4
|
-
<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
|
|
5
|
-
<path
|
|
6
|
-
d="m89.6854559 79.6500588c1.7300364 6.4823648 2.180423 13.3122689 3.3145441 20.3499412h-86c.5683151-15.8558542 2.98334063-30.7849367 15.1676149-41.6581341 22.9948067-20.518674 59.250299-9.0032844 67.517841 21.3081929zm-40.0998307-79.6500588c10.872402.0493248 19.9700408 9.25722341 19.917959 20.1421788-.0829413 11.042868-8.9616237 19.8492523-20.0602807 19.8578212-11.1181198 0-19.9397193-8.7904706-19.9397193-19.8908727-.0327543-11.11998815 9.0125781-20.17487063 20.082041-20.1091273z"
|
|
7
|
-
fill="#333"
|
|
8
|
-
fill-rule="evenodd"
|
|
9
|
-
/>
|
|
10
|
-
<title>Icon of a person</title>
|
|
11
|
-
</svg>
|
|
12
|
-
`;
|