@internetarchive/collection-browser 0.2.5 → 0.2.6

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 (42) hide show
  1. package/dist/src/{tiles/grid → assets/img}/icons/favorite-filled.d.ts +0 -0
  2. package/dist/src/{tiles/grid → assets/img}/icons/favorite-filled.js +0 -0
  3. package/dist/src/{tiles/grid → assets/img}/icons/favorite-filled.js.map +1 -1
  4. package/dist/src/{tiles/grid → assets/img}/icons/reviews.d.ts +0 -0
  5. package/dist/src/{tiles/grid → assets/img}/icons/reviews.js +0 -0
  6. package/dist/src/{tiles/grid → assets/img}/icons/reviews.js.map +1 -1
  7. package/dist/src/{tiles/grid → assets/img}/icons/upload.d.ts +0 -0
  8. package/dist/src/{tiles/grid → assets/img}/icons/upload.js +0 -0
  9. package/dist/src/{tiles/grid → assets/img}/icons/upload.js.map +1 -1
  10. package/dist/src/assets/img/icons/views.d.ts +1 -0
  11. package/dist/src/{tiles/grid → assets/img}/icons/views.js +1 -1
  12. package/dist/src/assets/img/icons/views.js.map +1 -0
  13. package/dist/src/tiles/grid/account-tile.d.ts +1 -0
  14. package/dist/src/tiles/grid/account-tile.js +45 -78
  15. package/dist/src/tiles/grid/account-tile.js.map +1 -1
  16. package/dist/src/tiles/grid/item-tile.d.ts +1 -0
  17. package/dist/src/tiles/grid/item-tile.js +49 -122
  18. package/dist/src/tiles/grid/item-tile.js.map +1 -1
  19. package/dist/src/tiles/grid/tile-stats.d.ts +10 -0
  20. package/dist/src/tiles/grid/tile-stats.js +134 -0
  21. package/dist/src/tiles/grid/tile-stats.js.map +1 -0
  22. package/dist/src/tiles/mediatype-icon.js +4 -0
  23. package/dist/src/tiles/mediatype-icon.js.map +1 -1
  24. package/dist/test/tile-stats.test.d.ts +1 -0
  25. package/dist/test/tile-stats.test.js +42 -0
  26. package/dist/test/tile-stats.test.js.map +1 -0
  27. package/package.json +1 -1
  28. package/src/{tiles/grid → assets/img}/icons/favorite-filled.ts +0 -0
  29. package/src/{tiles/grid → assets/img}/icons/reviews.ts +0 -0
  30. package/src/{tiles/grid → assets/img}/icons/upload.ts +0 -0
  31. package/src/{tiles/grid → assets/img}/icons/views.ts +1 -1
  32. package/src/tiles/grid/account-tile.ts +44 -77
  33. package/src/tiles/grid/item-tile.ts +50 -123
  34. package/src/tiles/grid/tile-stats.ts +132 -0
  35. package/src/tiles/mediatype-icon.ts +4 -0
  36. package/test/tile-stats.test.ts +57 -0
  37. package/dist/src/tiles/grid/icons/account.d.ts +0 -1
  38. package/dist/src/tiles/grid/icons/account.js +0 -12
  39. package/dist/src/tiles/grid/icons/account.js.map +0 -1
  40. package/dist/src/tiles/grid/icons/views.d.ts +0 -2
  41. package/dist/src/tiles/grid/icons/views.js.map +0 -1
  42. package/src/tiles/grid/icons/account.ts +0 -12
@@ -0,0 +1,134 @@
1
+ import { __decorate } from "tslib";
2
+ import { css, html, LitElement } from 'lit';
3
+ import { customElement, property } from 'lit/decorators.js';
4
+ import { favoriteFilledIcon } from '../../assets/img/icons/favorite-filled';
5
+ import { reviewsIcon } from '../../assets/img/icons/reviews';
6
+ import { uploadIcon } from '../../assets/img/icons/upload';
7
+ import { viewsIcon } from '../../assets/img/icons/views';
8
+ import { formatCount } from '../../utils/format-count';
9
+ let TileStats = class TileStats extends LitElement {
10
+ render() {
11
+ return html `
12
+ <div class="item-stats">
13
+ <p class="sr-only">
14
+ ${this.mediatype === 'account' ? 'Account Stats' : 'Item Stats'}
15
+ </p>
16
+ <ul id="stats-row">
17
+ <li class="col">
18
+ <p class="sr-only">Mediatype:</p>
19
+ <mediatype-icon .mediatype=${this.mediatype}></mediatype-icon>
20
+ </li>
21
+ <li class="col">
22
+ ${this.mediatype === 'account' ? uploadIcon : viewsIcon}
23
+ <p class="status-text">
24
+ <span class="sr-only">
25
+ ${this.mediatype === 'account' ? 'Uploads:' : 'Views:'}
26
+ </span>
27
+ ${formatCount(this.mediatype === 'account' ? this.itemCount : this.viewCount, 'short', 'short')}
28
+ </p>
29
+ </li>
30
+ <li class="col">
31
+ ${favoriteFilledIcon}
32
+ <p class="status-text">
33
+ <span class="sr-only">Favorites:</span>
34
+ ${formatCount(this.favCount, 'short', 'short')}
35
+ </p>
36
+ </li>
37
+ <li class="col">
38
+ ${reviewsIcon}
39
+ <p class="status-text">
40
+ <span class="sr-only">Reviews:</span>
41
+ ${formatCount(this.commentCount, 'short', 'short')}
42
+ </p>
43
+ </li>
44
+ </ul>
45
+ </div>
46
+ `;
47
+ }
48
+ static get styles() {
49
+ return css `
50
+ mediatype-icon {
51
+ --iconHeight: 25px;
52
+ --iconWidth: 25px;
53
+ }
54
+
55
+ ul {
56
+ all: unset; // unset all property values
57
+ list-style-type: none; // remove default list-style
58
+ }
59
+
60
+ li {
61
+ list-style-type: none; // remove default list-style
62
+ }
63
+
64
+ .item-stats {
65
+ height: 35px;
66
+ }
67
+
68
+ #stats-row {
69
+ border-top: 1px solid #bbb;
70
+ align-items: center;
71
+ display: flex;
72
+ flex: 1;
73
+ justify-content: space-evenly;
74
+ text-align: center;
75
+ width: 100%;
76
+ padding-top: 5px;
77
+ padding-bottom: 5px;
78
+ }
79
+
80
+ .sr-only {
81
+ position: absolute;
82
+ width: 1px;
83
+ height: 1px;
84
+ padding: 0;
85
+ margin: -1px;
86
+ overflow: hidden;
87
+ clip: rect(0, 0, 0, 0);
88
+ border: 0;
89
+ }
90
+
91
+ .col {
92
+ width: 25%;
93
+ height: 25px;
94
+ }
95
+
96
+ svg {
97
+ height: 10px;
98
+ width: 10px;
99
+ display: block;
100
+ margin: auto;
101
+ }
102
+
103
+ .status-text {
104
+ font-size: 14px;
105
+ height: 15px;
106
+ color: #2c2c2c;
107
+ line-height: 20px;
108
+ margin: auto;
109
+ display: block;
110
+ text-align: center;
111
+ }
112
+ `;
113
+ }
114
+ };
115
+ __decorate([
116
+ property({ type: String })
117
+ ], TileStats.prototype, "mediatype", void 0);
118
+ __decorate([
119
+ property({ type: Number })
120
+ ], TileStats.prototype, "itemCount", void 0);
121
+ __decorate([
122
+ property({ type: Number })
123
+ ], TileStats.prototype, "viewCount", void 0);
124
+ __decorate([
125
+ property({ type: Number })
126
+ ], TileStats.prototype, "favCount", void 0);
127
+ __decorate([
128
+ property({ type: Number })
129
+ ], TileStats.prototype, "commentCount", void 0);
130
+ TileStats = __decorate([
131
+ customElement('tile-stats')
132
+ ], TileStats);
133
+ export { TileStats };
134
+ //# sourceMappingURL=tile-stats.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tile-stats.js","sourceRoot":"","sources":["../../../../src/tiles/grid/tile-stats.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAkB,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAEzD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAGvD,IAAa,SAAS,GAAtB,MAAa,SAAU,SAAQ,UAAU;IAWvC,MAAM;QACJ,OAAO,IAAI,CAAA;;;YAGH,IAAI,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,YAAY;;;;;yCAKhC,IAAI,CAAC,SAAS;;;cAGzC,IAAI,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS;;;kBAGjD,IAAI,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ;;gBAEtD,WAAW,CACX,IAAI,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,EAC9D,OAAO,EACP,OAAO,CACR;;;;cAID,kBAAkB;;;gBAGhB,WAAW,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC;;;;cAI9C,WAAW;;;gBAGT,WAAW,CAAC,IAAI,CAAC,YAAY,EAAE,OAAO,EAAE,OAAO,CAAC;;;;;KAK3D,CAAC;IACJ,CAAC;IAED,MAAM,KAAK,MAAM;QACf,OAAO,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA+DT,CAAC;IACJ,CAAC;CACF,CAAA;AAvH6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4CAAoB;AAEnB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4CAAoB;AAEnB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4CAAoB;AAEnB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2CAAmB;AAElB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;+CAAuB;AATvC,SAAS;IADrB,aAAa,CAAC,YAAY,CAAC;GACf,SAAS,CAwHrB;SAxHY,SAAS","sourcesContent":["import { css, CSSResultGroup, html, LitElement } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\n\nimport { favoriteFilledIcon } from '../../assets/img/icons/favorite-filled';\nimport { reviewsIcon } from '../../assets/img/icons/reviews';\nimport { uploadIcon } from '../../assets/img/icons/upload';\nimport { viewsIcon } from '../../assets/img/icons/views';\n\nimport { formatCount } from '../../utils/format-count';\n\n@customElement('tile-stats')\nexport class TileStats extends LitElement {\n @property({ type: String }) mediatype?: string;\n\n @property({ type: Number }) itemCount?: number;\n\n @property({ type: Number }) viewCount?: number;\n\n @property({ type: Number }) favCount?: number;\n\n @property({ type: Number }) commentCount?: number;\n\n render() {\n return html`\n <div class=\"item-stats\">\n <p class=\"sr-only\">\n ${this.mediatype === 'account' ? 'Account Stats' : 'Item Stats'}\n </p>\n <ul id=\"stats-row\">\n <li class=\"col\">\n <p class=\"sr-only\">Mediatype:</p>\n <mediatype-icon .mediatype=${this.mediatype}></mediatype-icon>\n </li>\n <li class=\"col\">\n ${this.mediatype === 'account' ? uploadIcon : viewsIcon}\n <p class=\"status-text\">\n <span class=\"sr-only\">\n ${this.mediatype === 'account' ? 'Uploads:' : 'Views:'}\n </span>\n ${formatCount(\n this.mediatype === 'account' ? this.itemCount : this.viewCount,\n 'short',\n 'short'\n )}\n </p>\n </li>\n <li class=\"col\">\n ${favoriteFilledIcon}\n <p class=\"status-text\">\n <span class=\"sr-only\">Favorites:</span>\n ${formatCount(this.favCount, 'short', 'short')}\n </p>\n </li>\n <li class=\"col\">\n ${reviewsIcon}\n <p class=\"status-text\">\n <span class=\"sr-only\">Reviews:</span>\n ${formatCount(this.commentCount, 'short', 'short')}\n </p>\n </li>\n </ul>\n </div>\n `;\n }\n\n static get styles(): CSSResultGroup {\n return css`\n mediatype-icon {\n --iconHeight: 25px;\n --iconWidth: 25px;\n }\n\n ul {\n all: unset; // unset all property values\n list-style-type: none; // remove default list-style\n }\n\n li {\n list-style-type: none; // remove default list-style\n }\n\n .item-stats {\n height: 35px;\n }\n\n #stats-row {\n border-top: 1px solid #bbb;\n align-items: center;\n display: flex;\n flex: 1;\n justify-content: space-evenly;\n text-align: center;\n width: 100%;\n padding-top: 5px;\n padding-bottom: 5px;\n }\n\n .sr-only {\n position: absolute;\n width: 1px;\n height: 1px;\n padding: 0;\n margin: -1px;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n border: 0;\n }\n\n .col {\n width: 25%;\n height: 25px;\n }\n\n svg {\n height: 10px;\n width: 10px;\n display: block;\n margin: auto;\n }\n\n .status-text {\n font-size: 14px;\n height: 15px;\n color: #2c2c2c;\n line-height: 20px;\n margin: auto;\n display: block;\n text-align: center;\n }\n `;\n }\n}\n"]}
@@ -39,6 +39,10 @@ let MediatypeIcon = class MediatypeIcon extends LitElement {
39
39
  }
40
40
  static get styles() {
41
41
  return css `
42
+ #icon {
43
+ height: var(--iconHeight, 25px);
44
+ }
45
+
42
46
  .status-text {
43
47
  font-size: 14px;
44
48
  color: #2c2c2c;
@@ -1 +1 @@
1
- {"version":3,"file":"mediatype-icon.js","sourceRoot":"","sources":["../../../src/tiles/mediatype-icon.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAkB,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE5D,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAGhE,IAAa,aAAa,GAA1B,MAAa,aAAc,SAAQ,UAAU;IAA7C;;QAK+B,aAAQ,GAAG,KAAK,CAAC;IA+DhD,CAAC;IA7DC,IAAY,gBAAgB;;QAC1B,MAAM,YAAY,GAAG,CAAC,QAAQ,EAAE,WAAW,EAAE,YAAY,CAAC,CAAC;QAC3D,MAAM,eAAe,GAAG,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;QAElD,IACE,IAAI,CAAC,SAAS,KAAK,QAAQ;aAC3B,MAAA,IAAI,CAAC,WAAW,0CAAE,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAA,EAC3D;YACA,OAAO,IAAI,CAAC;SACb;QACD,IACE,IAAI,CAAC,SAAS,KAAK,OAAO;aAC1B,MAAA,IAAI,CAAC,WAAW,0CAAE,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,eAAe,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAA,EAC9D;YACA,OAAO,OAAO,CAAC;SAChB;QACD,OAAO,IAAI,CAAC,SAAS,IAAI,EAAE,CAAC;IAC9B,CAAC;IAED,MAAM;QACJ,MAAM,MAAM,GAAG,eAAe,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;QACtD,IAAI,CAAC,MAAM,EAAE;YACX,OAAO,IAAI,CAAA,EAAE,CAAC;SACf;QAED,OAAO,IAAI,CAAA;;;iBAGE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW;kCACxB,MAAM,CAAC,KAAK;;UAEpC,MAAM,CAAC,IAAI;iCACY,MAAM,CAAC,IAAI;;KAEvC,CAAC;IACJ,CAAC;IAED,MAAM,KAAK,MAAM;QACf,OAAO,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;KAqBT,CAAC;IACJ,CAAC;CACF,CAAA;AAnE6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gDAA+B;AAE/B;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;kDAAmC;AAEhC;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;+CAAkB;AALnC,aAAa;IADzB,aAAa,CAAC,gBAAgB,CAAC;GACnB,aAAa,CAoEzB;SApEY,aAAa","sourcesContent":["import { css, CSSResultGroup, html, LitElement } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\n\nimport { mediatypeConfig } from '../mediatype/mediatype-config';\n\n@customElement('mediatype-icon')\nexport class MediatypeIcon extends LitElement {\n @property({ type: String }) mediatype: string | undefined;\n\n @property({ type: Array }) collections: string[] | undefined;\n\n @property({ type: Boolean }) showText = false;\n\n private get displayMediatype(): string {\n const tvIdentifier = ['tvnews', 'tvarchive', 'television'];\n const radioIdentifier = ['radio', 'radioprogram'];\n\n if (\n this.mediatype === 'movies' &&\n this.collections?.some(id => tvIdentifier.indexOf(id) >= 0)\n ) {\n return 'tv';\n }\n if (\n this.mediatype === 'audio' &&\n this.collections?.some(id => radioIdentifier.indexOf(id) >= 0)\n ) {\n return 'radio';\n }\n return this.mediatype || '';\n }\n\n render() {\n const config = mediatypeConfig[this.displayMediatype];\n if (!config) {\n return html``;\n }\n\n return html`\n <div\n id=\"icon\"\n class=\"${this.showText ? 'show-text' : 'hide-text'}\"\n style=\"--iconFillColor: ${config.color}\"\n >\n ${config.icon}\n <p class=\"status-text\">${config.text}</p>\n </div>\n `;\n }\n\n static get styles(): CSSResultGroup {\n return css`\n .status-text {\n font-size: 14px;\n color: #2c2c2c;\n margin: auto;\n display: block;\n text-align: var(--iconTextAlign, center);\n }\n\n #icon.hide-text p {\n display: none;\n }\n\n svg {\n height: var(--iconHeight, 10px);\n width: var(--iconWidth, 10px);\n }\n\n .fill-color {\n fill: var(--iconFillColor, '#000000');\n }\n `;\n }\n}\n"]}
1
+ {"version":3,"file":"mediatype-icon.js","sourceRoot":"","sources":["../../../src/tiles/mediatype-icon.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAkB,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE5D,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAGhE,IAAa,aAAa,GAA1B,MAAa,aAAc,SAAQ,UAAU;IAA7C;;QAK+B,aAAQ,GAAG,KAAK,CAAC;IAmEhD,CAAC;IAjEC,IAAY,gBAAgB;;QAC1B,MAAM,YAAY,GAAG,CAAC,QAAQ,EAAE,WAAW,EAAE,YAAY,CAAC,CAAC;QAC3D,MAAM,eAAe,GAAG,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;QAElD,IACE,IAAI,CAAC,SAAS,KAAK,QAAQ;aAC3B,MAAA,IAAI,CAAC,WAAW,0CAAE,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAA,EAC3D;YACA,OAAO,IAAI,CAAC;SACb;QACD,IACE,IAAI,CAAC,SAAS,KAAK,OAAO;aAC1B,MAAA,IAAI,CAAC,WAAW,0CAAE,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,eAAe,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAA,EAC9D;YACA,OAAO,OAAO,CAAC;SAChB;QACD,OAAO,IAAI,CAAC,SAAS,IAAI,EAAE,CAAC;IAC9B,CAAC;IAED,MAAM;QACJ,MAAM,MAAM,GAAG,eAAe,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;QACtD,IAAI,CAAC,MAAM,EAAE;YACX,OAAO,IAAI,CAAA,EAAE,CAAC;SACf;QAED,OAAO,IAAI,CAAA;;;iBAGE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW;kCACxB,MAAM,CAAC,KAAK;;UAEpC,MAAM,CAAC,IAAI;iCACY,MAAM,CAAC,IAAI;;KAEvC,CAAC;IACJ,CAAC;IAED,MAAM,KAAK,MAAM;QACf,OAAO,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;KAyBT,CAAC;IACJ,CAAC;CACF,CAAA;AAvE6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gDAA+B;AAE/B;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;kDAAmC;AAEhC;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;+CAAkB;AALnC,aAAa;IADzB,aAAa,CAAC,gBAAgB,CAAC;GACnB,aAAa,CAwEzB;SAxEY,aAAa","sourcesContent":["import { css, CSSResultGroup, html, LitElement } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\n\nimport { mediatypeConfig } from '../mediatype/mediatype-config';\n\n@customElement('mediatype-icon')\nexport class MediatypeIcon extends LitElement {\n @property({ type: String }) mediatype: string | undefined;\n\n @property({ type: Array }) collections: string[] | undefined;\n\n @property({ type: Boolean }) showText = false;\n\n private get displayMediatype(): string {\n const tvIdentifier = ['tvnews', 'tvarchive', 'television'];\n const radioIdentifier = ['radio', 'radioprogram'];\n\n if (\n this.mediatype === 'movies' &&\n this.collections?.some(id => tvIdentifier.indexOf(id) >= 0)\n ) {\n return 'tv';\n }\n if (\n this.mediatype === 'audio' &&\n this.collections?.some(id => radioIdentifier.indexOf(id) >= 0)\n ) {\n return 'radio';\n }\n return this.mediatype || '';\n }\n\n render() {\n const config = mediatypeConfig[this.displayMediatype];\n if (!config) {\n return html``;\n }\n\n return html`\n <div\n id=\"icon\"\n class=\"${this.showText ? 'show-text' : 'hide-text'}\"\n style=\"--iconFillColor: ${config.color}\"\n >\n ${config.icon}\n <p class=\"status-text\">${config.text}</p>\n </div>\n `;\n }\n\n static get styles(): CSSResultGroup {\n return css`\n #icon {\n height: var(--iconHeight, 25px);\n }\n\n .status-text {\n font-size: 14px;\n color: #2c2c2c;\n margin: auto;\n display: block;\n text-align: var(--iconTextAlign, center);\n }\n\n #icon.hide-text p {\n display: none;\n }\n\n svg {\n height: var(--iconHeight, 10px);\n width: var(--iconWidth, 10px);\n }\n\n .fill-color {\n fill: var(--iconFillColor, '#000000');\n }\n `;\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ import '../src/tiles/grid/tile-stats';
@@ -0,0 +1,42 @@
1
+ /* eslint-disable import/no-duplicates */
2
+ import { expect, fixture } from '@open-wc/testing';
3
+ import { html } from 'lit';
4
+ import '../src/tiles/grid/tile-stats';
5
+ describe('Tile Stats', () => {
6
+ it('should render initial component', async () => {
7
+ var _a, _b;
8
+ const el = await fixture(html `<tile-stats></tile-stats>`);
9
+ const itemStats = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('.item-stats');
10
+ const statsRow = (_b = el.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('#stats-row');
11
+ const statsRowCount = statsRow === null || statsRow === void 0 ? void 0 : statsRow.childElementCount;
12
+ expect(itemStats).to.exist;
13
+ expect(statsRow).to.exist;
14
+ expect(statsRowCount).to.equal(4);
15
+ });
16
+ it('should render component with value', async () => {
17
+ var _a, _b, _c, _d, _e, _f, _g;
18
+ const el = await fixture(html `
19
+ <tile-stats
20
+ .mediatype=${'account'}
21
+ .itemCount=${1}
22
+ .favCount=${2}
23
+ .commentCount=${3}
24
+ >
25
+ </tile-stats>
26
+ `);
27
+ const statsRow = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('#stats-row');
28
+ const mediatypeStat = statsRow === null || statsRow === void 0 ? void 0 : statsRow.children.item(0);
29
+ // get second column item in stats row
30
+ const itemStatCount = (_c = (_b = statsRow === null || statsRow === void 0 ? void 0 : statsRow.children.item(1)) === null || _b === void 0 ? void 0 : _b.querySelector('.status-text')) === null || _c === void 0 ? void 0 : _c.textContent;
31
+ // get third column item in stats row
32
+ const favoritesStatCount = (_e = (_d = statsRow === null || statsRow === void 0 ? void 0 : statsRow.children.item(2)) === null || _d === void 0 ? void 0 : _d.querySelector('.status-text')) === null || _e === void 0 ? void 0 : _e.textContent;
33
+ // get fourth column item in stats row
34
+ const reviewsStatCount = (_g = (_f = statsRow === null || statsRow === void 0 ? void 0 : statsRow.children.item(3)) === null || _f === void 0 ? void 0 : _f.querySelector('.status-text')) === null || _g === void 0 ? void 0 : _g.textContent;
35
+ expect(mediatypeStat).to.exist;
36
+ // Snapshot testing - reference: https://open-wc.org/docs/testing/semantic-dom-diff/#snapshot-testing
37
+ expect(itemStatCount).to.equalSnapshot(1);
38
+ expect(favoritesStatCount).to.equalSnapshot(2);
39
+ expect(reviewsStatCount).to.equalSnapshot(3);
40
+ });
41
+ });
42
+ //# sourceMappingURL=tile-stats.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tile-stats.test.js","sourceRoot":"","sources":["../../test/tile-stats.test.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAG3B,OAAO,8BAA8B,CAAC;AAEtC,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;IAC1B,EAAE,CAAC,iCAAiC,EAAE,KAAK,IAAI,EAAE;;QAC/C,MAAM,EAAE,GAAG,MAAM,OAAO,CAAY,IAAI,CAAA,2BAA2B,CAAC,CAAC;QAErE,MAAM,SAAS,GAAG,MAAA,EAAE,CAAC,UAAU,0CAAE,aAAa,CAAC,aAAa,CAAC,CAAC;QAC9D,MAAM,QAAQ,GAAG,MAAA,EAAE,CAAC,UAAU,0CAAE,aAAa,CAAC,YAAY,CAAC,CAAC;QAC5D,MAAM,aAAa,GAAG,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,iBAAiB,CAAC;QAElD,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC;QAC3B,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC;QAC1B,MAAM,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,oCAAoC,EAAE,KAAK,IAAI,EAAE;;QAClD,MAAM,EAAE,GAAG,MAAM,OAAO,CACtB,IAAI,CAAA;;uBAEa,SAAS;uBACT,CAAC;sBACF,CAAC;0BACG,CAAC;;;OAGpB,CACF,CAAC;QAEF,MAAM,QAAQ,GAAG,MAAA,EAAE,CAAC,UAAU,0CAAE,aAAa,CAAC,YAAY,CAAC,CAAC;QAE5D,MAAM,aAAa,GAAG,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACjD,sCAAsC;QACtC,MAAM,aAAa,GAAG,MAAA,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,QAAQ,CACrC,IAAI,CAAC,CAAC,CAAC,0CACN,aAAa,CAAC,cAAc,CAAC,0CAAE,WAAW,CAAC;QAC/C,qCAAqC;QACrC,MAAM,kBAAkB,GAAG,MAAA,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,QAAQ,CAC1C,IAAI,CAAC,CAAC,CAAC,0CACN,aAAa,CAAC,cAAc,CAAC,0CAAE,WAAW,CAAC;QAC/C,sCAAsC;QACtC,MAAM,gBAAgB,GAAG,MAAA,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,QAAQ,CACxC,IAAI,CAAC,CAAC,CAAC,0CACN,aAAa,CAAC,cAAc,CAAC,0CAAE,WAAW,CAAC;QAE/C,MAAM,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC;QAE/B,qGAAqG;QACrG,MAAM,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;QAC1C,MAAM,CAAC,kBAAkB,CAAC,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;QAC/C,MAAM,CAAC,gBAAgB,CAAC,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IAC/C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["/* eslint-disable import/no-duplicates */\nimport { expect, fixture } from '@open-wc/testing';\nimport { html } from 'lit';\nimport { TileStats } from '../src/tiles/grid/tile-stats';\n\nimport '../src/tiles/grid/tile-stats';\n\ndescribe('Tile Stats', () => {\n it('should render initial component', async () => {\n const el = await fixture<TileStats>(html`<tile-stats></tile-stats>`);\n\n const itemStats = el.shadowRoot?.querySelector('.item-stats');\n const statsRow = el.shadowRoot?.querySelector('#stats-row');\n const statsRowCount = statsRow?.childElementCount;\n\n expect(itemStats).to.exist;\n expect(statsRow).to.exist;\n expect(statsRowCount).to.equal(4);\n });\n\n it('should render component with value', async () => {\n const el = await fixture<TileStats>(\n html`\n <tile-stats\n .mediatype=${'account'}\n .itemCount=${1}\n .favCount=${2}\n .commentCount=${3}\n >\n </tile-stats>\n `\n );\n\n const statsRow = el.shadowRoot?.querySelector('#stats-row');\n\n const mediatypeStat = statsRow?.children.item(0);\n // get second column item in stats row\n const itemStatCount = statsRow?.children\n .item(1)\n ?.querySelector('.status-text')?.textContent;\n // get third column item in stats row\n const favoritesStatCount = statsRow?.children\n .item(2)\n ?.querySelector('.status-text')?.textContent;\n // get fourth column item in stats row\n const reviewsStatCount = statsRow?.children\n .item(3)\n ?.querySelector('.status-text')?.textContent;\n\n expect(mediatypeStat).to.exist;\n\n // Snapshot testing - reference: https://open-wc.org/docs/testing/semantic-dom-diff/#snapshot-testing\n expect(itemStatCount).to.equalSnapshot(1);\n expect(favoritesStatCount).to.equalSnapshot(2);\n expect(reviewsStatCount).to.equalSnapshot(3);\n });\n});\n"]}
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "The Internet Archive Collection Browser.",
4
4
  "license": "AGPL-3.0-only",
5
5
  "author": "Internet Archive",
6
- "version": "0.2.5",
6
+ "version": "0.2.6",
7
7
  "main": "dist/index.js",
8
8
  "module": "dist/index.js",
9
9
  "scripts": {
File without changes
File without changes
@@ -1,6 +1,6 @@
1
1
  import { svg } from 'lit';
2
2
 
3
- export default svg`
3
+ export const viewsIcon = svg`
4
4
  <svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
5
5
  <path
6
6
  d="m98 50.5704143c-.2830293-.471515-.671154-1.1088947-1.1643742-1.9121392s-1.6003642-2.3617474-3.3214321-4.6755089c-1.7210678-2.3137614-3.522258-4.5325939-5.4035703-6.6564975-1.8813124-2.1239037-4.2828993-4.473133-7.2047606-7.0476881-2.9218612-2.5745551-5.8895067-4.7933876-8.9029363-6.6564976-3.0134295-1.86311-6.4628491-3.4330878-10.3482587-4.7099336-3.8854095-1.2768458-7.7822651-1.9142256-11.6905667-1.9121443-3.9083017.0020914-7.8051573.6154781-11.6905668 1.8401652-3.8854096 1.2246871-7.3702078 2.8301329-10.4543947 4.8163375-3.0841869 1.9862045-6.0278997 4.1695691-8.8311384 6.5500937s-5.2048256 4.7652219-7.2047605 7.1540919c-1.99993501 2.38887-3.75430043 4.5722346-5.26309632 6.5500938s-2.63883199 3.583305-3.39010829 4.8163374l-1.13003609 1.8401602c.2830293.4715149.67115403 1.1088946 1.16437421 1.9121391.49322017.8032445 1.5878776 2.3617475 3.28397229 4.6755089s3.47439274 4.521119 5.3348942 6.6220728c1.8605014 2.1009538 4.2506422 4.4387083 7.1704224 7.0132633 2.9197801 2.5745551 5.8874256 4.7819127 8.9029363 6.6220729 3.0155106 1.8401601 6.4774168 3.398663 10.3857184 4.6755088 3.9083017 1.2768458 7.8176438 1.9142256 11.7280266 1.9121443 3.9103827-.0020914 7.7957922-.6154781 11.6562286-1.8401652s7.3337886-2.818658 10.4200566-4.7819127 6.0299808-4.1351444 8.8311384-6.515669 5.2152311-4.7652219 7.2422203-7.1540919 3.8052873-4.5607597 5.3348942-6.515669c1.5296068-1.9549093 2.6721295-3.5488802 3.427568-4.7819127zm-24.5142913 0c0 6.467683-2.3079374 12.0152859-6.9238123 16.6428087s-10.1495139 6.9412843-16.600917 6.9412843c-6.4992683 0-12.0453939-2.3137615-16.6383767-6.9412843s-6.8894742-10.1751257-6.8894742-16.6428087 2.2964914-12.003811 6.8894742-16.608384 10.1391084-6.9068595 16.6383767-6.9068595c6.4534842 0 11.9871232 2.3022865 16.600917 6.9068595s6.9217312 10.140701 6.9238123 16.608384zm-23.5247293-10.552755c2.8261308 0 5.2870289 1.0619518 7.3826944 3.1858555 2.0956655 2.1239036 3.1434982 4.5795368 3.1434982 7.3668995 0 2.8332624-1.0478327 5.2888956-3.1434982 7.3668995-2.0956655 2.078004-4.5565636 3.1170059-7.3826944 3.1170059-2.873996 0-5.3348941-1.0264838-7.3826944-3.0794516-2.0478002-2.0529677-3.0717003-4.5200758-3.0717003-7.4013243 0-2.8332624 1.0239001-5.3003705 3.0717003-7.4013243 2.0478003-2.1009538 4.5086984-3.1514307 7.3826944-3.1514307z"
@@ -2,10 +2,7 @@ import { css, html, LitElement } from 'lit';
2
2
  import { customElement, property } from 'lit/decorators.js';
3
3
  import { TileModel } from '../../models';
4
4
 
5
- import { accountIcon } from './icons/account';
6
- import { favoriteFilledIcon } from './icons/favorite-filled';
7
- import { reviewsIcon } from './icons/reviews';
8
- import { uploadIcon } from './icons/upload';
5
+ import './tile-stats';
9
6
 
10
7
  @customElement('account-tile')
11
8
  export class AccountTile extends LitElement {
@@ -13,44 +10,32 @@ export class AccountTile extends LitElement {
13
10
 
14
11
  render() {
15
12
  return html`
16
- <div class="outer-holder">
17
- <div class="inner-holder">
18
- <div id="header-holder">
19
- <div id="title-holder">
20
- <h1 class="truncated">${this.model?.identifier}</h1>
21
- </div>
22
- <div id="avatar-holder">
23
- <div
24
- id="avatar"
25
- style="background-image: url('https://archive.org/services/img/${this
26
- .model?.identifier}')"
27
- ></div>
28
- </div>
29
- </div>
30
- <div id="year-holder">
31
- <div id="archivist-since">
32
- <h3>Archivist Since</h3>
33
- </div>
34
- <div id="year-holder">
35
- <h3>${this.model?.dateAdded?.getFullYear()}</h3>
36
- </div>
37
- </div>
38
- <div id="status-holder">
39
- <div id="patron-icon">${accountIcon}</div>
40
- <div class="stat-icon">
41
- ${uploadIcon}
42
- <h3>${this.model?.itemCount}</h3>
43
- </div>
44
- <div class="stat-icon">
45
- ${favoriteFilledIcon}
46
- <h3>${this.model?.favCount}</h3>
47
- </div>
48
- <div class="stat-icon">
49
- ${reviewsIcon}
50
- <h3>${this.model?.commentCount}</h3>
51
- </div>
13
+ <div class="account-tile-main">
14
+ <div id="title">
15
+ <h1 class="truncated">${this.model?.identifier}</h1>
16
+ </div>
17
+
18
+ <div class="account-info">
19
+ <div id="avatar-info">
20
+ <img
21
+ id="avatar"
22
+ alt="patron-avatar"
23
+ src="https://archive.org/services/img/${this.model?.identifier}"
24
+ />
52
25
  </div>
26
+
27
+ <span id="archivist-since">
28
+ Archivist since ${this.model?.dateAdded?.getFullYear()}
29
+ </span>
53
30
  </div>
31
+
32
+ <tile-stats
33
+ .mediatype=${this.model?.mediatype}
34
+ .itemCount=${this.model?.itemCount}
35
+ .favCount=${this.model?.favCount}
36
+ .commentCount=${this.model?.commentCount}
37
+ >
38
+ </tile-stats>
54
39
  </div>
55
40
  `;
56
41
  }
@@ -63,41 +48,45 @@ export class AccountTile extends LitElement {
63
48
  margin: 0;
64
49
  }
65
50
 
66
- h3 {
51
+ span {
67
52
  font-size: 14px;
68
- font-weight: bold;
69
53
  color: #2c2c2c;
70
54
  margin: 0px;
71
55
  }
72
56
 
73
- .outer-holder {
57
+ .account-tile-main {
74
58
  background-color: #fcf5e6;
75
59
  border: 1px #2c2c2c;
76
60
  border-radius: 4px;
77
61
  box-shadow: 1px 1px 2px 0px;
78
62
  height: 100%;
79
63
  display: flex;
64
+ flex-direction: column;
80
65
  text-align: center;
81
66
  width: 100%;
82
67
  }
83
68
 
84
- .inner-holder {
85
- padding: 5px;
86
- width: 100%;
87
- display: flex;
88
- flex-direction: column;
69
+ .account-info {
70
+ flex-grow: 1;
89
71
  }
90
72
 
91
- #header-holder {
92
- flex: 1;
73
+ #title {
74
+ padding: 5px 5px 0px 5px;
75
+ flex-shrink: 0;
76
+ height: 40px;
93
77
  }
94
78
 
95
- #title-holder {
96
- height: 40px;
97
- margin-bottom: 5px;
79
+ .account-tile-main:hover > #title > .truncated {
80
+ text-decoration: underline;
81
+ }
82
+
83
+ /** this is a workaround for Safari 15 where the hover effects are not working */
84
+ #title:hover > .truncated {
85
+ text-decoration: underline;
98
86
  }
99
87
 
100
- #avatar-holder {
88
+ #avatar-info {
89
+ margin-top: 5px;
101
90
  margin-bottom: 5px;
102
91
  display: flex;
103
92
  align-items: center;
@@ -112,27 +101,11 @@ export class AccountTile extends LitElement {
112
101
  box-shadow: 1px 1px 2px #888888;
113
102
  }
114
103
 
115
- #year-holder {
104
+ #archivist-since {
116
105
  margin-bottom: 5px;
117
106
  height: 40px;
118
107
  }
119
108
 
120
- #year-holder {
121
- margin: 0px;
122
- }
123
-
124
- #status-holder {
125
- height: 25px;
126
- display: flex;
127
- justify-content: space-evenly;
128
- line-height: initial;
129
- }
130
-
131
- #patron-icon {
132
- height: 25px;
133
- width: 25px;
134
- }
135
-
136
109
  .truncated {
137
110
  flex: 1;
138
111
  min-width: 0; /* Important for long words! */
@@ -142,15 +115,9 @@ export class AccountTile extends LitElement {
142
115
  display: -webkit-box;
143
116
  -webkit-box-orient: vertical;
144
117
  word-wrap: break-word;
145
- word-break: break-all;
146
118
  line-height: 2rem;
147
119
  text-align: center;
148
120
  }
149
-
150
- .stat-icon {
151
- height: 10px;
152
- width: 10px;
153
- }
154
121
  `;
155
122
  }
156
123
  }