@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.
- package/dist/src/collection-browser.js +10 -15
- package/dist/src/collection-browser.js.map +1 -1
- package/dist/src/tiles/grid/item-tile.d.ts +5 -6
- package/dist/src/tiles/grid/item-tile.js +51 -33
- package/dist/src/tiles/grid/item-tile.js.map +1 -1
- package/dist/src/tiles/item-image.d.ts +0 -5
- package/dist/src/tiles/item-image.js +3 -21
- package/dist/src/tiles/item-image.js.map +1 -1
- package/dist/src/tiles/item-tile-image.d.ts +15 -0
- package/dist/src/tiles/item-tile-image.js +68 -0
- package/dist/src/tiles/item-tile-image.js.map +1 -0
- package/dist/src/tiles/list/tile-list-compact.d.ts +0 -1
- package/dist/src/tiles/list/tile-list-compact.js +1 -10
- package/dist/src/tiles/list/tile-list-compact.js.map +1 -1
- package/dist/src/tiles/list/tile-list.d.ts +0 -1
- package/dist/src/tiles/list/tile-list.js +0 -5
- package/dist/src/tiles/list/tile-list.js.map +1 -1
- package/dist/src/tiles/tile-dispatcher.d.ts +0 -1
- package/dist/src/tiles/tile-dispatcher.js +1 -7
- package/dist/src/tiles/tile-dispatcher.js.map +1 -1
- 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 +2 -2
- package/src/collection-browser.ts +10 -15
- package/src/tiles/grid/item-tile.ts +51 -23
- package/src/tiles/item-image.ts +2 -22
- package/src/tiles/item-tile-image.ts +61 -0
- package/src/tiles/list/tile-list-compact.ts +1 -8
- package/src/tiles/list/tile-list.ts +0 -3
- package/src/tiles/tile-dispatcher.ts +1 -5
- package/test/tiles/grid/item-tile.test.ts +116 -0
- package/dist/src/assets/img/icons/login-required.d.ts +0 -1
- package/dist/src/assets/img/icons/login-required.js +0 -30
- package/dist/src/assets/img/icons/login-required.js.map +0 -1
- package/dist/src/tiles/overlay/icon-overlay.d.ts +0 -7
- package/dist/src/tiles/overlay/icon-overlay.js +0 -43
- package/dist/src/tiles/overlay/icon-overlay.js.map +0 -1
- package/dist/src/tiles/overlay/text-overlay.d.ts +0 -8
- package/dist/src/tiles/overlay/text-overlay.js +0 -53
- package/dist/src/tiles/overlay/text-overlay.js.map +0 -1
- package/dist/test/icon-overlay.test.d.ts +0 -1
- package/dist/test/icon-overlay.test.js +0 -23
- package/dist/test/icon-overlay.test.js.map +0 -1
- package/dist/test/item-image.test.d.ts +0 -1
- package/dist/test/item-image.test.js +0 -75
- package/dist/test/item-image.test.js.map +0 -1
- package/dist/test/text-overlay.test.d.ts +0 -1
- package/dist/test/text-overlay.test.js +0 -37
- package/dist/test/text-overlay.test.js.map +0 -1
- package/src/assets/img/icons/login-required.ts +0 -30
- package/src/tiles/overlay/icon-overlay.ts +0 -34
- package/src/tiles/overlay/text-overlay.ts +0 -44
- package/test/icon-overlay.test.ts +0 -30
- package/test/item-image.test.ts +0 -85
- package/test/text-overlay.test.ts +0 -44
|
@@ -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,M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C,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,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;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
|
-
});
|
package/test/item-image.test.ts
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
/* eslint-disable import/no-duplicates */
|
|
2
|
-
import { expect, fixture } from '@open-wc/testing';
|
|
3
|
-
import { html } from 'lit';
|
|
4
|
-
// import sinon from 'sinon';
|
|
5
|
-
|
|
6
|
-
import { TileModel } from '../src/models';
|
|
7
|
-
import { ItemImage } from '../src/tiles/item-image';
|
|
8
|
-
|
|
9
|
-
import '../src/tiles/item-image';
|
|
10
|
-
|
|
11
|
-
const baseImageUrl = 'https://archive.org';
|
|
12
|
-
const testBookModel: TileModel = {
|
|
13
|
-
collections: [],
|
|
14
|
-
commentCount: 0,
|
|
15
|
-
creators: [],
|
|
16
|
-
favCount: 0,
|
|
17
|
-
identifier: '18730130BloomfieldRecordCompleteIssue',
|
|
18
|
-
itemCount: 0,
|
|
19
|
-
mediatype: 'texts',
|
|
20
|
-
subjects: [],
|
|
21
|
-
title: 'Sample Waveform',
|
|
22
|
-
viewCount: 0,
|
|
23
|
-
loginRequired: false,
|
|
24
|
-
contentWarning: false,
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
const testAudioModel: TileModel = {
|
|
28
|
-
collections: [],
|
|
29
|
-
commentCount: 0,
|
|
30
|
-
creators: [],
|
|
31
|
-
favCount: 0,
|
|
32
|
-
identifier: 'dwd2015-01-24',
|
|
33
|
-
itemCount: 0,
|
|
34
|
-
mediatype: 'audio',
|
|
35
|
-
subjects: [],
|
|
36
|
-
title: 'Sample Waveform',
|
|
37
|
-
viewCount: 0,
|
|
38
|
-
loginRequired: false,
|
|
39
|
-
contentWarning: false,
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
describe('ItemImage component', () => {
|
|
43
|
-
it('should render initial component', async () => {
|
|
44
|
-
const el = await fixture<ItemImage>(html`
|
|
45
|
-
<item-image
|
|
46
|
-
.isListTile=${false}
|
|
47
|
-
.isCompactTile=${false}
|
|
48
|
-
.model=${testBookModel}
|
|
49
|
-
.baseImageUrl=${baseImageUrl}
|
|
50
|
-
>
|
|
51
|
-
</item-image>
|
|
52
|
-
`);
|
|
53
|
-
|
|
54
|
-
const dropShadow = el.shadowRoot?.querySelector('.drop-shadow');
|
|
55
|
-
const imgClassName = dropShadow?.querySelector('img')?.className;
|
|
56
|
-
|
|
57
|
-
expect(dropShadow).to.exist;
|
|
58
|
-
expect(imgClassName).to.eql(' contain ');
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it('should render component if mediatype is waveform', async () => {
|
|
62
|
-
// const onLoad = sinon.spy();
|
|
63
|
-
const el = await fixture<ItemImage>(html`
|
|
64
|
-
<item-image
|
|
65
|
-
.isListTile=${false}
|
|
66
|
-
.isCompactTile=${false}
|
|
67
|
-
.model=${testAudioModel}
|
|
68
|
-
.baseImageUrl=${baseImageUrl}
|
|
69
|
-
>
|
|
70
|
-
</item-image>
|
|
71
|
-
`);
|
|
72
|
-
|
|
73
|
-
const dropShadow = el.shadowRoot?.querySelector('.drop-shadow');
|
|
74
|
-
// const image = dropShadow?.querySelector('img');
|
|
75
|
-
|
|
76
|
-
expect(dropShadow).to.exist;
|
|
77
|
-
/**
|
|
78
|
-
* TODO:
|
|
79
|
-
* - simulate image onLoad event
|
|
80
|
-
* - check if image className is waveform
|
|
81
|
-
*/
|
|
82
|
-
// const imgClassName = dropShadow?.querySelector('img')?.className;
|
|
83
|
-
// expect(imgClassName).to.eql(' waveform ');
|
|
84
|
-
});
|
|
85
|
-
});
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/* eslint-disable import/no-duplicates */
|
|
2
|
-
import { expect, fixture } from '@open-wc/testing';
|
|
3
|
-
import { html } from 'lit';
|
|
4
|
-
import { TextOverlay } from '../src/tiles/overlay/text-overlay';
|
|
5
|
-
|
|
6
|
-
import '../src/tiles/overlay/text-overlay';
|
|
7
|
-
|
|
8
|
-
describe('Text Overlay component', () => {
|
|
9
|
-
it('should render initial component', async () => {
|
|
10
|
-
const el = await fixture<TextOverlay>(html`<text-overlay></text-overlay>`);
|
|
11
|
-
|
|
12
|
-
const overlay = el.shadowRoot?.querySelector('.overlay');
|
|
13
|
-
const noPreview = el.shadowRoot?.querySelector('.no-preview');
|
|
14
|
-
|
|
15
|
-
expect(overlay).to.exist;
|
|
16
|
-
expect(noPreview).to.exist;
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it('should render component if loggedIn required', async () => {
|
|
20
|
-
const el = await fixture<TextOverlay>(html`
|
|
21
|
-
<text-overlay .loggedIn=${false} .loginRequired=${true}> </text-overlay>
|
|
22
|
-
`);
|
|
23
|
-
|
|
24
|
-
const overlay = el.shadowRoot?.querySelector('.overlay');
|
|
25
|
-
const noPreview = el.shadowRoot?.querySelector('.no-preview');
|
|
26
|
-
|
|
27
|
-
expect(overlay).to.exist;
|
|
28
|
-
expect(noPreview).to.exist;
|
|
29
|
-
expect(noPreview?.textContent).to.equal('Log in\nto view this item');
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it('should render component if content warning', async () => {
|
|
33
|
-
const el = await fixture<TextOverlay>(html`
|
|
34
|
-
<text-overlay .loggedIn=${false} .loginRequired=${false}> </text-overlay>
|
|
35
|
-
`);
|
|
36
|
-
|
|
37
|
-
const overlay = el.shadowRoot?.querySelector('.overlay');
|
|
38
|
-
const noPreview = el.shadowRoot?.querySelector('.no-preview');
|
|
39
|
-
|
|
40
|
-
expect(overlay).to.exist;
|
|
41
|
-
expect(noPreview).to.exist;
|
|
42
|
-
expect(noPreview?.textContent).to.equal('Content may be inappropriate');
|
|
43
|
-
});
|
|
44
|
-
});
|