@internetarchive/collection-browser 0.1.7 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/demo/app-root.ts +20 -0
  2. package/dist/{src/waveform-view.d.ts → .nojekyll} +0 -0
  3. package/dist/app-root.js +816 -0
  4. package/dist/demo/app-root.d.ts +2 -0
  5. package/dist/demo/app-root.js +22 -0
  6. package/dist/demo/app-root.js.map +1 -1
  7. package/dist/index.html +23 -0
  8. package/dist/src/assets/img/icons/restricted.d.ts +1 -0
  9. package/dist/src/assets/img/icons/restricted.js +29 -0
  10. package/dist/src/assets/img/icons/restricted.js.map +1 -0
  11. package/dist/src/collection-browser.d.ts +5 -0
  12. package/dist/src/collection-browser.js +51 -20
  13. package/dist/src/collection-browser.js.map +1 -1
  14. package/dist/src/models.d.ts +2 -0
  15. package/dist/src/models.js.map +1 -1
  16. package/dist/src/styles/index.d.ts +8 -0
  17. package/dist/src/styles/index.js +101 -0
  18. package/dist/src/styles/index.js.map +1 -0
  19. package/dist/src/tiles/grid/account-tile.js +14 -1
  20. package/dist/src/tiles/grid/account-tile.js.map +1 -1
  21. package/dist/src/tiles/image/item-image.d.ts +18 -0
  22. package/dist/src/tiles/image/item-image.js +210 -0
  23. package/dist/src/tiles/image/item-image.js.map +1 -0
  24. package/dist/src/tiles/image/waveform-image.d.ts +16 -0
  25. package/dist/src/tiles/image/waveform-image.js +168 -0
  26. package/dist/src/tiles/image/waveform-image.js.map +1 -0
  27. package/dist/src/tiles/item-image.d.ts +7 -5
  28. package/dist/src/tiles/item-image.js +86 -23
  29. package/dist/src/tiles/item-image.js.map +1 -1
  30. package/dist/src/tiles/item-tile-image.d.ts +15 -0
  31. package/dist/src/tiles/item-tile-image.js +68 -0
  32. package/dist/src/tiles/item-tile-image.js.map +1 -0
  33. package/dist/src/tiles/list/tile-list-compact.js +54 -59
  34. package/dist/src/tiles/list/tile-list-compact.js.map +1 -1
  35. package/dist/src/tiles/list/tile-list.js +25 -22
  36. package/dist/src/tiles/list/tile-list.js.map +1 -1
  37. package/package.json +1 -1
  38. package/src/assets/img/icons/restricted.ts +29 -0
  39. package/src/collection-browser.ts +29 -0
  40. package/src/models.ts +2 -0
  41. package/src/tiles/grid/account-tile.ts +14 -1
  42. package/src/tiles/item-image.ts +90 -31
  43. package/src/tiles/list/tile-list-compact.ts +45 -50
  44. package/src/tiles/list/tile-list.ts +22 -21
  45. package/dist/src/assets/img/icons/mediatype/livemusic.d.ts +0 -1
  46. package/dist/src/assets/img/icons/mediatype/livemusic.js +0 -7
  47. package/dist/src/assets/img/icons/mediatype/livemusic.js.map +0 -1
  48. package/dist/src/assets/img/icons/mediatype/photos.d.ts +0 -1
  49. package/dist/src/assets/img/icons/mediatype/photos.js +0 -7
  50. package/dist/src/assets/img/icons/mediatype/photos.js.map +0 -1
  51. package/dist/src/helpers.d.ts +0 -1
  52. package/dist/src/helpers.js +0 -20
  53. package/dist/src/helpers.js.map +0 -1
  54. package/dist/src/mediatype/mediatype-color.d.ts +0 -3
  55. package/dist/src/mediatype/mediatype-color.js +0 -15
  56. package/dist/src/mediatype/mediatype-color.js.map +0 -1
  57. package/dist/src/mediatype/mediatype-display.d.ts +0 -3
  58. package/dist/src/mediatype/mediatype-display.js +0 -86
  59. package/dist/src/mediatype/mediatype-display.js.map +0 -1
  60. package/dist/src/mediatype/mediatype-icon.d.ts +0 -10
  61. package/dist/src/mediatype/mediatype-icon.js +0 -105
  62. package/dist/src/mediatype/mediatype-icon.js.map +0 -1
  63. package/dist/src/mediatype/mediatype-text.d.ts +0 -3
  64. package/dist/src/mediatype/mediatype-text.js +0 -17
  65. package/dist/src/mediatype/mediatype-text.js.map +0 -1
  66. package/dist/src/mediatype/mediatypeConfig.d.ts +0 -3
  67. package/dist/src/mediatype/mediatypeConfig.js +0 -86
  68. package/dist/src/mediatype/mediatypeConfig.js.map +0 -1
  69. package/dist/src/mediatype-icon.d.ts +0 -9
  70. package/dist/src/mediatype-icon.js +0 -78
  71. package/dist/src/mediatype-icon.js.map +0 -1
  72. package/dist/src/sort-filter-bar/img/grid.d.ts +0 -1
  73. package/dist/src/sort-filter-bar/img/grid.js +0 -5
  74. package/dist/src/sort-filter-bar/img/grid.js.map +0 -1
  75. package/dist/src/tiles/list/tile-list-detail.d.ts +0 -7
  76. package/dist/src/tiles/list/tile-list-detail.js +0 -28
  77. package/dist/src/tiles/list/tile-list-detail.js.map +0 -1
  78. package/dist/src/tiles/loading-tile.d.ts +0 -5
  79. package/dist/src/tiles/loading-tile.js +0 -32
  80. package/dist/src/tiles/loading-tile.js.map +0 -1
  81. package/dist/src/utils/format-string.d.ts +0 -2
  82. package/dist/src/utils/format-string.js +0 -7
  83. package/dist/src/utils/format-string.js.map +0 -1
  84. package/dist/src/waveform-thumbnail.d.ts +0 -7
  85. package/dist/src/waveform-thumbnail.js +0 -106
  86. package/dist/src/waveform-thumbnail.js.map +0 -1
  87. package/dist/src/waveform-view.js +0 -2
  88. package/dist/src/waveform-view.js.map +0 -1
  89. package/dist/src/your-webcomponent.d.ts +0 -8
  90. package/dist/src/your-webcomponent.js +0 -38
  91. package/dist/src/your-webcomponent.js.map +0 -1
  92. package/dist/test/mediatype-icon.test.d.ts +0 -0
  93. package/dist/test/mediatype-icon.test.js +0 -3
  94. package/dist/test/mediatype-icon.test.js.map +0 -1
  95. package/dist/test/mediatypeConfig.test.d.ts +0 -1
  96. package/dist/test/mediatypeConfig.test.js +0 -17
  97. package/dist/test/mediatypeConfig.test.js.map +0 -1
  98. package/dist/test/utils/format-string.test.d.ts +0 -1
  99. package/dist/test/utils/format-string.test.js +0 -17
  100. package/dist/test/utils/format-string.test.js.map +0 -1
  101. package/dist/test/your-webcomponent.test.d.ts +0 -1
  102. package/dist/test/your-webcomponent.test.js +0 -23
  103. package/dist/test/your-webcomponent.test.js.map +0 -1
@@ -0,0 +1,210 @@
1
+ import { __decorate } from "tslib";
2
+ import { css, html, LitElement, nothing } from 'lit';
3
+ import { customElement, property } from 'lit/decorators.js';
4
+ import { ifDefined } from 'lit/directives/if-defined.js';
5
+ import { restrictedIcon } from '../../assets/img/icons/restricted';
6
+ let ItemImage = class ItemImage extends LitElement {
7
+ constructor() {
8
+ super(...arguments);
9
+ this.isCompactTile = false;
10
+ this.isListTile = false;
11
+ }
12
+ render() {
13
+ return html `
14
+ <div class=${ifDefined(this.imageBoxClass)}>
15
+ ${this.itemTileImageTemplate} ${this.tileActionTemplate}
16
+ </div>
17
+ `;
18
+ }
19
+ get tileActionTemplate() {
20
+ var _a;
21
+ if (!((_a = this.model) === null || _a === void 0 ? void 0 : _a.contentWarning)) {
22
+ return nothing;
23
+ }
24
+ return html `
25
+ <div class="tile-action no-preview">Content may be inappropriate</div>
26
+ `;
27
+ }
28
+ get itemTileImageTemplate() {
29
+ return html `
30
+ ${this.isListTile ? this.listImageTemplate : this.tileImageTemplate}
31
+ `;
32
+ }
33
+ get tileImageTemplate() {
34
+ var _a;
35
+ return html `
36
+ <img
37
+ class=${this.imageClass}
38
+ src="${ifDefined(this.imageSrc)}"
39
+ alt="${ifDefined((_a = this.model) === null || _a === void 0 ? void 0 : _a.identifier)}"
40
+ />
41
+ ${this.tileActionTemplate}
42
+ `;
43
+ }
44
+ get listImageTemplate() {
45
+ if (!this.model) {
46
+ return nothing;
47
+ }
48
+ return html `
49
+ <img
50
+ src="${ifDefined(this.imageSrc)}"
51
+ alt=""
52
+ class="${this.listImageClass}"
53
+ />
54
+ ${this.restrictedIconTemplate}
55
+ `;
56
+ }
57
+ get restrictedIconTemplate() {
58
+ var _a;
59
+ if (!((_a = this.model) === null || _a === void 0 ? void 0 : _a.contentWarning)) {
60
+ return nothing;
61
+ }
62
+ return html ` ${restrictedIcon} `;
63
+ }
64
+ // Classes
65
+ get imageClass() {
66
+ var _a;
67
+ return `item-image ${((_a = this.model) === null || _a === void 0 ? void 0 : _a.contentWarning) ? 'deemphasize' : 'default'}`;
68
+ }
69
+ get listImageClass() {
70
+ var _a;
71
+ return `list-image ${(_a = this.model) === null || _a === void 0 ? void 0 : _a.mediatype}${this.isCompactTile ? ' compact' : ''}`;
72
+ }
73
+ get imageBoxClass() {
74
+ var _a, _b;
75
+ if (this.isListTile) {
76
+ return `list-image-box${((_a = this.model) === null || _a === void 0 ? void 0 : _a.contentWarning) ? ' deemphasize' : ''}`;
77
+ }
78
+ if ((_b = this.model) === null || _b === void 0 ? void 0 : _b.contentWarning) {
79
+ return 'item-image-box';
80
+ }
81
+ return undefined;
82
+ }
83
+ static get styles() {
84
+ return css `
85
+ .item-image-box {
86
+ width: 100%;
87
+ height: 100%;
88
+ overflow: hidden;
89
+ position: relative;
90
+ box-shadow: 1px 1px 2px 0px;
91
+ display: flex;
92
+ }
93
+
94
+ .item-image {
95
+ width: 16rem;
96
+ height: 16rem;
97
+ object-fit: contain;
98
+ background-repeat: no-repeat;
99
+ background-position: center center;
100
+ position: relative;
101
+ -webkit-appearance: none;
102
+ overflow: visible;
103
+ }
104
+
105
+ .list-image-box.deemphasize {
106
+ border: 1px solid #767676;
107
+ }
108
+
109
+ .list-image-box {
110
+ width: 100%;
111
+ height: 100%;
112
+ overflow: hidden;
113
+ box-sizing: border-box;
114
+ display: flex;
115
+ position: relative;
116
+ }
117
+
118
+ .list-image {
119
+ width: 100%;
120
+ height: 100%;
121
+ overflow: hidden;
122
+ }
123
+
124
+ img.list-image {
125
+ overflow: hidden;
126
+ object-fit: contain;
127
+ border-radius: var(--border-radius, 0);
128
+ -webkit-border-radius: var(--border-radius, 0);
129
+ -moz-border-radius: var(--border-radius, 0);
130
+ }
131
+
132
+ img.list-image.compact {
133
+ object-fit: cover;
134
+ }
135
+
136
+ .deemphasize .list-image,
137
+ .deemphasize.item-image {
138
+ background-size: contain;
139
+ filter: blur(15px);
140
+ z-index: 1;
141
+ }
142
+
143
+ .deemphasize svg {
144
+ padding: 25%;
145
+ z-index: 2;
146
+ position: absolute;
147
+ }
148
+
149
+ .tile-action {
150
+ border: 1px solid currentColor;
151
+ border-radius: 1px;
152
+ padding: 5px;
153
+ font-weight: 500;
154
+ width: auto;
155
+ position: absolute;
156
+ z-index: 2;
157
+ display: flex;
158
+ top: 5.5rem;
159
+ }
160
+
161
+ .default {
162
+ background-size: contain;
163
+ filter: drop-shadow(1px 1px 2px rgba(0, 0, 0, 0.8));
164
+ }
165
+
166
+ .deemphasize {
167
+ background-size: contain;
168
+ filter: blur(15px);
169
+ z-index: 1;
170
+ }
171
+
172
+ .tile-action {
173
+ border: 1px solid currentColor;
174
+ border-radius: 1px;
175
+ padding: 5px;
176
+ font-weight: 500;
177
+ width: auto;
178
+ position: absolute;
179
+ z-index: 2;
180
+ display: flex;
181
+ top: 5.5rem;
182
+ }
183
+
184
+ .no-preview {
185
+ background-color: #fffecb;
186
+ color: #2c2c2c;
187
+ font-size: 1.4rem;
188
+ line-height: 2rem;
189
+ text-align: center;
190
+ }
191
+ `;
192
+ }
193
+ };
194
+ __decorate([
195
+ property({ type: Object })
196
+ ], ItemImage.prototype, "model", void 0);
197
+ __decorate([
198
+ property({ type: String })
199
+ ], ItemImage.prototype, "imageSrc", void 0);
200
+ __decorate([
201
+ property({ type: Boolean })
202
+ ], ItemImage.prototype, "isCompactTile", void 0);
203
+ __decorate([
204
+ property({ type: Boolean })
205
+ ], ItemImage.prototype, "isListTile", void 0);
206
+ ItemImage = __decorate([
207
+ customElement('item-image')
208
+ ], ItemImage);
209
+ export { ItemImage };
210
+ //# sourceMappingURL=item-image.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"item-image.js","sourceRoot":"","sources":["../../../../src/tiles/image/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,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAIzD,OAAO,EAAE,cAAc,EAAE,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B,aAAa,CAAC,YAAY,CAAC;GACf,SAAS,CAuMrB;SAvMY,SAAS","sourcesContent":["import { css, CSSResultGroup, html, LitElement, nothing } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\n\nimport { TileModel } from '../../models';\n\nimport { restrictedIcon } from '../../assets/img/icons/restricted';\n\n@customElement('item-image')\nexport class ItemImage extends LitElement {\n @property({ type: Object }) model?: TileModel;\n\n @property({ type: String }) imageSrc?: string;\n\n @property({ type: Boolean }) isCompactTile = false;\n\n @property({ type: Boolean }) isListTile = false;\n\n render() {\n return html`\n <div class=${ifDefined(this.imageBoxClass)}>\n ${this.itemTileImageTemplate} ${this.tileActionTemplate}\n </div>\n `;\n }\n\n private get tileActionTemplate() {\n if (!this.model?.contentWarning) {\n return nothing;\n }\n return html`\n <div class=\"tile-action no-preview\">Content may be inappropriate</div>\n `;\n }\n\n private get itemTileImageTemplate() {\n return html`\n ${this.isListTile ? this.listImageTemplate : this.tileImageTemplate}\n `;\n }\n\n private get tileImageTemplate() {\n return html`\n <img\n class=${this.imageClass}\n src=\"${ifDefined(this.imageSrc)}\"\n alt=\"${ifDefined(this.model?.identifier)}\"\n />\n ${this.tileActionTemplate}\n `;\n }\n\n private get listImageTemplate() {\n if (!this.model) {\n return nothing;\n }\n return html`\n <img\n src=\"${ifDefined(this.imageSrc)}\"\n alt=\"\"\n class=\"${this.listImageClass}\"\n />\n ${this.restrictedIconTemplate}\n `;\n }\n\n private get restrictedIconTemplate() {\n if (!this.model?.contentWarning) {\n return nothing;\n }\n return html` ${restrictedIcon} `;\n }\n\n // Classes\n private get imageClass() {\n return `item-image ${\n this.model?.contentWarning ? 'deemphasize' : 'default'\n }`;\n }\n\n private get listImageClass() {\n return `list-image ${this.model?.mediatype}${\n this.isCompactTile ? ' compact' : ''\n }`;\n }\n\n private get imageBoxClass() {\n if (this.isListTile) {\n return `list-image-box${\n this.model?.contentWarning ? ' deemphasize' : ''\n }`;\n }\n if (this.model?.contentWarning) {\n return 'item-image-box';\n }\n return undefined;\n }\n\n static get styles(): CSSResultGroup {\n return css`\n .item-image-box {\n width: 100%;\n height: 100%;\n overflow: hidden;\n position: relative;\n box-shadow: 1px 1px 2px 0px;\n display: flex;\n }\n\n .item-image {\n width: 16rem;\n height: 16rem;\n object-fit: contain;\n background-repeat: no-repeat;\n background-position: center center;\n position: relative;\n -webkit-appearance: none;\n overflow: visible;\n }\n\n .list-image-box.deemphasize {\n border: 1px solid #767676;\n }\n\n .list-image-box {\n width: 100%;\n height: 100%;\n overflow: hidden;\n box-sizing: border-box;\n display: flex;\n position: relative;\n }\n\n .list-image {\n width: 100%;\n height: 100%;\n overflow: hidden;\n }\n\n img.list-image {\n overflow: hidden;\n object-fit: contain;\n border-radius: var(--border-radius, 0);\n -webkit-border-radius: var(--border-radius, 0);\n -moz-border-radius: var(--border-radius, 0);\n }\n\n img.list-image.compact {\n object-fit: cover;\n }\n\n .deemphasize .list-image,\n .deemphasize.item-image {\n background-size: contain;\n filter: blur(15px);\n z-index: 1;\n }\n\n .deemphasize svg {\n padding: 25%;\n z-index: 2;\n position: absolute;\n }\n\n .tile-action {\n border: 1px solid currentColor;\n border-radius: 1px;\n padding: 5px;\n font-weight: 500;\n width: auto;\n position: absolute;\n z-index: 2;\n display: flex;\n top: 5.5rem;\n }\n\n .default {\n background-size: contain;\n filter: drop-shadow(1px 1px 2px rgba(0, 0, 0, 0.8));\n }\n\n .deemphasize {\n background-size: contain;\n filter: blur(15px);\n z-index: 1;\n }\n\n .tile-action {\n border: 1px solid currentColor;\n border-radius: 1px;\n padding: 5px;\n font-weight: 500;\n width: auto;\n position: absolute;\n z-index: 2;\n display: flex;\n top: 5.5rem;\n }\n\n .no-preview {\n background-color: #fffecb;\n color: #2c2c2c;\n font-size: 1.4rem;\n line-height: 2rem;\n text-align: center;\n }\n `;\n }\n}\n"]}
@@ -0,0 +1,16 @@
1
+ import { CSSResultGroup, LitElement } from 'lit';
2
+ export declare class WaveformImage extends LitElement {
3
+ imageSrc?: string;
4
+ identifier?: string;
5
+ isCompactTile: boolean;
6
+ isListTile: boolean;
7
+ private isWaveform;
8
+ private itemImageWaveform;
9
+ render(): import("lit-html").TemplateResult<1>;
10
+ private hashStrToInt;
11
+ private get hashBasedGradient();
12
+ private get boxWaveformClass();
13
+ private get itemImageWaveformClass();
14
+ private onLoadItemImageCheck;
15
+ static get styles(): CSSResultGroup;
16
+ }
@@ -0,0 +1,168 @@
1
+ import { __decorate } from "tslib";
2
+ import { css, html, LitElement } from 'lit';
3
+ import { customElement, property, query, state } from 'lit/decorators.js';
4
+ import { ifDefined } from 'lit/directives/if-defined.js';
5
+ let WaveformImage = class WaveformImage extends LitElement {
6
+ constructor() {
7
+ super(...arguments);
8
+ this.isCompactTile = false;
9
+ this.isListTile = false;
10
+ this.isWaveform = false;
11
+ }
12
+ render() {
13
+ return html `
14
+ <div class=${this.boxWaveformClass}>
15
+ <img
16
+ class=${this.itemImageWaveformClass}
17
+ src="${ifDefined(this.imageSrc)}"
18
+ alt="${ifDefined(this.identifier)}"
19
+ @load=${this.onLoadItemImageCheck}
20
+ />
21
+ </div>
22
+ `;
23
+ }
24
+ // Classes
25
+ hashStrToInt(str) {
26
+ return str
27
+ .split('')
28
+ .reduce((acc, char) => acc + char.charCodeAt(0), 0);
29
+ }
30
+ get hashBasedGradient() {
31
+ if (!this.identifier) {
32
+ return 'grad1';
33
+ }
34
+ const gradient = this.hashStrToInt(this.identifier) % 6; // returns 0-5
35
+ return `grad${gradient}`;
36
+ }
37
+ get boxWaveformClass() {
38
+ return `${this.isListTile || this.isCompactTile
39
+ ? 'list-item-audio'
40
+ : 'grid-item-audio'} ${this.isWaveform ? this.hashBasedGradient : ''}`;
41
+ }
42
+ get itemImageWaveformClass() {
43
+ return `item-image${this.isWaveform ? ' waveform' : ''}`;
44
+ }
45
+ onLoadItemImageCheck() {
46
+ const aspectRatio = this.itemImageWaveform.naturalWidth /
47
+ this.itemImageWaveform.naturalHeight;
48
+ if (aspectRatio === 4) {
49
+ this.isWaveform = true;
50
+ }
51
+ }
52
+ static get styles() {
53
+ return css `
54
+ .list-item-audio {
55
+ width: 100%;
56
+ height: 100%;
57
+ }
58
+
59
+ .grid-item-audio {
60
+ width: 16rem;
61
+ height: 16rem;
62
+ }
63
+
64
+ .item-audio {
65
+ width: 16rem;
66
+ height: 16rem;
67
+ }
68
+
69
+ .item-image {
70
+ width: 100%;
71
+ height: 100%;
72
+ object-fit: contain;
73
+ -webkit-appearance: none;
74
+ overflow: hidden;
75
+ }
76
+
77
+ .waveform {
78
+ mix-blend-mode: screen;
79
+ height: 100%;
80
+ position: relative;
81
+ top: 50%;
82
+ transform: translateY(-50%);
83
+ }
84
+
85
+ .default {
86
+ background-size: contain;
87
+ filter: drop-shadow(1px 1px 2px rgba(0, 0, 0, 0.8));
88
+ }
89
+
90
+ .grad0 {
91
+ background: linear-gradient(
92
+ hsl(340, 80%, 55%),
93
+ hsl(0, 80%, 33%) 35%,
94
+ hsl(0, 80%, 22%) 70%,
95
+ hsl(0, 0%, 0%)
96
+ );
97
+ }
98
+
99
+ .grad1 {
100
+ background: linear-gradient(
101
+ hsl(300, 80%, 55%),
102
+ hsl(330, 80%, 33%) 35%,
103
+ hsl(330, 80%, 22%) 70%,
104
+ hsl(0, 0%, 0%)
105
+ );
106
+ }
107
+
108
+ .grad2 {
109
+ background: linear-gradient(
110
+ hsl(200, 80%, 55%),
111
+ hsl(230, 80%, 33%) 35%,
112
+ hsl(230, 80%, 22%) 70%,
113
+ hsl(0, 0%, 0%)
114
+ );
115
+ }
116
+
117
+ .grad3 {
118
+ background: linear-gradient(
119
+ hsl(160, 80%, 55%),
120
+ hsl(190, 80%, 33%) 35%,
121
+ hsl(190, 80%, 22%) 70%,
122
+ hsl(0, 0%, 0%)
123
+ );
124
+ }
125
+
126
+ .grad4 {
127
+ background: linear-gradient(
128
+ hsl(250, 80%, 55%),
129
+ hsl(280, 80%, 33%) 35%,
130
+ hsl(280, 80%, 22%) 70%,
131
+ hsl(0, 0%, 0%)
132
+ );
133
+ }
134
+
135
+ .grad5 {
136
+ background: linear-gradient(
137
+ hsl(280, 80%, 55%),
138
+ hsl(310, 80%, 33%) 35%,
139
+ hsl(310, 80%, 22%) 70%,
140
+ hsl(0, 0%, 0%)
141
+ );
142
+ }
143
+ `;
144
+ }
145
+ };
146
+ __decorate([
147
+ property({ type: String })
148
+ ], WaveformImage.prototype, "imageSrc", void 0);
149
+ __decorate([
150
+ property({ type: String })
151
+ ], WaveformImage.prototype, "identifier", void 0);
152
+ __decorate([
153
+ property({ type: Boolean })
154
+ ], WaveformImage.prototype, "isCompactTile", void 0);
155
+ __decorate([
156
+ property({ type: Boolean })
157
+ ], WaveformImage.prototype, "isListTile", void 0);
158
+ __decorate([
159
+ state()
160
+ ], WaveformImage.prototype, "isWaveform", void 0);
161
+ __decorate([
162
+ query('.item-image')
163
+ ], WaveformImage.prototype, "itemImageWaveform", void 0);
164
+ WaveformImage = __decorate([
165
+ customElement('waveform-image')
166
+ ], WaveformImage);
167
+ export { WaveformImage };
168
+ //# sourceMappingURL=waveform-image.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"waveform-image.js","sourceRoot":"","sources":["../../../../src/tiles/image/waveform-image.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAkB,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAGzD,IAAa,aAAa,GAA1B,MAAa,aAAc,SAAQ,UAAU;IAA7C;;QAK+B,kBAAa,GAAG,KAAK,CAAC;QAEtB,eAAU,GAAG,KAAK,CAAC;QAE/B,eAAU,GAAY,KAAK,CAAC;IAkJ/C,CAAC;IA9IC,MAAM;QACJ,OAAO,IAAI,CAAA;mBACI,IAAI,CAA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AC;IAED,MAAM,KAAK,MAAM;QACf,OAAO,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA0FT,CAAC;IACJ,CAAC;CACF,CAAA;AA1J6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;+CAAmB;AAElB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;iDAAqB;AAEnB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;oDAAuB;AAEtB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;iDAAoB;AAEvC;IAAR,KAAK,EAAE;iDAAqC;AAEvB;IAArB,KAAK,CAAC,aAAa,CAAC;wDAA8C;AAXxD,aAAa;IADzB,aAAa,CAAC,gBAAgB,CAAC;GACnB,aAAa,CA2JzB;SA3JY,aAAa","sourcesContent":["import { css, CSSResultGroup, html, LitElement } from 'lit';\nimport { customElement, property, query, state } from 'lit/decorators.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\n\n@customElement('waveform-image')\nexport class WaveformImage extends LitElement {\n @property({ type: String }) imageSrc?: string;\n\n @property({ type: String }) identifier?: string;\n\n @property({ type: Boolean }) isCompactTile = false;\n\n @property({ type: Boolean }) isListTile = false;\n\n @state() private isWaveform: boolean = false;\n\n @query('.item-image') private itemImageWaveform!: HTMLImageElement;\n\n render() {\n return html`\n <div class=${this.boxWaveformClass}>\n <img\n class=${this.itemImageWaveformClass}\n src=\"${ifDefined(this.imageSrc)}\"\n alt=\"${ifDefined(this.identifier)}\"\n @load=${this.onLoadItemImageCheck}\n />\n </div>\n `;\n }\n\n // Classes\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 private get hashBasedGradient() {\n if (!this.identifier) {\n return 'grad1';\n }\n const gradient = this.hashStrToInt(this.identifier) % 6; // returns 0-5\n return `grad${gradient}`;\n }\n\n private get boxWaveformClass() {\n return `${\n this.isListTile || this.isCompactTile\n ? 'list-item-audio'\n : 'grid-item-audio'\n } ${this.isWaveform ? this.hashBasedGradient : ''}`;\n }\n\n private get itemImageWaveformClass() {\n return `item-image${this.isWaveform ? ' waveform' : ''}`;\n }\n\n private onLoadItemImageCheck() {\n const aspectRatio =\n this.itemImageWaveform.naturalWidth /\n this.itemImageWaveform.naturalHeight;\n if (aspectRatio === 4) {\n this.isWaveform = true;\n }\n }\n\n static get styles(): CSSResultGroup {\n return css`\n .list-item-audio {\n width: 100%;\n height: 100%;\n }\n\n .grid-item-audio {\n width: 16rem;\n height: 16rem;\n }\n\n .item-audio {\n width: 16rem;\n height: 16rem;\n }\n\n .item-image {\n width: 100%;\n height: 100%;\n object-fit: contain;\n -webkit-appearance: none;\n overflow: hidden;\n }\n\n .waveform {\n mix-blend-mode: screen;\n height: 100%;\n position: relative;\n top: 50%;\n transform: translateY(-50%);\n }\n\n .default {\n background-size: contain;\n filter: drop-shadow(1px 1px 2px rgba(0, 0, 0, 0.8));\n }\n\n .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 .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 .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 .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 .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 .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 }\n}\n"]}
@@ -1,21 +1,23 @@
1
- import { CSSResultGroup, PropertyValues, LitElement } from 'lit';
1
+ import { CSSResultGroup, LitElement } from 'lit';
2
2
  import { TileModel } from '../models';
3
3
  export declare class ItemImage extends LitElement {
4
4
  model?: TileModel;
5
5
  baseImageUrl?: string;
6
6
  isListTile: boolean;
7
- private isDeemphasize;
7
+ isCompactTile: boolean;
8
8
  private isWaveform;
9
9
  private itemImageWaveform;
10
- protected updated(changed: PropertyValues): void;
11
- private setDeemphsize;
12
10
  render(): import("lit-html").TemplateResult<1>;
13
11
  private get imageSrc();
14
- private get backgroundImageTemplate();
12
+ private get itemImageTemplate();
13
+ private get tileImageTemplate();
14
+ private get listImageTemplate();
15
15
  private get waveformTemplate();
16
+ private get restrictedIconTemplate();
16
17
  private get tileActionTemplate();
17
18
  private onLoadItemImageCheck;
18
19
  private get imageClass();
20
+ private get listImageClass();
19
21
  private get imageBoxClass();
20
22
  private get boxWaveformClass();
21
23
  private get itemImageWaveformClass();
@@ -1,32 +1,22 @@
1
1
  import { __decorate } from "tslib";
2
- import { css, html, nothing, LitElement, } from 'lit';
2
+ import { css, html, nothing, LitElement } from 'lit';
3
3
  import { customElement, property, query, state } from 'lit/decorators.js';
4
4
  import { ifDefined } from 'lit/directives/if-defined.js';
5
+ import { restrictedIcon } from '../assets/img/icons/restricted';
5
6
  let ItemImage = class ItemImage extends LitElement {
6
7
  constructor() {
7
8
  super(...arguments);
8
9
  this.isListTile = false;
9
- this.isDeemphasize = false;
10
+ this.isCompactTile = false;
10
11
  this.isWaveform = false;
11
12
  }
12
- updated(changed) {
13
- if (changed.has('model')) {
14
- this.setDeemphsize();
15
- }
16
- }
17
- setDeemphsize() {
18
- var _a, _b;
19
- this.isDeemphasize =
20
- (_b = (_a = this.model) === null || _a === void 0 ? void 0 : _a.collections.includes('deemphasize')) !== null && _b !== void 0 ? _b : false;
21
- }
22
13
  render() {
23
14
  var _a;
24
15
  return html `
25
16
  <div class=${ifDefined(this.imageBoxClass)}>
26
17
  ${((_a = this.model) === null || _a === void 0 ? void 0 : _a.mediatype) === 'audio'
27
18
  ? this.waveformTemplate
28
- : this.backgroundImageTemplate}
29
- ${this.tileActionTemplate}
19
+ : this.itemImageTemplate}
30
20
  </div>
31
21
  `;
32
22
  }
@@ -35,12 +25,27 @@ let ItemImage = class ItemImage extends LitElement {
35
25
  return `${this.baseImageUrl}/services/img/${(_a = this.model) === null || _a === void 0 ? void 0 : _a.identifier}`;
36
26
  }
37
27
  // Templates
38
- get backgroundImageTemplate() {
28
+ get itemImageTemplate() {
29
+ return html `
30
+ ${this.isListTile ? this.listImageTemplate : this.tileImageTemplate}
31
+ `;
32
+ }
33
+ get tileImageTemplate() {
39
34
  return html `
40
35
  <div
41
36
  class=${this.imageClass}
42
37
  style="background-image:url(${this.imageSrc})"
43
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}
44
49
  `;
45
50
  }
46
51
  get waveformTemplate() {
@@ -50,14 +55,22 @@ let ItemImage = class ItemImage extends LitElement {
50
55
  <img
51
56
  class=${this.itemImageWaveformClass}
52
57
  src="${this.imageSrc}"
53
- alt="${ifDefined((_a = this.model) === null || _a === void 0 ? void 0 : _a.identifier)}"
58
+ alt="${ifDefined((_a = this.model) === null || _a === void 0 ? void 0 : _a.title)}"
54
59
  @load=${this.onLoadItemImageCheck}
55
60
  />
56
61
  </div>
57
62
  `;
58
63
  }
64
+ get restrictedIconTemplate() {
65
+ var _a;
66
+ if (!((_a = this.model) === null || _a === void 0 ? void 0 : _a.contentWarning)) {
67
+ return nothing;
68
+ }
69
+ return html ` ${restrictedIcon} `;
70
+ }
59
71
  get tileActionTemplate() {
60
- if (!this.isDeemphasize) {
72
+ var _a;
73
+ if (!((_a = this.model) === null || _a === void 0 ? void 0 : _a.contentWarning)) {
61
74
  return nothing;
62
75
  }
63
76
  return html `
@@ -73,10 +86,22 @@ let ItemImage = class ItemImage extends LitElement {
73
86
  }
74
87
  // Classes
75
88
  get imageClass() {
76
- return `item-image ${this.isDeemphasize ? 'deemphasize' : 'default'}`;
89
+ var _a;
90
+ return `item-image ${((_a = this.model) === null || _a === void 0 ? void 0 : _a.contentWarning) ? 'deemphasize' : 'default'}`;
91
+ }
92
+ get listImageClass() {
93
+ var _a;
94
+ return `list-image ${(_a = this.model) === null || _a === void 0 ? void 0 : _a.mediatype}${this.isCompactTile ? ' compact' : ''}`;
77
95
  }
78
96
  get imageBoxClass() {
79
- return this.isDeemphasize ? 'item-image-box' : undefined;
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;
80
105
  }
81
106
  get boxWaveformClass() {
82
107
  return `item-audio${this.isWaveform ? ` ${this.hashBasedGradient}` : ''}`;
@@ -119,6 +144,37 @@ let ItemImage = class ItemImage extends LitElement {
119
144
  overflow: visible;
120
145
  }
121
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
+
122
178
  .waveform {
123
179
  mix-blend-mode: screen;
124
180
  }
@@ -128,12 +184,19 @@ let ItemImage = class ItemImage extends LitElement {
128
184
  filter: drop-shadow(1px 1px 2px rgba(0, 0, 0, 0.8));
129
185
  }
130
186
 
131
- .deemphasize {
132
- background-size: cover;
187
+ .deemphasize .list-image,
188
+ .deemphasize.item-image {
189
+ background-size: contain;
133
190
  filter: blur(15px);
134
191
  z-index: 1;
135
192
  }
136
193
 
194
+ .deemphasize svg {
195
+ padding: 25%;
196
+ z-index: 2;
197
+ position: absolute;
198
+ }
199
+
137
200
  .tile-action {
138
201
  border: 1px solid currentColor;
139
202
  border-radius: 1px;
@@ -220,8 +283,8 @@ __decorate([
220
283
  property({ type: Boolean })
221
284
  ], ItemImage.prototype, "isListTile", void 0);
222
285
  __decorate([
223
- state()
224
- ], ItemImage.prototype, "isDeemphasize", void 0);
286
+ property({ type: Boolean })
287
+ ], ItemImage.prototype, "isCompactTile", void 0);
225
288
  __decorate([
226
289
  state()
227
290
  ], ItemImage.prototype, "isWaveform", void 0);