@internetarchive/collection-browser 0.4.3-alpha.9 → 0.4.4-alpha

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 (250) hide show
  1. package/.editorconfig +29 -29
  2. package/.github/workflows/ci.yml +26 -26
  3. package/.github/workflows/gh-pages-main.yml +39 -39
  4. package/.github/workflows/npm-publish.yml +39 -39
  5. package/.github/workflows/pr-preview.yml +38 -38
  6. package/.husky/pre-commit +4 -4
  7. package/LICENSE +661 -661
  8. package/README.md +83 -83
  9. package/dist/index.d.ts +9 -9
  10. package/dist/index.js +9 -9
  11. package/dist/src/app-root.d.ts +50 -48
  12. package/dist/src/app-root.js +449 -412
  13. package/dist/src/app-root.js.map +1 -1
  14. package/dist/src/assets/img/icons/arrow-left.d.ts +2 -2
  15. package/dist/src/assets/img/icons/arrow-left.js +2 -2
  16. package/dist/src/assets/img/icons/arrow-right.d.ts +2 -2
  17. package/dist/src/assets/img/icons/arrow-right.js +2 -2
  18. package/dist/src/assets/img/icons/chevron.d.ts +2 -2
  19. package/dist/src/assets/img/icons/chevron.js +2 -2
  20. package/dist/src/assets/img/icons/empty-query.d.ts +2 -2
  21. package/dist/src/assets/img/icons/empty-query.js +2 -2
  22. package/dist/src/assets/img/icons/eye-closed.d.ts +2 -2
  23. package/dist/src/assets/img/icons/eye-closed.js +2 -2
  24. package/dist/src/assets/img/icons/eye.d.ts +2 -2
  25. package/dist/src/assets/img/icons/eye.js +2 -2
  26. package/dist/src/assets/img/icons/favorite-filled.d.ts +1 -1
  27. package/dist/src/assets/img/icons/favorite-filled.js +2 -2
  28. package/dist/src/assets/img/icons/login-required.d.ts +1 -1
  29. package/dist/src/assets/img/icons/login-required.js +2 -2
  30. package/dist/src/assets/img/icons/mediatype/account.d.ts +1 -1
  31. package/dist/src/assets/img/icons/mediatype/account.js +2 -2
  32. package/dist/src/assets/img/icons/mediatype/audio.d.ts +1 -1
  33. package/dist/src/assets/img/icons/mediatype/audio.js +2 -2
  34. package/dist/src/assets/img/icons/mediatype/collection.d.ts +1 -1
  35. package/dist/src/assets/img/icons/mediatype/collection.js +2 -2
  36. package/dist/src/assets/img/icons/mediatype/data.d.ts +1 -1
  37. package/dist/src/assets/img/icons/mediatype/data.js +2 -2
  38. package/dist/src/assets/img/icons/mediatype/etree.d.ts +1 -1
  39. package/dist/src/assets/img/icons/mediatype/etree.js +2 -2
  40. package/dist/src/assets/img/icons/mediatype/film.d.ts +1 -1
  41. package/dist/src/assets/img/icons/mediatype/film.js +2 -2
  42. package/dist/src/assets/img/icons/mediatype/images.d.ts +1 -1
  43. package/dist/src/assets/img/icons/mediatype/images.js +2 -2
  44. package/dist/src/assets/img/icons/mediatype/radio.d.ts +1 -1
  45. package/dist/src/assets/img/icons/mediatype/radio.js +2 -2
  46. package/dist/src/assets/img/icons/mediatype/software.d.ts +1 -1
  47. package/dist/src/assets/img/icons/mediatype/software.js +2 -2
  48. package/dist/src/assets/img/icons/mediatype/texts.d.ts +1 -1
  49. package/dist/src/assets/img/icons/mediatype/texts.js +2 -2
  50. package/dist/src/assets/img/icons/mediatype/tv.d.ts +1 -1
  51. package/dist/src/assets/img/icons/mediatype/tv.js +2 -2
  52. package/dist/src/assets/img/icons/mediatype/video.d.ts +1 -1
  53. package/dist/src/assets/img/icons/mediatype/video.js +2 -2
  54. package/dist/src/assets/img/icons/mediatype/web.d.ts +1 -1
  55. package/dist/src/assets/img/icons/mediatype/web.js +2 -2
  56. package/dist/src/assets/img/icons/null-result.d.ts +2 -2
  57. package/dist/src/assets/img/icons/null-result.js +2 -2
  58. package/dist/src/assets/img/icons/restricted.d.ts +1 -1
  59. package/dist/src/assets/img/icons/restricted.js +2 -2
  60. package/dist/src/assets/img/icons/reviews.d.ts +1 -1
  61. package/dist/src/assets/img/icons/reviews.js +2 -2
  62. package/dist/src/assets/img/icons/upload.d.ts +1 -1
  63. package/dist/src/assets/img/icons/upload.js +2 -2
  64. package/dist/src/assets/img/icons/views.d.ts +1 -1
  65. package/dist/src/assets/img/icons/views.js +2 -2
  66. package/dist/src/circular-activity-indicator.d.ts +5 -5
  67. package/dist/src/circular-activity-indicator.js +17 -17
  68. package/dist/src/collection-browser.d.ts +315 -276
  69. package/dist/src/collection-browser.js +1276 -1179
  70. package/dist/src/collection-browser.js.map +1 -1
  71. package/dist/src/collection-facets/facet-tombstone-row.d.ts +5 -5
  72. package/dist/src/collection-facets/facet-tombstone-row.js +15 -15
  73. package/dist/src/collection-facets/facets-template.d.ts +16 -16
  74. package/dist/src/collection-facets/facets-template.js +125 -125
  75. package/dist/src/collection-facets/more-facets-content.d.ts +77 -77
  76. package/dist/src/collection-facets/more-facets-content.js +357 -357
  77. package/dist/src/collection-facets/more-facets-pagination.d.ts +36 -36
  78. package/dist/src/collection-facets/more-facets-pagination.js +192 -192
  79. package/dist/src/collection-facets.d.ts +78 -78
  80. package/dist/src/collection-facets.js +391 -391
  81. package/dist/src/empty-placeholder.d.ts +11 -11
  82. package/dist/src/empty-placeholder.js +42 -42
  83. package/dist/src/language-code-handler/language-code-handler.d.ts +37 -37
  84. package/dist/src/language-code-handler/language-code-handler.js +26 -26
  85. package/dist/src/language-code-handler/language-code-mapping.d.ts +1 -1
  86. package/dist/src/language-code-handler/language-code-mapping.js +562 -562
  87. package/dist/src/mediatype/mediatype-config.d.ts +3 -3
  88. package/dist/src/mediatype/mediatype-config.js +85 -85
  89. package/dist/src/models.d.ts +114 -112
  90. package/dist/src/models.js +125 -125
  91. package/dist/src/models.js.map +1 -1
  92. package/dist/src/restoration-state-handler.d.ts +45 -45
  93. package/dist/src/restoration-state-handler.js +230 -230
  94. package/dist/src/sort-filter-bar/alpha-bar.d.ts +12 -12
  95. package/dist/src/sort-filter-bar/alpha-bar.js +52 -52
  96. package/dist/src/sort-filter-bar/img/compact.d.ts +1 -1
  97. package/dist/src/sort-filter-bar/img/compact.js +2 -2
  98. package/dist/src/sort-filter-bar/img/list.d.ts +1 -1
  99. package/dist/src/sort-filter-bar/img/list.js +2 -2
  100. package/dist/src/sort-filter-bar/img/sort-triangle.d.ts +1 -1
  101. package/dist/src/sort-filter-bar/img/sort-triangle.js +2 -2
  102. package/dist/src/sort-filter-bar/img/tile.d.ts +1 -1
  103. package/dist/src/sort-filter-bar/img/tile.js +2 -2
  104. package/dist/src/sort-filter-bar/sort-filter-bar.d.ts +108 -108
  105. package/dist/src/sort-filter-bar/sort-filter-bar.js +428 -428
  106. package/dist/src/styles/item-image-styles.d.ts +8 -8
  107. package/dist/src/styles/item-image-styles.js +22 -12
  108. package/dist/src/styles/item-image-styles.js.map +1 -1
  109. package/dist/src/tiles/collection-browser-loading-tile.d.ts +5 -5
  110. package/dist/src/tiles/collection-browser-loading-tile.js +16 -16
  111. package/dist/src/tiles/collection-browser-loading-tile.js.map +1 -1
  112. package/dist/src/tiles/grid/account-tile.d.ts +17 -17
  113. package/dist/src/tiles/grid/account-tile.js +48 -47
  114. package/dist/src/tiles/grid/account-tile.js.map +1 -1
  115. package/dist/src/tiles/grid/collection-tile.d.ts +14 -7
  116. package/dist/src/tiles/grid/collection-tile.js +112 -146
  117. package/dist/src/tiles/grid/collection-tile.js.map +1 -1
  118. package/dist/src/tiles/grid/item-tile.d.ts +29 -29
  119. package/dist/src/tiles/grid/item-tile.js +110 -105
  120. package/dist/src/tiles/grid/item-tile.js.map +1 -1
  121. package/dist/src/tiles/grid/styles/tile-grid-shared-styles.d.ts +1 -1
  122. package/dist/src/tiles/grid/styles/tile-grid-shared-styles.js +12 -8
  123. package/dist/src/tiles/grid/styles/tile-grid-shared-styles.js.map +1 -1
  124. package/dist/src/tiles/grid/tile-stats.d.ts +10 -10
  125. package/dist/src/tiles/grid/tile-stats.js +41 -40
  126. package/dist/src/tiles/grid/tile-stats.js.map +1 -1
  127. package/dist/src/tiles/image-block.d.ts +17 -17
  128. package/dist/src/tiles/image-block.js +76 -72
  129. package/dist/src/tiles/image-block.js.map +1 -1
  130. package/dist/src/tiles/item-image.d.ts +35 -35
  131. package/dist/src/tiles/item-image.js +117 -116
  132. package/dist/src/tiles/item-image.js.map +1 -1
  133. package/dist/src/tiles/list/account-label.d.ts +1 -1
  134. package/dist/src/tiles/list/account-label.js +6 -6
  135. package/dist/src/tiles/list/date-label.d.ts +1 -1
  136. package/dist/src/tiles/list/date-label.js +12 -12
  137. package/dist/src/tiles/list/tile-list-compact-header.d.ts +12 -12
  138. package/dist/src/tiles/list/tile-list-compact-header.js +41 -41
  139. package/dist/src/tiles/list/tile-list-compact.d.ts +21 -21
  140. package/dist/src/tiles/list/tile-list-compact.js +93 -93
  141. package/dist/src/tiles/list/tile-list.d.ts +53 -53
  142. package/dist/src/tiles/list/tile-list.js +279 -279
  143. package/dist/src/tiles/mediatype-icon.d.ts +9 -9
  144. package/dist/src/tiles/mediatype-icon.js +47 -47
  145. package/dist/src/tiles/overlay/icon-overlay.d.ts +10 -10
  146. package/dist/src/tiles/overlay/icon-overlay.js +40 -40
  147. package/dist/src/tiles/overlay/icon-text-overlay.d.ts +9 -9
  148. package/dist/src/tiles/overlay/icon-text-overlay.js +38 -38
  149. package/dist/src/tiles/overlay/text-overlay.d.ts +10 -10
  150. package/dist/src/tiles/overlay/text-overlay.js +42 -42
  151. package/dist/src/tiles/text-snippet-block.d.ts +27 -27
  152. package/dist/src/tiles/text-snippet-block.js +73 -73
  153. package/dist/src/tiles/tile-dispatcher.d.ts +36 -36
  154. package/dist/src/tiles/tile-dispatcher.js +145 -128
  155. package/dist/src/tiles/tile-dispatcher.js.map +1 -1
  156. package/dist/src/utils/analytics-events.d.ts +22 -22
  157. package/dist/src/utils/analytics-events.js +24 -24
  158. package/dist/src/utils/format-count.d.ts +7 -7
  159. package/dist/src/utils/format-count.js +76 -76
  160. package/dist/src/utils/format-date.d.ts +2 -2
  161. package/dist/src/utils/format-date.js +23 -23
  162. package/dist/src/utils/format-unit-size.d.ts +2 -0
  163. package/dist/src/utils/format-unit-size.js +34 -0
  164. package/dist/src/utils/format-unit-size.js.map +1 -0
  165. package/dist/test/collection-browser.test.d.ts +1 -1
  166. package/dist/test/collection-browser.test.js +646 -646
  167. package/dist/test/collection-facets/facets-template.test.d.ts +1 -1
  168. package/dist/test/collection-facets/facets-template.test.js +62 -62
  169. package/dist/test/collection-facets/more-facets-content.test.d.ts +1 -1
  170. package/dist/test/collection-facets/more-facets-content.test.js +114 -114
  171. package/dist/test/collection-facets/more-facets-pagination.test.d.ts +1 -1
  172. package/dist/test/collection-facets/more-facets-pagination.test.js +117 -117
  173. package/dist/test/collection-facets.test.d.ts +2 -2
  174. package/dist/test/collection-facets.test.js +544 -544
  175. package/dist/test/empty-placeholder.test.d.ts +1 -1
  176. package/dist/test/empty-placeholder.test.js +33 -33
  177. package/dist/test/icon-overlay.test.d.ts +1 -1
  178. package/dist/test/icon-overlay.test.js +24 -24
  179. package/dist/test/image-block.test.d.ts +1 -1
  180. package/dist/test/image-block.test.js +48 -48
  181. package/dist/test/item-image.test.d.ts +1 -1
  182. package/dist/test/item-image.test.js +84 -80
  183. package/dist/test/item-image.test.js.map +1 -1
  184. package/dist/test/mediatype-config.test.d.ts +1 -1
  185. package/dist/test/mediatype-config.test.js +16 -16
  186. package/dist/test/mocks/mock-analytics-handler.d.ts +10 -10
  187. package/dist/test/mocks/mock-analytics-handler.js +15 -15
  188. package/dist/test/mocks/mock-collection-name-cache.d.ts +7 -7
  189. package/dist/test/mocks/mock-collection-name-cache.js +13 -13
  190. package/dist/test/mocks/mock-search-responses.d.ts +12 -12
  191. package/dist/test/mocks/mock-search-responses.js +341 -341
  192. package/dist/test/mocks/mock-search-service.d.ts +13 -13
  193. package/dist/test/mocks/mock-search-service.js +40 -40
  194. package/dist/test/restoration-state-handler.test.d.ts +1 -1
  195. package/dist/test/restoration-state-handler.test.js +125 -125
  196. package/dist/test/sort-filter-bar/alpha-bar.test.d.ts +1 -1
  197. package/dist/test/sort-filter-bar/alpha-bar.test.js +43 -43
  198. package/dist/test/sort-filter-bar/sort-filter-bar.test.d.ts +1 -1
  199. package/dist/test/sort-filter-bar/sort-filter-bar.test.js +141 -141
  200. package/dist/test/text-overlay.test.d.ts +1 -1
  201. package/dist/test/text-overlay.test.js +48 -48
  202. package/dist/test/text-snippet-block.test.d.ts +1 -1
  203. package/dist/test/text-snippet-block.test.js +57 -57
  204. package/dist/test/tile-stats.test.d.ts +1 -1
  205. package/dist/test/tile-stats.test.js +33 -33
  206. package/dist/test/tiles/grid/account-tile.test.d.ts +1 -1
  207. package/dist/test/tiles/grid/account-tile.test.js +60 -60
  208. package/dist/test/tiles/grid/collection-tile.test.d.ts +1 -0
  209. package/dist/test/tiles/grid/collection-tile.test.js +73 -0
  210. package/dist/test/tiles/grid/collection-tile.test.js.map +1 -0
  211. package/dist/test/tiles/grid/item-tile.test.d.ts +1 -1
  212. package/dist/test/tiles/grid/item-tile.test.js +142 -129
  213. package/dist/test/tiles/grid/item-tile.test.js.map +1 -1
  214. package/dist/test/tiles/list/tile-list-compact.test.d.ts +1 -1
  215. package/dist/test/tiles/list/tile-list-compact.test.js +92 -92
  216. package/dist/test/tiles/list/tile-list.test.d.ts +1 -1
  217. package/dist/test/tiles/list/tile-list.test.js +123 -123
  218. package/dist/test/utils/format-count.test.d.ts +1 -1
  219. package/dist/test/utils/format-count.test.js +23 -23
  220. package/dist/test/utils/format-date.test.d.ts +1 -1
  221. package/dist/test/utils/format-date.test.js +17 -17
  222. package/dist/test/utils/format-unit-size.test.d.ts +1 -0
  223. package/dist/test/utils/format-unit-size.test.js +18 -0
  224. package/dist/test/utils/format-unit-size.test.js.map +1 -0
  225. package/index.html +24 -24
  226. package/local.archive.org.cert +86 -86
  227. package/local.archive.org.key +27 -27
  228. package/package.json +2 -2
  229. package/renovate.json +6 -6
  230. package/src/app-root.ts +214 -169
  231. package/src/collection-browser.ts +122 -3
  232. package/src/models.ts +2 -0
  233. package/src/styles/item-image-styles.ts +13 -3
  234. package/src/tiles/collection-browser-loading-tile.ts +1 -1
  235. package/src/tiles/grid/account-tile.ts +4 -2
  236. package/src/tiles/grid/collection-tile.ts +106 -136
  237. package/src/tiles/grid/item-tile.ts +8 -2
  238. package/src/tiles/grid/styles/tile-grid-shared-styles.ts +6 -2
  239. package/src/tiles/grid/tile-stats.ts +1 -0
  240. package/src/tiles/image-block.ts +5 -2
  241. package/src/tiles/item-image.ts +4 -3
  242. package/src/tiles/tile-dispatcher.ts +17 -0
  243. package/src/utils/format-unit-size.ts +43 -0
  244. package/test/item-image.test.ts +4 -0
  245. package/test/tiles/grid/collection-tile.test.ts +85 -0
  246. package/test/tiles/grid/item-tile.test.ts +30 -4
  247. package/test/utils/format-unit-size.test.ts +21 -0
  248. package/tsconfig.json +21 -21
  249. package/web-dev-server.config.mjs +30 -30
  250. package/web-test-runner.config.mjs +41 -41
@@ -5,7 +5,6 @@ import { css } from 'lit';
5
5
  */
6
6
  export const baseItemImageStyles = css`
7
7
  .drop-shadow {
8
- filter: drop-shadow(1px 1px 2px rgba(0, 0, 0, 0.8));
9
8
  overflow: hidden;
10
9
  height: 100%;
11
10
  }
@@ -30,11 +29,22 @@ export const baseItemImageStyles = css`
30
29
 
31
30
  .blur {
32
31
  filter: blur(15px);
33
- box-shadow: 1px 1px 2px 0px;
32
+ box-shadow: 1px 1px 2px 0;
34
33
  }
35
34
 
36
- .radius50 {
35
+ .account-image {
36
+ object-fit: cover;
37
+ background-position: 50% 50%;
37
38
  border-radius: 50%;
39
+ width: 160px;
40
+ height: 160px;
41
+ }
42
+
43
+ .collection-image {
44
+ object-fit: cover;
45
+ border-radius: 8px;
46
+ width: 100%;
47
+ height: 160px;
38
48
  }
39
49
  `;
40
50
 
@@ -16,7 +16,7 @@ export class CollectionBrowserLoadingTile extends LitElement {
16
16
 
17
17
  #container {
18
18
  background: linear-gradient(to right bottom, #dddddd, #d8d8d8);
19
- border-radius: var(--collectionTileCornerRadius, 4px);
19
+ border-radius: var(--tileCornerRadius, 4px);
20
20
  background-size: 100% 100%;
21
21
  display: block;
22
22
  height: 100%;
@@ -63,11 +63,13 @@ export class AccountTile extends LitElement {
63
63
  * CSS
64
64
  */
65
65
  static get styles() {
66
+ const tileBorderColor = css`var(--tileBorderColor, #dddddd)`;
67
+
66
68
  return [
67
69
  baseTileStyles,
68
70
  css`
69
- image-block {
70
- --imageBlockBackgroundColor: #fcf5e6;
71
+ .container {
72
+ border: 1px solid ${tileBorderColor};
71
73
  }
72
74
  `,
73
75
  ];
@@ -1,156 +1,126 @@
1
- import { msg } from '@lit/localize';
2
- import { css, CSSResultGroup, html, LitElement } from 'lit';
1
+ import { css, CSSResultGroup, html, LitElement, TemplateResult } from 'lit';
3
2
  import { customElement, property } from 'lit/decorators.js';
4
3
  import { collectionIcon } from '../../assets/img/icons/mediatype/collection';
5
4
  import type { TileModel } from '../../models';
5
+ import { formatUnitSize } from '../../utils/format-unit-size';
6
+ import { baseTileStyles } from './styles/tile-grid-shared-styles';
7
+ import '../image-block';
6
8
 
7
9
  @customElement('collection-tile')
8
10
  export class CollectionTile extends LitElement {
9
11
  @property({ type: Object }) model?: TileModel;
10
12
 
13
+ @property({ type: String }) baseImageUrl?: string;
14
+
11
15
  render() {
12
16
  return html`
13
- <div id="container">
14
- <div id="collection-image-title">
15
- <div id="collection-title">${this.model?.title}</div>
16
- <div id="collection-image-container">
17
- <div
18
- id="collection-image"
19
- style="background-image:url('https://archive.org/services/img/${this
20
- .model?.identifier}')"
21
- ></div>
17
+ <div class="container">
18
+ <div class="tile-details">
19
+ <div class="item-info">
20
+ ${this.getImageBlockTemplate} ${this.getTitleTemplate}
22
21
  </div>
23
22
  </div>
24
- <div id="item-count-container">
25
- <div id="item-count-image-container">${collectionIcon}</div>
26
- <div id="item-count-stacked-text">
27
- <div id="item-count">${this.model?.itemCount.toLocaleString()}</div>
28
- <div id="items-text">${msg('items')}</div>
29
- </div>
23
+
24
+ ${this.getTileStatsTemplate}
25
+ </div>
26
+ `;
27
+ }
28
+
29
+ private get getImageBlockTemplate(): TemplateResult {
30
+ return html`
31
+ <image-block
32
+ .model=${this.model}
33
+ .baseImageUrl=${this.baseImageUrl}
34
+ .viewSize=${'grid'}
35
+ >
36
+ </image-block>
37
+ `;
38
+ }
39
+
40
+ private get getTitleTemplate() {
41
+ return html`<div id="title">
42
+ <h1 class="truncated">${this.model?.title}</h1>
43
+ </div>`;
44
+ }
45
+
46
+ private get getTileStatsTemplate() {
47
+ return html`
48
+ <div id="item-stats">
49
+ <div id="item-mediatype">${collectionIcon}</div>
50
+
51
+ <div id="stats-row">
52
+ ${this.getItemsTemplate} ${this.getSizeTemplate}
30
53
  </div>
31
54
  </div>
32
55
  `;
33
56
  }
34
57
 
58
+ private get getItemsTemplate() {
59
+ const collectionItems = this.model?.itemCount.toLocaleString();
60
+
61
+ return html`<span id="item-count"
62
+ >${collectionItems} item${Number(collectionItems) !== 1 ? 's' : ''}</span
63
+ >`;
64
+ }
65
+
66
+ private get getSizeTemplate() {
67
+ const collectionSize = this.model?.collectionSize ?? 0;
68
+
69
+ return collectionSize
70
+ ? html`<span id="item-size">${formatUnitSize(collectionSize, 1)}</span>`
71
+ : ``;
72
+ }
73
+
35
74
  static get styles(): CSSResultGroup {
36
- const cornerRadiusCss = css`var(--collectionTileCornerRadius, 4px)`;
37
-
38
- return css`
39
- #collection-image-container {
40
- display: flex;
41
- justify-content: center;
42
- flex: 1;
43
- }
44
-
45
- #collection-image {
46
- width: 16rem;
47
- height: 16rem;
48
- border-radius: 0.8rem;
49
- overflow: hidden;
50
- box-shadow: 1px 1px 2px 0px;
51
- object-fit: cover;
52
- background-position: center;
53
- background-size: cover;
54
- }
55
-
56
- #item-count-image-container svg {
57
- filter: invert(100%);
58
- }
59
-
60
- #collection-image-title {
61
- background-color: #666;
62
- border: 1px solid #2c2c2c;
63
- padding: 0.5rem;
64
- border-top-left-radius: ${cornerRadiusCss};
65
- border-top-right-radius: ${cornerRadiusCss};
66
- display: flex;
67
- flex-direction: column;
68
- flex: 1;
69
- }
70
-
71
- #collection-title {
72
- font-weight: bold;
73
- color: #fff;
74
- font-size: 1.6rem;
75
- text-align: center;
76
- margin-bottom: 0.5rem;
77
- overflow: hidden;
78
- text-overflow: ellipsis;
79
- display: -webkit-box;
80
- -webkit-line-clamp: 2;
81
- -webkit-box-orient: vertical;
82
- line-height: 2rem;
83
- height: 4rem;
84
- }
85
-
86
- #container {
87
- box-shadow: 1px 1px 2px 0px;
88
- border-radius: ${cornerRadiusCss};
89
- height: 100%;
90
- display: flex;
91
- flex-direction: column;
92
- }
93
-
94
- #container:hover > #collection-image-title > #collection-title {
95
- text-decoration: underline;
96
- }
97
-
98
- /* this is a workaround for Safari 15 where the hover effects are not working */
99
- #collection-image-title:hover > #collection-title {
100
- text-decoration: underline;
101
- }
102
-
103
- #container:hover > #collection-image-title {
104
- background-color: #757575;
105
- }
106
-
107
- #item-count-container {
108
- background-color: #444;
109
- border-bottom: 1px solid #2c2c2c;
110
- border-left: 1px solid #2c2c2c;
111
- border-right: 1px solid #2c2c2c;
112
- border-bottom-left-radius: ${cornerRadiusCss};
113
- border-bottom-right-radius: ${cornerRadiusCss};
114
- display: flex;
115
- padding: 0rem 0.5rem;
116
- height: 5.5rem;
117
- align-items: center;
118
- }
119
-
120
- #item-count-image-container {
121
- margin-right: 0.5rem;
122
- }
123
-
124
- #item-count-stacked-text {
125
- display: flex;
126
- align-items: baseline;
127
- color: #fff;
128
- }
129
- #item-count-image-container svg {
130
- height: 2.5rem;
131
- align-items: baseline;
132
- }
133
-
134
- #container:hover > #item-count-container {
135
- background-color: #575757;
136
- }
137
-
138
- #item-count {
139
- font-size: 1.4rem;
140
- font-weight: bold;
141
- }
142
-
143
- #item-count-image {
144
- width: 3rem;
145
- height: 3rem;
146
- margin-right: 1rem;
147
- }
148
-
149
- #items-text {
150
- font-size: 1.4rem;
151
- font-weight: bold;
152
- margin-left: 0.5rem;
153
- }
154
- `;
75
+ const tileBorderColor = css`var(--tileBorderColor, #555555)`;
76
+ const tileBackgroundColor = css`var(--tileBackgroundColor, #666666)`;
77
+ const whiteColor = css`#fff`;
78
+
79
+ return [
80
+ baseTileStyles,
81
+ css`
82
+ .container {
83
+ background-color: ${tileBackgroundColor};
84
+ border: 1px solid ${tileBorderColor};
85
+ }
86
+
87
+ .item-info {
88
+ flex-grow: initial;
89
+ }
90
+
91
+ h1.truncated {
92
+ color: ${whiteColor};
93
+ }
94
+
95
+ #item-mediatype svg {
96
+ filter: invert(100%);
97
+ height: 2.5rem;
98
+ align-items: baseline;
99
+ }
100
+
101
+ .container:hover > #title {
102
+ text-decoration: underline;
103
+ }
104
+
105
+ /* this is a workaround for Safari 15 where the hover effects are not working */
106
+ image-block:hover > #title {
107
+ text-decoration: underline;
108
+ }
109
+
110
+ #item-stats {
111
+ display: flex;
112
+ padding: 0 5px 5px;
113
+ align-items: center;
114
+ }
115
+
116
+ #stats-row {
117
+ display: flex;
118
+ align-items: baseline;
119
+ color: ${whiteColor};
120
+ flex-direction: column;
121
+ margin-left: 10px;
122
+ }
123
+ `,
124
+ ];
155
125
  }
156
126
  }
@@ -98,6 +98,7 @@ export class ItemTile extends LitElement {
98
98
  private get sortedDateInfoTemplate() {
99
99
  let sortedValue;
100
100
 
101
+ // console.log('model: ', this.model)
101
102
  switch (this.sortParam?.field) {
102
103
  case 'date':
103
104
  sortedValue = { field: 'published', value: this.model?.datePublished };
@@ -115,6 +116,9 @@ export class ItemTile extends LitElement {
115
116
  break;
116
117
  }
117
118
 
119
+ if (!sortedValue?.value) {
120
+ return nothing;
121
+ }
118
122
  return html`
119
123
  <div class="date-sorted-by truncated">
120
124
  <span>
@@ -159,11 +163,13 @@ export class ItemTile extends LitElement {
159
163
  * CSS
160
164
  */
161
165
  static get styles(): CSSResultGroup {
166
+ const tileBorderColor = css`var(--tileBorderColor, #dddddd)`;
167
+
162
168
  return [
163
169
  baseTileStyles,
164
170
  css`
165
- image-block {
166
- --imageBlockBackgroundColor: #f1f1f4;
171
+ .container {
172
+ border: 1px solid ${tileBorderColor};
167
173
  }
168
174
 
169
175
  text-snippet-block {
@@ -4,8 +4,8 @@ import { css } from 'lit';
4
4
  * Base tile styles
5
5
  */
6
6
 
7
- const tileCornerRadius = css`var(--collectionTileCornerRadius, 4px)`;
8
7
  const tileBackgroundColor = css`var(--tileBackgroundColor, #ffffff)`;
8
+ const tileCornerRadius = css`var(--tileCornerRadius, 4px)`;
9
9
 
10
10
  export const baseTileStyles = css`
11
11
  .container {
@@ -31,6 +31,7 @@ export const baseTileStyles = css`
31
31
  flex-direction: column;
32
32
  height: 100%;
33
33
  row-gap: 10px;
34
+ font-family: 'Helvetica Neue', ui-sans-serif, system-ui, sans-serif;
34
35
  }
35
36
 
36
37
  .item-info {
@@ -41,6 +42,7 @@ export const baseTileStyles = css`
41
42
  flex-shrink: 0;
42
43
  padding-left: 5px;
43
44
  padding-right: 5px;
45
+ margin-bottom: 10px;
44
46
  }
45
47
 
46
48
  .created-by,
@@ -50,7 +52,7 @@ export const baseTileStyles = css`
50
52
  display: flex;
51
53
  justify-content: left;
52
54
  align-items: flex-end; /* Important to start text from bottom */
53
- padding: 10px 5px 0px 5px;
55
+ padding: 0 5px 5px 5px;
54
56
  }
55
57
 
56
58
  .truncated {
@@ -72,6 +74,7 @@ export const baseTileStyles = css`
72
74
  line-height: 15px;
73
75
  font-size: 14px;
74
76
  font-weight: 500;
77
+ padding-bottom: 1px;
75
78
  }
76
79
 
77
80
  span {
@@ -82,6 +85,7 @@ export const baseTileStyles = css`
82
85
  word-wrap: break-word;
83
86
  -webkit-line-clamp: 1;
84
87
  -webkit-box-orient: vertical;
88
+ padding-bottom: 1px;
85
89
  }
86
90
 
87
91
  .container:hover > .tile-details > .item-info > #title > .truncated {
@@ -103,6 +103,7 @@ export class TileStats extends LitElement {
103
103
  height: 35px;
104
104
  padding-left: 5px;
105
105
  padding-right: 5px;
106
+ font-family: 'Helvetica Neue', ui-sans-serif, system-ui, sans-serif;
106
107
  }
107
108
 
108
109
  #stats-row {
@@ -44,6 +44,7 @@ export class ImageBlock extends LitElement {
44
44
  return {
45
45
  list: this.isListTile && !this.isCompactTile,
46
46
  'list-compact': this.isListTile && this.isCompactTile,
47
+ collection: this.model?.mediatype === 'collection', // fill the image in container
47
48
  [this.viewSize]: true,
48
49
  };
49
50
  }
@@ -82,7 +83,6 @@ export class ImageBlock extends LitElement {
82
83
 
83
84
  static get styles(): CSSResultGroup {
84
85
  const imageBlockBackgroundColor = css`var(--imageBlockBackgroundColor, #f1f1f4)`;
85
- const imageBlockBorderColor = css`var(--imageBlockBorderColor, #dddddd)`;
86
86
 
87
87
  return css`
88
88
  div {
@@ -90,7 +90,6 @@ export class ImageBlock extends LitElement {
90
90
  justify-content: center;
91
91
  position: relative;
92
92
  background-color: ${imageBlockBackgroundColor};
93
- border: 1px solid ${imageBlockBorderColor};
94
93
  }
95
94
 
96
95
  .grid {
@@ -100,6 +99,10 @@ export class ImageBlock extends LitElement {
100
99
  padding: 5px;
101
100
  }
102
101
 
102
+ .collection.grid {
103
+ display: block;
104
+ }
105
+
103
106
  /** tile-list view */
104
107
  .list.desktop {
105
108
  width: 100px;
@@ -81,14 +81,15 @@ export class ItemImage extends LitElement {
81
81
  cover: this.isCompactTile,
82
82
  blur: toBlur || false,
83
83
  waveform: this.isWaveform,
84
- radius50: this.itemImageRadius,
84
+ 'account-image': this.isAccountImage, // for account tile image
85
+ 'collection-image': this.model?.mediatype === 'collection', // for collection tile image
85
86
  };
86
87
  }
87
88
 
88
89
  /**
89
- * Helper function to determine if border radius is needed
90
+ * Helper function to determine if account tile image
90
91
  */
91
- private get itemImageRadius() {
92
+ private get isAccountImage() {
92
93
  return (
93
94
  this.model?.mediatype === 'account' &&
94
95
  !this.isCompactTile &&
@@ -143,6 +143,7 @@ export class TileDispatcher
143
143
  case 'collection':
144
144
  return html`<collection-tile
145
145
  .model=${model}
146
+ .baseImageUrl=${this.baseImageUrl}
146
147
  .currentWidth=${currentWidth}
147
148
  .currentHeight=${currentHeight}
148
149
  >
@@ -204,6 +205,22 @@ export class TileDispatcher
204
205
  height: 100%;
205
206
  }
206
207
 
208
+ collection-tile {
209
+ --tileBorderColor: #555555;
210
+ --tileBackgroundColor: #666666;
211
+ --imageBlockBackgroundColor: #666666;
212
+ }
213
+
214
+ account-tile {
215
+ --tileBorderColor: #dddddd;
216
+ --imageBlockBackgroundColor: #fcf5e6;
217
+ }
218
+
219
+ item-tile {
220
+ --tileBorderColor: #dddddd;
221
+ --imageBlockBackgroundColor: #f1f1f4;
222
+ }
223
+
207
224
  #container {
208
225
  height: 100%;
209
226
  }
@@ -0,0 +1,43 @@
1
+ /*
2
+ * Replaces Petabox www/common/Util::humanSize()
3
+ */
4
+ import { nothing } from 'lit';
5
+
6
+ enum unitSizes {
7
+ 'bytes',
8
+ 'kilobytes',
9
+ 'megabytes',
10
+ 'gigabytes',
11
+ 'terabytes',
12
+ 'petabytes',
13
+ 'exabytes',
14
+ 'zettabytes',
15
+ 'yottabytes',
16
+ }
17
+
18
+ export function formatUnitSize(
19
+ size: number | undefined,
20
+ nDecimals: number,
21
+ separator: string = ' '
22
+ ) {
23
+ let itemSize = size;
24
+ if (itemSize === undefined) return nothing; // early return.
25
+
26
+ let unitIndex = 0;
27
+
28
+ // convert byte to highest possible unit
29
+ while (itemSize > 1024) {
30
+ itemSize /= 1024;
31
+ unitIndex += 1;
32
+ }
33
+
34
+ const magnitude = 10 ** nDecimals;
35
+ itemSize = Math.round(itemSize * magnitude) / magnitude;
36
+
37
+ let unitText = unitSizes[unitIndex];
38
+
39
+ // convert plural to singular.
40
+ unitText = itemSize === 1 ? unitText.slice(0, -1) : unitText;
41
+
42
+ return `${itemSize.toLocaleString() + separator + unitText}`;
43
+ }
@@ -21,6 +21,8 @@ const testBookModel: TileModel = {
21
21
  viewCount: 0,
22
22
  loginRequired: false,
23
23
  contentWarning: false,
24
+ collectionFilesCount: 0,
25
+ collectionSize: 0,
24
26
  };
25
27
 
26
28
  const testAudioModel: TileModel = {
@@ -36,6 +38,8 @@ const testAudioModel: TileModel = {
36
38
  viewCount: 0,
37
39
  loginRequired: false,
38
40
  contentWarning: false,
41
+ collectionFilesCount: 0,
42
+ collectionSize: 0,
39
43
  };
40
44
 
41
45
  describe('ItemImage component', () => {
@@ -0,0 +1,85 @@
1
+ /* eslint-disable import/no-duplicates */
2
+ import { expect, fixture } from '@open-wc/testing';
3
+ import { html } from 'lit';
4
+ import type { CollectionTile } from '../../../src/tiles/grid/collection-tile';
5
+
6
+ import '../../../src/tiles/grid/collection-tile';
7
+
8
+ describe('Collection Tile', () => {
9
+ it('should render initial component', async () => {
10
+ const el = await fixture<CollectionTile>(
11
+ html`<collection-tile></collection-tile>`
12
+ );
13
+
14
+ const itemInfo = el.shadowRoot?.querySelector('.item-info');
15
+ const itemImage = el.shadowRoot?.querySelector('image-block');
16
+ const itemStats = el.shadowRoot?.querySelector('#item-stats');
17
+
18
+ expect(itemInfo).to.exist;
19
+ expect(itemImage).to.exist;
20
+ expect(itemStats).to.exist;
21
+ });
22
+
23
+ it('should render with title element', async () => {
24
+ const el = await fixture<CollectionTile>(html`
25
+ <collection-tile
26
+ .model=${{
27
+ identifier: 'books',
28
+ title: 'Books',
29
+ itemCount: 121,
30
+ }}
31
+ >
32
+ </collection-tile>
33
+ `);
34
+ await el.updateComplete;
35
+
36
+ const itemInfo = el.shadowRoot?.querySelector('.item-info');
37
+ const itemTitle = el.shadowRoot?.querySelector('#title');
38
+
39
+ expect(itemInfo).to.exist;
40
+ expect(itemTitle).to.exist;
41
+ expect(itemTitle?.querySelector('.truncated')?.textContent).to.equal(
42
+ 'Books'
43
+ );
44
+ });
45
+
46
+ it('should render with image-block element', async () => {
47
+ const el = await fixture<CollectionTile>(html`
48
+ <collection-tile
49
+ .model=${{
50
+ identifier: '@jack-sparrow',
51
+ itemCount: 1233,
52
+ }}
53
+ >
54
+ </collection-tile>
55
+ `);
56
+ await el.updateComplete;
57
+
58
+ const itemImageBlock = el.shadowRoot?.querySelector('image-block');
59
+ expect(itemImageBlock).to.exist;
60
+ });
61
+
62
+ it('should render with item stats element', async () => {
63
+ const el = await fixture<CollectionTile>(html`
64
+ <collection-tile
65
+ .model=${{
66
+ identifier: '@jack-sparrow',
67
+ itemCount: 14521,
68
+ collectionSize: 23222543,
69
+ }}
70
+ >
71
+ </collection-tile>
72
+ `);
73
+ await el.updateComplete;
74
+
75
+ const itemStats = el.shadowRoot?.querySelector('#item-stats');
76
+ const itemMediaType = el.shadowRoot?.querySelector('#item-mediatype');
77
+ const itemCount = el.shadowRoot?.querySelector('#item-count');
78
+ const itemSize = el.shadowRoot?.querySelector('#item-size');
79
+
80
+ expect(itemStats).to.exist;
81
+ expect(itemMediaType).to.exist;
82
+ expect(itemCount).to.exist;
83
+ expect(itemSize).to.exist;
84
+ });
85
+ });