@internetarchive/collection-browser 0.2.7-alpha.2 → 0.2.7

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 (56) hide show
  1. package/dist/src/collection-browser.js +10 -15
  2. package/dist/src/collection-browser.js.map +1 -1
  3. package/dist/src/tiles/grid/item-tile.d.ts +5 -6
  4. package/dist/src/tiles/grid/item-tile.js +51 -33
  5. package/dist/src/tiles/grid/item-tile.js.map +1 -1
  6. package/dist/src/tiles/item-image.d.ts +0 -5
  7. package/dist/src/tiles/item-image.js +3 -21
  8. package/dist/src/tiles/item-image.js.map +1 -1
  9. package/dist/src/tiles/item-tile-image.d.ts +15 -0
  10. package/dist/src/tiles/item-tile-image.js +68 -0
  11. package/dist/src/tiles/item-tile-image.js.map +1 -0
  12. package/dist/src/tiles/list/tile-list-compact.d.ts +0 -1
  13. package/dist/src/tiles/list/tile-list-compact.js +1 -10
  14. package/dist/src/tiles/list/tile-list-compact.js.map +1 -1
  15. package/dist/src/tiles/list/tile-list.d.ts +0 -1
  16. package/dist/src/tiles/list/tile-list.js +0 -5
  17. package/dist/src/tiles/list/tile-list.js.map +1 -1
  18. package/dist/src/tiles/tile-dispatcher.d.ts +0 -1
  19. package/dist/src/tiles/tile-dispatcher.js +1 -7
  20. package/dist/src/tiles/tile-dispatcher.js.map +1 -1
  21. package/dist/test/tiles/grid/item-tile.test.d.ts +1 -0
  22. package/dist/test/tiles/grid/item-tile.test.js +96 -0
  23. package/dist/test/tiles/grid/item-tile.test.js.map +1 -0
  24. package/package.json +2 -2
  25. package/src/collection-browser.ts +10 -15
  26. package/src/tiles/grid/item-tile.ts +51 -23
  27. package/src/tiles/item-image.ts +2 -22
  28. package/src/tiles/item-tile-image.ts +61 -0
  29. package/src/tiles/list/tile-list-compact.ts +1 -8
  30. package/src/tiles/list/tile-list.ts +0 -3
  31. package/src/tiles/tile-dispatcher.ts +1 -5
  32. package/test/tiles/grid/item-tile.test.ts +116 -0
  33. package/dist/src/assets/img/icons/login-required.d.ts +0 -1
  34. package/dist/src/assets/img/icons/login-required.js +0 -30
  35. package/dist/src/assets/img/icons/login-required.js.map +0 -1
  36. package/dist/src/tiles/overlay/icon-overlay.d.ts +0 -7
  37. package/dist/src/tiles/overlay/icon-overlay.js +0 -43
  38. package/dist/src/tiles/overlay/icon-overlay.js.map +0 -1
  39. package/dist/src/tiles/overlay/text-overlay.d.ts +0 -8
  40. package/dist/src/tiles/overlay/text-overlay.js +0 -53
  41. package/dist/src/tiles/overlay/text-overlay.js.map +0 -1
  42. package/dist/test/icon-overlay.test.d.ts +0 -1
  43. package/dist/test/icon-overlay.test.js +0 -23
  44. package/dist/test/icon-overlay.test.js.map +0 -1
  45. package/dist/test/item-image.test.d.ts +0 -1
  46. package/dist/test/item-image.test.js +0 -75
  47. package/dist/test/item-image.test.js.map +0 -1
  48. package/dist/test/text-overlay.test.d.ts +0 -1
  49. package/dist/test/text-overlay.test.js +0 -37
  50. package/dist/test/text-overlay.test.js.map +0 -1
  51. package/src/assets/img/icons/login-required.ts +0 -30
  52. package/src/tiles/overlay/icon-overlay.ts +0 -34
  53. package/src/tiles/overlay/text-overlay.ts +0 -44
  54. package/test/icon-overlay.test.ts +0 -30
  55. package/test/item-image.test.ts +0 -85
  56. package/test/text-overlay.test.ts +0 -44
@@ -0,0 +1 @@
1
+ {"version":3,"file":"item-tile.test.js","sourceRoot":"","sources":["../../../../test/tiles/grid/item-tile.test.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAG3B,OAAO,mCAAmC,CAAC;AAE3C,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;IACzB,EAAE,CAAC,iCAAiC,EAAE,KAAK,IAAI,EAAE;;QAC/C,MAAM,EAAE,GAAG,MAAM,OAAO,CAAW,IAAI,CAAA,yBA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C,CAAC;QAElE,EAAE,CAAC,SAAS,GAAG;YACb,KAAK,EAAE,MAAM;YACb,SAAS,EAAE,KAAK;SACjB,CAAC;QACF,MAAM,EAAE,CAAC,cAAc,CAAC;QAExB,MAAM,QAAQ,GAAG,MAAA,EAAE,CAAC,UAAU,0CAAE,aAAa,CAAC,YAAY,CAAC,CAAC;QAC5D,MAAM,SAAS,GAAG,MAAA,EAAE,CAAC,UAAU,0CAAE,aAAa,CAAC,aAAa,CAAC,CAAC;QAC9D,MAAM,YAAY,GAAG,MAAA,EAAE,CAAC,UAAU,0CAAE,aAAa,CAAC,iBAAiB,CAAC,CAAC;QAErE,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC;QAC1B,MAAM,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,8DAA8D;QACjG,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC;IAC7B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["/* eslint-disable import/no-duplicates */\nimport { expect, fixture } from '@open-wc/testing';\nimport { html } from 'lit';\nimport { ItemTile } from '../../../src/tiles/grid/item-tile';\n\nimport '../../../src/tiles/grid/item-tile';\n\ndescribe('Item Tile', () => {\n it('should render initial component', async () => {\n const el = await fixture<ItemTile>(html`<item-tile></item-tile>`);\n\n const itemInfo = el.shadowRoot?.querySelector('.item-info');\n const itemImage = el.shadowRoot?.querySelector('item-image');\n const itemTitle = el.shadowRoot?.querySelector('#title');\n\n expect(itemInfo).to.exist;\n expect(itemImage).to.exist;\n expect(itemTitle).to.exist;\n });\n\n it('should render with created-by element', async () => {\n const el = await fixture<ItemTile>(html`<item-tile></item-tile>`);\n\n const itemInfo = el.shadowRoot?.querySelector('.item-info');\n const createdBy = el.shadowRoot?.querySelector('.created-by');\n const dateSortedBy = el.shadowRoot?.querySelector('.date-sorted-by');\n\n expect(itemInfo).to.exist;\n expect(createdBy).to.exist;\n expect(dateSortedBy).to.not.exist;\n });\n\n it('should not render with created-by but date element', async () => {\n const el = await fixture<ItemTile>(html`<item-tile></item-tile>`);\n\n el.sortParam = {\n field: 'date',\n direction: 'desc',\n };\n await el.updateComplete;\n\n const createdBy = el.shadowRoot?.querySelector('.created-by');\n const dateSortedBy = el.shadowRoot?.querySelector('.date-sorted-by');\n\n expect(createdBy).to.not.exist;\n expect(dateSortedBy).to.exist;\n });\n\n it('should not render with created-by but reviewdate element', async () => {\n const el = await fixture<ItemTile>(html`<item-tile></item-tile>`);\n\n el.sortParam = {\n field: 'reviewdate',\n direction: 'desc',\n };\n await el.updateComplete;\n\n const createdBy = el.shadowRoot?.querySelector('.created-by');\n const dateSortedBy = el.shadowRoot?.querySelector('.date-sorted-by');\n\n expect(createdBy).to.not.exist;\n expect(dateSortedBy).to.exist;\n });\n\n it('should not render with created-by but publicdate element', async () => {\n const el = await fixture<ItemTile>(html`<item-tile></item-tile>`);\n\n el.sortParam = {\n field: 'publicdate',\n direction: 'desc',\n };\n await el.updateComplete;\n\n const createdBy = el.shadowRoot?.querySelector('.created-by');\n const dateSortedBy = el.shadowRoot?.querySelector('.date-sorted-by');\n\n expect(createdBy).to.not.exist;\n expect(dateSortedBy).to.exist;\n });\n\n it('should render with created-by when sorting not related to date', async () => {\n const el = await fixture<ItemTile>(html`<item-tile></item-tile>`);\n\n el.sortParam = {\n field: 'addeddate',\n direction: 'asc',\n };\n await el.updateComplete;\n\n const itemInfo = el.shadowRoot?.querySelector('.item-info');\n const createdBy = el.shadowRoot?.querySelector('.created-by');\n const dateSortedBy = el.shadowRoot?.querySelector('.date-sorted-by');\n\n expect(itemInfo).to.exist;\n expect(createdBy).to.not.exist;\n expect(dateSortedBy).to.exist;\n });\n\n it('should render with created-by when sort field id not like date', async () => {\n const el = await fixture<ItemTile>(html`<item-tile></item-tile>`);\n\n el.sortParam = {\n field: 'week',\n direction: 'asc',\n };\n await el.updateComplete;\n\n const itemInfo = el.shadowRoot?.querySelector('.item-info');\n const createdBy = el.shadowRoot?.querySelector('.created-by');\n const dateSortedBy = el.shadowRoot?.querySelector('.date-sorted-by');\n\n expect(itemInfo).to.exist;\n expect(dateSortedBy).to.not.exist; // it should be exist because this is not related to date sort\n expect(createdBy).to.exist;\n });\n});\n"]}
package/package.json CHANGED
@@ -3,11 +3,11 @@
3
3
  "description": "The Internet Archive Collection Browser.",
4
4
  "license": "AGPL-3.0-only",
5
5
  "author": "Internet Archive",
6
- "version": "0.2.7-alpha.2",
6
+ "version": "0.2.7",
7
7
  "main": "dist/index.js",
8
8
  "module": "dist/index.js",
9
9
  "scripts": {
10
- "start": "yarn run prepare && tsc && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"wds\"",
10
+ "start": "yarn run prepare && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"wds\"",
11
11
  "prepare:ghpages": "rimraf ghpages && yarn run prepare && vite build",
12
12
  "prepare": "rimraf dist && tsc && husky install",
13
13
  "lint": "eslint --ext .ts,.html . --ignore-path .gitignore && prettier \"**/*.ts\" --check --ignore-path .gitignore",
@@ -428,7 +428,6 @@ export class CollectionBrowser
428
428
  .resizeObserver=${this.resizeObserver}
429
429
  .sortParam=${this.sortParam}
430
430
  .mobileBreakpoint=${this.mobileBreakpoint}
431
- .loggedIn=${this.loggedIn}
432
431
  >
433
432
  </tile-dispatcher>
434
433
  </div>
@@ -1090,20 +1089,16 @@ export class CollectionBrowser
1090
1089
  const model = this.tileModelAtCellIndex(index);
1091
1090
  if (!model) return undefined;
1092
1091
 
1093
- return html`
1094
- <tile-dispatcher
1095
- .baseNavigationUrl=${this.baseNavigationUrl}
1096
- .baseImageUrl=${this.baseImageUrl}
1097
- .model=${model}
1098
- .tileDisplayMode=${this.displayMode}
1099
- .resizeObserver=${this.resizeObserver}
1100
- .collectionNameCache=${this.collectionNameCache}
1101
- .sortParam=${this.sortParam}
1102
- .mobileBreakpoint=${this.mobileBreakpoint}
1103
- .loggedIn=${this.loggedIn}
1104
- >
1105
- </tile-dispatcher>
1106
- `;
1092
+ return html` <tile-dispatcher
1093
+ .baseNavigationUrl=${this.baseNavigationUrl}
1094
+ .baseImageUrl=${this.baseImageUrl}
1095
+ .model=${model}
1096
+ .tileDisplayMode=${this.displayMode}
1097
+ .resizeObserver=${this.resizeObserver}
1098
+ .collectionNameCache=${this.collectionNameCache}
1099
+ .sortParam=${this.sortParam}
1100
+ .mobileBreakpoint=${this.mobileBreakpoint}
1101
+ ></tile-dispatcher>`;
1107
1102
  }
1108
1103
 
1109
1104
  /**
@@ -2,26 +2,25 @@
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
6
 
7
+ import { formatDate } from '../../utils/format-date';
6
8
  import { TileModel } from '../../models';
7
9
 
8
10
  import '../mediatype-icon';
9
11
  import '../item-image';
10
12
  import './tile-stats';
11
- import '../overlay/text-overlay';
12
13
 
13
14
  @customElement('item-tile')
14
15
  export class ItemTile extends LitElement {
15
- @property({ type: Boolean }) loggedIn = false;
16
-
17
16
  @property({ type: Object }) model?: TileModel;
18
17
 
19
18
  @property({ type: String }) baseImageUrl?: string;
20
19
 
20
+ @property({ type: Object }) sortParam?: SortParam;
21
+
21
22
  render() {
22
23
  const itemTitle = this.model?.title;
23
- const itemCreator = this.model?.creator;
24
-
25
24
  return html`
26
25
  <div class="container">
27
26
  <div class="item-info">
@@ -36,12 +35,12 @@ export class ItemTile extends LitElement {
36
35
  .model=${this.model}
37
36
  .baseImageUrl=${this.baseImageUrl}>
38
37
  </item-image>
39
- ${this.textOverlayTemplate}
40
- </div>
41
-
42
- <div class="created-by truncated">
43
- ${itemCreator ? html`<span>by&nbsp;${itemCreator}</span>` : nothing}
44
38
  </div>
39
+ ${
40
+ this.doesSortedByDate
41
+ ? this.sortedDateInfoTemplate
42
+ : this.creatorTemplate
43
+ }
45
44
  </div>
46
45
 
47
46
  <tile-stats
@@ -55,19 +54,48 @@ export class ItemTile extends LitElement {
55
54
  `;
56
55
  }
57
56
 
58
- /**
59
- * Templates
60
- */
61
- private get textOverlayTemplate() {
62
- if (!this.model?.loginRequired && !this.model?.contentWarning) {
63
- return nothing;
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;
64
81
  }
82
+
65
83
  return html`
66
- <text-overlay
67
- .loggedIn=${this.loggedIn}
68
- .loginRequired=${this.model?.loginRequired}
69
- .contentWarning=${this.model?.contentWarning}
70
- ></text-overlay>
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&nbsp;${this.model?.creator}</span>`
97
+ : nothing}
98
+ </div>
71
99
  `;
72
100
  }
73
101
 
@@ -96,7 +124,6 @@ export class ItemTile extends LitElement {
96
124
  justify-content: center;
97
125
  flex: 1;
98
126
  height: 16rem;
99
- position: relative;
100
127
  }
101
128
 
102
129
  .hidden {
@@ -112,7 +139,8 @@ export class ItemTile extends LitElement {
112
139
  text-decoration: underline;
113
140
  }
114
141
 
115
- .created-by {
142
+ .created-by,
143
+ .date-sorted-by {
116
144
  display: flex;
117
145
  justify-content: center;
118
146
  align-items: flex-end; /* Important to start text from bottom */
@@ -1,4 +1,4 @@
1
- import { css, CSSResultGroup, html, LitElement, nothing } from 'lit';
1
+ 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
 
@@ -9,8 +9,6 @@ import {
9
9
  waveformGradientStyles,
10
10
  } from '../styles/item-image-styles';
11
11
 
12
- import './overlay/icon-overlay';
13
-
14
12
  @customElement('item-image')
15
13
  export class ItemImage extends LitElement {
16
14
  @property({ type: Object }) model?: TileModel;
@@ -36,26 +34,10 @@ export class ItemImage extends LitElement {
36
34
  alt=""
37
35
  @load=${this.onLoad}
38
36
  />
39
- ${this.iconOverlayTemplate}
40
37
  </div>
41
38
  `;
42
39
  }
43
40
 
44
- /**
45
- * Templates
46
- */
47
- private get iconOverlayTemplate() {
48
- if (!this.model?.loginRequired && !this.model?.contentWarning) {
49
- return nothing;
50
- }
51
- return html`
52
- <icon-overlay
53
- .loggedIn=${this.loggedIn}
54
- .loginRequired=${this.model?.loginRequired}
55
- ></icon-overlay>
56
- `;
57
- }
58
-
59
41
  /**
60
42
  * Helpers
61
43
  */
@@ -89,12 +71,10 @@ export class ItemImage extends LitElement {
89
71
  }
90
72
 
91
73
  private get itemImageClass(): ClassInfo {
92
- const toBlur = this.model?.contentWarning || this.model?.loginRequired;
93
-
94
74
  return {
95
75
  contain: !this.isCompactTile && !this.isWaveform,
96
76
  cover: this.isCompactTile,
97
- blur: toBlur || false,
77
+ blur: this.model?.contentWarning || false,
98
78
  waveform: this.isWaveform,
99
79
  };
100
80
  }
@@ -0,0 +1,61 @@
1
+ import { html, LitElement } from 'lit';
2
+ import { customElement, property } from 'lit/decorators.js';
3
+
4
+ import { TileModel } from '../models';
5
+
6
+ import './image/item-image';
7
+ import './image/waveform-image';
8
+
9
+ @customElement('item-tile-image')
10
+ export class ItemTileImage extends LitElement {
11
+ @property({ type: Object }) model?: TileModel;
12
+
13
+ @property({ type: String }) baseImageUrl?: string;
14
+
15
+ @property({ type: Boolean }) isListTile = false;
16
+
17
+ @property({ type: Boolean }) isCompactTile = false;
18
+
19
+ render() {
20
+ return html`
21
+ ${this.isWithWaveformMediatype
22
+ ? this.waveformImageTemplate
23
+ : this.itemImageTemplate}
24
+ `;
25
+ }
26
+
27
+ private get imageSrc() {
28
+ return `${this.baseImageUrl}/services/img/${this.model?.identifier}`;
29
+ }
30
+
31
+ private get isWithWaveformMediatype() {
32
+ return (
33
+ this.model?.mediatype === 'audio' || this.model?.mediatype === 'etree'
34
+ );
35
+ }
36
+
37
+ // Templates
38
+ private get itemImageTemplate() {
39
+ return html`
40
+ <item-image
41
+ .model=${this.model}
42
+ .imageSrc=${this.imageSrc}
43
+ .isCompactTile=${this.isCompactTile}
44
+ .isListTile=${this.isListTile}
45
+ >
46
+ </item-image>
47
+ `;
48
+ }
49
+
50
+ private get waveformImageTemplate() {
51
+ return html`
52
+ <waveform-image
53
+ .imageSrc=${this.imageSrc}
54
+ .identifier=${this.model?.identifier}
55
+ .isCompactTile=${this.isCompactTile}
56
+ .isListTile=${this.isListTile}
57
+ >
58
+ </waveform-image>
59
+ `;
60
+ }
61
+ }
@@ -28,8 +28,6 @@ export class TileListCompact extends LitElement {
28
28
 
29
29
  @property({ type: String }) baseImageUrl?: string;
30
30
 
31
- @property({ type: Boolean }) loggedIn = false;
32
-
33
31
  render() {
34
32
  return html`
35
33
  <div id="list-line" class="${this.classSize}">
@@ -67,7 +65,7 @@ export class TileListCompact extends LitElement {
67
65
  .baseImageUrl=${this.baseImageUrl}
68
66
  .isListTile=${true}
69
67
  .isCompactTile=${true}
70
- .loggedIn=${this.loggedIn}
68
+ style="--imgHeight: 100%; --imgWidth: 100%"
71
69
  >
72
70
  </item-image>
73
71
  `;
@@ -207,11 +205,6 @@ export class TileListCompact extends LitElement {
207
205
  --iconHeight: 20px;
208
206
  --iconWidth: 20px;
209
207
  }
210
-
211
- item-image {
212
- --imgHeight: 100%;
213
- --imgWidth: 100%;
214
- }
215
208
  `;
216
209
  }
217
210
  }
@@ -45,8 +45,6 @@ export class TileList extends LitElement {
45
45
 
46
46
  @property({ type: String }) baseImageUrl?: string;
47
47
 
48
- @property({ type: Boolean }) loggedIn = false;
49
-
50
48
  protected updated(changed: PropertyValues): void {
51
49
  if (changed.has('model')) {
52
50
  this.fetchCollectionNames();
@@ -149,7 +147,6 @@ export class TileList extends LitElement {
149
147
  .model=${this.model}
150
148
  .baseImageUrl=${this.baseImageUrl}
151
149
  .isListTile=${true}
152
- .loggedIn=${this.loggedIn}
153
150
  style="--imgHeight: 100%; --imgWidth: 100%"
154
151
  >
155
152
  </item-image>
@@ -43,8 +43,6 @@ export class TileDispatcher
43
43
 
44
44
  @property({ type: String }) baseImageUrl?: string;
45
45
 
46
- @property({ type: Boolean }) loggedIn = false;
47
-
48
46
  render() {
49
47
  return html`
50
48
  <div id="container">
@@ -156,7 +154,7 @@ export class TileDispatcher
156
154
  .currentHeight=${this.currentHeight}
157
155
  .collectionNameCache=${this.collectionNameCache}
158
156
  .baseImageUrl=${this.baseImageUrl}
159
- .loggedIn=${this.loggedIn}
157
+ .sortParam=${sortParam}
160
158
  ></item-tile>`;
161
159
  }
162
160
  case 'list-compact':
@@ -168,7 +166,6 @@ export class TileDispatcher
168
166
  .sortParam=${sortParam}
169
167
  .mobileBreakpoint=${mobileBreakpoint}
170
168
  .baseImageUrl=${this.baseImageUrl}
171
- .loggedIn=${this.loggedIn}
172
169
  ></tile-list-compact>`;
173
170
  case 'list-detail':
174
171
  return html`<tile-list
@@ -180,7 +177,6 @@ export class TileDispatcher
180
177
  .sortParam=${sortParam}
181
178
  .mobileBreakpoint=${mobileBreakpoint}
182
179
  .baseImageUrl=${this.baseImageUrl}
183
- .loggedIn=${this.loggedIn}
184
180
  ></tile-list>`;
185
181
  default:
186
182
  return nothing;
@@ -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 loginRequiredIcon: import("lit-html").TemplateResult<2>;
@@ -1,30 +0,0 @@
1
- import { svg } from 'lit';
2
- export const loginRequiredIcon = svg `
3
- <svg
4
- viewBox="0 0 100 100"
5
- xmlns="http://www.w3.org/2000/svg"
6
- >
7
- <g fill="none" fill-rule="nonzero">
8
- <path
9
- d="m11 48h11c-.0377367 5.0230706-.0377367 17.6897373 0 38h28v-38h12c-14.7643578-21.746483-22.9310245-33.4131497-24.5-35z"
10
- fill="#fff"
11
- transform="matrix(0 1 -1 0 86 13)"
12
- />
13
- <path
14
- d="m17 44h9c-.0377367 5.0230706-.0377367 17.0230706 0 36h18v-36h10c-10.0976911-15.0798163-15.9310245-23.4131497-17.5-25z"
15
- fill="#000"
16
- transform="matrix(0 1 -1 0 85 14)"
17
- />
18
- <path
19
- d="m84.3595506 0h-55.7191012c-8.6379817 0-15.6404494 6.39593215-15.6404494 14.2857143v15.7142857h20v-11h47v62l-47-1v-11h-20v16.7142857c0 7.8897822 7.0024677 14.2857143 15.6404494 14.2857143h55.7191012c8.6379817 0 15.6404494-6.3959321 15.6404494-14.2857143v-71.4285714c0-7.88978215-7.0024677-14.2857143-15.6404494-14.2857143z"
20
- fill="#fff"
21
- />
22
- <path
23
- d="m84.2597403 5c5.3793969 0 9.7402597 4.02943725 9.7402597 9v72c0 4.9705627-4.3608628 9-9.7402597 9h-55.5194806c-5.3793969 0-9.7402597-4.0294373-9.7402597-9v-12h8v7.5c0 2.4198792 1.8593897 4.3936363 4.4510815 4.4958424l48.9709964.0041576c2.6189169 0 4.4673094-2.6052767 4.5779221-5v-62c0-2.4852814-2.3103015-5-5-5h-48.3376623c-2.618917 0-4.551725 1.6052767-4.6623377 4v7h-8v-11c0-4.97056275 4.3608628-9 9.7402597-9z"
24
- fill="#000"
25
- />
26
- </g>
27
- <title>Log in to view this item</title>
28
- </svg>
29
- `;
30
- //# sourceMappingURL=login-required.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"login-required.js","sourceRoot":"","sources":["../../../../../src/assets/img/icons/login-required.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BnC,CAAC","sourcesContent":["import { svg } from 'lit';\n\nexport const loginRequiredIcon = svg`\n <svg\n viewBox=\"0 0 100 100\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <g fill=\"none\" fill-rule=\"nonzero\">\n <path\n d=\"m11 48h11c-.0377367 5.0230706-.0377367 17.6897373 0 38h28v-38h12c-14.7643578-21.746483-22.9310245-33.4131497-24.5-35z\"\n fill=\"#fff\"\n transform=\"matrix(0 1 -1 0 86 13)\"\n />\n <path\n d=\"m17 44h9c-.0377367 5.0230706-.0377367 17.0230706 0 36h18v-36h10c-10.0976911-15.0798163-15.9310245-23.4131497-17.5-25z\"\n fill=\"#000\"\n transform=\"matrix(0 1 -1 0 85 14)\"\n />\n <path\n d=\"m84.3595506 0h-55.7191012c-8.6379817 0-15.6404494 6.39593215-15.6404494 14.2857143v15.7142857h20v-11h47v62l-47-1v-11h-20v16.7142857c0 7.8897822 7.0024677 14.2857143 15.6404494 14.2857143h55.7191012c8.6379817 0 15.6404494-6.3959321 15.6404494-14.2857143v-71.4285714c0-7.88978215-7.0024677-14.2857143-15.6404494-14.2857143z\"\n fill=\"#fff\"\n />\n <path\n d=\"m84.2597403 5c5.3793969 0 9.7402597 4.02943725 9.7402597 9v72c0 4.9705627-4.3608628 9-9.7402597 9h-55.5194806c-5.3793969 0-9.7402597-4.0294373-9.7402597-9v-12h8v7.5c0 2.4198792 1.8593897 4.3936363 4.4510815 4.4958424l48.9709964.0041576c2.6189169 0 4.4673094-2.6052767 4.5779221-5v-62c0-2.4852814-2.3103015-5-5-5h-48.3376623c-2.618917 0-4.551725 1.6052767-4.6623377 4v7h-8v-11c0-4.97056275 4.3608628-9 9.7402597-9z\"\n fill=\"#000\"\n />\n </g>\n <title>Log in to view this item</title>\n </svg>\n`;\n"]}
@@ -1,7 +0,0 @@
1
- import { CSSResultGroup, LitElement } from 'lit';
2
- export declare class IconOverlay extends LitElement {
3
- loggedIn: boolean;
4
- loginRequired: boolean;
5
- render(): import("lit-html").TemplateResult<1>;
6
- static get styles(): CSSResultGroup;
7
- }
@@ -1,43 +0,0 @@
1
- import { __decorate } from "tslib";
2
- import { css, html, LitElement } from 'lit';
3
- import { customElement, property } from 'lit/decorators.js';
4
- import { restrictedIcon } from '../../assets/img/icons/restricted';
5
- import { loginRequiredIcon } from '../../assets/img/icons/login-required';
6
- let IconOverlay = class IconOverlay extends LitElement {
7
- constructor() {
8
- super(...arguments);
9
- this.loggedIn = false;
10
- this.loginRequired = false;
11
- }
12
- render() {
13
- if (this.loginRequired && !this.loggedIn) {
14
- return html `${loginRequiredIcon} `;
15
- }
16
- return html `${restrictedIcon}`;
17
- }
18
- static get styles() {
19
- return css `
20
- :host {
21
- position: absolute;
22
- width: 100%;
23
- height: 100%;
24
- z-index: 2;
25
- }
26
-
27
- svg {
28
- padding: 25%;
29
- }
30
- `;
31
- }
32
- };
33
- __decorate([
34
- property({ type: Boolean })
35
- ], IconOverlay.prototype, "loggedIn", void 0);
36
- __decorate([
37
- property({ type: Boolean })
38
- ], IconOverlay.prototype, "loginRequired", void 0);
39
- IconOverlay = __decorate([
40
- customElement('icon-overlay')
41
- ], IconOverlay);
42
- export { IconOverlay };
43
- //# sourceMappingURL=icon-overlay.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"icon-overlay.js","sourceRoot":"","sources":["../../../../src/tiles/overlay/icon-overlay.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAkB,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE5D,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAG1E,IAAa,WAAW,GAAxB,MAAa,WAAY,SAAQ,UAAU;IAA3C;;QAC+B,aAAQ,GAAG,KAAK,CAAC;QAEjB,kBAAa,GAAG,KAAK,CAAC;IAuBrD,CAAC;IArBC,MAAM;QACJ,IAAI,IAAI,CAAC,aAAa,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;YACxC,OAAO,IAAI,CAAA,GAAG,iBAAiB,GAAG,CAAC;SACpC;QACD,OAAO,IAAI,CAAA,GAAG,cAAc,EAAE,CAAC;IACjC,CAAC;IAED,MAAM,KAAK,MAAM;QACf,OAAO,GAAG,CAAA;;;;;;;;;;;KAWT,CAAC;IACJ,CAAC;CACF,CAAA;AAzB8B;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;6CAAkB;AAEjB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;kDAAuB;AAHxC,WAAW;IADvB,aAAa,CAAC,cAAc,CAAC;GACjB,WAAW,CA0BvB;SA1BY,WAAW","sourcesContent":["import { css, CSSResultGroup, html, LitElement } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\n\nimport { restrictedIcon } from '../../assets/img/icons/restricted';\nimport { loginRequiredIcon } from '../../assets/img/icons/login-required';\n\n@customElement('icon-overlay')\nexport class IconOverlay extends LitElement {\n @property({ type: Boolean }) loggedIn = false;\n\n @property({ type: Boolean }) loginRequired = false;\n\n render() {\n if (this.loginRequired && !this.loggedIn) {\n return html`${loginRequiredIcon} `;\n }\n return html`${restrictedIcon}`;\n }\n\n static get styles(): CSSResultGroup {\n return css`\n :host {\n position: absolute;\n width: 100%;\n height: 100%;\n z-index: 2;\n }\n\n svg {\n padding: 25%;\n }\n `;\n }\n}\n"]}
@@ -1,8 +0,0 @@
1
- import { CSSResultGroup, LitElement } from 'lit';
2
- export declare class TextOverlay extends LitElement {
3
- loggedIn: boolean;
4
- loginRequired: boolean;
5
- render(): import("lit-html").TemplateResult<1>;
6
- private get textDisplay();
7
- static get styles(): CSSResultGroup;
8
- }