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

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/collection-browser.js +14 -15
  2. package/dist/src/collection-browser.js.map +1 -1
  3. package/dist/src/tiles/grid/item-tile.d.ts +0 -6
  4. package/dist/src/tiles/grid/item-tile.js +0 -27
  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 +0 -7
  20. package/dist/src/tiles/tile-dispatcher.js.map +1 -1
  21. package/package.json +2 -2
  22. package/src/collection-browser.ts +14 -15
  23. package/src/tiles/grid/item-tile.ts +0 -23
  24. package/src/tiles/item-image.ts +2 -22
  25. package/src/tiles/item-tile-image.ts +61 -0
  26. package/src/tiles/list/tile-list-compact.ts +1 -8
  27. package/src/tiles/list/tile-list.ts +0 -3
  28. package/src/tiles/tile-dispatcher.ts +0 -5
  29. package/dist/src/assets/img/icons/login-required.d.ts +0 -1
  30. package/dist/src/assets/img/icons/login-required.js +0 -30
  31. package/dist/src/assets/img/icons/login-required.js.map +0 -1
  32. package/dist/src/tiles/overlay/icon-overlay.d.ts +0 -7
  33. package/dist/src/tiles/overlay/icon-overlay.js +0 -43
  34. package/dist/src/tiles/overlay/icon-overlay.js.map +0 -1
  35. package/dist/src/tiles/overlay/text-overlay.d.ts +0 -8
  36. package/dist/src/tiles/overlay/text-overlay.js +0 -53
  37. package/dist/src/tiles/overlay/text-overlay.js.map +0 -1
  38. package/dist/test/icon-overlay.test.d.ts +0 -1
  39. package/dist/test/icon-overlay.test.js +0 -23
  40. package/dist/test/icon-overlay.test.js.map +0 -1
  41. package/dist/test/item-image.test.d.ts +0 -1
  42. package/dist/test/item-image.test.js +0 -75
  43. package/dist/test/item-image.test.js.map +0 -1
  44. package/dist/test/text-overlay.test.d.ts +0 -1
  45. package/dist/test/text-overlay.test.js +0 -37
  46. package/dist/test/text-overlay.test.js.map +0 -1
  47. package/src/assets/img/icons/login-required.ts +0 -30
  48. package/src/tiles/overlay/icon-overlay.ts +0 -34
  49. package/src/tiles/overlay/text-overlay.ts +0 -44
  50. package/test/icon-overlay.test.ts +0 -30
  51. package/test/item-image.test.ts +0 -85
  52. package/test/text-overlay.test.ts +0 -44
@@ -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,6 @@ export class TileDispatcher
156
154
  .currentHeight=${this.currentHeight}
157
155
  .collectionNameCache=${this.collectionNameCache}
158
156
  .baseImageUrl=${this.baseImageUrl}
159
- .loggedIn=${this.loggedIn}
160
157
  ></item-tile>`;
161
158
  }
162
159
  case 'list-compact':
@@ -168,7 +165,6 @@ export class TileDispatcher
168
165
  .sortParam=${sortParam}
169
166
  .mobileBreakpoint=${mobileBreakpoint}
170
167
  .baseImageUrl=${this.baseImageUrl}
171
- .loggedIn=${this.loggedIn}
172
168
  ></tile-list-compact>`;
173
169
  case 'list-detail':
174
170
  return html`<tile-list
@@ -180,7 +176,6 @@ export class TileDispatcher
180
176
  .sortParam=${sortParam}
181
177
  .mobileBreakpoint=${mobileBreakpoint}
182
178
  .baseImageUrl=${this.baseImageUrl}
183
- .loggedIn=${this.loggedIn}
184
179
  ></tile-list>`;
185
180
  default:
186
181
  return nothing;
@@ -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
- }
@@ -1,53 +0,0 @@
1
- import { __decorate } from "tslib";
2
- import { css, html, LitElement } from 'lit';
3
- import { customElement, property } from 'lit/decorators.js';
4
- let TextOverlay = class TextOverlay extends LitElement {
5
- constructor() {
6
- super(...arguments);
7
- this.loggedIn = false;
8
- this.loginRequired = false;
9
- }
10
- render() {
11
- return html ` <div class="overlay no-preview">${this.textDisplay}</div> `;
12
- }
13
- get textDisplay() {
14
- return this.loginRequired && !this.loggedIn
15
- ? 'Log in\nto view this item'
16
- : 'Content may be inappropriate';
17
- }
18
- static get styles() {
19
- return css `
20
- .overlay {
21
- border: 1px solid #2c2c2c;
22
- border-radius: 1px;
23
- position: absolute;
24
- right: 0;
25
- left: 0;
26
- top: 35%;
27
- margin: auto;
28
- width: auto;
29
- padding: 5px;
30
- }
31
-
32
- .no-preview {
33
- background-color: #fffecb;
34
- color: #2c2c2c;
35
- font-size: 1.4rem;
36
- line-height: 2rem;
37
- text-align: center;
38
- white-space: pre-wrap; // for the newline character
39
- }
40
- `;
41
- }
42
- };
43
- __decorate([
44
- property({ type: Boolean })
45
- ], TextOverlay.prototype, "loggedIn", void 0);
46
- __decorate([
47
- property({ type: Boolean })
48
- ], TextOverlay.prototype, "loginRequired", void 0);
49
- TextOverlay = __decorate([
50
- customElement('text-overlay')
51
- ], TextOverlay);
52
- export { TextOverlay };
53
- //# sourceMappingURL=text-overlay.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"text-overlay.js","sourceRoot":"","sources":["../../../../src/tiles/overlay/text-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;AAG5D,IAAa,WAAW,GAAxB,MAAa,WAAY,SAAQ,UAAU;IAA3C;;QAC+B,aAAQ,GAAG,KAAK,CAAC;QAEjB,kBAAa,GAAG,KAAK,CAAC;IAoCrD,CAAC;IAlCC,MAAM;QACJ,OAAO,IAAI,CAAA,oCAAoC,IAAI,CAAC,WAAW,SAAS,CAAC;IAC3E,CAAC;IAED,IAAY,WAAW;QACrB,OAAO,IAAI,CAAC,aAAa,IAAI,CAAC,IAAI,CAAC,QAAQ;YACzC,CAAC,CAAC,2BAA2B;YAC7B,CAAC,CAAC,8BAA8B,CAAC;IACrC,CAAC;IAED,MAAM,KAAK,MAAM;QACf,OAAO,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;KAqBT,CAAC;IACJ,CAAC;CACF,CAAA;AAtC8B;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,CAuCvB;SAvCY,WAAW","sourcesContent":["import { css, CSSResultGroup, html, LitElement } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\n\n@customElement('text-overlay')\nexport class TextOverlay extends LitElement {\n @property({ type: Boolean }) loggedIn = false;\n\n @property({ type: Boolean }) loginRequired = false;\n\n render() {\n return html` <div class=\"overlay no-preview\">${this.textDisplay}</div> `;\n }\n\n private get textDisplay() {\n return this.loginRequired && !this.loggedIn\n ? 'Log in\\nto view this item'\n : 'Content may be inappropriate';\n }\n\n static get styles(): CSSResultGroup {\n return css`\n .overlay {\n border: 1px solid #2c2c2c;\n border-radius: 1px;\n position: absolute;\n right: 0;\n left: 0;\n top: 35%;\n margin: auto;\n width: auto;\n padding: 5px;\n }\n\n .no-preview {\n background-color: #fffecb;\n color: #2c2c2c;\n font-size: 1.4rem;\n line-height: 2rem;\n text-align: center;\n white-space: pre-wrap; // for the newline character\n }\n `;\n }\n}\n"]}
@@ -1 +0,0 @@
1
- import '../src/tiles/overlay/icon-overlay';
@@ -1,23 +0,0 @@
1
- /* eslint-disable import/no-duplicates */
2
- import { expect, fixture } from '@open-wc/testing';
3
- import { html } from 'lit';
4
- import '../src/tiles/overlay/icon-overlay';
5
- describe('Icon Overlay component', () => {
6
- it('should render component if loggedIn required', async () => {
7
- var _a, _b, _c;
8
- const el = await fixture(html `
9
- <icon-overlay .loggedIn=${false} .loginRequired=${true}> </icon-overlay>
10
- `);
11
- const svgTitle = (_c = (_b = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('svg')) === null || _b === void 0 ? void 0 : _b.querySelector('title')) === null || _c === void 0 ? void 0 : _c.textContent;
12
- expect(svgTitle).to.equal('Log in to view this item');
13
- });
14
- it('should render component if content warning', async () => {
15
- var _a, _b, _c;
16
- const el = await fixture(html `
17
- <icon-overlay .loggedIn=${false} .loginRequired=${false}> </icon-overlay>
18
- `);
19
- const svgTitle = (_c = (_b = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('svg')) === null || _b === void 0 ? void 0 : _b.querySelector('title')) === null || _c === void 0 ? void 0 : _c.textContent;
20
- expect(svgTitle).to.equal('Content may be inappropriate');
21
- });
22
- });
23
- //# sourceMappingURL=icon-overlay.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"icon-overlay.test.js","sourceRoot":"","sources":["../../test/icon-overlay.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,wBAAwB,EAAE,GAAG,EAAE;IACtC,EAAE,CAAC,8CAA8C,EAAE,KAAK,IAAI,EAAE;;QAC5D,MAAM,EAAE,GAAG,MAAM,OAAO,CAAc,IAAI,CAAA;gCACd,KAAK,mBAAmB,IAAI;KACvD,CAAC,CAAC;QAEH,MAAM,QAAQ,GAAG,MAAA,MAAA,MAAA,EAAE,CAAC,UAAU,0CAC1B,aAAa,CAAC,KAAK,CAAC,0CACpB,aAAa,CAAC,OAAO,CAAC,0CAAE,WAAW,CAAC;QACxC,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAC;IACxD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,4CAA4C,EAAE,KAAK,IAAI,EAAE;;QAC1D,MAAM,EAAE,GAAG,MAAM,OAAO,CAAc,IAAI,CAAA;gCACd,KAAK,mBAAmB,KAAK;KACxD,CAAC,CAAC;QAEH,MAAM,QAAQ,GAAG,MAAA,MAAA,MAAA,EAAE,CAAC,UAAU,0CAC1B,aAAa,CAAC,KAAK,CAAC,0CACpB,aAAa,CAAC,OAAO,CAAC,0CAAE,WAAW,CAAC;QACxC,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAC;IAC5D,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 { IconOverlay } from '../src/tiles/overlay/icon-overlay';\n\nimport '../src/tiles/overlay/icon-overlay';\n\ndescribe('Icon Overlay component', () => {\n it('should render component if loggedIn required', async () => {\n const el = await fixture<IconOverlay>(html`\n <icon-overlay .loggedIn=${false} .loginRequired=${true}> </icon-overlay>\n `);\n\n const svgTitle = el.shadowRoot\n ?.querySelector('svg')\n ?.querySelector('title')?.textContent;\n expect(svgTitle).to.equal('Log in to view this item');\n });\n\n it('should render component if content warning', async () => {\n const el = await fixture<IconOverlay>(html`\n <icon-overlay .loggedIn=${false} .loginRequired=${false}> </icon-overlay>\n `);\n\n const svgTitle = el.shadowRoot\n ?.querySelector('svg')\n ?.querySelector('title')?.textContent;\n expect(svgTitle).to.equal('Content may be inappropriate');\n });\n});\n"]}
@@ -1 +0,0 @@
1
- import '../src/tiles/item-image';
@@ -1,75 +0,0 @@
1
- /* eslint-disable import/no-duplicates */
2
- import { expect, fixture } from '@open-wc/testing';
3
- import { html } from 'lit';
4
- import '../src/tiles/item-image';
5
- const baseImageUrl = 'https://archive.org';
6
- const testBookModel = {
7
- collections: [],
8
- commentCount: 0,
9
- creators: [],
10
- favCount: 0,
11
- identifier: '18730130BloomfieldRecordCompleteIssue',
12
- itemCount: 0,
13
- mediatype: 'texts',
14
- subjects: [],
15
- title: 'Sample Waveform',
16
- viewCount: 0,
17
- loginRequired: false,
18
- contentWarning: false,
19
- };
20
- const testAudioModel = {
21
- collections: [],
22
- commentCount: 0,
23
- creators: [],
24
- favCount: 0,
25
- identifier: 'dwd2015-01-24',
26
- itemCount: 0,
27
- mediatype: 'audio',
28
- subjects: [],
29
- title: 'Sample Waveform',
30
- viewCount: 0,
31
- loginRequired: false,
32
- contentWarning: false,
33
- };
34
- describe('ItemImage component', () => {
35
- it('should render initial component', async () => {
36
- var _a, _b;
37
- const el = await fixture(html `
38
- <item-image
39
- .isListTile=${false}
40
- .isCompactTile=${false}
41
- .model=${testBookModel}
42
- .baseImageUrl=${baseImageUrl}
43
- >
44
- </item-image>
45
- `);
46
- const dropShadow = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('.drop-shadow');
47
- const imgClassName = (_b = dropShadow === null || dropShadow === void 0 ? void 0 : dropShadow.querySelector('img')) === null || _b === void 0 ? void 0 : _b.className;
48
- expect(dropShadow).to.exist;
49
- expect(imgClassName).to.eql(' contain ');
50
- });
51
- it('should render component if mediatype is waveform', async () => {
52
- var _a;
53
- // const onLoad = sinon.spy();
54
- const el = await fixture(html `
55
- <item-image
56
- .isListTile=${false}
57
- .isCompactTile=${false}
58
- .model=${testAudioModel}
59
- .baseImageUrl=${baseImageUrl}
60
- >
61
- </item-image>
62
- `);
63
- const dropShadow = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('.drop-shadow');
64
- // const image = dropShadow?.querySelector('img');
65
- expect(dropShadow).to.exist;
66
- /**
67
- * TODO:
68
- * - simulate image onLoad event
69
- * - check if image className is waveform
70
- */
71
- // const imgClassName = dropShadow?.querySelector('img')?.className;
72
- // expect(imgClassName).to.eql(' waveform ');
73
- });
74
- });
75
- //# sourceMappingURL=item-image.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"item-image.test.js","sourceRoot":"","sources":["../../test/item-image.test.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAM3B,OAAO,yBAAyB,CAAC;AAEjC,MAAM,YAAY,GAAG,qBAAqB,CAAC;AAC3C,MAAM,aAAa,GAAc;IAC/B,WAAW,EAAE,EAAE;IACf,YAAY,EAAE,CAAC;IACf,QAAQ,EAAE,EAAE;IACZ,QAAQ,EAAE,CAAC;IACX,UAAU,EAAE,uCAAuC;IACnD,SAAS,EAAE,CAAC;IACZ,SAAS,EAAE,OAAO;IAClB,QAAQ,EAAE,EAAE;IACZ,KAAK,EAAE,iBAAiB;IACxB,SAAS,EAAE,CAAC;IACZ,aAAa,EAAE,KAAK;IACpB,cAAc,EAAE,KAAK;CACtB,CAAC;AAEF,MAAM,cAAc,GAAc;IAChC,WAAW,EAAE,EAAE;IACf,YAAY,EAAE,CAAC;IACf,QAAQ,EAAE,EAAE;IACZ,QAAQ,EAAE,CAAC;IACX,UAAU,EAAE,eAAe;IAC3B,SAAS,EAAE,CAAC;IACZ,SAAS,EAAE,OAAO;IAClB,QAAQ,EAAE,EAAE;IACZ,KAAK,EAAE,iBAAiB;IACxB,SAAS,EAAE,CAAC;IACZ,aAAa,EAAE,KAAK;IACpB,cAAc,EAAE,KAAK;CACtB,CAAC;AAEF,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE;IACnC,EAAE,CAAC,iCAAiC,EAAE,KAAK,IAAI,EAAE;;QAC/C,MAAM,EAAE,GAAG,MAAM,OAAO,CAAY,IAAI,CAAA;;sBAEtB,KAAK;yBACF,KAAK;iBACb,aAAa;wBACN,YAAY;;;KAG/B,CAAC,CAAC;QAEH,MAAM,UAAU,GAAG,MAAA,EAAE,CAAC,UAAU,0CAAE,aAAa,CAAC,cAAc,CAAC,CAAC;QAChE,MAAM,YAAY,GAAG,MAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,aAAa,CAAC,KAAK,CAAC,0CAAE,SAAS,CAAC;QAEjE,MAAM,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC;QAC5B,MAAM,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAC3C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,kDAAkD,EAAE,KAAK,IAAI,EAAE;;QAChE,8BAA8B;QAC9B,MAAM,EAAE,GAAG,MAAM,OAAO,CAAY,IAAI,CAAA;;sBAEtB,KAAK;yBACF,KAAK;iBACb,cAAc;wBACP,YAAY;;;KAG/B,CAAC,CAAC;QAEH,MAAM,UAAU,GAAG,MAAA,EAAE,CAAC,UAAU,0CAAE,aAAa,CAAC,cAAc,CAAC,CAAC;QAChE,kDAAkD;QAElD,MAAM,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC;QAC5B;;;;WAIG;QACH,oEAAoE;QACpE,6CAA6C;IAC/C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["/* eslint-disable import/no-duplicates */\nimport { expect, fixture } from '@open-wc/testing';\nimport { html } from 'lit';\n// import sinon from 'sinon';\n\nimport { TileModel } from '../src/models';\nimport { ItemImage } from '../src/tiles/item-image';\n\nimport '../src/tiles/item-image';\n\nconst baseImageUrl = 'https://archive.org';\nconst testBookModel: TileModel = {\n collections: [],\n commentCount: 0,\n creators: [],\n favCount: 0,\n identifier: '18730130BloomfieldRecordCompleteIssue',\n itemCount: 0,\n mediatype: 'texts',\n subjects: [],\n title: 'Sample Waveform',\n viewCount: 0,\n loginRequired: false,\n contentWarning: false,\n};\n\nconst testAudioModel: TileModel = {\n collections: [],\n commentCount: 0,\n creators: [],\n favCount: 0,\n identifier: 'dwd2015-01-24',\n itemCount: 0,\n mediatype: 'audio',\n subjects: [],\n title: 'Sample Waveform',\n viewCount: 0,\n loginRequired: false,\n contentWarning: false,\n};\n\ndescribe('ItemImage component', () => {\n it('should render initial component', async () => {\n const el = await fixture<ItemImage>(html`\n <item-image\n .isListTile=${false}\n .isCompactTile=${false}\n .model=${testBookModel}\n .baseImageUrl=${baseImageUrl}\n >\n </item-image>\n `);\n\n const dropShadow = el.shadowRoot?.querySelector('.drop-shadow');\n const imgClassName = dropShadow?.querySelector('img')?.className;\n\n expect(dropShadow).to.exist;\n expect(imgClassName).to.eql(' contain ');\n });\n\n it('should render component if mediatype is waveform', async () => {\n // const onLoad = sinon.spy();\n const el = await fixture<ItemImage>(html`\n <item-image\n .isListTile=${false}\n .isCompactTile=${false}\n .model=${testAudioModel}\n .baseImageUrl=${baseImageUrl}\n >\n </item-image>\n `);\n\n const dropShadow = el.shadowRoot?.querySelector('.drop-shadow');\n // const image = dropShadow?.querySelector('img');\n\n expect(dropShadow).to.exist;\n /**\n * TODO:\n * - simulate image onLoad event\n * - check if image className is waveform\n */\n // const imgClassName = dropShadow?.querySelector('img')?.className;\n // expect(imgClassName).to.eql(' waveform ');\n });\n});\n"]}
@@ -1 +0,0 @@
1
- import '../src/tiles/overlay/text-overlay';
@@ -1,37 +0,0 @@
1
- /* eslint-disable import/no-duplicates */
2
- import { expect, fixture } from '@open-wc/testing';
3
- import { html } from 'lit';
4
- import '../src/tiles/overlay/text-overlay';
5
- describe('Text Overlay component', () => {
6
- it('should render initial component', async () => {
7
- var _a, _b;
8
- const el = await fixture(html `<text-overlay></text-overlay>`);
9
- const overlay = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('.overlay');
10
- const noPreview = (_b = el.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('.no-preview');
11
- expect(overlay).to.exist;
12
- expect(noPreview).to.exist;
13
- });
14
- it('should render component if loggedIn required', async () => {
15
- var _a, _b;
16
- const el = await fixture(html `
17
- <text-overlay .loggedIn=${false} .loginRequired=${true}> </text-overlay>
18
- `);
19
- const overlay = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('.overlay');
20
- const noPreview = (_b = el.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('.no-preview');
21
- expect(overlay).to.exist;
22
- expect(noPreview).to.exist;
23
- expect(noPreview === null || noPreview === void 0 ? void 0 : noPreview.textContent).to.equal('Log in\nto view this item');
24
- });
25
- it('should render component if content warning', async () => {
26
- var _a, _b;
27
- const el = await fixture(html `
28
- <text-overlay .loggedIn=${false} .loginRequired=${false}> </text-overlay>
29
- `);
30
- const overlay = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('.overlay');
31
- const noPreview = (_b = el.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('.no-preview');
32
- expect(overlay).to.exist;
33
- expect(noPreview).to.exist;
34
- expect(noPreview === null || noPreview === void 0 ? void 0 : noPreview.textContent).to.equal('Content may be inappropriate');
35
- });
36
- });
37
- //# sourceMappingURL=text-overlay.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"text-overlay.test.js","sourceRoot":"","sources":["../../test/text-overlay.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,wBAAwB,EAAE,GAAG,EAAE;IACtC,EAAE,CAAC,iCAAiC,EAAE,KAAK,IAAI,EAAE;;QAC/C,MAAM,EAAE,GAAG,MAAM,OAAO,CAAc,IAAI,CAAA,+BAA+B,CAAC,CAAC;QAE3E,MAAM,OAAO,GAAG,MAAA,EAAE,CAAC,UAAU,0CAAE,aAAa,CAAC,UAAU,CAAC,CAAC;QACzD,MAAM,SAAS,GAAG,MAAA,EAAE,CAAC,UAAU,0CAAE,aAAa,CAAC,aAAa,CAAC,CAAC;QAE9D,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC;QACzB,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC;IAC7B,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,8CAA8C,EAAE,KAAK,IAAI,EAAE;;QAC5D,MAAM,EAAE,GAAG,MAAM,OAAO,CAAc,IAAI,CAAA;gCACd,KAAK,mBAAmB,IAAI;KACvD,CAAC,CAAC;QAEH,MAAM,OAAO,GAAG,MAAA,EAAE,CAAC,UAAU,0CAAE,aAAa,CAAC,UAAU,CAAC,CAAC;QACzD,MAAM,SAAS,GAAG,MAAA,EAAE,CAAC,UAAU,0CAAE,aAAa,CAAC,aAAa,CAAC,CAAC;QAE9D,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC;QACzB,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC;QAC3B,MAAM,CAAC,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,WAAW,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,2BAA2B,CAAC,CAAC;IACvE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,4CAA4C,EAAE,KAAK,IAAI,EAAE;;QAC1D,MAAM,EAAE,GAAG,MAAM,OAAO,CAAc,IAAI,CAAA;gCACd,KAAK,mBAAmB,KAAK;KACxD,CAAC,CAAC;QAEH,MAAM,OAAO,GAAG,MAAA,EAAE,CAAC,UAAU,0CAAE,aAAa,CAAC,UAAU,CAAC,CAAC;QACzD,MAAM,SAAS,GAAG,MAAA,EAAE,CAAC,UAAU,0CAAE,aAAa,CAAC,aAAa,CAAC,CAAC;QAE9D,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC;QACzB,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC;QAC3B,MAAM,CAAC,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,WAAW,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAC;IAC1E,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 { TextOverlay } from '../src/tiles/overlay/text-overlay';\n\nimport '../src/tiles/overlay/text-overlay';\n\ndescribe('Text Overlay component', () => {\n it('should render initial component', async () => {\n const el = await fixture<TextOverlay>(html`<text-overlay></text-overlay>`);\n\n const overlay = el.shadowRoot?.querySelector('.overlay');\n const noPreview = el.shadowRoot?.querySelector('.no-preview');\n\n expect(overlay).to.exist;\n expect(noPreview).to.exist;\n });\n\n it('should render component if loggedIn required', async () => {\n const el = await fixture<TextOverlay>(html`\n <text-overlay .loggedIn=${false} .loginRequired=${true}> </text-overlay>\n `);\n\n const overlay = el.shadowRoot?.querySelector('.overlay');\n const noPreview = el.shadowRoot?.querySelector('.no-preview');\n\n expect(overlay).to.exist;\n expect(noPreview).to.exist;\n expect(noPreview?.textContent).to.equal('Log in\\nto view this item');\n });\n\n it('should render component if content warning', async () => {\n const el = await fixture<TextOverlay>(html`\n <text-overlay .loggedIn=${false} .loginRequired=${false}> </text-overlay>\n `);\n\n const overlay = el.shadowRoot?.querySelector('.overlay');\n const noPreview = el.shadowRoot?.querySelector('.no-preview');\n\n expect(overlay).to.exist;\n expect(noPreview).to.exist;\n expect(noPreview?.textContent).to.equal('Content may be inappropriate');\n });\n});\n"]}
@@ -1,30 +0,0 @@
1
- import { svg } from 'lit';
2
-
3
- export const loginRequiredIcon = svg`
4
- <svg
5
- viewBox="0 0 100 100"
6
- xmlns="http://www.w3.org/2000/svg"
7
- >
8
- <g fill="none" fill-rule="nonzero">
9
- <path
10
- d="m11 48h11c-.0377367 5.0230706-.0377367 17.6897373 0 38h28v-38h12c-14.7643578-21.746483-22.9310245-33.4131497-24.5-35z"
11
- fill="#fff"
12
- transform="matrix(0 1 -1 0 86 13)"
13
- />
14
- <path
15
- d="m17 44h9c-.0377367 5.0230706-.0377367 17.0230706 0 36h18v-36h10c-10.0976911-15.0798163-15.9310245-23.4131497-17.5-25z"
16
- fill="#000"
17
- transform="matrix(0 1 -1 0 85 14)"
18
- />
19
- <path
20
- 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"
21
- fill="#fff"
22
- />
23
- <path
24
- 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"
25
- fill="#000"
26
- />
27
- </g>
28
- <title>Log in to view this item</title>
29
- </svg>
30
- `;
@@ -1,34 +0,0 @@
1
- import { css, CSSResultGroup, html, LitElement } from 'lit';
2
- import { customElement, property } from 'lit/decorators.js';
3
-
4
- import { restrictedIcon } from '../../assets/img/icons/restricted';
5
- import { loginRequiredIcon } from '../../assets/img/icons/login-required';
6
-
7
- @customElement('icon-overlay')
8
- export class IconOverlay extends LitElement {
9
- @property({ type: Boolean }) loggedIn = false;
10
-
11
- @property({ type: Boolean }) loginRequired = false;
12
-
13
- render() {
14
- if (this.loginRequired && !this.loggedIn) {
15
- return html`${loginRequiredIcon} `;
16
- }
17
- return html`${restrictedIcon}`;
18
- }
19
-
20
- static get styles(): CSSResultGroup {
21
- return css`
22
- :host {
23
- position: absolute;
24
- width: 100%;
25
- height: 100%;
26
- z-index: 2;
27
- }
28
-
29
- svg {
30
- padding: 25%;
31
- }
32
- `;
33
- }
34
- }
@@ -1,44 +0,0 @@
1
- import { css, CSSResultGroup, html, LitElement } from 'lit';
2
- import { customElement, property } from 'lit/decorators.js';
3
-
4
- @customElement('text-overlay')
5
- export class TextOverlay extends LitElement {
6
- @property({ type: Boolean }) loggedIn = false;
7
-
8
- @property({ type: Boolean }) loginRequired = false;
9
-
10
- render() {
11
- return html` <div class="overlay no-preview">${this.textDisplay}</div> `;
12
- }
13
-
14
- private get textDisplay() {
15
- return this.loginRequired && !this.loggedIn
16
- ? 'Log in\nto view this item'
17
- : 'Content may be inappropriate';
18
- }
19
-
20
- static get styles(): CSSResultGroup {
21
- return css`
22
- .overlay {
23
- border: 1px solid #2c2c2c;
24
- border-radius: 1px;
25
- position: absolute;
26
- right: 0;
27
- left: 0;
28
- top: 35%;
29
- margin: auto;
30
- width: auto;
31
- padding: 5px;
32
- }
33
-
34
- .no-preview {
35
- background-color: #fffecb;
36
- color: #2c2c2c;
37
- font-size: 1.4rem;
38
- line-height: 2rem;
39
- text-align: center;
40
- white-space: pre-wrap; // for the newline character
41
- }
42
- `;
43
- }
44
- }
@@ -1,30 +0,0 @@
1
- /* eslint-disable import/no-duplicates */
2
- import { expect, fixture } from '@open-wc/testing';
3
- import { html } from 'lit';
4
- import { IconOverlay } from '../src/tiles/overlay/icon-overlay';
5
-
6
- import '../src/tiles/overlay/icon-overlay';
7
-
8
- describe('Icon Overlay component', () => {
9
- it('should render component if loggedIn required', async () => {
10
- const el = await fixture<IconOverlay>(html`
11
- <icon-overlay .loggedIn=${false} .loginRequired=${true}> </icon-overlay>
12
- `);
13
-
14
- const svgTitle = el.shadowRoot
15
- ?.querySelector('svg')
16
- ?.querySelector('title')?.textContent;
17
- expect(svgTitle).to.equal('Log in to view this item');
18
- });
19
-
20
- it('should render component if content warning', async () => {
21
- const el = await fixture<IconOverlay>(html`
22
- <icon-overlay .loggedIn=${false} .loginRequired=${false}> </icon-overlay>
23
- `);
24
-
25
- const svgTitle = el.shadowRoot
26
- ?.querySelector('svg')
27
- ?.querySelector('title')?.textContent;
28
- expect(svgTitle).to.equal('Content may be inappropriate');
29
- });
30
- });