@internetarchive/collection-browser 0.1.9 → 0.2.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.
@@ -0,0 +1,61 @@
1
+ import { html, LitElement } from 'lit';
2
+ import { customElement, property } from 'lit/decorators.js';
3
+
4
+ import { TileModel } from '../models';
5
+
6
+ import './image/item-image';
7
+ import './image/waveform-image';
8
+
9
+ @customElement('item-tile-image')
10
+ export class ItemTileImage extends LitElement {
11
+ @property({ type: Object }) model?: TileModel;
12
+
13
+ @property({ type: String }) baseImageUrl?: string;
14
+
15
+ @property({ type: Boolean }) isListTile = false;
16
+
17
+ @property({ type: Boolean }) isCompactTile = false;
18
+
19
+ render() {
20
+ return html`
21
+ ${this.isWithWaveformMediatype
22
+ ? this.waveformImageTemplate
23
+ : this.itemImageTemplate}
24
+ `;
25
+ }
26
+
27
+ private get imageSrc() {
28
+ return `${this.baseImageUrl}/services/img/${this.model?.identifier}`;
29
+ }
30
+
31
+ private get isWithWaveformMediatype() {
32
+ return (
33
+ this.model?.mediatype === 'audio' || this.model?.mediatype === 'etree'
34
+ );
35
+ }
36
+
37
+ // Templates
38
+ private get itemImageTemplate() {
39
+ return html`
40
+ <item-image
41
+ .model=${this.model}
42
+ .imageSrc=${this.imageSrc}
43
+ .isCompactTile=${this.isCompactTile}
44
+ .isListTile=${this.isListTile}
45
+ >
46
+ </item-image>
47
+ `;
48
+ }
49
+
50
+ private get waveformImageTemplate() {
51
+ return html`
52
+ <waveform-image
53
+ .imageSrc=${this.imageSrc}
54
+ .identifier=${this.model?.identifier}
55
+ .isCompactTile=${this.isCompactTile}
56
+ .isListTile=${this.isListTile}
57
+ >
58
+ </waveform-image>
59
+ `;
60
+ }
61
+ }
@@ -3,10 +3,13 @@ import { ifDefined } from 'lit/directives/if-defined.js';
3
3
  import { customElement, property } from 'lit/decorators.js';
4
4
  import { SortParam } from '@internetarchive/search-service';
5
5
  import DOMPurify from 'dompurify';
6
+
6
7
  import { TileModel } from '../../models';
7
8
  import { formatCount, NumberFormat } from '../../utils/format-count';
8
9
  import { formatDate, DateFormat } from '../../utils/format-date';
9
10
  import { accountLabel } from './account-label';
11
+
12
+ import '../item-image';
10
13
  import '../mediatype-icon';
11
14
 
12
15
  @customElement('tile-list-compact')
@@ -71,6 +74,7 @@ export class TileListCompact extends LitElement {
71
74
  .baseImageUrl=${this.baseImageUrl}
72
75
  .isListTile=${true}
73
76
  .isCompactTile=${true}
77
+ style="--imgHeight: 100%; --imgWidth: 100%"
74
78
  >
75
79
  </item-image>
76
80
  `;
@@ -10,14 +10,18 @@ import { ifDefined } from 'lit/directives/if-defined.js';
10
10
  import { join } from 'lit/directives/join.js';
11
11
  import { map } from 'lit/directives/map.js';
12
12
  import { customElement, property, state } from 'lit/decorators.js';
13
+
14
+ import { CollectionNameCacheInterface } from '@internetarchive/collection-name-cache';
13
15
  import { SortParam } from '@internetarchive/search-service';
14
16
  import DOMPurify from 'dompurify';
15
- import { CollectionNameCacheInterface } from '@internetarchive/collection-name-cache';
17
+
16
18
  import { dateLabel } from './date-label';
17
19
  import { accountLabel } from './account-label';
18
20
  import { TileModel } from '../../models';
19
21
  import { formatCount, NumberFormat } from '../../utils/format-count';
20
22
  import { formatDate, DateFormat } from '../../utils/format-date';
23
+
24
+ import '../item-image';
21
25
  import '../mediatype-icon';
22
26
 
23
27
  @customElement('tile-list')
@@ -143,6 +147,7 @@ export class TileList extends LitElement {
143
147
  .model=${this.model}
144
148
  .baseImageUrl=${this.baseImageUrl}
145
149
  .isListTile=${true}
150
+ style="--imgHeight: 100%; --imgWidth: 100%"
146
151
  >
147
152
  </item-image>
148
153
  `;