@internetarchive/collection-browser 0.2.4-rc1 → 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.
Files changed (52) hide show
  1. package/dist/src/{tiles/grid → assets/img}/icons/favorite-filled.d.ts +0 -0
  2. package/dist/src/{tiles/grid → assets/img}/icons/favorite-filled.js +0 -0
  3. package/dist/src/{tiles/grid → assets/img}/icons/favorite-filled.js.map +1 -1
  4. package/dist/src/{tiles/grid → assets/img}/icons/reviews.d.ts +0 -0
  5. package/dist/src/{tiles/grid → assets/img}/icons/reviews.js +0 -0
  6. package/dist/src/{tiles/grid → assets/img}/icons/reviews.js.map +1 -1
  7. package/dist/src/{tiles/grid → assets/img}/icons/upload.d.ts +0 -0
  8. package/dist/src/{tiles/grid → assets/img}/icons/upload.js +0 -0
  9. package/dist/src/{tiles/grid → assets/img}/icons/upload.js.map +1 -1
  10. package/dist/src/assets/img/icons/views.d.ts +1 -0
  11. package/dist/src/{tiles/grid → assets/img}/icons/views.js +1 -1
  12. package/dist/src/assets/img/icons/views.js.map +1 -0
  13. package/dist/src/sort-filter-bar/sort-filter-bar.js +1 -1
  14. package/dist/src/sort-filter-bar/sort-filter-bar.js.map +1 -1
  15. package/dist/src/tiles/grid/account-tile.d.ts +1 -0
  16. package/dist/src/tiles/grid/account-tile.js +45 -78
  17. package/dist/src/tiles/grid/account-tile.js.map +1 -1
  18. package/dist/src/tiles/grid/item-tile.d.ts +6 -0
  19. package/dist/src/tiles/grid/item-tile.js +96 -124
  20. package/dist/src/tiles/grid/item-tile.js.map +1 -1
  21. package/dist/src/tiles/grid/tile-stats.d.ts +10 -0
  22. package/dist/src/tiles/grid/tile-stats.js +134 -0
  23. package/dist/src/tiles/grid/tile-stats.js.map +1 -0
  24. package/dist/src/tiles/mediatype-icon.js +4 -0
  25. package/dist/src/tiles/mediatype-icon.js.map +1 -1
  26. package/dist/src/tiles/tile-dispatcher.js +1 -0
  27. package/dist/src/tiles/tile-dispatcher.js.map +1 -1
  28. package/dist/test/tile-stats.test.d.ts +1 -0
  29. package/dist/test/tile-stats.test.js +42 -0
  30. package/dist/test/tile-stats.test.js.map +1 -0
  31. package/dist/test/tiles/grid/item-tile.test.d.ts +1 -0
  32. package/dist/test/tiles/grid/item-tile.test.js +96 -0
  33. package/dist/test/tiles/grid/item-tile.test.js.map +1 -0
  34. package/package.json +1 -1
  35. package/src/{tiles/grid → assets/img}/icons/favorite-filled.ts +0 -0
  36. package/src/{tiles/grid → assets/img}/icons/reviews.ts +0 -0
  37. package/src/{tiles/grid → assets/img}/icons/upload.ts +0 -0
  38. package/src/{tiles/grid → assets/img}/icons/views.ts +1 -1
  39. package/src/sort-filter-bar/sort-filter-bar.ts +1 -1
  40. package/src/tiles/grid/account-tile.ts +44 -77
  41. package/src/tiles/grid/item-tile.ts +103 -125
  42. package/src/tiles/grid/tile-stats.ts +132 -0
  43. package/src/tiles/mediatype-icon.ts +4 -0
  44. package/src/tiles/tile-dispatcher.ts +1 -0
  45. package/test/tile-stats.test.ts +57 -0
  46. package/test/tiles/grid/item-tile.test.ts +116 -0
  47. package/dist/src/tiles/grid/icons/account.d.ts +0 -1
  48. package/dist/src/tiles/grid/icons/account.js +0 -12
  49. package/dist/src/tiles/grid/icons/account.js.map +0 -1
  50. package/dist/src/tiles/grid/icons/views.d.ts +0 -2
  51. package/dist/src/tiles/grid/icons/views.js.map +0 -1
  52. package/src/tiles/grid/icons/account.ts +0 -12
@@ -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
+ }
@@ -50,6 +50,10 @@ export class MediatypeIcon extends LitElement {
50
50
 
51
51
  static get styles(): CSSResultGroup {
52
52
  return css`
53
+ #icon {
54
+ height: var(--iconHeight, 25px);
55
+ }
56
+
53
57
  .status-text {
54
58
  font-size: 14px;
55
59
  color: #2c2c2c;
@@ -154,6 +154,7 @@ export class TileDispatcher
154
154
  .currentHeight=${this.currentHeight}
155
155
  .collectionNameCache=${this.collectionNameCache}
156
156
  .baseImageUrl=${this.baseImageUrl}
157
+ .sortParam=${sortParam}
157
158
  ></item-tile>`;
158
159
  }
159
160
  case 'list-compact':
@@ -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,2 +0,0 @@
1
- declare const _default: import("lit-html").TemplateResult<2>;
2
- export default _default;
@@ -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
- `;