@internetarchive/collection-browser 0.3.9 → 0.4.0
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/assets/img/icons/login-required.js +3 -15
- package/dist/src/assets/img/icons/login-required.js.map +1 -1
- package/dist/src/assets/img/icons/restricted.js +1 -17
- package/dist/src/assets/img/icons/restricted.js.map +1 -1
- package/dist/src/styles/item-image-styles.js +3 -6
- package/dist/src/styles/item-image-styles.js.map +1 -1
- package/dist/src/tiles/grid/item-tile.js +2 -0
- package/dist/src/tiles/grid/item-tile.js.map +1 -1
- package/dist/src/tiles/image-block.js +8 -0
- package/dist/src/tiles/image-block.js.map +1 -1
- package/dist/src/tiles/item-image.js +5 -2
- package/dist/src/tiles/item-image.js.map +1 -1
- package/dist/src/tiles/overlay/icon-overlay.d.ts +3 -0
- package/dist/src/tiles/overlay/icon-overlay.js +33 -3
- package/dist/src/tiles/overlay/icon-overlay.js.map +1 -1
- package/dist/src/tiles/overlay/icon-text-overlay.d.ts +9 -0
- package/dist/src/tiles/overlay/icon-text-overlay.js +83 -0
- package/dist/src/tiles/overlay/icon-text-overlay.js.map +1 -0
- package/dist/src/tiles/overlay/text-overlay.d.ts +2 -0
- package/dist/src/tiles/overlay/text-overlay.js +35 -7
- package/dist/src/tiles/overlay/text-overlay.js.map +1 -1
- package/dist/test/item-image.test.js +46 -0
- package/dist/test/item-image.test.js.map +1 -1
- package/dist/test/text-overlay.test.js +13 -6
- package/dist/test/text-overlay.test.js.map +1 -1
- package/package.json +1 -1
- package/src/assets/img/icons/login-required.ts +3 -15
- package/src/assets/img/icons/restricted.ts +1 -17
- package/src/styles/item-image-styles.ts +3 -6
- package/src/tiles/grid/item-tile.ts +2 -0
- package/src/tiles/image-block.ts +8 -0
- package/src/tiles/item-image.ts +5 -2
- package/src/tiles/overlay/icon-overlay.ts +33 -3
- package/src/tiles/overlay/icon-text-overlay.ts +75 -0
- package/src/tiles/overlay/text-overlay.ts +34 -7
- package/test/item-image.test.ts +49 -0
- package/test/text-overlay.test.ts +10 -3
|
@@ -4,24 +4,12 @@ export const loginRequiredIcon = svg `
|
|
|
4
4
|
viewBox="0 0 100 100"
|
|
5
5
|
xmlns="http://www.w3.org/2000/svg"
|
|
6
6
|
>
|
|
7
|
-
<g fill="
|
|
7
|
+
<g fill="#000" fill-rule="evenodd">
|
|
8
8
|
<path
|
|
9
|
-
d="
|
|
10
|
-
fill="#fff"
|
|
11
|
-
transform="matrix(0 1 -1 0 86 13)"
|
|
9
|
+
d="m86 0c5.5228475 0 10 4.4771525 10 10v80c0 5.5228475-4.4771525 10-10 10h-57c-5.5228475 0-10-4.4771525-10-10v-13h7.999l.001 8c0 2.6887547 2.1223067 4.8818181 4.7831104 4.9953805l.2168896.0046195h50.06c2.6887547 0 4.8818181-2.1223067 4.9953805-4.7831104l.0046195-.2168896v-70c0-2.7614237-2.2385763-5-5-5h-50.06c-2.6887547 0-4.8818181 2.1223067-4.9953805 4.7831104l-.0046195.2168896-.001 7h-7.999v-12c0-5.5228475 4.4771525-10 10-10z"
|
|
12
10
|
/>
|
|
13
11
|
<path
|
|
14
|
-
d="
|
|
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"
|
|
12
|
+
d="m4 52h14c-.0377367 5.0230706-.0377367 15.3564039 0 31h35v-31h16c-20.0693886-21.0798163-30.8885707-32.4131497-32.4575462-34z" fill-rule="nonzero" transform="matrix(0 1 -1 0 87 14)"
|
|
25
13
|
/>
|
|
26
14
|
</g>
|
|
27
15
|
<title>Log in to view this item</title>
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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;;;;;;;;;;;;;;;CAenC,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=\"#000\" fill-rule=\"evenodd\">\n <path\n d=\"m86 0c5.5228475 0 10 4.4771525 10 10v80c0 5.5228475-4.4771525 10-10 10h-57c-5.5228475 0-10-4.4771525-10-10v-13h7.999l.001 8c0 2.6887547 2.1223067 4.8818181 4.7831104 4.9953805l.2168896.0046195h50.06c2.6887547 0 4.8818181-2.1223067 4.9953805-4.7831104l.0046195-.2168896v-70c0-2.7614237-2.2385763-5-5-5h-50.06c-2.6887547 0-4.8818181 2.1223067-4.9953805 4.7831104l-.0046195.2168896-.001 7h-7.999v-12c0-5.5228475 4.4771525-10 10-10z\"\n />\n <path\n d=\"m4 52h14c-.0377367 5.0230706-.0377367 15.3564039 0 31h35v-31h16c-20.0693886-21.0798163-30.8885707-32.4131497-32.4575462-34z\" fill-rule=\"nonzero\" transform=\"matrix(0 1 -1 0 87 14)\"\n />\n </g>\n <title>Log in to view this item</title>\n </svg>\n`;\n"]}
|
|
@@ -4,25 +4,9 @@ export const restrictedIcon = svg `
|
|
|
4
4
|
viewBox="0 0 100 100"
|
|
5
5
|
xmlns="http://www.w3.org/2000/svg"
|
|
6
6
|
>
|
|
7
|
-
<g
|
|
8
|
-
fill="none"
|
|
9
|
-
fill-rule="evenodd"
|
|
10
|
-
>
|
|
11
7
|
<path
|
|
12
|
-
d="m56.4612493 8.80450354 41.8901185 75.94632926c1.7706782 2.8433173 2.1150372 5.2623412 1.0330766 7.2570716-1.0819604 1.9947304-3.26978 2.9920956-6.5634587 2.9920956h-85.69973905c-3.29367873 0-5.46954894-.9973652-6.52761065-2.9920956-1.0580617-1.9947304-.70175345-4.4137543 1.06892476-7.2570716l41.89011844-75.12308969c1.8184757-2.84331737 3.9693609-4.37738627 6.4526556-4.60220671s4.6341799 1.03483527 6.4526556 3.
|
|
13
|
-
fill="#000"
|
|
14
|
-
fill-rule="nonzero"
|
|
8
|
+
d="m56.4612493 8.80450354 41.8901185 75.94632926c1.7706782 2.8433173 2.1150372 5.2623412 1.0330766 7.2570716-1.0819604 1.9947304-3.26978 2.9920956-6.5634587 2.9920956h-85.69973905c-3.29367873 0-5.46954894-.9973652-6.52761065-2.9920956-1.0580617-1.9947304-.70175345-4.4137543 1.06892476-7.2570716l41.89011844-75.12308969c1.8184757-2.84331737 3.9693609-4.37738627 6.4526556-4.60220671s4.6341799 1.03483527 6.4526556 3.77896714zm28.5387507 75.19549646-35.037482-62-34.962518 62zm-31-34.7484359v-10.2515641h-8v10.2515641l2.089172 14.7484359h3.8184713zm-8 19.7484359v8h8v-8z"
|
|
15
9
|
/>
|
|
16
|
-
<path
|
|
17
|
-
d="m94.0140845 90-44.5547054-79-44.4593791 79z"
|
|
18
|
-
fill="#f8e71c"
|
|
19
|
-
fill-rule="nonzero"
|
|
20
|
-
/>
|
|
21
|
-
<path
|
|
22
|
-
d="m54 69v8h-8v-8zm0-30v10.2515641l-2.0923567 14.7484359h-3.8184713l-2.089172-14.7484359v-10.2515641z"
|
|
23
|
-
fill="#000"
|
|
24
|
-
/>
|
|
25
|
-
</g>
|
|
26
10
|
<title>Content may be inappropriate</title>
|
|
27
11
|
</svg>
|
|
28
12
|
`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"restricted.js","sourceRoot":"","sources":["../../../../../src/assets/img/icons/restricted.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,CAAA
|
|
1
|
+
{"version":3,"file":"restricted.js","sourceRoot":"","sources":["../../../../../src/assets/img/icons/restricted.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,CAAA;;;;;;;;;;CAUhC,CAAC","sourcesContent":["import { svg } from 'lit';\n\nexport const restrictedIcon = svg`\n <svg\n viewBox=\"0 0 100 100\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n d=\"m56.4612493 8.80450354 41.8901185 75.94632926c1.7706782 2.8433173 2.1150372 5.2623412 1.0330766 7.2570716-1.0819604 1.9947304-3.26978 2.9920956-6.5634587 2.9920956h-85.69973905c-3.29367873 0-5.46954894-.9973652-6.52761065-2.9920956-1.0580617-1.9947304-.70175345-4.4137543 1.06892476-7.2570716l41.89011844-75.12308969c1.8184757-2.84331737 3.9693609-4.37738627 6.4526556-4.60220671s4.6341799 1.03483527 6.4526556 3.77896714zm28.5387507 75.19549646-35.037482-62-34.962518 62zm-31-34.7484359v-10.2515641h-8v10.2515641l2.089172 14.7484359h3.8184713zm-8 19.7484359v8h8v-8z\"\n />\n <title>Content may be inappropriate</title>\n </svg>\n`;\n"]}
|
|
@@ -10,18 +10,14 @@ export const baseItemImageStyles = css `
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
.list-box {
|
|
13
|
-
width: 100%;
|
|
14
|
-
height: 100%;
|
|
15
13
|
overflow: hidden;
|
|
16
14
|
box-sizing: border-box;
|
|
17
|
-
display:
|
|
15
|
+
display: inline-block;
|
|
18
16
|
position: relative;
|
|
19
|
-
max-width: 100px;
|
|
20
17
|
}
|
|
21
18
|
|
|
22
19
|
.contain {
|
|
23
20
|
object-fit: contain;
|
|
24
|
-
object-position: top;
|
|
25
21
|
height: 100%;
|
|
26
22
|
width: 100%;
|
|
27
23
|
}
|
|
@@ -31,7 +27,8 @@ export const baseItemImageStyles = css `
|
|
|
31
27
|
}
|
|
32
28
|
|
|
33
29
|
.blur {
|
|
34
|
-
filter: blur(
|
|
30
|
+
filter: blur(15px);
|
|
31
|
+
box-shadow: 1px 1px 2px 0px;
|
|
35
32
|
}
|
|
36
33
|
`;
|
|
37
34
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"item-image-styles.js","sourceRoot":"","sources":["../../../src/styles/item-image-styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,CAAA
|
|
1
|
+
{"version":3,"file":"item-image-styles.js","sourceRoot":"","sources":["../../../src/styles/item-image-styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4BrC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8DxC,CAAC","sourcesContent":["import { css } from 'lit';\n\n/**\n * Base item-image styles\n */\nexport const baseItemImageStyles = css`\n .drop-shadow {\n filter: drop-shadow(1px 1px 2px rgba(0, 0, 0, 0.8));\n overflow: hidden;\n height: 100%;\n }\n\n .list-box {\n overflow: hidden;\n box-sizing: border-box;\n display: inline-block;\n position: relative;\n }\n\n .contain {\n object-fit: contain;\n height: 100%;\n width: 100%;\n }\n\n .cover {\n object-fit: cover;\n }\n\n .blur {\n filter: blur(15px);\n box-shadow: 1px 1px 2px 0px;\n }\n`;\n\n/**\n * Waveform styles\n */\nexport const waveformGradientStyles = css`\n .waveform {\n mix-blend-mode: screen;\n position: relative;\n height: 62.5%;\n top: 50%;\n transform: translateY(-50%);\n }\n\n .waveform-grad0 {\n background: linear-gradient(\n hsl(340, 80%, 55%),\n hsl(0, 80%, 33%) 35%,\n hsl(0, 80%, 22%) 70%,\n hsl(0, 0%, 0%)\n );\n }\n\n .waveform-grad1 {\n background: linear-gradient(\n hsl(300, 80%, 55%),\n hsl(330, 80%, 33%) 35%,\n hsl(330, 80%, 22%) 70%,\n hsl(0, 0%, 0%)\n );\n }\n\n .waveform-grad2 {\n background: linear-gradient(\n hsl(200, 80%, 55%),\n hsl(230, 80%, 33%) 35%,\n hsl(230, 80%, 22%) 70%,\n hsl(0, 0%, 0%)\n );\n }\n\n .waveform-grad3 {\n background: linear-gradient(\n hsl(160, 80%, 55%),\n hsl(190, 80%, 33%) 35%,\n hsl(190, 80%, 22%) 70%,\n hsl(0, 0%, 0%)\n );\n }\n\n .waveform-grad4 {\n background: linear-gradient(\n hsl(250, 80%, 55%),\n hsl(280, 80%, 33%) 35%,\n hsl(280, 80%, 22%) 70%,\n hsl(0, 0%, 0%)\n );\n }\n\n .waveform-grad5 {\n background: linear-gradient(\n hsl(280, 80%, 55%),\n hsl(310, 80%, 33%) 35%,\n hsl(310, 80%, 22%) 70%,\n hsl(0, 0%, 0%)\n );\n }\n`;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"item-tile.js","sourceRoot":"","sources":["../../../../src/tiles/grid/item-tile.ts"],"names":[],"mappings":";AAAA,yCAAyC;AACzC,OAAO,EACL,GAAG,EAEH,IAAI,EACJ,UAAU,EACV,OAAO,GAER,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAGzD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAGrD,OAAO,gBAAgB,CAAC;AACxB,OAAO,uBAAuB,CAAC;AAC/B,OAAO,eAAe,CAAC;AACvB,OAAO,mBAAmB,CAAC;AAC3B,OAAO,cAAc,CAAC;AAGtB,IAAa,QAAQ,GAArB,MAAa,QAAS,SAAQ,UAAU;IAAxC;;QAG+B,aAAQ,GAAG,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"item-tile.js","sourceRoot":"","sources":["../../../../src/tiles/grid/item-tile.ts"],"names":[],"mappings":";AAAA,yCAAyC;AACzC,OAAO,EACL,GAAG,EAEH,IAAI,EACJ,UAAU,EACV,OAAO,GAER,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAGzD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAGrD,OAAO,gBAAgB,CAAC;AACxB,OAAO,uBAAuB,CAAC;AAC/B,OAAO,eAAe,CAAC;AACvB,OAAO,mBAAmB,CAAC;AAC3B,OAAO,cAAc,CAAC;AAG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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA8ET,CAAC;IACJ,CAAC;CACF,CAAA;AAhM6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8CAAuB;AAErB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;0CAAkB;AAElB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uCAAmB;AAElB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2CAAuB;AAPvC,QAAQ;IADpB,aAAa,CAAC,WAAW,CAAC;GACd,QAAQ,CAiMpB;SAjMY,QAAQ","sourcesContent":["/* eslint-disable import/no-duplicates */\nimport {\n css,\n CSSResultGroup,\n html,\n LitElement,\n nothing,\n TemplateResult,\n} from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport type { SortParam } from '@internetarchive/search-service';\n\nimport { formatDate } from '../../utils/format-date';\nimport type { TileModel } from '../../models';\n\nimport '../image-block';\nimport '../text-snippet-block';\nimport '../item-image';\nimport '../mediatype-icon';\nimport './tile-stats';\n\n@customElement('item-tile')\nexport class ItemTile extends LitElement {\n @property({ type: String }) baseImageUrl?: string;\n\n @property({ type: Boolean }) loggedIn = false;\n\n @property({ type: Object }) model?: TileModel;\n\n @property({ type: Object }) sortParam?: SortParam;\n\n render() {\n const itemTitle = this.model?.title;\n\n return html`\n <div class=\"container\">\n <div class=\"item-info\">\n <div id=\"title\">\n <h1 class=\"truncated\" title=${ifDefined(itemTitle)}>\n ${itemTitle}\n </h1>\n </div>\n\n <image-block \n class=${this.hasSnippets ? 'has-snippets' : nothing}\n .model=${this.model}\n .baseImageUrl=${this.baseImageUrl}\n .loggedIn=${this.loggedIn}\n .isCompactTile=${false}\n .isListTile=${false}\n .viewSize=${'grid'}>\n </image-block>\n\n ${this.textSnippetsTemplate}\n\n ${\n this.doesSortedByDate\n ? this.sortedDateInfoTemplate\n : this.creatorTemplate\n }\n </div>\n\n <tile-stats \n .mediatype=${this.model?.mediatype}\n .viewCount=${this.model?.viewCount}\n .favCount=${this.model?.favCount}\n .commentCount=${this.model?.commentCount}>\n </tile-stats>\n </div>\n </div>\n `;\n }\n\n /**\n * Templates\n */\n private get doesSortedByDate() {\n return ['date', 'reviewdate', 'addeddate', 'publicdate'].includes(\n this.sortParam?.field as string\n );\n }\n\n private get sortedDateInfoTemplate() {\n let sortedValue;\n\n switch (this.sortParam?.field) {\n case 'date':\n sortedValue = { field: 'published', value: this.model?.datePublished };\n break;\n case 'reviewdate':\n sortedValue = { field: 'reviewed', value: this.model?.dateReviewed };\n break;\n case 'addeddate':\n sortedValue = { field: 'added', value: this.model?.dateAdded };\n break;\n case 'publicdate':\n sortedValue = { field: 'archived', value: this.model?.dateArchived };\n break;\n default:\n break;\n }\n\n return html`\n <div class=\"date-sorted-by truncated\">\n <span>\n ${sortedValue?.field} ${formatDate(sortedValue?.value, 'long')}\n </span>\n </div>\n `;\n }\n\n private get creatorTemplate() {\n return html`\n <div class=\"created-by truncated\">\n ${this.model?.creator\n ? html`<span>by ${this.model?.creator}</span>`\n : nothing}\n </div>\n `;\n }\n\n private get textSnippetsTemplate(): TemplateResult | typeof nothing {\n if (!this.hasSnippets) return nothing;\n\n return html`<text-snippet-block\n viewsize=\"grid\"\n .snippets=${this.model?.snippets}\n ></text-snippet-block>`;\n }\n\n private get hasSnippets(): boolean {\n return !!this.model?.snippets?.length;\n }\n\n static get styles(): CSSResultGroup {\n return css`\n .container {\n background-color: #ffffff;\n border-radius: var(--collectionTileCornerRadius, 4px);\n box-shadow: 1px 1px 2px 0px;\n display: flex;\n flex-direction: column;\n height: 100%;\n }\n\n .item-info {\n padding: 5px 5px 0 5px;\n flex-grow: 1;\n }\n\n #title {\n flex-shrink: 0;\n }\n\n .hidden {\n display: none;\n }\n\n .container:hover > .item-info > #title > .truncated {\n text-decoration: underline;\n }\n\n /** this is a workaround for Safari 15 where the hover effects are not working */\n #title:hover > .truncated {\n text-decoration: underline;\n }\n\n image-block {\n display: block;\n margin-bottom: 5px;\n position: relative;\n text-align: center;\n }\n\n image-block.has-snippets {\n /* If there is a text snippet block present, the image block needs to shrink */\n --imgBlockHeight: 11rem;\n }\n\n .created-by,\n .date-sorted-by {\n display: flex;\n justify-content: center;\n align-items: flex-end; /* Important to start text from bottom */\n height: 3rem;\n padding-top: 1rem;\n }\n\n .truncated {\n flex: 1;\n color: #2c2c2c;\n min-width: 0; /* Important for long words! */\n text-align: center;\n line-height: 2rem;\n text-overflow: ellipsis;\n overflow: hidden;\n word-wrap: break-word;\n -webkit-line-clamp: 2;\n -webkit-box-orient: vertical;\n }\n\n .truncated span {\n font-size: 1.4rem;\n display: -webkit-box;\n }\n\n h1.truncated {\n margin-top: 0rem;\n margin-bottom: 0.5rem;\n font-size: 1.6rem;\n height: 4rem;\n display: -webkit-box;\n }\n `;\n }\n}\n"]}
|
|
@@ -48,6 +48,7 @@ let ImageBlock = class ImageBlock extends LitElement {
|
|
|
48
48
|
<icon-overlay
|
|
49
49
|
.loggedIn=${this.loggedIn}
|
|
50
50
|
.loginRequired=${(_c = this.model) === null || _c === void 0 ? void 0 : _c.loginRequired}
|
|
51
|
+
.isCompactTile=${this.isCompactTile}
|
|
51
52
|
>
|
|
52
53
|
</icon-overlay>
|
|
53
54
|
`;
|
|
@@ -62,6 +63,7 @@ let ImageBlock = class ImageBlock extends LitElement {
|
|
|
62
63
|
<text-overlay
|
|
63
64
|
.loggedIn=${this.loggedIn}
|
|
64
65
|
.loginRequired=${(_c = this.model) === null || _c === void 0 ? void 0 : _c.loginRequired}
|
|
66
|
+
?iconRequired=${true}
|
|
65
67
|
>
|
|
66
68
|
</text-overlay>
|
|
67
69
|
`;
|
|
@@ -77,12 +79,17 @@ let ImageBlock = class ImageBlock extends LitElement {
|
|
|
77
79
|
.grid {
|
|
78
80
|
height: var(--imgBlockHeight, 16rem);
|
|
79
81
|
flex: 1;
|
|
82
|
+
display: inline-block;
|
|
83
|
+
position: initial;
|
|
80
84
|
}
|
|
81
85
|
|
|
82
86
|
/** tile-list view */
|
|
83
87
|
.list.desktop {
|
|
84
88
|
width: 100px;
|
|
85
89
|
height: 100px;
|
|
90
|
+
display: inline-block;
|
|
91
|
+
position: relative;
|
|
92
|
+
text-align: center;
|
|
86
93
|
}
|
|
87
94
|
|
|
88
95
|
.list.mobile {
|
|
@@ -93,6 +100,7 @@ let ImageBlock = class ImageBlock extends LitElement {
|
|
|
93
100
|
/** tile-list-compact view */
|
|
94
101
|
.list-compact {
|
|
95
102
|
display: block;
|
|
103
|
+
text-align: center;
|
|
96
104
|
}
|
|
97
105
|
|
|
98
106
|
.list-compact.desktop {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image-block.js","sourceRoot":"","sources":["../../../src/tiles/image-block.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAkB,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAa,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAIlE,OAAO,wBAAwB,CAAC;AAChC,OAAO,wBAAwB,CAAC;AAGhC,IAAa,UAAU,GAAvB,MAAa,UAAW,SAAQ,UAAU;IAA1C;;QAG+B,kBAAa,GAAG,KAAK,CAAC;QAEtB,eAAU,GAAG,KAAK,CAAC;QAEnB,aAAQ,GAAG,KAAK,CAAC;QAIlB,aAAQ,GAAW,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"image-block.js","sourceRoot":"","sources":["../../../src/tiles/image-block.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAkB,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,QAA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AAC,QAAQ;yBACR,MAAA,IAAI,CAAC,KAAK,0CAAE,aAAa;yBACzB,IAAI,CAAC,aAAa;;;KAGtC,CAAC;IACJ,CAAC;IAED,IAAY,mBAAmB;;QAC7B,IAAI,IAAI,CAAC,UAAU;YAAE,OAAO,OAAO,CAAC;QAEpC,IAAI,CAAC,CAAA,MAAA,IAAI,CAAC,KAAK,0CAAE,aAAa,CAAA,IAAI,CAAC,CAAA,MAAA,IAAI,CAAC,KAAK,0CAAE,cAAc,CAAA;YAC3D,OAAO,OAAO,CAAC;QAEjB,OAAO,IAAI,CAAA;;oBAEK,IAAI,CAAC,QAAQ;yBACR,MAAA,IAAI,CAAC,KAAK,0CAAE,aAAa;wBAC1B,IAAI;;;KAGvB,CAAC;IACJ,CAAC;IAED,MAAM,KAAK,MAAM;QACf,OAAO,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA2CT,CAAC;IACJ,CAAC;CACF,CAAA;AArH6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gDAAuB;AAErB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;iDAAuB;AAEtB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;8CAAoB;AAEnB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;4CAAkB;AAElB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;yCAAmB;AAElB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4CAA8B;AAX9C,UAAU;IADtB,aAAa,CAAC,aAAa,CAAC;GAChB,UAAU,CAsHtB;SAtHY,UAAU","sourcesContent":["import { css, CSSResultGroup, html, LitElement, nothing } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport { ClassInfo, classMap } from 'lit/directives/class-map.js';\n\nimport type { TileModel } from '../models';\n\nimport './overlay/icon-overlay';\nimport './overlay/text-overlay';\n\n@customElement('image-block')\nexport class ImageBlock extends LitElement {\n @property({ type: String }) baseImageUrl?: string;\n\n @property({ type: Boolean }) isCompactTile = false;\n\n @property({ type: Boolean }) isListTile = false;\n\n @property({ type: Boolean }) loggedIn = false;\n\n @property({ type: Object }) model?: TileModel;\n\n @property({ type: String }) viewSize: string = 'desktop';\n\n render() {\n if (!this.model?.identifier) return nothing;\n\n return html`\n <div class=${classMap(this.baseClass)}>\n <item-image\n .model=${this.model}\n .baseImageUrl=${this.baseImageUrl}\n .isListTile=${this.isListTile}\n .isCompactTile=${this.isCompactTile}\n .loggedIn=${this.loggedIn}\n style=\"--imgHeight: 100%; --imgWidth: 100%\"\n >\n </item-image>\n ${this.textOverlayTemplate} ${this.iconOverlayTemplate}\n </div>\n `;\n }\n\n private get baseClass(): ClassInfo {\n return {\n list: this.isListTile && !this.isCompactTile,\n 'list-compact': this.isListTile && this.isCompactTile,\n [this.viewSize]: true,\n };\n }\n\n private get iconOverlayTemplate() {\n if (!this.isListTile) return nothing;\n\n if (!this.model?.loginRequired && !this.model?.contentWarning)\n return nothing;\n\n return html`\n <icon-overlay\n .loggedIn=${this.loggedIn}\n .loginRequired=${this.model?.loginRequired}\n .isCompactTile=${this.isCompactTile}\n >\n </icon-overlay>\n `;\n }\n\n private get textOverlayTemplate() {\n if (this.isListTile) return nothing;\n\n if (!this.model?.loginRequired && !this.model?.contentWarning)\n return nothing;\n\n return html`\n <text-overlay\n .loggedIn=${this.loggedIn}\n .loginRequired=${this.model?.loginRequired}\n ?iconRequired=${true}\n >\n </text-overlay>\n `;\n }\n\n static get styles(): CSSResultGroup {\n return css`\n div {\n display: flex;\n justify-content: center;\n position: relative;\n }\n\n .grid {\n height: var(--imgBlockHeight, 16rem);\n flex: 1;\n display: inline-block;\n position: initial;\n }\n\n /** tile-list view */\n .list.desktop {\n width: 100px;\n height: 100px;\n display: inline-block;\n position: relative;\n text-align: center;\n }\n\n .list.mobile {\n width: 90px;\n height: 90px;\n }\n\n /** tile-list-compact view */\n .list-compact {\n display: block;\n text-align: center;\n }\n\n .list-compact.desktop {\n width: 45px;\n height: 45px;\n }\n\n .list-compact.mobile {\n width: 30px;\n height: 30px;\n }\n `;\n }\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import { css, html, LitElement } from 'lit';
|
|
2
|
+
import { css, html, LitElement, nothing } from 'lit';
|
|
3
3
|
import { customElement, property, query, state } from 'lit/decorators.js';
|
|
4
4
|
import { classMap } from 'lit/directives/class-map.js';
|
|
5
5
|
import { baseItemImageStyles, waveformGradientStyles, } from '../styles/item-image-styles';
|
|
@@ -28,7 +28,10 @@ let ItemImage = class ItemImage extends LitElement {
|
|
|
28
28
|
*/
|
|
29
29
|
get imageSrc() {
|
|
30
30
|
var _a;
|
|
31
|
-
|
|
31
|
+
// Don't try to load invalid image URLs
|
|
32
|
+
return this.baseImageUrl && ((_a = this.model) === null || _a === void 0 ? void 0 : _a.identifier)
|
|
33
|
+
? `${this.baseImageUrl}/services/img/${this.model.identifier}`
|
|
34
|
+
: nothing;
|
|
32
35
|
}
|
|
33
36
|
get hashBasedGradient() {
|
|
34
37
|
var _a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"item-image.js","sourceRoot":"","sources":["../../../src/tiles/item-image.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAkB,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"item-image.js","sourceRoot":"","sources":["../../../src/tiles/item-image.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAkB,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AA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AE,IAAI,EAAE,OAAO,EAAE,CAAC;6CAAoB;AAEnB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;gDAAuB;AAEtB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;2CAAkB;AAErC;IAAR,KAAK,EAAE;6CAA4B;AAEtB;IAAb,KAAK,CAAC,KAAK,CAAC;4CAAsC;AAbxC,SAAS;IADrB,aAAa,CAAC,YAAY,CAAC;GACf,SAAS,CAsGrB;SAtGY,SAAS","sourcesContent":["import { css, CSSResultGroup, html, LitElement, nothing } from 'lit';\nimport { customElement, property, query, state } from 'lit/decorators.js';\nimport { ClassInfo, classMap } from 'lit/directives/class-map.js';\n\nimport type { TileModel } from '../models';\n\nimport {\n baseItemImageStyles,\n waveformGradientStyles,\n} from '../styles/item-image-styles';\n\n@customElement('item-image')\nexport class ItemImage extends LitElement {\n @property({ type: Object }) model?: TileModel;\n\n @property({ type: String }) baseImageUrl?: string;\n\n @property({ type: Boolean }) isListTile = false;\n\n @property({ type: Boolean }) isCompactTile = false;\n\n @property({ type: Boolean }) loggedIn = false;\n\n @state() private isWaveform = false;\n\n @query('img') private baseImage!: HTMLImageElement;\n\n render() {\n return html`\n <div class=${classMap(this.itemBaseClass)}>\n <img\n class=${classMap(this.itemImageClass)}\n src=\"${this.imageSrc}\"\n alt=\"\"\n @load=${this.onLoad}\n />\n </div>\n `;\n }\n\n /**\n * Helpers\n */\n private get imageSrc() {\n // Don't try to load invalid image URLs\n return this.baseImageUrl && this.model?.identifier\n ? `${this.baseImageUrl}/services/img/${this.model.identifier}`\n : nothing;\n }\n\n private get hashBasedGradient() {\n if (!this.model?.identifier) {\n return 'waveform-grad0';\n }\n const gradient = this.hashStrToInt(this.model.identifier) % 6; // returns 0-5\n return `waveform-grad${gradient}`;\n }\n\n private hashStrToInt(str: string): number {\n return str\n .split('')\n .reduce((acc: number, char: string) => acc + char.charCodeAt(0), 0);\n }\n\n /**\n * Classes\n */\n private get itemBaseClass(): ClassInfo {\n return {\n 'drop-shadow': true,\n 'list-box': this.isListTile,\n [this.hashBasedGradient]: this.isWaveform,\n };\n }\n\n private get itemImageClass(): ClassInfo {\n const toBlur = this.model?.contentWarning || this.model?.loginRequired;\n\n return {\n contain: !this.isCompactTile && !this.isWaveform,\n cover: this.isCompactTile,\n blur: toBlur || false,\n waveform: this.isWaveform,\n };\n }\n\n /**\n * Event listener sets isWaveform true if image is waveform\n */\n private onLoad() {\n if (\n (this.model?.mediatype === 'audio' ||\n this.model?.mediatype === 'etree') &&\n this.baseImage.naturalWidth / this.baseImage.naturalHeight === 4\n ) {\n this.isWaveform = true;\n }\n }\n\n /**\n * CSS\n */\n static get styles(): CSSResultGroup {\n return [\n baseItemImageStyles,\n waveformGradientStyles,\n css`\n img {\n height: var(--imgHeight, 16rem);\n width: var(--imgWidth, 16rem);\n }\n `,\n ];\n }\n}\n"]}
|
|
@@ -2,6 +2,9 @@ import { CSSResultGroup, LitElement } from 'lit';
|
|
|
2
2
|
export declare class IconOverlay extends LitElement {
|
|
3
3
|
loggedIn: boolean;
|
|
4
4
|
loginRequired: boolean;
|
|
5
|
+
isCompactTile: boolean;
|
|
5
6
|
render(): import("lit-html").TemplateResult<1>;
|
|
7
|
+
private get getClass();
|
|
8
|
+
private get iconDisplay();
|
|
6
9
|
static get styles(): CSSResultGroup;
|
|
7
10
|
}
|
|
@@ -8,8 +8,17 @@ let IconOverlay = class IconOverlay extends LitElement {
|
|
|
8
8
|
super(...arguments);
|
|
9
9
|
this.loggedIn = false;
|
|
10
10
|
this.loginRequired = false;
|
|
11
|
+
this.isCompactTile = false;
|
|
11
12
|
}
|
|
12
13
|
render() {
|
|
14
|
+
return html `<div class="icon-overlay ${this.getClass}">
|
|
15
|
+
${this.iconDisplay}
|
|
16
|
+
</div>`;
|
|
17
|
+
}
|
|
18
|
+
get getClass() {
|
|
19
|
+
return this.isCompactTile ? 'list-compact' : 'list-detail';
|
|
20
|
+
}
|
|
21
|
+
get iconDisplay() {
|
|
13
22
|
return this.loginRequired && !this.loggedIn
|
|
14
23
|
? html `${loginRequiredIcon}`
|
|
15
24
|
: html `${restrictedIcon}`;
|
|
@@ -21,10 +30,28 @@ let IconOverlay = class IconOverlay extends LitElement {
|
|
|
21
30
|
top: 50%;
|
|
22
31
|
left: 50%;
|
|
23
32
|
transform: translate(-50%, -50%);
|
|
24
|
-
|
|
25
|
-
width: 50%;
|
|
26
|
-
height: 50%;
|
|
33
|
+
width: 100%;
|
|
27
34
|
z-index: 2;
|
|
35
|
+
background-color: rgb(255, 254, 203);
|
|
36
|
+
display: flex;
|
|
37
|
+
justify-content: center;
|
|
38
|
+
border: 1px solid #2c2c2c;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.icon-overlay {
|
|
42
|
+
height: 20px;
|
|
43
|
+
width: 20px;
|
|
44
|
+
padding: 2px;
|
|
45
|
+
padding: 2px;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.list-detail {
|
|
49
|
+
height: 20px;
|
|
50
|
+
width: 20px;
|
|
51
|
+
}
|
|
52
|
+
.list-compact {
|
|
53
|
+
height: 15px;
|
|
54
|
+
width: 15px;
|
|
28
55
|
}
|
|
29
56
|
`;
|
|
30
57
|
}
|
|
@@ -35,6 +62,9 @@ __decorate([
|
|
|
35
62
|
__decorate([
|
|
36
63
|
property({ type: Boolean })
|
|
37
64
|
], IconOverlay.prototype, "loginRequired", void 0);
|
|
65
|
+
__decorate([
|
|
66
|
+
property({ type: Boolean })
|
|
67
|
+
], IconOverlay.prototype, "isCompactTile", void 0);
|
|
38
68
|
IconOverlay = __decorate([
|
|
39
69
|
customElement('icon-overlay')
|
|
40
70
|
], IconOverlay);
|
|
@@ -1 +1 @@
|
|
|
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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E,CAAC;IAC9B,CAAC;IAED,MAAM,KAAK,MAAM;QACf,OAAO,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA6BT,CAAC;IACJ,CAAC;CACF,CAAA;AAtD8B;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;6CAAkB;AAEjB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;kDAAuB;AAEtB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;kDAAuB;AALxC,WAAW;IADvB,aAAa,CAAC,cAAc,CAAC;GACjB,WAAW,CAuDvB;SAvDY,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 @property({ type: Boolean }) isCompactTile = false;\n\n render() {\n return html`<div class=\"icon-overlay ${this.getClass}\">\n ${this.iconDisplay}\n </div>`;\n }\n\n private get getClass() {\n return this.isCompactTile ? 'list-compact' : 'list-detail';\n }\n\n private get iconDisplay() {\n return this.loginRequired && !this.loggedIn\n ? html`${loginRequiredIcon}`\n : html`${restrictedIcon}`;\n }\n\n static get styles(): CSSResultGroup {\n return css`\n :host {\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n width: 100%;\n z-index: 2;\n background-color: rgb(255, 254, 203);\n display: flex;\n justify-content: center;\n border: 1px solid #2c2c2c;\n }\n\n .icon-overlay {\n height: 20px;\n width: 20px;\n padding: 2px;\n padding: 2px;\n }\n\n .list-detail {\n height: 20px;\n width: 20px;\n }\n .list-compact {\n height: 15px;\n width: 15px;\n }\n `;\n }\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CSSResultGroup, LitElement } from 'lit';
|
|
2
|
+
export declare class IconTextOverlay extends LitElement {
|
|
3
|
+
loggedIn: boolean;
|
|
4
|
+
loginRequired: boolean;
|
|
5
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
6
|
+
private get iconDisplay();
|
|
7
|
+
private get textDisplay();
|
|
8
|
+
static get styles(): CSSResultGroup;
|
|
9
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { css, html, LitElement } from 'lit';
|
|
3
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
4
|
+
import { loginRequiredIcon } from '../../assets/img/icons/login-required';
|
|
5
|
+
import { restrictedIcon } from '../../assets/img/icons/restricted';
|
|
6
|
+
let IconTextOverlay = class IconTextOverlay extends LitElement {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(...arguments);
|
|
9
|
+
this.loggedIn = false;
|
|
10
|
+
this.loginRequired = false;
|
|
11
|
+
}
|
|
12
|
+
render() {
|
|
13
|
+
return html `
|
|
14
|
+
<div class="overlay no-preview">
|
|
15
|
+
<div class="icon-overlay">${this.iconDisplay}</div>
|
|
16
|
+
<p class="text-overlay">${this.textDisplay}</p>
|
|
17
|
+
</div>
|
|
18
|
+
`;
|
|
19
|
+
}
|
|
20
|
+
get iconDisplay() {
|
|
21
|
+
return this.loginRequired && !this.loggedIn
|
|
22
|
+
? html `${loginRequiredIcon}`
|
|
23
|
+
: html `${restrictedIcon}`;
|
|
24
|
+
}
|
|
25
|
+
get textDisplay() {
|
|
26
|
+
return this.loginRequired && !this.loggedIn
|
|
27
|
+
? 'Log in\nto view this item'
|
|
28
|
+
: 'Content may be inappropriate';
|
|
29
|
+
}
|
|
30
|
+
static get styles() {
|
|
31
|
+
return css `
|
|
32
|
+
:host {
|
|
33
|
+
align-items: center;
|
|
34
|
+
display: flex;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.overlay {
|
|
38
|
+
border: 1px solid #2c2c2c;
|
|
39
|
+
border-radius: 1px;
|
|
40
|
+
position: absolute;
|
|
41
|
+
right: 0;
|
|
42
|
+
left: 0;
|
|
43
|
+
width: auto;
|
|
44
|
+
height: auto;
|
|
45
|
+
padding: 5px;
|
|
46
|
+
display: flex;
|
|
47
|
+
align-items: center;
|
|
48
|
+
border-radius: 1px;
|
|
49
|
+
text-align: center;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.icon-overlay {
|
|
53
|
+
width: 40px;
|
|
54
|
+
height: 40px;
|
|
55
|
+
display: inherit;
|
|
56
|
+
}
|
|
57
|
+
.text-overlay {
|
|
58
|
+
margin: 0;
|
|
59
|
+
vertical-align: bottom;
|
|
60
|
+
padding-left: 5px;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.no-preview {
|
|
64
|
+
background-color: #fffecb;
|
|
65
|
+
border: 1px solid #2c2c2c;
|
|
66
|
+
color: #2c2c2c;
|
|
67
|
+
font-size: 1.4rem;
|
|
68
|
+
line-height: 2rem;
|
|
69
|
+
}
|
|
70
|
+
`;
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
__decorate([
|
|
74
|
+
property({ type: Boolean })
|
|
75
|
+
], IconTextOverlay.prototype, "loggedIn", void 0);
|
|
76
|
+
__decorate([
|
|
77
|
+
property({ type: Boolean })
|
|
78
|
+
], IconTextOverlay.prototype, "loginRequired", void 0);
|
|
79
|
+
IconTextOverlay = __decorate([
|
|
80
|
+
customElement('icon-text-overlay')
|
|
81
|
+
], IconTextOverlay);
|
|
82
|
+
export { IconTextOverlay };
|
|
83
|
+
//# sourceMappingURL=icon-text-overlay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icon-text-overlay.js","sourceRoot":"","sources":["../../../../src/tiles/overlay/icon-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;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAGnE,IAAa,eAAe,GAA5B,MAAa,eAAgB,SAAQ,UAAU;IAA/C;;QAC+B,aAAQ,GAAG,KAAK,CAAC;QAEjB,kBAAa,GAAG,KAAK,CAAC;IAiErD,CAAC;IA/DC,MAAM;QACJ,OAAO,IAAI,CAAA;;oCAEqB,IAAI,CAAC,WAAW;kCAClB,IAAI,CAAC,WAAW;;KAE7C,CAAC;IACJ,CAAC;IAED,IAAY,WAAW;QACrB,OAAO,IAAI,CAAC,aAAa,IAAI,CAAC,IAAI,CAAC,QAAQ;YACzC,CAAC,CAAC,IAAI,CAAA,GAAG,iBAAiB,EAAE;YAC5B,CAAC,CAAC,IAAI,CAAA,GAAG,cAAc,EAAE,CAAC;IAC9B,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAuCT,CAAC;IACJ,CAAC;CACF,CAAA;AAnE8B;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;iDAAkB;AAEjB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;sDAAuB;AAHxC,eAAe;IAD3B,aAAa,CAAC,mBAAmB,CAAC;GACtB,eAAe,CAoE3B;SApEY,eAAe","sourcesContent":["import { css, CSSResultGroup, html, LitElement } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport { loginRequiredIcon } from '../../assets/img/icons/login-required';\nimport { restrictedIcon } from '../../assets/img/icons/restricted';\n\n@customElement('icon-text-overlay')\nexport class IconTextOverlay extends LitElement {\n @property({ type: Boolean }) loggedIn = false;\n\n @property({ type: Boolean }) loginRequired = false;\n\n render() {\n return html`\n <div class=\"overlay no-preview\">\n <div class=\"icon-overlay\">${this.iconDisplay}</div>\n <p class=\"text-overlay\">${this.textDisplay}</p>\n </div>\n `;\n }\n\n private get iconDisplay() {\n return this.loginRequired && !this.loggedIn\n ? html`${loginRequiredIcon}`\n : html`${restrictedIcon}`;\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 :host {\n align-items: center;\n display: flex;\n }\n\n .overlay {\n border: 1px solid #2c2c2c;\n border-radius: 1px;\n position: absolute;\n right: 0;\n left: 0;\n width: auto;\n height: auto;\n padding: 5px;\n display: flex;\n align-items: center;\n border-radius: 1px;\n text-align: center;\n }\n\n .icon-overlay {\n width: 40px;\n height: 40px;\n display: inherit;\n }\n .text-overlay {\n margin: 0;\n vertical-align: bottom;\n padding-left: 5px;\n }\n\n .no-preview {\n background-color: #fffecb;\n border: 1px solid #2c2c2c;\n color: #2c2c2c;\n font-size: 1.4rem;\n line-height: 2rem;\n }\n `;\n }\n}\n"]}
|
|
@@ -2,7 +2,9 @@ import { CSSResultGroup, LitElement } from 'lit';
|
|
|
2
2
|
export declare class TextOverlay extends LitElement {
|
|
3
3
|
loggedIn: boolean;
|
|
4
4
|
loginRequired: boolean;
|
|
5
|
+
iconRequired: boolean;
|
|
5
6
|
render(): import("lit-html").TemplateResult<1>;
|
|
7
|
+
private get iconDisplay();
|
|
6
8
|
private get textDisplay();
|
|
7
9
|
static get styles(): CSSResultGroup;
|
|
8
10
|
}
|
|
@@ -1,19 +1,32 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { css, html, LitElement } from 'lit';
|
|
3
3
|
import { customElement, property } from 'lit/decorators.js';
|
|
4
|
+
import { loginRequiredIcon } from '../../assets/img/icons/login-required';
|
|
5
|
+
import { restrictedIcon } from '../../assets/img/icons/restricted';
|
|
4
6
|
let TextOverlay = class TextOverlay extends LitElement {
|
|
5
7
|
constructor() {
|
|
6
8
|
super(...arguments);
|
|
7
9
|
this.loggedIn = false;
|
|
8
10
|
this.loginRequired = false;
|
|
11
|
+
this.iconRequired = false;
|
|
9
12
|
}
|
|
10
13
|
render() {
|
|
11
|
-
return html `
|
|
14
|
+
return html `
|
|
15
|
+
<div class="overlay no-preview">
|
|
16
|
+
<div class="icon-overlay">${this.iconDisplay}</div>
|
|
17
|
+
<p class="text-overlay">${this.textDisplay}</p>
|
|
18
|
+
</div>
|
|
19
|
+
`;
|
|
20
|
+
}
|
|
21
|
+
get iconDisplay() {
|
|
22
|
+
return this.loginRequired && !this.loggedIn
|
|
23
|
+
? html `${loginRequiredIcon}`
|
|
24
|
+
: html `${restrictedIcon}`;
|
|
12
25
|
}
|
|
13
26
|
get textDisplay() {
|
|
14
27
|
return this.loginRequired && !this.loggedIn
|
|
15
|
-
?
|
|
16
|
-
:
|
|
28
|
+
? html `Log in to view this item`
|
|
29
|
+
: html `Content may be inappropriate`;
|
|
17
30
|
}
|
|
18
31
|
static get styles() {
|
|
19
32
|
return css `
|
|
@@ -28,18 +41,30 @@ let TextOverlay = class TextOverlay extends LitElement {
|
|
|
28
41
|
position: absolute;
|
|
29
42
|
right: 0;
|
|
30
43
|
left: 0;
|
|
44
|
+
top: 50%;
|
|
45
|
+
transform: translate(0px, -50%);
|
|
31
46
|
width: auto;
|
|
32
47
|
height: auto;
|
|
33
48
|
padding: 5px;
|
|
49
|
+
background-color: #fffecb;
|
|
50
|
+
display: flex;
|
|
51
|
+
align-items: center;
|
|
52
|
+
border-radius: 1px;
|
|
34
53
|
}
|
|
35
54
|
|
|
36
|
-
.
|
|
37
|
-
|
|
55
|
+
.icon-overlay {
|
|
56
|
+
width: 40px;
|
|
57
|
+
height: 40px;
|
|
58
|
+
display: inherit;
|
|
59
|
+
}
|
|
60
|
+
.text-overlay {
|
|
61
|
+
margin: 0;
|
|
62
|
+
vertical-align: bottom;
|
|
63
|
+
padding-left: 5px;
|
|
64
|
+
text-align: center;
|
|
38
65
|
color: #2c2c2c;
|
|
39
66
|
font-size: 1.4rem;
|
|
40
67
|
line-height: 2rem;
|
|
41
|
-
text-align: center;
|
|
42
|
-
white-space: pre-wrap; // for the newline character
|
|
43
68
|
}
|
|
44
69
|
`;
|
|
45
70
|
}
|
|
@@ -50,6 +75,9 @@ __decorate([
|
|
|
50
75
|
__decorate([
|
|
51
76
|
property({ type: Boolean })
|
|
52
77
|
], TextOverlay.prototype, "loginRequired", void 0);
|
|
78
|
+
__decorate([
|
|
79
|
+
property({ type: Boolean })
|
|
80
|
+
], TextOverlay.prototype, "iconRequired", void 0);
|
|
53
81
|
TextOverlay = __decorate([
|
|
54
82
|
customElement('text-overlay')
|
|
55
83
|
], TextOverlay);
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAGnE,IAAa,WAAW,GAAxB,MAAa,WAAY,SAAQ,UAAU;IAA3C;;QAC+B,aAAQ,GAAG,KAAK,CAAC;QAEjB,kBAAa,GAAG,KAAK,CAAC;QAEtB,iBAAY,GAAG,KAAK,CAAC;IA+DpD,CAAC;IA7DC,MAAM;QACJ,OAAO,IAAI,CAAA;;oCAEqB,IAAI,CAAC,WAAW;kCAClB,IAAI,CAAC,WAAW;;KAE7C,CAAC;IACJ,CAAC;IAED,IAAY,WAAW;QACrB,OAAO,IAAI,CAAC,aAAa,IAAI,CAAC,IAAI,CAAC,QAAQ;YACzC,CAAC,CAAC,IAAI,CAAA,GAAG,iBAAiB,EAAE;YAC5B,CAAC,CAAC,IAAI,CAAA,GAAG,cAAc,EAAE,CAAC;IAC9B,CAAC;IAED,IAAY,WAAW;QACrB,OAAO,IAAI,CAAC,aAAa,IAAI,CAAC,IAAI,CAAC,QAAQ;YACzC,CAAC,CAAC,IAAI,CAAA,0BAA0B;YAChC,CAAC,CAAC,IAAI,CAAA,8BAA8B,CAAC;IACzC,CAAC;IAED,MAAM,KAAK,MAAM;QACf,OAAO,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAqCT,CAAC;IACJ,CAAC;CACF,CAAA;AAnE8B;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;6CAAkB;AAEjB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;kDAAuB;AAEtB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;iDAAsB;AALvC,WAAW;IADvB,aAAa,CAAC,cAAc,CAAC;GACjB,WAAW,CAoEvB;SApEY,WAAW","sourcesContent":["import { css, CSSResultGroup, html, LitElement } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport { loginRequiredIcon } from '../../assets/img/icons/login-required';\nimport { restrictedIcon } from '../../assets/img/icons/restricted';\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 @property({ type: Boolean }) iconRequired = false;\n\n render() {\n return html`\n <div class=\"overlay no-preview\">\n <div class=\"icon-overlay\">${this.iconDisplay}</div>\n <p class=\"text-overlay\">${this.textDisplay}</p>\n </div>\n `;\n }\n\n private get iconDisplay() {\n return this.loginRequired && !this.loggedIn\n ? html`${loginRequiredIcon}`\n : html`${restrictedIcon}`;\n }\n\n private get textDisplay() {\n return this.loginRequired && !this.loggedIn\n ? html`Log in to view this item`\n : html`Content may be inappropriate`;\n }\n\n static get styles(): CSSResultGroup {\n return css`\n :host {\n align-items: center;\n display: flex;\n }\n\n .overlay {\n border: 1px solid #2c2c2c;\n border-radius: 1px;\n position: absolute;\n right: 0;\n left: 0;\n top: 50%;\n transform: translate(0px, -50%);\n width: auto;\n height: auto;\n padding: 5px;\n background-color: #fffecb;\n display: flex;\n align-items: center;\n border-radius: 1px;\n }\n\n .icon-overlay {\n width: 40px;\n height: 40px;\n display: inherit;\n }\n .text-overlay {\n margin: 0;\n vertical-align: bottom;\n padding-left: 5px;\n text-align: center;\n color: #2c2c2c;\n font-size: 1.4rem;\n line-height: 2rem;\n }\n `;\n }\n}\n"]}
|
|
@@ -69,5 +69,51 @@ describe('ItemImage component', () => {
|
|
|
69
69
|
expect(imgClassName).to.eql(' waveform ');
|
|
70
70
|
}, 1000);
|
|
71
71
|
});
|
|
72
|
+
it('should not fetch image with undefined base url', async () => {
|
|
73
|
+
var _a;
|
|
74
|
+
const el = await fixture(html `
|
|
75
|
+
<item-image
|
|
76
|
+
.isListTile=${false}
|
|
77
|
+
.isCompactTile=${false}
|
|
78
|
+
.model=${testBookModel}
|
|
79
|
+
>
|
|
80
|
+
</item-image>
|
|
81
|
+
`);
|
|
82
|
+
// Doesn't set the image src if base url is undefined
|
|
83
|
+
const img = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('img');
|
|
84
|
+
expect(img).to.exist;
|
|
85
|
+
expect(img === null || img === void 0 ? void 0 : img.getAttribute('src')).not.to.exist;
|
|
86
|
+
});
|
|
87
|
+
it('should not fetch image with undefined model', async () => {
|
|
88
|
+
var _a;
|
|
89
|
+
const el = await fixture(html `
|
|
90
|
+
<item-image
|
|
91
|
+
.isListTile=${false}
|
|
92
|
+
.isCompactTile=${false}
|
|
93
|
+
.baseImageUrl=${baseImageUrl}
|
|
94
|
+
>
|
|
95
|
+
</item-image>
|
|
96
|
+
`);
|
|
97
|
+
// Doesn't set the image src if model is not present
|
|
98
|
+
const img = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('img');
|
|
99
|
+
expect(img).to.exist;
|
|
100
|
+
expect(img === null || img === void 0 ? void 0 : img.getAttribute('src')).not.to.exist;
|
|
101
|
+
});
|
|
102
|
+
it('should not fetch image with undefined identifier', async () => {
|
|
103
|
+
var _a;
|
|
104
|
+
const el = await fixture(html `
|
|
105
|
+
<item-image
|
|
106
|
+
.isListTile=${false}
|
|
107
|
+
.isCompactTile=${false}
|
|
108
|
+
.model=${{}}
|
|
109
|
+
.baseImageUrl=${baseImageUrl}
|
|
110
|
+
>
|
|
111
|
+
</item-image>
|
|
112
|
+
`);
|
|
113
|
+
// Doesn't set the image src if identifier is not present
|
|
114
|
+
const img = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('img');
|
|
115
|
+
expect(img).to.exist;
|
|
116
|
+
expect(img === null || img === void 0 ? void 0 : img.getAttribute('src')).not.to.exist;
|
|
117
|
+
});
|
|
72
118
|
});
|
|
73
119
|
//# sourceMappingURL=item-image.test.js.map
|
|
@@ -1 +1 @@
|
|
|
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;AAK3B,OAA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CAAC,EAAE,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAC3C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,kDAAkD,EAAE,KAAK,IAAI,EAAE;;QAChE,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,MAAM,KAAK,GAAG,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,aAAa,CAAC,KAAK,CAAC,CAAC;QAC/C,MAAM,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC;QAC5B,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC;QAEvB,mEAAmE;QACnE,UAAU,CAAC,GAAG,EAAE;YACd,MAAM,YAAY,GAAG,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAAS,CAAC;YACtC,MAAM,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;QAC5C,CAAC,EAAE,IAAI,CAAC,CAAC;IACX,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\nimport type { TileModel } from '../src/models';\nimport type { 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 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 expect(dropShadow).to.exist;\n expect(image).to.exist;\n\n // simulate image onLoad event check if image className is waveform\n setTimeout(() => {\n const imgClassName = image?.className;\n expect(imgClassName).to.eql(' waveform ');\n }, 1000);\n });\n});\n"]}
|
|
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;AAK3B,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;I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AG,GAAG,MAAA,EAAE,CAAC,UAAU,0CAAE,aAAa,CAAC,KAAK,CAAC,CAAC;QAChD,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC;QACrB,MAAM,CAAC,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC;IAChD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,kDAAkD,EAAE,KAAK,IAAI,EAAE;;QAChE,MAAM,EAAE,GAAG,MAAM,OAAO,CAAY,IAAI,CAAA;;sBAEtB,KAAK;yBACF,KAAK;iBACb,EAAE;wBACK,YAAY;;;KAG/B,CAAC,CAAC;QAEH,yDAAyD;QACzD,MAAM,GAAG,GAAG,MAAA,EAAE,CAAC,UAAU,0CAAE,aAAa,CAAC,KAAK,CAAC,CAAC;QAChD,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC;QACrB,MAAM,CAAC,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC;IAChD,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\nimport type { TileModel } from '../src/models';\nimport type { 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 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 expect(dropShadow).to.exist;\n expect(image).to.exist;\n\n // simulate image onLoad event check if image className is waveform\n setTimeout(() => {\n const imgClassName = image?.className;\n expect(imgClassName).to.eql(' waveform ');\n }, 1000);\n });\n\n it('should not fetch image with undefined base url', async () => {\n const el = await fixture<ItemImage>(html`\n <item-image\n .isListTile=${false}\n .isCompactTile=${false}\n .model=${testBookModel}\n >\n </item-image>\n `);\n\n // Doesn't set the image src if base url is undefined\n const img = el.shadowRoot?.querySelector('img');\n expect(img).to.exist;\n expect(img?.getAttribute('src')).not.to.exist;\n });\n\n it('should not fetch image with undefined model', async () => {\n const el = await fixture<ItemImage>(html`\n <item-image\n .isListTile=${false}\n .isCompactTile=${false}\n .baseImageUrl=${baseImageUrl}\n >\n </item-image>\n `);\n\n // Doesn't set the image src if model is not present\n const img = el.shadowRoot?.querySelector('img');\n expect(img).to.exist;\n expect(img?.getAttribute('src')).not.to.exist;\n });\n\n it('should not fetch image with undefined identifier', async () => {\n const el = await fixture<ItemImage>(html`\n <item-image\n .isListTile=${false}\n .isCompactTile=${false}\n .model=${{}}\n .baseImageUrl=${baseImageUrl}\n >\n </item-image>\n `);\n\n // Doesn't set the image src if identifier is not present\n const img = el.shadowRoot?.querySelector('img');\n expect(img).to.exist;\n expect(img?.getAttribute('src')).not.to.exist;\n });\n});\n"]}
|
|
@@ -12,37 +12,44 @@ describe('Text Overlay component', () => {
|
|
|
12
12
|
expect(noPreview).to.exist;
|
|
13
13
|
});
|
|
14
14
|
it('should render component if loggedIn required', async () => {
|
|
15
|
-
var _a, _b;
|
|
15
|
+
var _a, _b, _c, _d;
|
|
16
16
|
const el = await fixture(html `
|
|
17
17
|
<text-overlay .loggedIn=${false} .loginRequired=${true}> </text-overlay>
|
|
18
18
|
`);
|
|
19
19
|
const overlay = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('.overlay');
|
|
20
20
|
const noPreview = (_b = el.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('.no-preview');
|
|
21
|
+
const iconOverlay = (_c = el.shadowRoot) === null || _c === void 0 ? void 0 : _c.querySelector('.icon-overlay');
|
|
22
|
+
const textOverlay = (_d = el.shadowRoot) === null || _d === void 0 ? void 0 : _d.querySelector('.text-overlay');
|
|
21
23
|
expect(overlay).to.exist;
|
|
22
24
|
expect(noPreview).to.exist;
|
|
23
|
-
expect(
|
|
25
|
+
expect(iconOverlay).to.exist;
|
|
26
|
+
expect(textOverlay === null || textOverlay === void 0 ? void 0 : textOverlay.textContent).to.equal('Log in to view this item');
|
|
24
27
|
});
|
|
25
28
|
it('should render component if content warning', async () => {
|
|
26
|
-
var _a, _b;
|
|
29
|
+
var _a, _b, _c, _d;
|
|
27
30
|
const el = await fixture(html `
|
|
28
31
|
<text-overlay .loggedIn=${false} .loginRequired=${false}> </text-overlay>
|
|
29
32
|
`);
|
|
30
33
|
const overlay = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('.overlay');
|
|
31
34
|
const noPreview = (_b = el.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('.no-preview');
|
|
35
|
+
const iconOverlay = (_c = el.shadowRoot) === null || _c === void 0 ? void 0 : _c.querySelector('.icon-overlay');
|
|
36
|
+
const textOverlay = (_d = el.shadowRoot) === null || _d === void 0 ? void 0 : _d.querySelector('.text-overlay');
|
|
32
37
|
expect(overlay).to.exist;
|
|
33
38
|
expect(noPreview).to.exist;
|
|
34
|
-
expect(
|
|
39
|
+
expect(iconOverlay).to.exist;
|
|
40
|
+
expect(textOverlay === null || textOverlay === void 0 ? void 0 : textOverlay.textContent).to.equal('Content may be inappropriate');
|
|
35
41
|
});
|
|
36
42
|
it('should render component if content warning', async () => {
|
|
37
|
-
var _a, _b;
|
|
43
|
+
var _a, _b, _c;
|
|
38
44
|
const el = await fixture(html `
|
|
39
45
|
<text-overlay .loggedIn=${true} .loginRequired=${true}> </text-overlay>
|
|
40
46
|
`);
|
|
41
47
|
const overlay = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('.overlay');
|
|
42
48
|
const noPreview = (_b = el.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('.no-preview');
|
|
49
|
+
const textOverlay = (_c = el.shadowRoot) === null || _c === void 0 ? void 0 : _c.querySelector('.text-overlay');
|
|
43
50
|
expect(overlay).to.exist;
|
|
44
51
|
expect(noPreview).to.exist;
|
|
45
|
-
expect(
|
|
52
|
+
expect(textOverlay === null || textOverlay === void 0 ? void 0 : textOverlay.textContent).to.equal('Content may be inappropriate');
|
|
46
53
|
});
|
|
47
54
|
});
|
|
48
55
|
//# sourceMappingURL=text-overlay.test.js.map
|
|
@@ -1 +1 @@
|
|
|
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,mCAAm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AAC,EAAE,CAAC,KAAK,CAAC;QAC3B,MAAM,CAAC,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,WAAW,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAC;IAC5E,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 type { 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 const iconOverlay = el.shadowRoot?.querySelector('.icon-overlay');\n const textOverlay = el.shadowRoot?.querySelector('.text-overlay');\n\n expect(overlay).to.exist;\n expect(noPreview).to.exist;\n expect(iconOverlay).to.exist;\n expect(textOverlay?.textContent).to.equal('Log in to 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 const iconOverlay = el.shadowRoot?.querySelector('.icon-overlay');\n const textOverlay = el.shadowRoot?.querySelector('.text-overlay');\n\n expect(overlay).to.exist;\n expect(noPreview).to.exist;\n expect(iconOverlay).to.exist;\n expect(textOverlay?.textContent).to.equal('Content may be inappropriate');\n });\n\n it('should render component if content warning', async () => {\n const el = await fixture<TextOverlay>(html`\n <text-overlay .loggedIn=${true} .loginRequired=${true}> </text-overlay>\n `);\n\n const overlay = el.shadowRoot?.querySelector('.overlay');\n const noPreview = el.shadowRoot?.querySelector('.no-preview');\n const textOverlay = el.shadowRoot?.querySelector('.text-overlay');\n\n expect(overlay).to.exist;\n expect(noPreview).to.exist;\n expect(textOverlay?.textContent).to.equal('Content may be inappropriate');\n });\n});\n"]}
|
package/package.json
CHANGED
|
@@ -5,24 +5,12 @@ export const loginRequiredIcon = svg`
|
|
|
5
5
|
viewBox="0 0 100 100"
|
|
6
6
|
xmlns="http://www.w3.org/2000/svg"
|
|
7
7
|
>
|
|
8
|
-
<g fill="
|
|
8
|
+
<g fill="#000" fill-rule="evenodd">
|
|
9
9
|
<path
|
|
10
|
-
d="
|
|
11
|
-
fill="#fff"
|
|
12
|
-
transform="matrix(0 1 -1 0 86 13)"
|
|
10
|
+
d="m86 0c5.5228475 0 10 4.4771525 10 10v80c0 5.5228475-4.4771525 10-10 10h-57c-5.5228475 0-10-4.4771525-10-10v-13h7.999l.001 8c0 2.6887547 2.1223067 4.8818181 4.7831104 4.9953805l.2168896.0046195h50.06c2.6887547 0 4.8818181-2.1223067 4.9953805-4.7831104l.0046195-.2168896v-70c0-2.7614237-2.2385763-5-5-5h-50.06c-2.6887547 0-4.8818181 2.1223067-4.9953805 4.7831104l-.0046195.2168896-.001 7h-7.999v-12c0-5.5228475 4.4771525-10 10-10z"
|
|
13
11
|
/>
|
|
14
12
|
<path
|
|
15
|
-
d="
|
|
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"
|
|
13
|
+
d="m4 52h14c-.0377367 5.0230706-.0377367 15.3564039 0 31h35v-31h16c-20.0693886-21.0798163-30.8885707-32.4131497-32.4575462-34z" fill-rule="nonzero" transform="matrix(0 1 -1 0 87 14)"
|
|
26
14
|
/>
|
|
27
15
|
</g>
|
|
28
16
|
<title>Log in to view this item</title>
|
|
@@ -5,25 +5,9 @@ export const restrictedIcon = svg`
|
|
|
5
5
|
viewBox="0 0 100 100"
|
|
6
6
|
xmlns="http://www.w3.org/2000/svg"
|
|
7
7
|
>
|
|
8
|
-
<g
|
|
9
|
-
fill="none"
|
|
10
|
-
fill-rule="evenodd"
|
|
11
|
-
>
|
|
12
8
|
<path
|
|
13
|
-
d="m56.4612493 8.80450354 41.8901185 75.94632926c1.7706782 2.8433173 2.1150372 5.2623412 1.0330766 7.2570716-1.0819604 1.9947304-3.26978 2.9920956-6.5634587 2.9920956h-85.69973905c-3.29367873 0-5.46954894-.9973652-6.52761065-2.9920956-1.0580617-1.9947304-.70175345-4.4137543 1.06892476-7.2570716l41.89011844-75.12308969c1.8184757-2.84331737 3.9693609-4.37738627 6.4526556-4.60220671s4.6341799 1.03483527 6.4526556 3.
|
|
14
|
-
fill="#000"
|
|
15
|
-
fill-rule="nonzero"
|
|
9
|
+
d="m56.4612493 8.80450354 41.8901185 75.94632926c1.7706782 2.8433173 2.1150372 5.2623412 1.0330766 7.2570716-1.0819604 1.9947304-3.26978 2.9920956-6.5634587 2.9920956h-85.69973905c-3.29367873 0-5.46954894-.9973652-6.52761065-2.9920956-1.0580617-1.9947304-.70175345-4.4137543 1.06892476-7.2570716l41.89011844-75.12308969c1.8184757-2.84331737 3.9693609-4.37738627 6.4526556-4.60220671s4.6341799 1.03483527 6.4526556 3.77896714zm28.5387507 75.19549646-35.037482-62-34.962518 62zm-31-34.7484359v-10.2515641h-8v10.2515641l2.089172 14.7484359h3.8184713zm-8 19.7484359v8h8v-8z"
|
|
16
10
|
/>
|
|
17
|
-
<path
|
|
18
|
-
d="m94.0140845 90-44.5547054-79-44.4593791 79z"
|
|
19
|
-
fill="#f8e71c"
|
|
20
|
-
fill-rule="nonzero"
|
|
21
|
-
/>
|
|
22
|
-
<path
|
|
23
|
-
d="m54 69v8h-8v-8zm0-30v10.2515641l-2.0923567 14.7484359h-3.8184713l-2.089172-14.7484359v-10.2515641z"
|
|
24
|
-
fill="#000"
|
|
25
|
-
/>
|
|
26
|
-
</g>
|
|
27
11
|
<title>Content may be inappropriate</title>
|
|
28
12
|
</svg>
|
|
29
13
|
`;
|
|
@@ -11,18 +11,14 @@ export const baseItemImageStyles = css`
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
.list-box {
|
|
14
|
-
width: 100%;
|
|
15
|
-
height: 100%;
|
|
16
14
|
overflow: hidden;
|
|
17
15
|
box-sizing: border-box;
|
|
18
|
-
display:
|
|
16
|
+
display: inline-block;
|
|
19
17
|
position: relative;
|
|
20
|
-
max-width: 100px;
|
|
21
18
|
}
|
|
22
19
|
|
|
23
20
|
.contain {
|
|
24
21
|
object-fit: contain;
|
|
25
|
-
object-position: top;
|
|
26
22
|
height: 100%;
|
|
27
23
|
width: 100%;
|
|
28
24
|
}
|
|
@@ -32,7 +28,8 @@ export const baseItemImageStyles = css`
|
|
|
32
28
|
}
|
|
33
29
|
|
|
34
30
|
.blur {
|
|
35
|
-
filter: blur(
|
|
31
|
+
filter: blur(15px);
|
|
32
|
+
box-shadow: 1px 1px 2px 0px;
|
|
36
33
|
}
|
|
37
34
|
`;
|
|
38
35
|
|
package/src/tiles/image-block.ts
CHANGED
|
@@ -58,6 +58,7 @@ export class ImageBlock extends LitElement {
|
|
|
58
58
|
<icon-overlay
|
|
59
59
|
.loggedIn=${this.loggedIn}
|
|
60
60
|
.loginRequired=${this.model?.loginRequired}
|
|
61
|
+
.isCompactTile=${this.isCompactTile}
|
|
61
62
|
>
|
|
62
63
|
</icon-overlay>
|
|
63
64
|
`;
|
|
@@ -73,6 +74,7 @@ export class ImageBlock extends LitElement {
|
|
|
73
74
|
<text-overlay
|
|
74
75
|
.loggedIn=${this.loggedIn}
|
|
75
76
|
.loginRequired=${this.model?.loginRequired}
|
|
77
|
+
?iconRequired=${true}
|
|
76
78
|
>
|
|
77
79
|
</text-overlay>
|
|
78
80
|
`;
|
|
@@ -89,12 +91,17 @@ export class ImageBlock extends LitElement {
|
|
|
89
91
|
.grid {
|
|
90
92
|
height: var(--imgBlockHeight, 16rem);
|
|
91
93
|
flex: 1;
|
|
94
|
+
display: inline-block;
|
|
95
|
+
position: initial;
|
|
92
96
|
}
|
|
93
97
|
|
|
94
98
|
/** tile-list view */
|
|
95
99
|
.list.desktop {
|
|
96
100
|
width: 100px;
|
|
97
101
|
height: 100px;
|
|
102
|
+
display: inline-block;
|
|
103
|
+
position: relative;
|
|
104
|
+
text-align: center;
|
|
98
105
|
}
|
|
99
106
|
|
|
100
107
|
.list.mobile {
|
|
@@ -105,6 +112,7 @@ export class ImageBlock extends LitElement {
|
|
|
105
112
|
/** tile-list-compact view */
|
|
106
113
|
.list-compact {
|
|
107
114
|
display: block;
|
|
115
|
+
text-align: center;
|
|
108
116
|
}
|
|
109
117
|
|
|
110
118
|
.list-compact.desktop {
|
package/src/tiles/item-image.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { css, CSSResultGroup, html, LitElement } from 'lit';
|
|
1
|
+
import { css, CSSResultGroup, html, LitElement, nothing } 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
|
|
|
@@ -42,7 +42,10 @@ export class ItemImage extends LitElement {
|
|
|
42
42
|
* Helpers
|
|
43
43
|
*/
|
|
44
44
|
private get imageSrc() {
|
|
45
|
-
|
|
45
|
+
// Don't try to load invalid image URLs
|
|
46
|
+
return this.baseImageUrl && this.model?.identifier
|
|
47
|
+
? `${this.baseImageUrl}/services/img/${this.model.identifier}`
|
|
48
|
+
: nothing;
|
|
46
49
|
}
|
|
47
50
|
|
|
48
51
|
private get hashBasedGradient() {
|
|
@@ -10,7 +10,19 @@ export class IconOverlay extends LitElement {
|
|
|
10
10
|
|
|
11
11
|
@property({ type: Boolean }) loginRequired = false;
|
|
12
12
|
|
|
13
|
+
@property({ type: Boolean }) isCompactTile = false;
|
|
14
|
+
|
|
13
15
|
render() {
|
|
16
|
+
return html`<div class="icon-overlay ${this.getClass}">
|
|
17
|
+
${this.iconDisplay}
|
|
18
|
+
</div>`;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
private get getClass() {
|
|
22
|
+
return this.isCompactTile ? 'list-compact' : 'list-detail';
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
private get iconDisplay() {
|
|
14
26
|
return this.loginRequired && !this.loggedIn
|
|
15
27
|
? html`${loginRequiredIcon}`
|
|
16
28
|
: html`${restrictedIcon}`;
|
|
@@ -23,10 +35,28 @@ export class IconOverlay extends LitElement {
|
|
|
23
35
|
top: 50%;
|
|
24
36
|
left: 50%;
|
|
25
37
|
transform: translate(-50%, -50%);
|
|
26
|
-
|
|
27
|
-
width: 50%;
|
|
28
|
-
height: 50%;
|
|
38
|
+
width: 100%;
|
|
29
39
|
z-index: 2;
|
|
40
|
+
background-color: rgb(255, 254, 203);
|
|
41
|
+
display: flex;
|
|
42
|
+
justify-content: center;
|
|
43
|
+
border: 1px solid #2c2c2c;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.icon-overlay {
|
|
47
|
+
height: 20px;
|
|
48
|
+
width: 20px;
|
|
49
|
+
padding: 2px;
|
|
50
|
+
padding: 2px;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.list-detail {
|
|
54
|
+
height: 20px;
|
|
55
|
+
width: 20px;
|
|
56
|
+
}
|
|
57
|
+
.list-compact {
|
|
58
|
+
height: 15px;
|
|
59
|
+
width: 15px;
|
|
30
60
|
}
|
|
31
61
|
`;
|
|
32
62
|
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { css, CSSResultGroup, html, LitElement } from 'lit';
|
|
2
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
3
|
+
import { loginRequiredIcon } from '../../assets/img/icons/login-required';
|
|
4
|
+
import { restrictedIcon } from '../../assets/img/icons/restricted';
|
|
5
|
+
|
|
6
|
+
@customElement('icon-text-overlay')
|
|
7
|
+
export class IconTextOverlay extends LitElement {
|
|
8
|
+
@property({ type: Boolean }) loggedIn = false;
|
|
9
|
+
|
|
10
|
+
@property({ type: Boolean }) loginRequired = false;
|
|
11
|
+
|
|
12
|
+
render() {
|
|
13
|
+
return html`
|
|
14
|
+
<div class="overlay no-preview">
|
|
15
|
+
<div class="icon-overlay">${this.iconDisplay}</div>
|
|
16
|
+
<p class="text-overlay">${this.textDisplay}</p>
|
|
17
|
+
</div>
|
|
18
|
+
`;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
private get iconDisplay() {
|
|
22
|
+
return this.loginRequired && !this.loggedIn
|
|
23
|
+
? html`${loginRequiredIcon}`
|
|
24
|
+
: html`${restrictedIcon}`;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
private get textDisplay() {
|
|
28
|
+
return this.loginRequired && !this.loggedIn
|
|
29
|
+
? 'Log in\nto view this item'
|
|
30
|
+
: 'Content may be inappropriate';
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
static get styles(): CSSResultGroup {
|
|
34
|
+
return css`
|
|
35
|
+
:host {
|
|
36
|
+
align-items: center;
|
|
37
|
+
display: flex;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.overlay {
|
|
41
|
+
border: 1px solid #2c2c2c;
|
|
42
|
+
border-radius: 1px;
|
|
43
|
+
position: absolute;
|
|
44
|
+
right: 0;
|
|
45
|
+
left: 0;
|
|
46
|
+
width: auto;
|
|
47
|
+
height: auto;
|
|
48
|
+
padding: 5px;
|
|
49
|
+
display: flex;
|
|
50
|
+
align-items: center;
|
|
51
|
+
border-radius: 1px;
|
|
52
|
+
text-align: center;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.icon-overlay {
|
|
56
|
+
width: 40px;
|
|
57
|
+
height: 40px;
|
|
58
|
+
display: inherit;
|
|
59
|
+
}
|
|
60
|
+
.text-overlay {
|
|
61
|
+
margin: 0;
|
|
62
|
+
vertical-align: bottom;
|
|
63
|
+
padding-left: 5px;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.no-preview {
|
|
67
|
+
background-color: #fffecb;
|
|
68
|
+
border: 1px solid #2c2c2c;
|
|
69
|
+
color: #2c2c2c;
|
|
70
|
+
font-size: 1.4rem;
|
|
71
|
+
line-height: 2rem;
|
|
72
|
+
}
|
|
73
|
+
`;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { css, CSSResultGroup, html, LitElement } from 'lit';
|
|
2
2
|
import { customElement, property } from 'lit/decorators.js';
|
|
3
|
+
import { loginRequiredIcon } from '../../assets/img/icons/login-required';
|
|
4
|
+
import { restrictedIcon } from '../../assets/img/icons/restricted';
|
|
3
5
|
|
|
4
6
|
@customElement('text-overlay')
|
|
5
7
|
export class TextOverlay extends LitElement {
|
|
@@ -7,14 +9,27 @@ export class TextOverlay extends LitElement {
|
|
|
7
9
|
|
|
8
10
|
@property({ type: Boolean }) loginRequired = false;
|
|
9
11
|
|
|
12
|
+
@property({ type: Boolean }) iconRequired = false;
|
|
13
|
+
|
|
10
14
|
render() {
|
|
11
|
-
return html`
|
|
15
|
+
return html`
|
|
16
|
+
<div class="overlay no-preview">
|
|
17
|
+
<div class="icon-overlay">${this.iconDisplay}</div>
|
|
18
|
+
<p class="text-overlay">${this.textDisplay}</p>
|
|
19
|
+
</div>
|
|
20
|
+
`;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
private get iconDisplay() {
|
|
24
|
+
return this.loginRequired && !this.loggedIn
|
|
25
|
+
? html`${loginRequiredIcon}`
|
|
26
|
+
: html`${restrictedIcon}`;
|
|
12
27
|
}
|
|
13
28
|
|
|
14
29
|
private get textDisplay() {
|
|
15
30
|
return this.loginRequired && !this.loggedIn
|
|
16
|
-
?
|
|
17
|
-
:
|
|
31
|
+
? html`Log in to view this item`
|
|
32
|
+
: html`Content may be inappropriate`;
|
|
18
33
|
}
|
|
19
34
|
|
|
20
35
|
static get styles(): CSSResultGroup {
|
|
@@ -30,18 +45,30 @@ export class TextOverlay extends LitElement {
|
|
|
30
45
|
position: absolute;
|
|
31
46
|
right: 0;
|
|
32
47
|
left: 0;
|
|
48
|
+
top: 50%;
|
|
49
|
+
transform: translate(0px, -50%);
|
|
33
50
|
width: auto;
|
|
34
51
|
height: auto;
|
|
35
52
|
padding: 5px;
|
|
53
|
+
background-color: #fffecb;
|
|
54
|
+
display: flex;
|
|
55
|
+
align-items: center;
|
|
56
|
+
border-radius: 1px;
|
|
36
57
|
}
|
|
37
58
|
|
|
38
|
-
.
|
|
39
|
-
|
|
59
|
+
.icon-overlay {
|
|
60
|
+
width: 40px;
|
|
61
|
+
height: 40px;
|
|
62
|
+
display: inherit;
|
|
63
|
+
}
|
|
64
|
+
.text-overlay {
|
|
65
|
+
margin: 0;
|
|
66
|
+
vertical-align: bottom;
|
|
67
|
+
padding-left: 5px;
|
|
68
|
+
text-align: center;
|
|
40
69
|
color: #2c2c2c;
|
|
41
70
|
font-size: 1.4rem;
|
|
42
71
|
line-height: 2rem;
|
|
43
|
-
text-align: center;
|
|
44
|
-
white-space: pre-wrap; // for the newline character
|
|
45
72
|
}
|
|
46
73
|
`;
|
|
47
74
|
}
|
package/test/item-image.test.ts
CHANGED
|
@@ -79,4 +79,53 @@ describe('ItemImage component', () => {
|
|
|
79
79
|
expect(imgClassName).to.eql(' waveform ');
|
|
80
80
|
}, 1000);
|
|
81
81
|
});
|
|
82
|
+
|
|
83
|
+
it('should not fetch image with undefined base url', async () => {
|
|
84
|
+
const el = await fixture<ItemImage>(html`
|
|
85
|
+
<item-image
|
|
86
|
+
.isListTile=${false}
|
|
87
|
+
.isCompactTile=${false}
|
|
88
|
+
.model=${testBookModel}
|
|
89
|
+
>
|
|
90
|
+
</item-image>
|
|
91
|
+
`);
|
|
92
|
+
|
|
93
|
+
// Doesn't set the image src if base url is undefined
|
|
94
|
+
const img = el.shadowRoot?.querySelector('img');
|
|
95
|
+
expect(img).to.exist;
|
|
96
|
+
expect(img?.getAttribute('src')).not.to.exist;
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it('should not fetch image with undefined model', async () => {
|
|
100
|
+
const el = await fixture<ItemImage>(html`
|
|
101
|
+
<item-image
|
|
102
|
+
.isListTile=${false}
|
|
103
|
+
.isCompactTile=${false}
|
|
104
|
+
.baseImageUrl=${baseImageUrl}
|
|
105
|
+
>
|
|
106
|
+
</item-image>
|
|
107
|
+
`);
|
|
108
|
+
|
|
109
|
+
// Doesn't set the image src if model is not present
|
|
110
|
+
const img = el.shadowRoot?.querySelector('img');
|
|
111
|
+
expect(img).to.exist;
|
|
112
|
+
expect(img?.getAttribute('src')).not.to.exist;
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it('should not fetch image with undefined identifier', async () => {
|
|
116
|
+
const el = await fixture<ItemImage>(html`
|
|
117
|
+
<item-image
|
|
118
|
+
.isListTile=${false}
|
|
119
|
+
.isCompactTile=${false}
|
|
120
|
+
.model=${{}}
|
|
121
|
+
.baseImageUrl=${baseImageUrl}
|
|
122
|
+
>
|
|
123
|
+
</item-image>
|
|
124
|
+
`);
|
|
125
|
+
|
|
126
|
+
// Doesn't set the image src if identifier is not present
|
|
127
|
+
const img = el.shadowRoot?.querySelector('img');
|
|
128
|
+
expect(img).to.exist;
|
|
129
|
+
expect(img?.getAttribute('src')).not.to.exist;
|
|
130
|
+
});
|
|
82
131
|
});
|
|
@@ -23,10 +23,13 @@ describe('Text Overlay component', () => {
|
|
|
23
23
|
|
|
24
24
|
const overlay = el.shadowRoot?.querySelector('.overlay');
|
|
25
25
|
const noPreview = el.shadowRoot?.querySelector('.no-preview');
|
|
26
|
+
const iconOverlay = el.shadowRoot?.querySelector('.icon-overlay');
|
|
27
|
+
const textOverlay = el.shadowRoot?.querySelector('.text-overlay');
|
|
26
28
|
|
|
27
29
|
expect(overlay).to.exist;
|
|
28
30
|
expect(noPreview).to.exist;
|
|
29
|
-
expect(
|
|
31
|
+
expect(iconOverlay).to.exist;
|
|
32
|
+
expect(textOverlay?.textContent).to.equal('Log in to view this item');
|
|
30
33
|
});
|
|
31
34
|
|
|
32
35
|
it('should render component if content warning', async () => {
|
|
@@ -36,10 +39,13 @@ describe('Text Overlay component', () => {
|
|
|
36
39
|
|
|
37
40
|
const overlay = el.shadowRoot?.querySelector('.overlay');
|
|
38
41
|
const noPreview = el.shadowRoot?.querySelector('.no-preview');
|
|
42
|
+
const iconOverlay = el.shadowRoot?.querySelector('.icon-overlay');
|
|
43
|
+
const textOverlay = el.shadowRoot?.querySelector('.text-overlay');
|
|
39
44
|
|
|
40
45
|
expect(overlay).to.exist;
|
|
41
46
|
expect(noPreview).to.exist;
|
|
42
|
-
expect(
|
|
47
|
+
expect(iconOverlay).to.exist;
|
|
48
|
+
expect(textOverlay?.textContent).to.equal('Content may be inappropriate');
|
|
43
49
|
});
|
|
44
50
|
|
|
45
51
|
it('should render component if content warning', async () => {
|
|
@@ -49,9 +55,10 @@ describe('Text Overlay component', () => {
|
|
|
49
55
|
|
|
50
56
|
const overlay = el.shadowRoot?.querySelector('.overlay');
|
|
51
57
|
const noPreview = el.shadowRoot?.querySelector('.no-preview');
|
|
58
|
+
const textOverlay = el.shadowRoot?.querySelector('.text-overlay');
|
|
52
59
|
|
|
53
60
|
expect(overlay).to.exist;
|
|
54
61
|
expect(noPreview).to.exist;
|
|
55
|
-
expect(
|
|
62
|
+
expect(textOverlay?.textContent).to.equal('Content may be inappropriate');
|
|
56
63
|
});
|
|
57
64
|
});
|