@internetarchive/collection-browser 2.12.2 → 2.12.3-alpha-webdev7452.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.
Files changed (51) hide show
  1. package/dist/src/assets/img/icons/mediatype/tv-commercial.d.ts +1 -0
  2. package/dist/src/assets/img/icons/mediatype/tv-commercial.js +12 -0
  3. package/dist/src/assets/img/icons/mediatype/tv-commercial.js.map +1 -0
  4. package/dist/src/assets/img/icons/mediatype/tv-fact-check.d.ts +1 -0
  5. package/dist/src/assets/img/icons/mediatype/tv-fact-check.js +12 -0
  6. package/dist/src/assets/img/icons/mediatype/tv-fact-check.js.map +1 -0
  7. package/dist/src/assets/img/icons/mediatype/tv-quote.d.ts +1 -0
  8. package/dist/src/assets/img/icons/mediatype/tv-quote.js +12 -0
  9. package/dist/src/assets/img/icons/mediatype/tv-quote.js.map +1 -0
  10. package/dist/src/collection-browser.js +1 -1
  11. package/dist/src/collection-browser.js.map +1 -1
  12. package/dist/src/collection-facets/smart-facets/smart-facet-button.js +1 -1
  13. package/dist/src/collection-facets/smart-facets/smart-facet-button.js.map +1 -1
  14. package/dist/src/data-source/collection-browser-data-source.js +3 -3
  15. package/dist/src/data-source/collection-browser-data-source.js.map +1 -1
  16. package/dist/src/mediatype/mediatype-config.d.ts +10 -2
  17. package/dist/src/mediatype/mediatype-config.js +24 -1
  18. package/dist/src/mediatype/mediatype-config.js.map +1 -1
  19. package/dist/src/models.d.ts +2 -1
  20. package/dist/src/models.js +3 -1
  21. package/dist/src/models.js.map +1 -1
  22. package/dist/src/tiles/grid/tile-stats.d.ts +4 -0
  23. package/dist/src/tiles/grid/tile-stats.js +13 -1
  24. package/dist/src/tiles/grid/tile-stats.js.map +1 -1
  25. package/dist/src/tiles/list/tile-list-compact.js +3 -2
  26. package/dist/src/tiles/list/tile-list-compact.js.map +1 -1
  27. package/dist/src/tiles/list/tile-list.js +2 -1
  28. package/dist/src/tiles/list/tile-list.js.map +1 -1
  29. package/dist/src/tiles/mediatype-icon.d.ts +19 -2
  30. package/dist/src/tiles/mediatype-icon.js +45 -10
  31. package/dist/src/tiles/mediatype-icon.js.map +1 -1
  32. package/dist/test/mediatype-config.test.js +0 -6
  33. package/dist/test/mediatype-config.test.js.map +1 -1
  34. package/dist/test/tiles/mediatype-icon.test.d.ts +1 -0
  35. package/dist/test/tiles/mediatype-icon.test.js +88 -0
  36. package/dist/test/tiles/mediatype-icon.test.js.map +1 -0
  37. package/package.json +1 -1
  38. package/src/assets/img/icons/mediatype/tv-commercial.ts +12 -0
  39. package/src/assets/img/icons/mediatype/tv-fact-check.ts +12 -0
  40. package/src/assets/img/icons/mediatype/tv-quote.ts +12 -0
  41. package/src/collection-browser.ts +1 -1
  42. package/src/collection-facets/smart-facets/smart-facet-button.ts +5 -2
  43. package/src/data-source/collection-browser-data-source.ts +3 -1
  44. package/src/mediatype/mediatype-config.ts +55 -2
  45. package/src/models.ts +5 -1
  46. package/src/tiles/grid/tile-stats.ts +11 -1
  47. package/src/tiles/list/tile-list-compact.ts +1 -0
  48. package/src/tiles/list/tile-list.ts +1 -0
  49. package/src/tiles/mediatype-icon.ts +52 -16
  50. package/test/mediatype-config.test.ts +0 -7
  51. package/test/tiles/mediatype-icon.test.ts +97 -0
@@ -1,25 +1,57 @@
1
1
  import { __decorate } from "tslib";
2
2
  import { css, html, LitElement } from 'lit';
3
3
  import { customElement, property } from 'lit/decorators.js';
4
- import { mediatypeConfig } from '../mediatype/mediatype-config';
4
+ import { mediatypeConfig, } from '../mediatype/mediatype-config';
5
+ const TV_COMMERCIAL_COLLECTION = 'tv_ads';
6
+ const TV_FACT_CHECK_COLLECTION = 'factchecked';
7
+ const TV_TOP_LEVEL_COLLECTIONS = new Set(['tvnews', 'tvarchive']);
8
+ const RADIO_TOP_LEVEL_COLLECTIONS = new Set(['radio', 'radioprogram']);
5
9
  let MediatypeIcon = class MediatypeIcon extends LitElement {
6
10
  constructor() {
7
11
  super(...arguments);
12
+ this.isTvSearchResult = false;
8
13
  this.showText = false;
9
14
  }
15
+ /**
16
+ * Returns the appropriate mediatype config key for the current mediatype/collections.
17
+ */
10
18
  get displayMediatype() {
19
+ var _a;
20
+ if (this.isTvItem)
21
+ return this.tvDisplayMediatype;
22
+ if (this.isRadioItem)
23
+ return 'radio';
24
+ return (_a = this.mediatype) !== null && _a !== void 0 ? _a : 'none';
25
+ }
26
+ /**
27
+ * Returns the appropriate TV mediatype, depending on the current collections.
28
+ */
29
+ get tvDisplayMediatype() {
11
30
  var _a, _b;
12
- const tvIdentifier = ['tvnews', 'tvarchive', 'television'];
13
- const radioIdentifier = ['radio', 'radioprogram'];
14
- if (this.mediatype === 'movies' &&
15
- ((_a = this.collections) === null || _a === void 0 ? void 0 : _a.some(id => tvIdentifier.indexOf(id) >= 0))) {
16
- return 'tv';
31
+ if ((_a = this.collections) === null || _a === void 0 ? void 0 : _a.includes(TV_COMMERCIAL_COLLECTION)) {
32
+ return 'tvCommercial';
17
33
  }
18
- if (this.mediatype === 'audio' &&
19
- ((_b = this.collections) === null || _b === void 0 ? void 0 : _b.some(id => radioIdentifier.indexOf(id) >= 0))) {
20
- return 'radio';
34
+ else if (this.isTvSearchResult &&
35
+ ((_b = this.collections) === null || _b === void 0 ? void 0 : _b.includes(TV_FACT_CHECK_COLLECTION))) {
36
+ return 'tvFactCheck';
21
37
  }
22
- return this.mediatype || '';
38
+ return 'tv';
39
+ }
40
+ /**
41
+ * Whether this represents a TV item
42
+ */
43
+ get isTvItem() {
44
+ var _a;
45
+ return (this.mediatype === 'movies' &&
46
+ !!((_a = this.collections) === null || _a === void 0 ? void 0 : _a.some(id => TV_TOP_LEVEL_COLLECTIONS.has(id))));
47
+ }
48
+ /**
49
+ * Whether this represents a radio item
50
+ */
51
+ get isRadioItem() {
52
+ var _a;
53
+ return (this.mediatype === 'audio' &&
54
+ !!((_a = this.collections) === null || _a === void 0 ? void 0 : _a.some(id => RADIO_TOP_LEVEL_COLLECTIONS.has(id))));
23
55
  }
24
56
  render() {
25
57
  const config = mediatypeConfig[this.displayMediatype];
@@ -74,6 +106,9 @@ __decorate([
74
106
  __decorate([
75
107
  property({ type: Array })
76
108
  ], MediatypeIcon.prototype, "collections", void 0);
109
+ __decorate([
110
+ property({ type: Boolean })
111
+ ], MediatypeIcon.prototype, "isTvSearchResult", void 0);
77
112
  __decorate([
78
113
  property({ type: Boolean })
79
114
  ], MediatypeIcon.prototype, "showText", void 0);
@@ -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;AAGzD,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,UAAU;IAAtC;;QAKwB,aAAQ,GAAG,KAAK,CAAC;IAqEhD,CAAC;IAnEC,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,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC;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,CAAC;YACD,OAAO,OAAO,CAAC;QACjB,CAAC;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,CAAC;YACZ,OAAO,IAAI,CAAA,EAAE,CAAC;QAChB,CAAC;QAED,OAAO,IAAI,CAAA;;;iBAGE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW;iBACzC,MAAM,CAAC,IAAI;kCACM,MAAM,CAAC,KAAK;;UAEpC,MAAM,CAAC,IAAI;iCACY,MAAM,CAAC,IAAI;;KAEvC,CAAC;IACJ,CAAC;IAED,MAAM,KAAK,MAAM;QACf,OAAO,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;KA0BT,CAAC;IACJ,CAAC;CACF,CAAA;AAzE6B;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,CA0EzB","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 title=\"${config.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 pointer-events: none;\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,EACL,eAAe,GAEhB,MAAM,+BAA+B,CAAC;AAEvC,MAAM,wBAAwB,GAAG,QAAQ,CAAC;AAC1C,MAAM,wBAAwB,GAAG,aAAa,CAAC;AAC/C,MAAM,wBAAwB,GAAG,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC,CAAC;AAClE,MAAM,2BAA2B,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC;AAGhE,IAAM,aAAa,GAAnB,MAAM,aAAc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AAC;QACtD,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,OAAO,IAAI,CAAA,EAAE,CAAC;QAChB,CAAC;QAED,OAAO,IAAI,CAAA;;;iBAGE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW;iBACzC,MAAM,CAAC,IAAI;kCACM,MAAM,CAAC,KAAK;;UAEpC,MAAM,CAAC,IAAI;iCACY,MAAM,CAAC,IAAI;;KAEvC,CAAC;IACJ,CAAC;IAED,MAAM,KAAK,MAAM;QACf,OAAO,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;KA0BT,CAAC;IACJ,CAAC;CACF,CAAA;AArG6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gDAAgC;AAEhC;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;kDAAwB;AAErB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;uDAA0B;AAEzB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;+CAAkB;AAPnC,aAAa;IADzB,aAAa,CAAC,gBAAgB,CAAC;GACnB,aAAa,CAsGzB","sourcesContent":["import { css, CSSResultGroup, html, LitElement } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\n\nimport {\n mediatypeConfig,\n MediatypeConfigKey,\n} from '../mediatype/mediatype-config';\n\nconst TV_COMMERCIAL_COLLECTION = 'tv_ads';\nconst TV_FACT_CHECK_COLLECTION = 'factchecked';\nconst TV_TOP_LEVEL_COLLECTIONS = new Set(['tvnews', 'tvarchive']);\nconst RADIO_TOP_LEVEL_COLLECTIONS = new Set(['radio', 'radioprogram']);\n\n@customElement('mediatype-icon')\nexport class MediatypeIcon extends LitElement {\n @property({ type: String }) mediatype?: MediatypeConfigKey;\n\n @property({ type: Array }) collections?: string[];\n\n @property({ type: Boolean }) isTvSearchResult = false;\n\n @property({ type: Boolean }) showText = false;\n\n /**\n * Returns the appropriate mediatype config key for the current mediatype/collections.\n */\n private get displayMediatype(): MediatypeConfigKey {\n if (this.isTvItem) return this.tvDisplayMediatype;\n if (this.isRadioItem) return 'radio';\n return this.mediatype ?? 'none';\n }\n\n /**\n * Returns the appropriate TV mediatype, depending on the current collections.\n */\n private get tvDisplayMediatype(): MediatypeConfigKey {\n if (this.collections?.includes(TV_COMMERCIAL_COLLECTION)) {\n return 'tvCommercial';\n } else if (\n this.isTvSearchResult &&\n this.collections?.includes(TV_FACT_CHECK_COLLECTION)\n ) {\n return 'tvFactCheck';\n }\n\n return 'tv';\n }\n\n /**\n * Whether this represents a TV item\n */\n private get isTvItem(): boolean {\n return (\n this.mediatype === 'movies' &&\n !!this.collections?.some(id => TV_TOP_LEVEL_COLLECTIONS.has(id))\n );\n }\n\n /**\n * Whether this represents a radio item\n */\n private get isRadioItem(): boolean {\n return (\n this.mediatype === 'audio' &&\n !!this.collections?.some(id => RADIO_TOP_LEVEL_COLLECTIONS.has(id))\n );\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 title=\"${config.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 pointer-events: none;\n }\n\n .fill-color {\n fill: var(--iconFillColor, '#000000');\n }\n `;\n }\n}\n"]}
@@ -1,12 +1,6 @@
1
1
  import { expect } from '@open-wc/testing';
2
2
  import { mediatypeConfig } from '../src/mediatype/mediatype-config';
3
3
  describe('mediatypeConfig', () => {
4
- it('returns undefined', () => {
5
- expect(mediatypeConfig['']).to.equal(undefined);
6
- expect(mediatypeConfig.test).to.equal(undefined);
7
- expect(mediatypeConfig.media).to.equal(undefined);
8
- expect(mediatypeConfig.testing).to.equal(undefined);
9
- });
10
4
  it('returns audio', () => {
11
5
  expect(mediatypeConfig.audio).to.exist;
12
6
  expect(mediatypeConfig.audio.color).to.exist;
@@ -1 +1 @@
1
- {"version":3,"file":"mediatype-config.test.js","sourceRoot":"","sources":["../../test/mediatype-config.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AAEpE,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,EAAE,CAAC,mBAAmB,EAAE,GAAG,EAAE;QAC3B,MAAM,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QAChD,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QACjD,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QAClD,MAAM,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IACtD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,eAAe,EAAE,GAAG,EAAE;QACvB,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC;QACvC,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC;QAC7C,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC;QAC5C,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC;IAC9C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { expect } from '@open-wc/testing';\nimport { mediatypeConfig } from '../src/mediatype/mediatype-config';\n\ndescribe('mediatypeConfig', () => {\n it('returns undefined', () => {\n expect(mediatypeConfig['']).to.equal(undefined);\n expect(mediatypeConfig.test).to.equal(undefined);\n expect(mediatypeConfig.media).to.equal(undefined);\n expect(mediatypeConfig.testing).to.equal(undefined);\n });\n\n it('returns audio', () => {\n expect(mediatypeConfig.audio).to.exist;\n expect(mediatypeConfig.audio.color).to.exist;\n expect(mediatypeConfig.audio.icon).to.exist;\n expect(mediatypeConfig.audio.text).to.exist;\n });\n});\n"]}
1
+ {"version":3,"file":"mediatype-config.test.js","sourceRoot":"","sources":["../../test/mediatype-config.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AAEpE,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,EAAE,CAAC,eAAe,EAAE,GAAG,EAAE;QACvB,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC;QACvC,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC;QAC7C,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC;QAC5C,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC;IAC9C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { expect } from '@open-wc/testing';\nimport { mediatypeConfig } from '../src/mediatype/mediatype-config';\n\ndescribe('mediatypeConfig', () => {\n it('returns audio', () => {\n expect(mediatypeConfig.audio).to.exist;\n expect(mediatypeConfig.audio.color).to.exist;\n expect(mediatypeConfig.audio.icon).to.exist;\n expect(mediatypeConfig.audio.text).to.exist;\n });\n});\n"]}
@@ -0,0 +1 @@
1
+ import '../../src/tiles/mediatype-icon';
@@ -0,0 +1,88 @@
1
+ import { expect, fixture } from '@open-wc/testing';
2
+ import { html } from 'lit';
3
+ import '../../src/tiles/mediatype-icon';
4
+ describe('Mediatype Icon', () => {
5
+ it('renders component', async () => {
6
+ var _a;
7
+ const el = await fixture(html `
8
+ <mediatype-icon mediatype="texts"></mediatype-icon>
9
+ `);
10
+ const iconDiv = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('#icon');
11
+ expect(iconDiv).to.exist;
12
+ });
13
+ it('renders basic mediatype correctly', async () => {
14
+ var _a;
15
+ const el = await fixture(html `
16
+ <mediatype-icon mediatype="movies"></mediatype-icon>
17
+ `);
18
+ const iconDiv = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('#icon');
19
+ expect(iconDiv.title).to.equal('Movie');
20
+ expect(iconDiv.getAttribute('style')).to.include('#f1644b');
21
+ expect(iconDiv.children[0]).to.be.instanceOf(SVGElement);
22
+ });
23
+ it('renders TV mediatype', async () => {
24
+ var _a;
25
+ const el = await fixture(html `
26
+ <mediatype-icon
27
+ mediatype="movies"
28
+ .collections=${['tvnews']}
29
+ ></mediatype-icon>
30
+ `);
31
+ const iconDiv = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('#icon');
32
+ expect(iconDiv.title).to.equal('TV');
33
+ });
34
+ it('renders TV Commercial mediatype', async () => {
35
+ var _a;
36
+ const el = await fixture(html `
37
+ <mediatype-icon
38
+ mediatype="movies"
39
+ .collections=${['tvnews', 'tv_ads']}
40
+ ></mediatype-icon>
41
+ `);
42
+ const iconDiv = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('#icon');
43
+ expect(iconDiv.title).to.equal('TV Commercial');
44
+ });
45
+ it('renders TV Fact Check mediatype for search results', async () => {
46
+ var _a;
47
+ const el = await fixture(html `
48
+ <mediatype-icon
49
+ isTvSearchResult
50
+ mediatype="movies"
51
+ .collections=${['tvnews', 'factchecked']}
52
+ ></mediatype-icon>
53
+ `);
54
+ const iconDiv = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('#icon');
55
+ expect(iconDiv.title).to.equal('TV Fact Check');
56
+ });
57
+ it('does not use TV Fact Check mediatype for non-search results', async () => {
58
+ var _a;
59
+ const el = await fixture(html `
60
+ <mediatype-icon
61
+ mediatype="movies"
62
+ .collections=${['tvnews', 'factchecked']}
63
+ ></mediatype-icon>
64
+ `);
65
+ const iconDiv = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('#icon');
66
+ expect(iconDiv.title).to.equal('TV');
67
+ });
68
+ it('renders radio mediatype', async () => {
69
+ var _a;
70
+ const el = await fixture(html `
71
+ <mediatype-icon
72
+ mediatype="audio"
73
+ .collections=${['radio']}
74
+ ></mediatype-icon>
75
+ `);
76
+ const iconDiv = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('#icon');
77
+ expect(iconDiv.title).to.equal('Radio');
78
+ });
79
+ it('renders no icon if mediatype is unrecognized', async () => {
80
+ var _a;
81
+ const el = await fixture(html `
82
+ <mediatype-icon mediatype="foobar"></mediatype-icon>
83
+ `);
84
+ const iconDiv = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('#icon');
85
+ expect(iconDiv).not.to.exist;
86
+ });
87
+ });
88
+ //# sourceMappingURL=mediatype-icon.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mediatype-icon.test.js","sourceRoot":"","sources":["../../../test/tiles/mediatype-icon.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;A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AE,CAAC,yBAAyB,EAAE,KAAK,IAAI,EAAE;;QACvC,MAAM,EAAE,GAAG,MAAM,OAAO,CAAgB,IAAI,CAAA;;;uBAGzB,CAAC,OAAO,CAAC;;KAE3B,CAAC,CAAC;QAEH,MAAM,OAAO,GAAG,MAAA,EAAE,CAAC,UAAU,0CAAE,aAAa,CAAC,OAAO,CAAmB,CAAC;QACxE,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC1C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,8CAA8C,EAAE,KAAK,IAAI,EAAE;;QAC5D,MAAM,EAAE,GAAG,MAAM,OAAO,CAAgB,IAAI,CAAA;;KAE3C,CAAC,CAAC;QAEH,MAAM,OAAO,GAAG,MAAA,EAAE,CAAC,UAAU,0CAAE,aAAa,CAAC,OAAO,CAAC,CAAC;QACtD,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC;IAC/B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { expect, fixture } from '@open-wc/testing';\nimport { html } from 'lit';\nimport type { MediatypeIcon } from '../../src/tiles/mediatype-icon';\n\nimport '../../src/tiles/mediatype-icon';\n\ndescribe('Mediatype Icon', () => {\n it('renders component', async () => {\n const el = await fixture<MediatypeIcon>(html`\n <mediatype-icon mediatype=\"texts\"></mediatype-icon>\n `);\n\n const iconDiv = el.shadowRoot?.querySelector('#icon');\n expect(iconDiv).to.exist;\n });\n\n it('renders basic mediatype correctly', async () => {\n const el = await fixture<MediatypeIcon>(html`\n <mediatype-icon mediatype=\"movies\"></mediatype-icon>\n `);\n\n const iconDiv = el.shadowRoot?.querySelector('#icon') as HTMLDivElement;\n expect(iconDiv.title).to.equal('Movie');\n expect(iconDiv.getAttribute('style')).to.include('#f1644b');\n expect(iconDiv.children[0]).to.be.instanceOf(SVGElement);\n });\n\n it('renders TV mediatype', async () => {\n const el = await fixture<MediatypeIcon>(html`\n <mediatype-icon\n mediatype=\"movies\"\n .collections=${['tvnews']}\n ></mediatype-icon>\n `);\n\n const iconDiv = el.shadowRoot?.querySelector('#icon') as HTMLDivElement;\n expect(iconDiv.title).to.equal('TV');\n });\n\n it('renders TV Commercial mediatype', async () => {\n const el = await fixture<MediatypeIcon>(html`\n <mediatype-icon\n mediatype=\"movies\"\n .collections=${['tvnews', 'tv_ads']}\n ></mediatype-icon>\n `);\n\n const iconDiv = el.shadowRoot?.querySelector('#icon') as HTMLDivElement;\n expect(iconDiv.title).to.equal('TV Commercial');\n });\n\n it('renders TV Fact Check mediatype for search results', async () => {\n const el = await fixture<MediatypeIcon>(html`\n <mediatype-icon\n isTvSearchResult\n mediatype=\"movies\"\n .collections=${['tvnews', 'factchecked']}\n ></mediatype-icon>\n `);\n\n const iconDiv = el.shadowRoot?.querySelector('#icon') as HTMLDivElement;\n expect(iconDiv.title).to.equal('TV Fact Check');\n });\n\n it('does not use TV Fact Check mediatype for non-search results', async () => {\n const el = await fixture<MediatypeIcon>(html`\n <mediatype-icon\n mediatype=\"movies\"\n .collections=${['tvnews', 'factchecked']}\n ></mediatype-icon>\n `);\n\n const iconDiv = el.shadowRoot?.querySelector('#icon') as HTMLDivElement;\n expect(iconDiv.title).to.equal('TV');\n });\n\n it('renders radio mediatype', async () => {\n const el = await fixture<MediatypeIcon>(html`\n <mediatype-icon\n mediatype=\"audio\"\n .collections=${['radio']}\n ></mediatype-icon>\n `);\n\n const iconDiv = el.shadowRoot?.querySelector('#icon') as HTMLDivElement;\n expect(iconDiv.title).to.equal('Radio');\n });\n\n it('renders no icon if mediatype is unrecognized', async () => {\n const el = await fixture<MediatypeIcon>(html`\n <mediatype-icon mediatype=\"foobar\"></mediatype-icon>\n `);\n\n const iconDiv = el.shadowRoot?.querySelector('#icon');\n expect(iconDiv).not.to.exist;\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": "2.12.2",
6
+ "version": "2.12.3-alpha-webdev7452.0",
7
7
  "main": "dist/index.js",
8
8
  "module": "dist/index.js",
9
9
  "scripts": {
@@ -0,0 +1,12 @@
1
+ import { html } from 'lit';
2
+
3
+ export const tvCommercialIcon = html`
4
+ <svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
5
+ <path
6
+ class="fill-color"
7
+ d="m38.4615385 55.5197275-4.8171501 7.0895871c4.1025641 2.9421734 8.9186633 4.7253407 14.4482976 5.3495018v13.0411836h5.6179067v-12.9749847c3.8356452-.357264 6.8905002-1.5278287 9.1645649-3.5116942 2.2740648-1.9838655 3.4110971-4.5582672 3.4110971-7.7232052v-.0661989c0-3.2553047-1.025641-5.7635075-3.076923-7.5246085-2.0512821-1.7611009-5.3068517-3.1544302-9.7667087-4.1799878v-6.2195444c2.6754939.6682937 5.083018 1.7379839 7.2225725 3.2090706l4.4136191-7.1557861c-3.2114333-2.2738797-6.9798234-3.6787675-11.3051702-4.2146634v-11.6383974h-5.5517024v11.5028473c-4.0584279.3131313-7.2026061 1.4721374-9.4325347 3.4770185-2.2299285 2.004881-3.3448928 4.5908413-3.3448928 7.7578808v.1323978c0 3.2111721 1.0372005 5.6857501 3.1116015 7.423734 2.074401 1.7379838 5.3625473 3.1197546 9.8644389 4.1453122v6.4212934c-3.1651955-.4896617-6.4869694-1.9386821-9.9653216-4.3470612zm-24.4136192-32.7716087c-4.32534679 3.7008338-7.74800337 8.0142702-10.26796974 12.9403091s-3.77994956 10.1536506-3.77994956 15.6828351c0 4.9050234 1.02564103 9.6093485 3.07692308 14.1129754 2.05128205 4.5036268 4.88335435 8.5606738 8.49621692 12.1711409.357293.3572639 1.1149642.6252118 2.2730138.8038438s2.2057588-.0220663 3.1431274-.6020948c.5800757-.4896617.8701135-1.1138228.8701135-1.8724832s-.1229508-1.3828215-.3688525-1.8724832c-.2459016-.4896617-.5023119-.8689919-.7692307-1.1379907-6.5111392-6.3761101-9.76670873-13.5770795-9.76670873-21.6029082 0-4.6822589 1.1034048-9.0850112 3.31021443-13.2082571 2.2068095-4.1232459 5.2059688-7.6570063 8.9974779-10.6012813.0882724-.0882652.1775956-.1880889.2679697-.2994712s.2574611-.3562131.5012611-.7344926c.2437999-.3782794.4224464-.7460511.5359394-1.103315.1134931-.3572639.1250526-.770219.0346785-1.2388652s-.3131568-.8816012-.6683481-1.2388651c-.668348-.6682937-1.4932745-1.0245068-2.4747793-1.0686394s-1.8064313.0893159-2.4747793.4003457zm71.9041614 0c4.3253468 3.7008338 7.7480034 8.0142702 10.2679697 12.9403091 2.5199664 4.9260389 3.7799496 10.1536506 3.7799496 15.6828351 0 4.8608908-1.025641 9.5536573-3.0769231 14.0782997-2.051282 4.5246424-4.8602354 8.593248-8.42686 12.2058166-.4014292.3572639-1.1822194.6252118-2.3423707.8038438-1.1601514.178632-2.1857924-.0220663-3.0769231-.6020948-.5800757-.4896617-.8806221-1.1138228-.9016394-1.8724832-.0210172-.7586604.0903741-1.3828215.3341741-1.8724832.2437999-.4896617.5002101-.8689919.7692307-1.1379907 6.4649012-6.3319775 9.6973519-13.5329469 9.6973519-21.6029082 0-4.6822589-1.1034048-9.0850112-3.3102144-13.2082571s-5.18285-7.6570063-8.9281211-10.6012813c-.0882724-.0882652-.1775956-.1880889-.2679697-.2994712s-.2574611-.3562131-.5012611-.7344926c-.2437999-.3782794-.4224464-.7460511-.5359394-1.103315-.1134931-.3572639-.1250526-.770219-.0346785-1.2388652s.3131568-.8816012.6683481-1.2388651c.668348-.6682937 1.4932745-1.0245068 2.4747793-1.0686394s1.7843632.0893159 2.408575.4003457zm-62.2730139 8.0920276c-3.1210592 2.4525117-5.6179066 5.4840011-7.4905422 9.0944682s-2.8089534 7.4447495-2.8089534 11.5028473c0 6.2878449 2.2068096 11.9725442 6.6204288 17.054098.1786465.3131313.858554.469697 2.0397226.469697 1.1811685 0 2.1290458-.2900143 2.8436318-.8700427.5359394-.4896618.8259773-1.1253814.8701134-1.9071589.0441362-.7817775-.045187-1.2167988-.2679697-1.305064-1.6939891-1.7842181-3.1094998-3.9582741-4.2465321-6.522168-1.1370324-2.563894-1.7055486-5.0720968-1.7055486-7.5246085 0-3.34357.7471627-6.3424853 2.241488-8.996746 1.4943254-2.6542607 3.5571669-4.7390008 6.1885246-6.2542201.0441362-.0441326.1113914-.12189.2017655-.2332723s.2238335-.3341468.4003783-.6682937c.1765447-.3341468.2994956-.6577859.3688524-.9709172.0693569-.3131313.0472888-.7029693-.0662043-1.1695139-.113493-.4665447-.3478352-.901566-.7030264-1.3050641-.4897016-.5358959-1.102354-.8364179-1.8379572-.901566s-1.3482555-.009457-1.8379571.1670734zm52.5063052 0c3.1651955 2.4966443 5.6956705 5.5396923 7.591425 9.1291438 1.8957545 3.5894516 2.8436318 7.4132262 2.8436318 11.471324 0 6.2416107-2.2519967 11.9263101-6.75599 17.054098-.1345103.3131313-.7923497.469697-1.9735182.469697-1.1811686 0-2.1290459-.2900142-2.8436318-.8700427-.5359395-.4896617-.8259773-1.1253813-.8701135-1.9071589-.0441362-.7817775.045187-1.2167988.2679697-1.305064 1.6498529-1.8283506 3.0432955-4.0244729 4.1803279-6.5883669s1.7055485-5.0500305 1.7055485-7.4584096c0-3.3435699-.7356032-6.3309267-2.2068095-8.9620704-1.4712064-2.6311436-3.5004204-4.7263914-6.0876419-6.2857433l-.2332913-.2332723s-.1450189-.2227646-.4350568-.6682937c-.2900378-.4455291-.4129886-.7691682-.3688524-.9709172.0441362-.2017491.0662043-.591587.0662043-1.169514 0-.5779269.2343421-1.0129482.7030265-1.305064.4897015-.5358959 1.1023539-.8364179 1.8379571-.901566.7356032-.0651482 1.3482555-.009457 1.8379571.1670734zm-31.3682219 10.2324588v-.0661989c0-1.605586 1.2263556-2.497695 3.6790668-2.676327v5.7529998c-1.4270702-.4013965-2.3970156-.8248593-2.9098361-1.2703884-.5128205-.4455292-.7692307-1.0255576-.7692307-1.7400855zm12.1721311 16.3196055v.0661989c0 1.5614535-1.2042875 2.4756288-3.6128625 2.7425259v-5.8853976c1.382934.4013965 2.3308112.8248594 2.8436317 1.2703885.5128206.4455291.7692308 1.0476239.7692308 1.8062843z"
8
+ fill="black"
9
+ fill-rule="evenodd"
10
+ />
11
+ </svg>
12
+ `;
@@ -0,0 +1,12 @@
1
+ import { html } from 'lit';
2
+
3
+ export const tvFactCheckIcon = html`
4
+ <svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
5
+ <path
6
+ class="fill-color"
7
+ d="m53.8329111 72.530691-28.3707393-20.2314977c-1.2950216-.9306676-2.0122823-2.1279084-2.1517819-3.5917222-.1394997-1.4638139.1499621-2.9054133.8683852-4.3247984.7184232-1.419385 1.5275211-2.780311 2.4272938-4.0827779.8997726-1.302467 1.7204955-2.3488835 2.4621686-3.1392494l1.178772-1.1855489 20.6040968 16.1873027 36.4861309-43.88284817 3.885065-3.27955103c2.311044 1.53396469 4.1722017 3.06909856 5.5834731 4.60540161 1.4112713 1.53630309 2.2901191 2.86215359 2.6365432 3.97755169.3464241 1.1153982.5312611 2.1150474.5545111 2.9989478.0232494.8839004-.0813748 1.5351339-.3138742 1.9537004l-.4150115.6980007zm15.0520112 11.0943528v-5.022799c-.0464999-.1403016-.0813748-.2911259-.1046247-.4524728-.02325-.1613469-.0464999-.486379-.0697498-.9750964-.02325-.4887175.0116249-.8020578.1046247-.9400211.0464999-.1870689.2197119-.4898866.5196361-.9084532.2999243-.4185666.589386-.7903659.8683853-1.1153981l.4150114-.4875482 9.5731628-11.1645037v32.4412487h-80.1913681v-80.6524027h68.1874241l-7.1458691 8.5829534c-1.0183473 1.5807319-1.8041953 2.5113995-2.3575439 2.7920028h-47.3775653v57.9059979h57.574989z"
8
+ fill="black"
9
+ fill-rule="evenodd"
10
+ />
11
+ </svg>
12
+ `;
@@ -0,0 +1,12 @@
1
+ import { html } from 'lit';
2
+
3
+ export const tvQuoteIcon = html`
4
+ <svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
5
+ <path
6
+ class="fill-color"
7
+ d="m45.3394669 100.000002h7.4385828c6.4511217-.3595144 12.58904-1.9152224 18.4137548-4.6671261s10.8424956-6.3426695 15.0533425-10.7722976c4.2108468-4.429628 7.556034-9.6360206 10.0355616-15.6191778s3.7192914-12.2669975 3.7192914-18.8515208c0-9.0967521-2.2250498-17.4897316-6.6751493-25.1789383-4.4500995-7.6892068-10.5140669-13.7638762-18.1919023-18.22400833-7.6778355-4.46013212-16.0560287-6.68910874-25.1345797-6.68693148-6.8100007 0-13.2915728 1.31603472-19.4447163 3.94810096-6.1531434 2.63206624-11.4699901 6.17816545-15.9505399 10.63829755-4.4805499 4.4601321-8.03453942 9.7863622-10.66196865 15.9786902s-3.94114385 12.7005912-3.94114385 19.5247894c0 12.9271929 4.36092352 24.1624988 13.0827705 33.7059178 8.7218471 9.543419 19.4751667 14.9448198 32.2599589 16.2042045zm-28.136113-51.5246596c2.2707252-7.480036 5.6159125-13.1058597 10.0355616-16.8774711 4.2412972-3.9502783 8.9610997-5.4166529 14.1594076-4.399124.2979783.1786667.1783519.507675-.358879.9870248-.537231.4793498-1.433341 1.2572039-2.6883299 2.3335621-1.254989 1.0763582-2.3000881 2.1538058-3.1352974 3.2323429-1.074462 1.4358706-1.7911325 2.7976598-2.1500114 4.0853677-.358879 1.2877079-.448055 2.214814-.267528 2.7813184.180527.5665043.180527 1.1798542 0 1.8400496 3.1059345-.1786668 5.8236273.5545206 8.1530782 2.199562s3.9726817 3.7095139 4.9296923 6.1934174c.9570107 2.4839036 1.210401 5.2063926.760171 8.1674672-.45023 2.9610745-1.6595435 5.6094822-3.6279404 7.9452231-3.3451872 3.6495952-7.5712592 5.2205552-12.678216 4.7128802s-8.9154242-2.6767329-11.4254021-6.5071737c-1.5529673-2.1548953-2.4490773-4.8479697-2.6883299-8.0792232-.2392527-3.2312535.089176-6.1040841.9852859-8.6184917zm34.7655868 0c2.2098245-7.3013692 5.5854621-12.9271929 10.1269126-16.8774711 4.1825715-3.9502783 8.8719237-5.4166529 14.0680565-4.399124.358879.1786667.2838407.507675-.225115.9870248-.5089556.4793498-1.3898404 1.2572039-2.6426544 2.3335621-1.2528139 1.0763582-2.3283634 2.1538058-3.2266484 3.2323429-1.0744619 1.4358706-1.7911324 2.7976598-2.1500114 4.0853677s-.4632801 2.214814-.3132035 2.7813184c.1500767.5665043.1348515 1.1798542-.0456755 1.8400496 3.1059346-.1786668 5.8236273.5545206 8.1530782 2.199562s3.9726817 3.7095139 4.9296924 6.1934174c.9570106 2.4839036 1.2256261 5.2063926.8058464 8.1674672-.4197796 2.9610745-1.6443183 5.6094822-3.6736158 7.9452231-3.3451873 3.6495952-7.5712593 5.2205552-12.6782161 4.7128802s-8.9154242-2.6767329-11.4254021-6.5071737c-1.4942416-2.1548953-2.3609888-4.8479697-2.6002414-8.0792232-.2392527-3.2312535.0598131-6.1040841.8971975-8.6184917z"
8
+ fill="black"
9
+ fill-rule="evenodd"
10
+ />
11
+ </svg>
12
+ `;
@@ -2120,7 +2120,7 @@ export class CollectionBrowser
2120
2120
  .mobileBreakpoint=${this.mobileBreakpoint}
2121
2121
  .loggedIn=${this.loggedIn}
2122
2122
  .isManageView=${this.isManageView}
2123
- ?showTvClips=${this.isTVCollection}
2123
+ ?showTvClips=${this.isTVCollection || this.searchType === SearchType.TV}
2124
2124
  ?enableHoverPane=${true}
2125
2125
  @resultSelected=${(e: CustomEvent) => this.resultSelected(e)}
2126
2126
  >
@@ -1,6 +1,9 @@
1
1
  import { css, html, LitElement, CSSResultGroup, nothing } from 'lit';
2
2
  import { customElement, property } from 'lit/decorators.js';
3
- import { mediatypeConfig } from '../../mediatype/mediatype-config';
3
+ import {
4
+ mediatypeConfig,
5
+ MediatypeConfigKey,
6
+ } from '../../mediatype/mediatype-config';
4
7
  import type { SmartFacet, SmartFacetEvent } from './models';
5
8
 
6
9
  import closeCircleDark from '../../assets/img/icons/close-circle-dark';
@@ -38,7 +41,7 @@ export class SmartFacetButton extends LitElement {
38
41
 
39
42
  const icon =
40
43
  isSingleFacet && firstFacet.facetType === 'mediatype'
41
- ? mediatypeConfig[firstFacet.bucketKey].icon
44
+ ? mediatypeConfig[firstFacet.bucketKey as MediatypeConfigKey].icon
42
45
  : nothing;
43
46
 
44
47
  return html`
@@ -1190,6 +1190,7 @@ export class CollectionBrowserDataSource
1190
1190
  pageNumber + i,
1191
1191
  results.slice(pageStartIndex, pageStartIndex + this.pageSize),
1192
1192
  !isUnpagedElement || i === numPages - 1,
1193
+ !this.host.withinCollection && this.host.searchType === SearchType.TV,
1193
1194
  );
1194
1195
  }
1195
1196
  }
@@ -1216,11 +1217,12 @@ export class CollectionBrowserDataSource
1216
1217
  pageNumber: number,
1217
1218
  results: SearchResult[],
1218
1219
  needsReload = true,
1220
+ isTvSearch = false,
1219
1221
  ): void {
1220
1222
  const tiles: TileModel[] = [];
1221
1223
  results?.forEach(result => {
1222
1224
  if (!result.identifier) return;
1223
- tiles.push(new TileModel(result));
1225
+ tiles.push(new TileModel(result, isTvSearch));
1224
1226
  });
1225
1227
 
1226
1228
  this.addPage(pageNumber, tiles);
@@ -1,3 +1,4 @@
1
+ import { html, TemplateResult } from 'lit';
1
2
  import { accountIcon } from '../assets/img/icons/mediatype/account';
2
3
  import { audioIcon } from '../assets/img/icons/mediatype/audio';
3
4
  import { collectionIcon } from '../assets/img/icons/mediatype/collection';
@@ -9,12 +10,44 @@ import { radioIcon } from '../assets/img/icons/mediatype/radio';
9
10
  import { softwareIcon } from '../assets/img/icons/mediatype/software';
10
11
  import { textsIcon } from '../assets/img/icons/mediatype/texts';
11
12
  import { tvIcon } from '../assets/img/icons/mediatype/tv';
13
+ import { tvCommercialIcon } from '../assets/img/icons/mediatype/tv-commercial';
14
+ import { tvFactCheckIcon } from '../assets/img/icons/mediatype/tv-fact-check';
12
15
  import { videoIcon } from '../assets/img/icons/mediatype/video';
13
16
  import { webIcon } from '../assets/img/icons/mediatype/web';
14
17
  import { searchIcon } from '../assets/img/icons/mediatype/search';
18
+ import { tvQuoteIcon } from '../assets/img/icons/mediatype/tv-quote';
15
19
 
16
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
17
- export const mediatypeConfig: { [key: string]: any } = {
20
+ /**
21
+ * Union of keys with valid mediatype config entries
22
+ */
23
+ export type MediatypeConfigKey =
24
+ | 'account'
25
+ | 'audio'
26
+ | 'collection'
27
+ | 'data'
28
+ | 'etree'
29
+ | 'film'
30
+ | 'image'
31
+ | 'movies'
32
+ | 'none'
33
+ | 'radio'
34
+ | 'search'
35
+ | 'software'
36
+ | 'texts'
37
+ | 'tv'
38
+ | 'tvCommercial'
39
+ | 'tvFactCheck'
40
+ | 'tvQuote'
41
+ | 'video'
42
+ | 'web';
43
+
44
+ export type MediatypeConfig = {
45
+ color: string;
46
+ icon: TemplateResult;
47
+ text: string;
48
+ };
49
+
50
+ export const mediatypeConfig: Record<MediatypeConfigKey, MediatypeConfig> = {
18
51
  account: {
19
52
  color: '#000000',
20
53
  icon: accountIcon,
@@ -55,6 +88,11 @@ export const mediatypeConfig: { [key: string]: any } = {
55
88
  icon: filmIcon,
56
89
  text: 'Movie',
57
90
  },
91
+ none: {
92
+ color: '#00000000',
93
+ icon: html``, // Empty
94
+ text: '',
95
+ },
58
96
  radio: {
59
97
  color: '#8fdaef',
60
98
  icon: radioIcon,
@@ -75,6 +113,21 @@ export const mediatypeConfig: { [key: string]: any } = {
75
113
  icon: tvIcon,
76
114
  text: 'TV',
77
115
  },
116
+ tvCommercial: {
117
+ color: '#84b648',
118
+ icon: tvCommercialIcon,
119
+ text: 'TV Commercial',
120
+ },
121
+ tvFactCheck: {
122
+ color: 'f1644b',
123
+ icon: tvFactCheckIcon,
124
+ text: 'TV Fact Check',
125
+ },
126
+ tvQuote: {
127
+ color: '',
128
+ icon: tvQuoteIcon,
129
+ text: 'TV Quote',
130
+ },
78
131
  video: {
79
132
  color: '#f1644b',
80
133
  icon: videoIcon,
package/src/models.ts CHANGED
@@ -110,7 +110,9 @@ export class TileModel {
110
110
 
111
111
  contentWarning: boolean;
112
112
 
113
- constructor(result: SearchResult) {
113
+ isTvSearchResult: boolean;
114
+
115
+ constructor(result: SearchResult, isFromTvSearch = false) {
114
116
  const flags = this.getFlags(result);
115
117
 
116
118
  this.averageRating = result.avg_rating?.value;
@@ -147,6 +149,7 @@ export class TileModel {
147
149
  this.weeklyViewCount = result.week?.value;
148
150
  this.loginRequired = flags.loginRequired;
149
151
  this.contentWarning = flags.contentWarning;
152
+ this.isTvSearchResult = isFromTvSearch && result.hit_type === 'tv_clip';
150
153
  }
151
154
 
152
155
  /**
@@ -186,6 +189,7 @@ export class TileModel {
186
189
  cloned.weeklyViewCount = this.weeklyViewCount;
187
190
  cloned.loginRequired = this.loginRequired;
188
191
  cloned.contentWarning = this.contentWarning;
192
+ cloned.isTvSearchResult = this.isTvSearchResult;
189
193
  return cloned;
190
194
  }
191
195
 
@@ -16,6 +16,9 @@ export class TileStats extends LitElement {
16
16
  /** The mediatype of the item these stats represent */
17
17
  @property({ type: String }) mediatype?: string;
18
18
 
19
+ /** The collections this item is part of */
20
+ @property({ type: Array }) collections?: string[];
21
+
19
22
  /** The number of uploaded items, if representing an account */
20
23
  @property({ type: Number }) itemCount?: number;
21
24
 
@@ -31,6 +34,9 @@ export class TileStats extends LitElement {
31
34
  /** The number of times the item has been reviewed */
32
35
  @property({ type: Number }) commentCount?: number;
33
36
 
37
+ /** Whether the tile represents the result of a search */
38
+ @property({ type: Boolean }) isTvSearchResult = false;
39
+
34
40
  /** Whether to show the number of TV clips in place of reviews */
35
41
  @property({ type: Boolean }) showTvClips = false;
36
42
 
@@ -64,7 +70,11 @@ export class TileStats extends LitElement {
64
70
  return html`
65
71
  <li class="col">
66
72
  <p class="sr-only">${msg('Mediatype:')}</p>
67
- <mediatype-icon .mediatype=${this.mediatype}></mediatype-icon>
73
+ <mediatype-icon
74
+ .mediatype=${this.mediatype}
75
+ .collections=${this.collections}
76
+ ?isTvSearchResult=${this.isTvSearchResult}
77
+ ></mediatype-icon>
68
78
  </li>
69
79
  `;
70
80
  }
@@ -53,6 +53,7 @@ export class TileListCompact extends BaseTileComponent {
53
53
  <mediatype-icon
54
54
  .mediatype=${this.model?.mediatype}
55
55
  .collections=${this.model?.collections}
56
+ ?isTvSearchResult=${this.model?.isTvSearchResult}
56
57
  >
57
58
  </mediatype-icon>
58
59
  </div>
@@ -129,6 +129,7 @@ export class TileList extends BaseTileComponent {
129
129
  <mediatype-icon
130
130
  .mediatype=${this.model?.mediatype}
131
131
  .collections=${this.model?.collections}
132
+ ?isTvSearchResult=${this.model?.isTvSearchResult}
132
133
  >
133
134
  </mediatype-icon>
134
135
  </a>
@@ -1,33 +1,69 @@
1
1
  import { css, CSSResultGroup, html, LitElement } from 'lit';
2
2
  import { customElement, property } from 'lit/decorators.js';
3
3
 
4
- import { mediatypeConfig } from '../mediatype/mediatype-config';
4
+ import {
5
+ mediatypeConfig,
6
+ MediatypeConfigKey,
7
+ } from '../mediatype/mediatype-config';
8
+
9
+ const TV_COMMERCIAL_COLLECTION = 'tv_ads';
10
+ const TV_FACT_CHECK_COLLECTION = 'factchecked';
11
+ const TV_TOP_LEVEL_COLLECTIONS = new Set(['tvnews', 'tvarchive']);
12
+ const RADIO_TOP_LEVEL_COLLECTIONS = new Set(['radio', 'radioprogram']);
5
13
 
6
14
  @customElement('mediatype-icon')
7
15
  export class MediatypeIcon extends LitElement {
8
- @property({ type: String }) mediatype: string | undefined;
16
+ @property({ type: String }) mediatype?: MediatypeConfigKey;
17
+
18
+ @property({ type: Array }) collections?: string[];
9
19
 
10
- @property({ type: Array }) collections: string[] | undefined;
20
+ @property({ type: Boolean }) isTvSearchResult = false;
11
21
 
12
22
  @property({ type: Boolean }) showText = false;
13
23
 
14
- private get displayMediatype(): string {
15
- const tvIdentifier = ['tvnews', 'tvarchive', 'television'];
16
- const radioIdentifier = ['radio', 'radioprogram'];
24
+ /**
25
+ * Returns the appropriate mediatype config key for the current mediatype/collections.
26
+ */
27
+ private get displayMediatype(): MediatypeConfigKey {
28
+ if (this.isTvItem) return this.tvDisplayMediatype;
29
+ if (this.isRadioItem) return 'radio';
30
+ return this.mediatype ?? 'none';
31
+ }
17
32
 
18
- if (
19
- this.mediatype === 'movies' &&
20
- this.collections?.some(id => tvIdentifier.indexOf(id) >= 0)
33
+ /**
34
+ * Returns the appropriate TV mediatype, depending on the current collections.
35
+ */
36
+ private get tvDisplayMediatype(): MediatypeConfigKey {
37
+ if (this.collections?.includes(TV_COMMERCIAL_COLLECTION)) {
38
+ return 'tvCommercial';
39
+ } else if (
40
+ this.isTvSearchResult &&
41
+ this.collections?.includes(TV_FACT_CHECK_COLLECTION)
21
42
  ) {
22
- return 'tv';
43
+ return 'tvFactCheck';
23
44
  }
24
- if (
45
+
46
+ return 'tv';
47
+ }
48
+
49
+ /**
50
+ * Whether this represents a TV item
51
+ */
52
+ private get isTvItem(): boolean {
53
+ return (
54
+ this.mediatype === 'movies' &&
55
+ !!this.collections?.some(id => TV_TOP_LEVEL_COLLECTIONS.has(id))
56
+ );
57
+ }
58
+
59
+ /**
60
+ * Whether this represents a radio item
61
+ */
62
+ private get isRadioItem(): boolean {
63
+ return (
25
64
  this.mediatype === 'audio' &&
26
- this.collections?.some(id => radioIdentifier.indexOf(id) >= 0)
27
- ) {
28
- return 'radio';
29
- }
30
- return this.mediatype || '';
65
+ !!this.collections?.some(id => RADIO_TOP_LEVEL_COLLECTIONS.has(id))
66
+ );
31
67
  }
32
68
 
33
69
  render() {
@@ -2,13 +2,6 @@ import { expect } from '@open-wc/testing';
2
2
  import { mediatypeConfig } from '../src/mediatype/mediatype-config';
3
3
 
4
4
  describe('mediatypeConfig', () => {
5
- it('returns undefined', () => {
6
- expect(mediatypeConfig['']).to.equal(undefined);
7
- expect(mediatypeConfig.test).to.equal(undefined);
8
- expect(mediatypeConfig.media).to.equal(undefined);
9
- expect(mediatypeConfig.testing).to.equal(undefined);
10
- });
11
-
12
5
  it('returns audio', () => {
13
6
  expect(mediatypeConfig.audio).to.exist;
14
7
  expect(mediatypeConfig.audio.color).to.exist;