@internetarchive/collection-browser 0.1.9-alpha1 → 0.2.1
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/.github/workflows/gh-pages-main.yml +39 -0
- package/.github/workflows/npm-publish.yml +39 -0
- package/.github/workflows/pr-preview.yml +38 -0
- package/README.md +9 -3
- package/dist/src/styles/item-image-styles.d.ts +8 -0
- package/dist/src/styles/item-image-styles.js +101 -0
- package/dist/src/styles/item-image-styles.js.map +1 -0
- package/dist/src/tiles/item-image.d.ts +17 -13
- package/dist/src/tiles/item-image.js +63 -244
- 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 +1 -0
- package/dist/src/tiles/list/tile-list-compact.js +2 -0
- package/dist/src/tiles/list/tile-list-compact.js.map +1 -1
- package/dist/src/tiles/list/tile-list.d.ts +2 -1
- package/dist/src/tiles/list/tile-list.js +2 -0
- package/dist/src/tiles/list/tile-list.js.map +1 -1
- package/package.json +3 -2
- package/src/styles/item-image-styles.ts +102 -0
- package/src/tiles/item-image.ts +68 -255
- package/src/tiles/item-tile-image.ts +61 -0
- package/src/tiles/list/tile-list-compact.ts +4 -0
- package/src/tiles/list/tile-list.ts +6 -1
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# This workflow will generate the static page under `main` subdirectory inside the `gh-pages` branch
|
|
2
|
+
|
|
3
|
+
# This workflow will run every time new changes were pushed to the `main` branch
|
|
4
|
+
|
|
5
|
+
name: App build CI/CD to main branch
|
|
6
|
+
|
|
7
|
+
on:
|
|
8
|
+
push:
|
|
9
|
+
branches: [ main ]
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
build:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v3
|
|
17
|
+
with:
|
|
18
|
+
persist-credentials: false
|
|
19
|
+
|
|
20
|
+
- uses: actions/setup-node@v3
|
|
21
|
+
with:
|
|
22
|
+
node-version: 16.x
|
|
23
|
+
|
|
24
|
+
- name: Install dependencies
|
|
25
|
+
run: yarn install
|
|
26
|
+
|
|
27
|
+
- name: Create build files for gh-pages deploy
|
|
28
|
+
run: yarn prepare:ghpages
|
|
29
|
+
|
|
30
|
+
# Reference: https://github.com/JamesIves/github-pages-deploy-action
|
|
31
|
+
- name: Deploy 🚀
|
|
32
|
+
uses: JamesIves/github-pages-deploy-action@v4.3.3
|
|
33
|
+
with:
|
|
34
|
+
branch: gh-pages
|
|
35
|
+
folder: ghpages
|
|
36
|
+
clean-exclude: pr/
|
|
37
|
+
force: false
|
|
38
|
+
target-folder: main
|
|
39
|
+
token: ${{ secrets.GH_TOKEN }}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# This workflow will be triggered if there's a new release tag created/pushed in Github repo
|
|
2
|
+
|
|
3
|
+
# This workflow will do the following:
|
|
4
|
+
# - run tests using node
|
|
5
|
+
# - publish a package to GitHub Packages when a release is created
|
|
6
|
+
|
|
7
|
+
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages
|
|
8
|
+
|
|
9
|
+
name: Node.js Package
|
|
10
|
+
|
|
11
|
+
on:
|
|
12
|
+
release:
|
|
13
|
+
types: [created]
|
|
14
|
+
|
|
15
|
+
jobs:
|
|
16
|
+
build:
|
|
17
|
+
runs-on: ubuntu-latest
|
|
18
|
+
steps:
|
|
19
|
+
- uses: actions/checkout@v3
|
|
20
|
+
- uses: actions/setup-node@v3
|
|
21
|
+
with:
|
|
22
|
+
node-version: 16
|
|
23
|
+
- run: npm ci
|
|
24
|
+
- run: npm prepare
|
|
25
|
+
- run: npm test
|
|
26
|
+
|
|
27
|
+
publish-npm:
|
|
28
|
+
needs: build
|
|
29
|
+
runs-on: ubuntu-latest
|
|
30
|
+
steps:
|
|
31
|
+
- uses: actions/checkout@v3
|
|
32
|
+
- uses: actions/setup-node@v3
|
|
33
|
+
with:
|
|
34
|
+
node-version: 16
|
|
35
|
+
registry-url: https://registry.npmjs.org/
|
|
36
|
+
- run: npm ci
|
|
37
|
+
- run: npm publish --tag next
|
|
38
|
+
env:
|
|
39
|
+
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# This workflow will generate the static page under `pr` subdirectory inside the `gh-pages` branch
|
|
2
|
+
|
|
3
|
+
# This workflow will run every time there's a PR opened, reopened, synchronize, or closed
|
|
4
|
+
|
|
5
|
+
name: Deploy PR previews
|
|
6
|
+
|
|
7
|
+
on:
|
|
8
|
+
pull_request:
|
|
9
|
+
types:
|
|
10
|
+
- opened
|
|
11
|
+
- reopened
|
|
12
|
+
- synchronize
|
|
13
|
+
- closed
|
|
14
|
+
|
|
15
|
+
concurrency: preview-${{ github.ref }}
|
|
16
|
+
|
|
17
|
+
jobs:
|
|
18
|
+
deploy-preview:
|
|
19
|
+
runs-on: ubuntu-20.04
|
|
20
|
+
steps:
|
|
21
|
+
- name: Checkout
|
|
22
|
+
uses: actions/checkout@v3
|
|
23
|
+
|
|
24
|
+
- uses: actions/setup-node@v3
|
|
25
|
+
with:
|
|
26
|
+
node-version: 16.x
|
|
27
|
+
|
|
28
|
+
- name: Install and Build
|
|
29
|
+
run: |
|
|
30
|
+
yarn install
|
|
31
|
+
yarn prepare:ghpages
|
|
32
|
+
|
|
33
|
+
# Reference: https://github.com/rossjrw/pr-preview-action
|
|
34
|
+
- name: Deploy preview
|
|
35
|
+
uses: rossjrw/pr-preview-action@v1
|
|
36
|
+
with:
|
|
37
|
+
source-dir: ./ghpages/
|
|
38
|
+
umbrella-dir: pr
|
package/README.md
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
This is the main collection browser for the Internet Archive website.
|
|
7
7
|
|
|
8
|
+
[Review app URL](https://internetarchive.github.io/iaux-collection-browser/main)
|
|
8
9
|
## Usage
|
|
9
10
|
|
|
10
11
|
```ts
|
|
@@ -66,13 +67,18 @@ For most of the tools, the configuration is in the `package.json` to reduce the
|
|
|
66
67
|
|
|
67
68
|
If you customize the configuration a lot, you can consider moving them to individual files.
|
|
68
69
|
|
|
69
|
-
##
|
|
70
|
+
## Manual Deploy using `gh-pages`
|
|
70
71
|
|
|
72
|
+
Live demo app from current main branch: [https://internetarchive.github.io/iaux-collection-browser](https://internetarchive.github.io/iaux-collection-browser)
|
|
71
73
|
|
|
72
74
|
```
|
|
73
|
-
yarn run deploy
|
|
75
|
+
yarn run deploy
|
|
74
76
|
```
|
|
75
77
|
|
|
76
|
-
|
|
78
|
+
## Automatic Deploy of Demo App
|
|
77
79
|
|
|
80
|
+
When you create a Pull Request, if your code passes codecov unit tests, it will be always served live at base url / pull request number. For this demo app, you must create a Pull Request, nothing will be created from a simple branch.
|
|
78
81
|
|
|
82
|
+
This URL will be removed when the Pull Request is merged/closed.
|
|
83
|
+
|
|
84
|
+
Example: `https://internetarchive.github.io/iaux-collection-browser/pr/<pr-number>`
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
/**
|
|
3
|
+
* Base item-image styles
|
|
4
|
+
*/
|
|
5
|
+
export const baseItemImageStyles = css `
|
|
6
|
+
.drop-shadow {
|
|
7
|
+
filter: drop-shadow(1px 1px 2px rgba(0, 0, 0, 0.8));
|
|
8
|
+
overflow: hidden;
|
|
9
|
+
height: 100%;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.list-box {
|
|
13
|
+
width: 100%;
|
|
14
|
+
height: 100%;
|
|
15
|
+
overflow: hidden;
|
|
16
|
+
box-sizing: border-box;
|
|
17
|
+
display: flex;
|
|
18
|
+
position: relative;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.contain {
|
|
22
|
+
object-fit: contain;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.cover {
|
|
26
|
+
object-fit: cover;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.blur {
|
|
30
|
+
filter: blur(15px);
|
|
31
|
+
width: 100%;
|
|
32
|
+
transform: scale(1.1);
|
|
33
|
+
}
|
|
34
|
+
`;
|
|
35
|
+
/**
|
|
36
|
+
* Waveform styles
|
|
37
|
+
*/
|
|
38
|
+
export const waveformGradientStyles = css `
|
|
39
|
+
.waveform {
|
|
40
|
+
mix-blend-mode: screen;
|
|
41
|
+
position: relative;
|
|
42
|
+
height: 62.5%;
|
|
43
|
+
top: 50%;
|
|
44
|
+
transform: translateY(-50%);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.waveform-grad0 {
|
|
48
|
+
background: linear-gradient(
|
|
49
|
+
hsl(340, 80%, 55%),
|
|
50
|
+
hsl(0, 80%, 33%) 35%,
|
|
51
|
+
hsl(0, 80%, 22%) 70%,
|
|
52
|
+
hsl(0, 0%, 0%)
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.waveform-grad1 {
|
|
57
|
+
background: linear-gradient(
|
|
58
|
+
hsl(300, 80%, 55%),
|
|
59
|
+
hsl(330, 80%, 33%) 35%,
|
|
60
|
+
hsl(330, 80%, 22%) 70%,
|
|
61
|
+
hsl(0, 0%, 0%)
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.waveform-grad2 {
|
|
66
|
+
background: linear-gradient(
|
|
67
|
+
hsl(200, 80%, 55%),
|
|
68
|
+
hsl(230, 80%, 33%) 35%,
|
|
69
|
+
hsl(230, 80%, 22%) 70%,
|
|
70
|
+
hsl(0, 0%, 0%)
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.waveform-grad3 {
|
|
75
|
+
background: linear-gradient(
|
|
76
|
+
hsl(160, 80%, 55%),
|
|
77
|
+
hsl(190, 80%, 33%) 35%,
|
|
78
|
+
hsl(190, 80%, 22%) 70%,
|
|
79
|
+
hsl(0, 0%, 0%)
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.waveform-grad4 {
|
|
84
|
+
background: linear-gradient(
|
|
85
|
+
hsl(250, 80%, 55%),
|
|
86
|
+
hsl(280, 80%, 33%) 35%,
|
|
87
|
+
hsl(280, 80%, 22%) 70%,
|
|
88
|
+
hsl(0, 0%, 0%)
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.waveform-grad5 {
|
|
93
|
+
background: linear-gradient(
|
|
94
|
+
hsl(280, 80%, 55%),
|
|
95
|
+
hsl(310, 80%, 33%) 35%,
|
|
96
|
+
hsl(310, 80%, 22%) 70%,
|
|
97
|
+
hsl(0, 0%, 0%)
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
`;
|
|
101
|
+
//# sourceMappingURL=item-image-styles.js.map
|
|
@@ -0,0 +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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6BrC,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 width: 100%;\n height: 100%;\n overflow: hidden;\n box-sizing: border-box;\n display: flex;\n position: relative;\n }\n\n .contain {\n object-fit: contain;\n }\n\n .cover {\n object-fit: cover;\n }\n\n .blur {\n filter: blur(15px);\n width: 100%;\n transform: scale(1.1);\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"]}
|
|
@@ -5,23 +5,27 @@ export declare class ItemImage extends LitElement {
|
|
|
5
5
|
baseImageUrl?: string;
|
|
6
6
|
isListTile: boolean;
|
|
7
7
|
isCompactTile: boolean;
|
|
8
|
+
loggedIn: boolean;
|
|
8
9
|
private isWaveform;
|
|
9
|
-
private
|
|
10
|
+
private baseImage;
|
|
10
11
|
render(): import("lit-html").TemplateResult<1>;
|
|
12
|
+
/**
|
|
13
|
+
* Helpers
|
|
14
|
+
*/
|
|
11
15
|
private get imageSrc();
|
|
12
|
-
private get itemImageTemplate();
|
|
13
|
-
private get tileImageTemplate();
|
|
14
|
-
private get listImageTemplate();
|
|
15
|
-
private get waveformTemplate();
|
|
16
|
-
private get restrictedIconTemplate();
|
|
17
|
-
private get tileActionTemplate();
|
|
18
|
-
private onLoadItemImageCheck;
|
|
19
|
-
private get imageClass();
|
|
20
|
-
private get listImageClass();
|
|
21
|
-
private get imageBoxClass();
|
|
22
|
-
private get boxWaveformClass();
|
|
23
|
-
private get itemImageWaveformClass();
|
|
24
16
|
private get hashBasedGradient();
|
|
25
17
|
private hashStrToInt;
|
|
18
|
+
/**
|
|
19
|
+
* Classes
|
|
20
|
+
*/
|
|
21
|
+
private get itemBaseClass();
|
|
22
|
+
private get itemImageClass();
|
|
23
|
+
/**
|
|
24
|
+
* Event listener sets isWaveform true if image is waveform
|
|
25
|
+
*/
|
|
26
|
+
private onLoad;
|
|
27
|
+
/**
|
|
28
|
+
* CSS
|
|
29
|
+
*/
|
|
26
30
|
static get styles(): CSSResultGroup;
|
|
27
31
|
}
|
|
@@ -1,276 +1,92 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import { css, html,
|
|
2
|
+
import { css, html, LitElement } from 'lit';
|
|
3
3
|
import { customElement, property, query, state } from 'lit/decorators.js';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
5
|
+
import { baseItemImageStyles, waveformGradientStyles, } from '../styles/item-image-styles';
|
|
6
6
|
let ItemImage = class ItemImage extends LitElement {
|
|
7
7
|
constructor() {
|
|
8
8
|
super(...arguments);
|
|
9
9
|
this.isListTile = false;
|
|
10
10
|
this.isCompactTile = false;
|
|
11
|
+
this.loggedIn = false;
|
|
11
12
|
this.isWaveform = false;
|
|
12
13
|
}
|
|
13
14
|
render() {
|
|
14
|
-
var _a;
|
|
15
15
|
return html `
|
|
16
|
-
<div class=${
|
|
17
|
-
${((_a = this.model) === null || _a === void 0 ? void 0 : _a.mediatype) === 'audio'
|
|
18
|
-
? this.waveformTemplate
|
|
19
|
-
: this.itemImageTemplate}
|
|
20
|
-
</div>
|
|
21
|
-
`;
|
|
22
|
-
}
|
|
23
|
-
get imageSrc() {
|
|
24
|
-
var _a;
|
|
25
|
-
return `${this.baseImageUrl}/services/img/${(_a = this.model) === null || _a === void 0 ? void 0 : _a.identifier}`;
|
|
26
|
-
}
|
|
27
|
-
// Templates
|
|
28
|
-
get itemImageTemplate() {
|
|
29
|
-
return html `
|
|
30
|
-
${this.isListTile ? this.listImageTemplate : this.tileImageTemplate}
|
|
31
|
-
`;
|
|
32
|
-
}
|
|
33
|
-
get tileImageTemplate() {
|
|
34
|
-
return html `
|
|
35
|
-
<div
|
|
36
|
-
class=${this.imageClass}
|
|
37
|
-
style="background-image:url(${this.imageSrc})"
|
|
38
|
-
></div>
|
|
39
|
-
${this.tileActionTemplate}
|
|
40
|
-
`;
|
|
41
|
-
}
|
|
42
|
-
get listImageTemplate() {
|
|
43
|
-
if (!this.model) {
|
|
44
|
-
return nothing;
|
|
45
|
-
}
|
|
46
|
-
return html `
|
|
47
|
-
<img src="${this.imageSrc}" alt="" class="${this.listImageClass}" />
|
|
48
|
-
${this.restrictedIconTemplate}
|
|
49
|
-
`;
|
|
50
|
-
}
|
|
51
|
-
get waveformTemplate() {
|
|
52
|
-
var _a;
|
|
53
|
-
return html `
|
|
54
|
-
<div class=${this.boxWaveformClass}>
|
|
16
|
+
<div class=${classMap(this.itemBaseClass)}>
|
|
55
17
|
<img
|
|
56
|
-
class=${this.
|
|
18
|
+
class=${classMap(this.itemImageClass)}
|
|
57
19
|
src="${this.imageSrc}"
|
|
58
|
-
alt="
|
|
59
|
-
@load=${this.
|
|
20
|
+
alt=""
|
|
21
|
+
@load=${this.onLoad}
|
|
60
22
|
/>
|
|
61
23
|
</div>
|
|
62
24
|
`;
|
|
63
25
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
return html ` ${restrictedIcon} `;
|
|
70
|
-
}
|
|
71
|
-
get tileActionTemplate() {
|
|
72
|
-
var _a;
|
|
73
|
-
if (!((_a = this.model) === null || _a === void 0 ? void 0 : _a.contentWarning)) {
|
|
74
|
-
return nothing;
|
|
75
|
-
}
|
|
76
|
-
return html `
|
|
77
|
-
<div class="tile-action no-preview">Content may be inappropriate</div>
|
|
78
|
-
`;
|
|
79
|
-
}
|
|
80
|
-
onLoadItemImageCheck() {
|
|
81
|
-
const aspectRatio = this.itemImageWaveform.naturalWidth /
|
|
82
|
-
this.itemImageWaveform.naturalHeight;
|
|
83
|
-
if (aspectRatio === 4) {
|
|
84
|
-
this.isWaveform = true;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
// Classes
|
|
88
|
-
get imageClass() {
|
|
89
|
-
var _a;
|
|
90
|
-
return `item-image ${((_a = this.model) === null || _a === void 0 ? void 0 : _a.contentWarning) ? 'deemphasize' : 'default'}`;
|
|
91
|
-
}
|
|
92
|
-
get listImageClass() {
|
|
26
|
+
/**
|
|
27
|
+
* Helpers
|
|
28
|
+
*/
|
|
29
|
+
get imageSrc() {
|
|
93
30
|
var _a;
|
|
94
|
-
return
|
|
95
|
-
}
|
|
96
|
-
get imageBoxClass() {
|
|
97
|
-
var _a, _b;
|
|
98
|
-
if (this.isListTile) {
|
|
99
|
-
return `list-image-box${((_a = this.model) === null || _a === void 0 ? void 0 : _a.contentWarning) ? ' deemphasize' : ''}`;
|
|
100
|
-
}
|
|
101
|
-
if ((_b = this.model) === null || _b === void 0 ? void 0 : _b.contentWarning) {
|
|
102
|
-
return 'item-image-box';
|
|
103
|
-
}
|
|
104
|
-
return undefined;
|
|
105
|
-
}
|
|
106
|
-
get boxWaveformClass() {
|
|
107
|
-
return `item-audio${this.isWaveform ? ` ${this.hashBasedGradient}` : ''}`;
|
|
108
|
-
}
|
|
109
|
-
get itemImageWaveformClass() {
|
|
110
|
-
return `item-image${this.isWaveform ? ' waveform' : ''}`;
|
|
31
|
+
return `${this.baseImageUrl}/services/img/${(_a = this.model) === null || _a === void 0 ? void 0 : _a.identifier}`;
|
|
111
32
|
}
|
|
112
33
|
get hashBasedGradient() {
|
|
113
34
|
var _a;
|
|
114
35
|
if (!((_a = this.model) === null || _a === void 0 ? void 0 : _a.identifier)) {
|
|
115
|
-
return '
|
|
36
|
+
return 'waveform-grad0';
|
|
116
37
|
}
|
|
117
38
|
const gradient = this.hashStrToInt(this.model.identifier) % 6; // returns 0-5
|
|
118
|
-
return `grad${gradient}`;
|
|
39
|
+
return `waveform-grad${gradient}`;
|
|
119
40
|
}
|
|
120
41
|
hashStrToInt(str) {
|
|
121
42
|
return str
|
|
122
43
|
.split('')
|
|
123
44
|
.reduce((acc, char) => acc + char.charCodeAt(0), 0);
|
|
124
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* Classes
|
|
48
|
+
*/
|
|
49
|
+
get itemBaseClass() {
|
|
50
|
+
return {
|
|
51
|
+
'drop-shadow': true,
|
|
52
|
+
'list-box': this.isListTile,
|
|
53
|
+
[this.hashBasedGradient]: this.isWaveform,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
get itemImageClass() {
|
|
57
|
+
var _a;
|
|
58
|
+
return {
|
|
59
|
+
contain: !this.isCompactTile && !this.isWaveform,
|
|
60
|
+
cover: this.isCompactTile,
|
|
61
|
+
blur: ((_a = this.model) === null || _a === void 0 ? void 0 : _a.contentWarning) || false,
|
|
62
|
+
waveform: this.isWaveform,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Event listener sets isWaveform true if image is waveform
|
|
67
|
+
*/
|
|
68
|
+
onLoad() {
|
|
69
|
+
var _a, _b;
|
|
70
|
+
if ((((_a = this.model) === null || _a === void 0 ? void 0 : _a.mediatype) === 'audio' ||
|
|
71
|
+
((_b = this.model) === null || _b === void 0 ? void 0 : _b.mediatype) === 'etree') &&
|
|
72
|
+
this.baseImage.naturalWidth / this.baseImage.naturalHeight === 4) {
|
|
73
|
+
this.isWaveform = true;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* CSS
|
|
78
|
+
*/
|
|
125
79
|
static get styles() {
|
|
126
|
-
return
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
.item-image {
|
|
137
|
-
width: 16rem;
|
|
138
|
-
height: 16rem;
|
|
139
|
-
object-fit: contain;
|
|
140
|
-
background-repeat: no-repeat;
|
|
141
|
-
background-position: center center;
|
|
142
|
-
position: relative;
|
|
143
|
-
-webkit-appearance: none;
|
|
144
|
-
overflow: visible;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
.list-image-box.deemphasize {
|
|
148
|
-
border: 1px solid #767676;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
.list-image-box {
|
|
152
|
-
width: 100%;
|
|
153
|
-
height: 100%;
|
|
154
|
-
overflow: hidden;
|
|
155
|
-
box-sizing: border-box;
|
|
156
|
-
display: flex;
|
|
157
|
-
position: relative;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
.list-image {
|
|
161
|
-
width: 100%;
|
|
162
|
-
height: 100%;
|
|
163
|
-
overflow: hidden;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
img.list-image {
|
|
167
|
-
overflow: hidden;
|
|
168
|
-
object-fit: contain;
|
|
169
|
-
border-radius: var(--border-radius, 0);
|
|
170
|
-
-webkit-border-radius: var(--border-radius, 0);
|
|
171
|
-
-moz-border-radius: var(--border-radius, 0);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
img.list-image.compact {
|
|
175
|
-
object-fit: cover;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
.waveform {
|
|
179
|
-
mix-blend-mode: screen;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
.default {
|
|
183
|
-
background-size: contain;
|
|
184
|
-
filter: drop-shadow(1px 1px 2px rgba(0, 0, 0, 0.8));
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
.deemphasize .list-image,
|
|
188
|
-
.deemphasize.item-image {
|
|
189
|
-
background-size: contain;
|
|
190
|
-
filter: blur(15px);
|
|
191
|
-
z-index: 1;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
.deemphasize svg {
|
|
195
|
-
padding: 25%;
|
|
196
|
-
z-index: 2;
|
|
197
|
-
position: absolute;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
.tile-action {
|
|
201
|
-
border: 1px solid currentColor;
|
|
202
|
-
border-radius: 1px;
|
|
203
|
-
padding: 5px;
|
|
204
|
-
font-weight: 500;
|
|
205
|
-
width: auto;
|
|
206
|
-
position: absolute;
|
|
207
|
-
z-index: 2;
|
|
208
|
-
display: flex;
|
|
209
|
-
top: 5.5rem;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
.no-preview {
|
|
213
|
-
background-color: #fffecb;
|
|
214
|
-
color: #2c2c2c;
|
|
215
|
-
font-size: 1.4rem;
|
|
216
|
-
line-height: 2rem;
|
|
217
|
-
text-align: center;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
.grad0 {
|
|
221
|
-
background: linear-gradient(
|
|
222
|
-
hsl(340, 80%, 55%),
|
|
223
|
-
hsl(0, 80%, 33%) 35%,
|
|
224
|
-
hsl(0, 80%, 22%) 70%,
|
|
225
|
-
hsl(0, 0%, 0%)
|
|
226
|
-
);
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
.grad1 {
|
|
230
|
-
background: linear-gradient(
|
|
231
|
-
hsl(300, 80%, 55%),
|
|
232
|
-
hsl(330, 80%, 33%) 35%,
|
|
233
|
-
hsl(330, 80%, 22%) 70%,
|
|
234
|
-
hsl(0, 0%, 0%)
|
|
235
|
-
);
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
.grad2 {
|
|
239
|
-
background: linear-gradient(
|
|
240
|
-
hsl(200, 80%, 55%),
|
|
241
|
-
hsl(230, 80%, 33%) 35%,
|
|
242
|
-
hsl(230, 80%, 22%) 70%,
|
|
243
|
-
hsl(0, 0%, 0%)
|
|
244
|
-
);
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
.grad3 {
|
|
248
|
-
background: linear-gradient(
|
|
249
|
-
hsl(160, 80%, 55%),
|
|
250
|
-
hsl(190, 80%, 33%) 35%,
|
|
251
|
-
hsl(190, 80%, 22%) 70%,
|
|
252
|
-
hsl(0, 0%, 0%)
|
|
253
|
-
);
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
.grad4 {
|
|
257
|
-
background: linear-gradient(
|
|
258
|
-
hsl(250, 80%, 55%),
|
|
259
|
-
hsl(280, 80%, 33%) 35%,
|
|
260
|
-
hsl(280, 80%, 22%) 70%,
|
|
261
|
-
hsl(0, 0%, 0%)
|
|
262
|
-
);
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
.grad5 {
|
|
266
|
-
background: linear-gradient(
|
|
267
|
-
hsl(280, 80%, 55%),
|
|
268
|
-
hsl(310, 80%, 33%) 35%,
|
|
269
|
-
hsl(310, 80%, 22%) 70%,
|
|
270
|
-
hsl(0, 0%, 0%)
|
|
271
|
-
);
|
|
272
|
-
}
|
|
273
|
-
`;
|
|
80
|
+
return [
|
|
81
|
+
baseItemImageStyles,
|
|
82
|
+
waveformGradientStyles,
|
|
83
|
+
css `
|
|
84
|
+
img {
|
|
85
|
+
height: var(--imgHeight, 16rem);
|
|
86
|
+
width: var(--imgWidth, 16rem);
|
|
87
|
+
}
|
|
88
|
+
`,
|
|
89
|
+
];
|
|
274
90
|
}
|
|
275
91
|
};
|
|
276
92
|
__decorate([
|
|
@@ -285,12 +101,15 @@ __decorate([
|
|
|
285
101
|
__decorate([
|
|
286
102
|
property({ type: Boolean })
|
|
287
103
|
], ItemImage.prototype, "isCompactTile", void 0);
|
|
104
|
+
__decorate([
|
|
105
|
+
property({ type: Boolean })
|
|
106
|
+
], ItemImage.prototype, "loggedIn", void 0);
|
|
288
107
|
__decorate([
|
|
289
108
|
state()
|
|
290
109
|
], ItemImage.prototype, "isWaveform", void 0);
|
|
291
110
|
__decorate([
|
|
292
|
-
query('
|
|
293
|
-
], ItemImage.prototype, "
|
|
111
|
+
query('img')
|
|
112
|
+
], ItemImage.prototype, "baseImage", void 0);
|
|
294
113
|
ItemImage = __decorate([
|
|
295
114
|
customElement('item-image')
|
|
296
115
|
], ItemImage);
|