@internetarchive/collection-browser 1.14.2 → 1.14.3

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 (37) hide show
  1. package/dist/src/assets/img/icons/mediatype/search.d.ts +1 -0
  2. package/dist/src/assets/img/icons/mediatype/search.js +14 -0
  3. package/dist/src/assets/img/icons/mediatype/search.js.map +1 -0
  4. package/dist/src/collection-browser.d.ts +1 -0
  5. package/dist/src/collection-browser.js +27 -9
  6. package/dist/src/collection-browser.js.map +1 -1
  7. package/dist/src/mediatype/mediatype-config.js +6 -0
  8. package/dist/src/mediatype/mediatype-config.js.map +1 -1
  9. package/dist/src/styles/item-image-styles.js +4 -0
  10. package/dist/src/styles/item-image-styles.js.map +1 -1
  11. package/dist/src/tiles/grid/search-tile.d.ts +10 -0
  12. package/dist/src/tiles/grid/search-tile.js +92 -0
  13. package/dist/src/tiles/grid/search-tile.js.map +1 -0
  14. package/dist/src/tiles/image-block.js +4 -2
  15. package/dist/src/tiles/image-block.js.map +1 -1
  16. package/dist/src/tiles/item-image.d.ts +1 -0
  17. package/dist/src/tiles/item-image.js +31 -8
  18. package/dist/src/tiles/item-image.js.map +1 -1
  19. package/dist/src/tiles/list/tile-list.js +5 -1
  20. package/dist/src/tiles/list/tile-list.js.map +1 -1
  21. package/dist/src/tiles/tile-dispatcher.d.ts +1 -0
  22. package/dist/src/tiles/tile-dispatcher.js +25 -1
  23. package/dist/src/tiles/tile-dispatcher.js.map +1 -1
  24. package/dist/test/tiles/grid/search-tile.test.d.ts +1 -0
  25. package/dist/test/tiles/grid/search-tile.test.js +67 -0
  26. package/dist/test/tiles/grid/search-tile.test.js.map +1 -0
  27. package/package.json +4 -4
  28. package/src/assets/img/icons/mediatype/search.ts +14 -0
  29. package/src/collection-browser.ts +20 -1
  30. package/src/mediatype/mediatype-config.ts +6 -0
  31. package/src/styles/item-image-styles.ts +4 -0
  32. package/src/tiles/grid/search-tile.ts +87 -0
  33. package/src/tiles/image-block.ts +3 -1
  34. package/src/tiles/item-image.ts +31 -8
  35. package/src/tiles/list/tile-list.ts +5 -0
  36. package/src/tiles/tile-dispatcher.ts +23 -1
  37. package/test/tiles/grid/search-tile.test.ts +76 -0
@@ -1 +1 @@
1
- {"version":3,"file":"tile-dispatcher.js","sourceRoot":"","sources":["../../../src/tiles/tile-dispatcher.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAkB,MAAM,KAAK,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAOpC,OAAO,wBAAwB,CAAC;AAChC,OAAO,kBAAkB,CAAC;AAC1B,OAAO,qBAAqB,CAAC;AAC7B,OAAO,yBAAyB,CAAC;AACjC,OAAO,kBAAkB,CAAC;AAC1B,OAAO,0BAA0B,CAAC;AAClC,OAAO,iCAAiC,CAAC;AAEzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EACL,mBAAmB,GAIpB,MAAM,+BAA+B,CAAC;AAGvC,IAAa,cAAc,sBAA3B,MAAa,cACX,SAAQ,iBAAiB;IAD3B;QAME;;;;;;;;;;;;WAYG;;QAI0B,iBAAY,GAAG,KAAK,CAAC;QAOlD,uFAAuF;QAC1D,oBAAe,GAAG,KAAK,CAAC;QAEzB,qBAAgB,GAAG,GAAG,CAChD,gCAAgC,CACjC,CAAC;IA+XJ,CAAC;IA1WC,MAAM;;QACJ,MAAM,UAAU,GAAG,IAAI,CAAC,eAAe,KAAK,MAAM,CAAC;QACnD,MAAM,iBAAiB,GACrB,MAAA,MAAA,IAAI,CAAC,mBAAmB,0CAAE,WAAW,EAAE,mCAAI,OAAO,CAAC;QACrD,OAAO,IAAI,CAAA;kCACmB,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Q,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;oDAAsB;AAEtB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;sDAAgD;AAG3E;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2DACwB;AAGtB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;uDAAyB;AAEzB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;wDAEzB;AAKF;IADC,KAAK,CAAC,YAAY,CAAC;iDACe;AAGnC;IADC,KAAK,CAAC,iBAAiB,CAAC;iDACS;AA1CvB,cAAc;IAD1B,aAAa,CAAC,iBAAiB,CAAC;GACpB,cAAc,CAia1B;SAjaY,cAAc","sourcesContent":["import { css, html, nothing, PropertyValues } from 'lit';\nimport { customElement, property, query } from 'lit/decorators.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { msg } from '@lit/localize';\nimport type {\n SharedResizeObserverInterface,\n SharedResizeObserverResizeHandlerInterface,\n} from '@internetarchive/shared-resize-observer';\nimport type { CollectionNameCacheInterface } from '@internetarchive/collection-name-cache';\nimport type { TileDisplayMode } from '../models';\nimport './grid/collection-tile';\nimport './grid/item-tile';\nimport './grid/account-tile';\nimport './hover/tile-hover-pane';\nimport './list/tile-list';\nimport './list/tile-list-compact';\nimport './list/tile-list-compact-header';\nimport type { TileHoverPane } from './hover/tile-hover-pane';\nimport { BaseTileComponent } from './base-tile-component';\nimport {\n HoverPaneController,\n HoverPaneControllerInterface,\n HoverPaneProperties,\n HoverPaneProviderInterface,\n} from './hover/hover-pane-controller';\n\n@customElement('tile-dispatcher')\nexport class TileDispatcher\n extends BaseTileComponent\n implements\n SharedResizeObserverResizeHandlerInterface,\n HoverPaneProviderInterface\n{\n /*\n * Reactive properties inherited from BaseTileComponent:\n * - model?: TileModel;\n * - currentWidth?: number;\n * - currentHeight?: number;\n * - baseNavigationUrl?: string;\n * - baseImageUrl?: string;\n * - collectionPagePath?: string;\n * - sortParam: SortParam | null = null;\n * - creatorFilter?: string;\n * - mobileBreakpoint?: number;\n * - loggedIn = false;\n */\n\n @property({ type: String }) tileDisplayMode?: TileDisplayMode;\n\n @property({ type: Boolean }) isManageView = false;\n\n @property({ type: Object }) resizeObserver?: SharedResizeObserverInterface;\n\n @property({ type: Object })\n collectionNameCache?: CollectionNameCacheInterface;\n\n /** Whether this tile should include a hover pane at all (for applicable tile modes) */\n @property({ type: Boolean }) enableHoverPane = false;\n\n @property({ type: String }) manageCheckTitle = msg(\n 'Remove this item from the list'\n );\n\n private hoverPaneController?: HoverPaneControllerInterface;\n\n @query('#container')\n private container!: HTMLDivElement;\n\n @query('tile-hover-pane')\n private hoverPane?: TileHoverPane;\n\n /** Maps each display mode to whether hover panes should appear in that mode */\n private static readonly HOVER_PANE_DISPLAY_MODES: Record<\n TileDisplayMode,\n boolean\n > = {\n grid: true,\n 'list-compact': true,\n 'list-detail': false,\n 'list-header': false,\n };\n\n render() {\n const isGridMode = this.tileDisplayMode === 'grid';\n const hoverPaneTemplate =\n this.hoverPaneController?.getTemplate() ?? nothing;\n return html`\n <div id=\"container\" class=${isGridMode ? 'hoverable' : nothing}>\n ${this.tileDisplayMode === 'list-header'\n ? this.headerTemplate\n : this.tileTemplate}\n ${this.manageCheckTemplate} ${hoverPaneTemplate}\n </div>\n `;\n }\n\n protected firstUpdated(): void {\n if (this.shouldPrepareHoverPane) {\n this.hoverPaneController = new HoverPaneController(this, {\n mobileBreakpoint: this.mobileBreakpoint,\n enableLongPress: false,\n });\n }\n }\n\n private get headerTemplate() {\n const { currentWidth, sortParam, mobileBreakpoint } = this;\n return html`\n <tile-list-compact-header\n class=\"header\"\n .currentWidth=${currentWidth}\n .sortParam=${sortParam}\n .mobileBreakpoint=${mobileBreakpoint}\n >\n </tile-list-compact-header>\n `;\n }\n\n private get tileTemplate() {\n return html`\n ${this.tileDisplayMode === 'list-detail'\n ? this.tile\n : this.linkTileTemplate}\n `;\n }\n\n private get linkTileTemplate() {\n return html`\n <a\n href=${this.linkTileHref}\n aria-label=${this.model?.title ?? 'Untitled item'}\n title=${this.shouldPrepareHoverPane\n ? nothing // Don't show title tooltips when we have the tile info popups\n : ifDefined(this.model?.title)}\n @click=${this.handleLinkClicked}\n @contextmenu=${this.handleLinkContextMenu}\n >\n ${this.tile}\n </a>\n `;\n }\n\n private get linkTileHref(): string | typeof nothing {\n if (!this.model?.identifier || this.baseNavigationUrl == null)\n return nothing;\n\n // Use the server-specified href if available.\n // Otherwise, construct a details page URL from the item identifier.\n if (this.model.href) {\n return `${this.baseNavigationUrl}${this.model.href}`;\n }\n\n return this.displayValueProvider.itemPageUrl(\n this.model.identifier,\n this.model.mediatype === 'collection'\n );\n }\n\n private get manageCheckTemplate() {\n if (!this.isManageView || this.tileDisplayMode !== 'grid') return nothing;\n\n return html`\n <div class=\"manage-check\">\n <input\n type=\"checkbox\"\n title=${this.manageCheckTitle}\n .checked=${this.model?.checked}\n @change=${() => {\n if (this.model) this.model.checked = !this.model.checked;\n }}\n />\n </div>\n `;\n }\n\n /**\n * Whether hover pane behavior should be prepared for this tile\n * (e.g., whether mouse listeners should be attached, etc.)\n */\n private get shouldPrepareHoverPane(): boolean {\n return (\n this.enableHoverPane &&\n !!this.tileDisplayMode &&\n TileDispatcher.HOVER_PANE_DISPLAY_MODES[this.tileDisplayMode]\n );\n }\n\n private get isHoverEnabled(): boolean {\n return window.matchMedia('(hover: hover)').matches;\n }\n\n /** @inheritdoc */\n getHoverPane(): TileHoverPane | undefined {\n return this.hoverPane;\n }\n\n /** @inheritdoc */\n getHoverPaneProps(): HoverPaneProperties {\n return this;\n }\n\n handleResize(entry: ResizeObserverEntry): void {\n this.currentWidth = entry.contentRect.width;\n this.currentHeight = entry.contentRect.height;\n }\n\n disconnectedCallback(): void {\n this.stopResizeObservation(this.resizeObserver);\n }\n\n private stopResizeObservation(observer?: SharedResizeObserverInterface) {\n observer?.removeObserver({\n handler: this,\n target: this.container,\n });\n }\n\n private startResizeObservation() {\n this.stopResizeObservation(this.resizeObserver);\n this.resizeObserver?.addObserver({\n handler: this,\n target: this.container,\n });\n }\n\n updated(props: PropertyValues) {\n if (props.has('resizeObserver')) {\n const previousObserver = props.get(\n 'resizeObserver'\n ) as SharedResizeObserverInterface;\n this.stopResizeObservation(previousObserver);\n this.startResizeObservation();\n }\n }\n\n /**\n * Handler for when the tile link is left-clicked. Emits the `resultSelected` event.\n * In manage view, it also checks/unchecks the tile.\n */\n private handleLinkClicked(e: Event): void {\n if (this.isManageView) {\n e.preventDefault();\n if (this.model) this.model.checked = !this.model.checked;\n }\n\n this.dispatchEvent(\n new CustomEvent('resultSelected', { detail: this.model })\n );\n }\n\n /**\n * Handler for when the tile link is right-clicked.\n * In manage view, it opens the item in a new tab. Otherwise, does nothing.\n */\n private handleLinkContextMenu(e: Event): void {\n if (this.isManageView && this.linkTileHref !== nothing) {\n e.preventDefault();\n window.open(this.linkTileHref, '_blank');\n }\n }\n\n private tileInfoButtonPressed(\n e: CustomEvent<{ x: number; y: number }>\n ): void {\n this.hoverPaneController?.toggleHoverPane({\n coords: e.detail,\n enableTouchBackdrop: true,\n });\n }\n\n private get tile() {\n const {\n model,\n collectionPagePath,\n baseNavigationUrl,\n currentWidth,\n currentHeight,\n sortParam,\n creatorFilter,\n mobileBreakpoint,\n } = this;\n\n if (!model) return nothing;\n\n switch (this.tileDisplayMode) {\n case 'grid':\n switch (model.mediatype) {\n case 'collection':\n return html`<collection-tile\n .model=${model}\n .collectionPagePath=${collectionPagePath}\n .baseImageUrl=${this.baseImageUrl}\n .currentWidth=${currentWidth}\n .currentHeight=${currentHeight}\n .creatorFilter=${creatorFilter}\n .isManageView=${this.isManageView}\n ?showInfoButton=${!this.isHoverEnabled}\n @infoButtonPressed=${this.tileInfoButtonPressed}\n >\n </collection-tile>`;\n case 'account':\n return html`<account-tile\n .model=${model}\n .collectionPagePath=${collectionPagePath}\n .baseImageUrl=${this.baseImageUrl}\n .currentWidth=${currentWidth}\n .currentHeight=${currentHeight}\n .creatorFilter=${creatorFilter}\n .isManageView=${this.isManageView}\n ?showInfoButton=${!this.isHoverEnabled}\n @infoButtonPressed=${this.tileInfoButtonPressed}\n >\n </account-tile>`;\n default:\n return html`<item-tile\n .model=${model}\n .collectionPagePath=${collectionPagePath}\n .currentWidth=${this.currentWidth}\n .currentHeight=${this.currentHeight}\n .collectionNameCache=${this.collectionNameCache}\n .baseImageUrl=${this.baseImageUrl}\n .sortParam=${sortParam}\n .creatorFilter=${creatorFilter}\n .loggedIn=${this.loggedIn}\n .isManageView=${this.isManageView}\n ?showInfoButton=${!this.isHoverEnabled}\n @infoButtonPressed=${this.tileInfoButtonPressed}\n >\n </item-tile>`;\n }\n case 'list-compact':\n return html`<tile-list-compact\n .model=${model}\n .collectionPagePath=${collectionPagePath}\n .currentWidth=${currentWidth}\n .currentHeight=${currentHeight}\n .baseNavigationUrl=${baseNavigationUrl}\n .sortParam=${sortParam}\n .creatorFilter=${creatorFilter}\n .mobileBreakpoint=${mobileBreakpoint}\n .baseImageUrl=${this.baseImageUrl}\n .loggedIn=${this.loggedIn}\n >\n </tile-list-compact>`;\n case 'list-detail':\n return html`<tile-list\n .model=${model}\n .collectionPagePath=${collectionPagePath}\n .collectionNameCache=${this.collectionNameCache}\n .currentWidth=${currentWidth}\n .currentHeight=${currentHeight}\n .baseNavigationUrl=${baseNavigationUrl}\n .sortParam=${sortParam}\n .creatorFilter=${creatorFilter}\n .mobileBreakpoint=${mobileBreakpoint}\n .baseImageUrl=${this.baseImageUrl}\n .loggedIn=${this.loggedIn}\n >\n </tile-list>`;\n default:\n return nothing;\n }\n }\n\n static get styles() {\n return css`\n :host {\n display: block;\n height: 100%;\n }\n\n collection-tile {\n --tileBorderColor: #555555;\n --tileBackgroundColor: #666666;\n --imageBlockBackgroundColor: #666666;\n }\n\n account-tile {\n --tileBorderColor: #dddddd;\n --imageBlockBackgroundColor: #fcf5e6;\n }\n\n item-tile {\n --tileBorderColor: #dddddd;\n --imageBlockBackgroundColor: #f1f1f4;\n }\n\n #container {\n position: relative;\n height: 100%;\n border-radius: 4px;\n }\n\n #container.hoverable:hover {\n box-shadow: 0 0 6px 2px rgba(8, 8, 32, 0.8);\n transition: box-shadow 0.1s ease;\n }\n\n a {\n display: block;\n height: 100%;\n color: unset;\n text-decoration: none;\n transition: transform 0.05s ease;\n }\n\n a :first-child {\n display: block;\n height: 100%;\n }\n\n .manage-check {\n position: absolute;\n right: 0;\n top: 0;\n border: 5px solid #2c2c2c;\n border-radius: 3px;\n background-color: #2c2c2c;\n z-index: 1;\n }\n\n .manage-check > input[type='checkbox'] {\n display: block;\n margin: 0;\n }\n\n #touch-backdrop {\n position: fixed;\n width: 100vw;\n height: 100vh;\n top: 0;\n left: 0;\n z-index: 2;\n background: transparent;\n }\n\n tile-hover-pane {\n position: absolute;\n top: 0;\n left: -9999px;\n z-index: 2;\n }\n `;\n }\n}\n"]}
1
+ {"version":3,"file":"tile-dispatcher.js","sourceRoot":"","sources":["../../../src/tiles/tile-dispatcher.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAkB,MAAM,KAAK,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAOpC,OAAO,wBAAwB,CAAC;AAChC,OAAO,kBAAkB,CAAC;AAC1B,OAAO,qBAAqB,CAAC;AAC7B,OAAO,oBAAoB,CAAC;AAC5B,OAAO,yBAAyB,CAAC;AACjC,OAAO,kBAAkB,CAAC;AAC1B,OAAO,0BAA0B,CAAC;AAClC,OAAO,iCAAiC,CAAC;AAEzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EACL,mB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iBAAiB,CAAC;GACpB,cAAc,CAsb1B;SAtbY,cAAc","sourcesContent":["import { css, html, nothing, PropertyValues } from 'lit';\nimport { customElement, property, query } from 'lit/decorators.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { msg } from '@lit/localize';\nimport type {\n SharedResizeObserverInterface,\n SharedResizeObserverResizeHandlerInterface,\n} from '@internetarchive/shared-resize-observer';\nimport type { CollectionNameCacheInterface } from '@internetarchive/collection-name-cache';\nimport type { TileDisplayMode } from '../models';\nimport './grid/collection-tile';\nimport './grid/item-tile';\nimport './grid/account-tile';\nimport './grid/search-tile';\nimport './hover/tile-hover-pane';\nimport './list/tile-list';\nimport './list/tile-list-compact';\nimport './list/tile-list-compact-header';\nimport type { TileHoverPane } from './hover/tile-hover-pane';\nimport { BaseTileComponent } from './base-tile-component';\nimport {\n HoverPaneController,\n HoverPaneControllerInterface,\n HoverPaneProperties,\n HoverPaneProviderInterface,\n} from './hover/hover-pane-controller';\n\n@customElement('tile-dispatcher')\nexport class TileDispatcher\n extends BaseTileComponent\n implements\n SharedResizeObserverResizeHandlerInterface,\n HoverPaneProviderInterface\n{\n /*\n * Reactive properties inherited from BaseTileComponent:\n * - model?: TileModel;\n * - currentWidth?: number;\n * - currentHeight?: number;\n * - baseNavigationUrl?: string;\n * - baseImageUrl?: string;\n * - collectionPagePath?: string;\n * - sortParam: SortParam | null = null;\n * - creatorFilter?: string;\n * - mobileBreakpoint?: number;\n * - loggedIn = false;\n */\n\n @property({ type: String }) tileDisplayMode?: TileDisplayMode;\n\n @property({ type: Boolean }) isManageView = false;\n\n @property({ type: Object }) resizeObserver?: SharedResizeObserverInterface;\n\n @property({ type: Object })\n collectionNameCache?: CollectionNameCacheInterface;\n\n /** Whether this tile should include a hover pane at all (for applicable tile modes) */\n @property({ type: Boolean }) enableHoverPane = false;\n\n @property({ type: String }) manageCheckTitle = msg(\n 'Remove this item from the list'\n );\n\n private hoverPaneController?: HoverPaneControllerInterface;\n\n @query('#container')\n private container!: HTMLDivElement;\n\n @query('tile-hover-pane')\n private hoverPane?: TileHoverPane;\n\n /** Maps each display mode to whether hover panes should appear in that mode */\n private static readonly HOVER_PANE_DISPLAY_MODES: Record<\n TileDisplayMode,\n boolean\n > = {\n grid: true,\n 'list-compact': true,\n 'list-detail': false,\n 'list-header': false,\n };\n\n render() {\n const isGridMode = this.tileDisplayMode === 'grid';\n const hoverPaneTemplate =\n this.hoverPaneController?.getTemplate() ?? nothing;\n return html`\n <div id=\"container\" class=${isGridMode ? 'hoverable' : nothing}>\n ${this.tileDisplayMode === 'list-header'\n ? this.headerTemplate\n : this.tileTemplate}\n ${this.manageCheckTemplate} ${hoverPaneTemplate}\n </div>\n `;\n }\n\n protected firstUpdated(): void {\n if (this.shouldPrepareHoverPane) {\n this.hoverPaneController = new HoverPaneController(this, {\n mobileBreakpoint: this.mobileBreakpoint,\n enableLongPress: false,\n });\n }\n }\n\n private get headerTemplate() {\n const { currentWidth, sortParam, mobileBreakpoint } = this;\n return html`\n <tile-list-compact-header\n class=\"header\"\n .currentWidth=${currentWidth}\n .sortParam=${sortParam}\n .mobileBreakpoint=${mobileBreakpoint}\n >\n </tile-list-compact-header>\n `;\n }\n\n private get tileTemplate() {\n return html`\n ${this.tileDisplayMode === 'list-detail'\n ? this.tile\n : this.linkTileTemplate}\n `;\n }\n\n private get linkTileTemplate() {\n return html`\n <a\n href=${this.linkTileHref}\n aria-label=${this.model?.title ?? 'Untitled item'}\n title=${this.shouldPrepareHoverPane\n ? nothing // Don't show title tooltips when we have the tile info popups\n : ifDefined(this.model?.title)}\n @click=${this.handleLinkClicked}\n @contextmenu=${this.handleLinkContextMenu}\n >\n ${this.tile}\n </a>\n `;\n }\n\n private get linkTileHref(): string | typeof nothing {\n if (!this.model?.identifier || this.baseNavigationUrl == null)\n return nothing;\n\n // Use the server-specified href if available.\n // Otherwise, construct a details page URL from the item identifier.\n if (this.model.href) {\n return `${this.baseNavigationUrl}${this.model.href}`;\n }\n\n return this.displayValueProvider.itemPageUrl(\n this.model.identifier,\n this.model.mediatype === 'collection'\n );\n }\n\n private get manageCheckTemplate() {\n if (!this.isManageView || this.tileDisplayMode !== 'grid') return nothing;\n\n return html`\n <div class=\"manage-check\">\n <input\n type=\"checkbox\"\n title=${this.manageCheckTitle}\n .checked=${this.model?.checked}\n @change=${() => {\n if (this.model) this.model.checked = !this.model.checked;\n }}\n />\n </div>\n `;\n }\n\n /**\n * Whether hover pane behavior should be prepared for this tile\n * (e.g., whether mouse listeners should be attached, etc.)\n */\n private get shouldPrepareHoverPane(): boolean {\n return (\n this.enableHoverPane &&\n !!this.tileDisplayMode &&\n TileDispatcher.HOVER_PANE_DISPLAY_MODES[this.tileDisplayMode] &&\n this.model?.mediatype !== 'search' // don't show hover panes on search tiles\n );\n }\n\n private get isHoverEnabled(): boolean {\n return window.matchMedia('(hover: hover)').matches;\n }\n\n /** @inheritdoc */\n getHoverPane(): TileHoverPane | undefined {\n return this.hoverPane;\n }\n\n /** @inheritdoc */\n getHoverPaneProps(): HoverPaneProperties {\n return this;\n }\n\n handleResize(entry: ResizeObserverEntry): void {\n this.currentWidth = entry.contentRect.width;\n this.currentHeight = entry.contentRect.height;\n }\n\n disconnectedCallback(): void {\n this.stopResizeObservation(this.resizeObserver);\n }\n\n private stopResizeObservation(observer?: SharedResizeObserverInterface) {\n observer?.removeObserver({\n handler: this,\n target: this.container,\n });\n }\n\n private startResizeObservation() {\n this.stopResizeObservation(this.resizeObserver);\n this.resizeObserver?.addObserver({\n handler: this,\n target: this.container,\n });\n }\n\n updated(props: PropertyValues) {\n if (props.has('resizeObserver')) {\n const previousObserver = props.get(\n 'resizeObserver'\n ) as SharedResizeObserverInterface;\n this.stopResizeObservation(previousObserver);\n this.startResizeObservation();\n }\n }\n\n /**\n * Handler for when the tile link is left-clicked. Emits the `resultSelected` event.\n * In manage view, it also checks/unchecks the tile.\n */\n private handleLinkClicked(e: Event): void {\n if (this.isManageView) {\n e.preventDefault();\n if (this.model) this.model.checked = !this.model.checked;\n }\n\n this.dispatchEvent(\n new CustomEvent('resultSelected', { detail: this.model })\n );\n }\n\n /**\n * Handler for when the tile link is right-clicked.\n * In manage view, it opens the item in a new tab. Otherwise, does nothing.\n */\n private handleLinkContextMenu(e: Event): void {\n if (this.isManageView && this.linkTileHref !== nothing) {\n e.preventDefault();\n window.open(this.linkTileHref, '_blank');\n }\n }\n\n private tileInfoButtonPressed(\n e: CustomEvent<{ x: number; y: number }>\n ): void {\n this.hoverPaneController?.toggleHoverPane({\n coords: e.detail,\n enableTouchBackdrop: true,\n });\n }\n\n private get tile() {\n const {\n model,\n collectionPagePath,\n baseNavigationUrl,\n currentWidth,\n currentHeight,\n sortParam,\n creatorFilter,\n mobileBreakpoint,\n } = this;\n\n if (!model) return nothing;\n\n switch (this.tileDisplayMode) {\n case 'grid':\n switch (model.mediatype) {\n case 'collection':\n return html`<collection-tile\n .model=${model}\n .collectionPagePath=${collectionPagePath}\n .baseImageUrl=${this.baseImageUrl}\n .currentWidth=${currentWidth}\n .currentHeight=${currentHeight}\n .creatorFilter=${creatorFilter}\n .isManageView=${this.isManageView}\n ?showInfoButton=${!this.isHoverEnabled}\n @infoButtonPressed=${this.tileInfoButtonPressed}\n >\n </collection-tile>`;\n case 'account':\n return html`<account-tile\n .model=${model}\n .collectionPagePath=${collectionPagePath}\n .baseImageUrl=${this.baseImageUrl}\n .currentWidth=${currentWidth}\n .currentHeight=${currentHeight}\n .creatorFilter=${creatorFilter}\n .isManageView=${this.isManageView}\n ?showInfoButton=${!this.isHoverEnabled}\n @infoButtonPressed=${this.tileInfoButtonPressed}\n >\n </account-tile>`;\n case 'search':\n return html`<search-tile\n .model=${model}\n .collectionPagePath=${collectionPagePath}\n .baseImageUrl=${this.baseImageUrl}\n .currentWidth=${currentWidth}\n .currentHeight=${currentHeight}\n .creatorFilter=${creatorFilter}\n .isManageView=${this.isManageView}\n ?showInfoButton=${false}\n @infoButtonPressed=${this.tileInfoButtonPressed}\n >\n </search-tile>`;\n default:\n return html`<item-tile\n .model=${model}\n .collectionPagePath=${collectionPagePath}\n .currentWidth=${this.currentWidth}\n .currentHeight=${this.currentHeight}\n .collectionNameCache=${this.collectionNameCache}\n .baseImageUrl=${this.baseImageUrl}\n .sortParam=${sortParam}\n .creatorFilter=${creatorFilter}\n .loggedIn=${this.loggedIn}\n .isManageView=${this.isManageView}\n ?showInfoButton=${!this.isHoverEnabled}\n @infoButtonPressed=${this.tileInfoButtonPressed}\n >\n </item-tile>`;\n }\n case 'list-compact':\n return html`<tile-list-compact\n .model=${model}\n .collectionPagePath=${collectionPagePath}\n .currentWidth=${currentWidth}\n .currentHeight=${currentHeight}\n .baseNavigationUrl=${baseNavigationUrl}\n .sortParam=${sortParam}\n .creatorFilter=${creatorFilter}\n .mobileBreakpoint=${mobileBreakpoint}\n .baseImageUrl=${this.baseImageUrl}\n .loggedIn=${this.loggedIn}\n >\n </tile-list-compact>`;\n case 'list-detail':\n return html`<tile-list\n .model=${model}\n .collectionPagePath=${collectionPagePath}\n .collectionNameCache=${this.collectionNameCache}\n .currentWidth=${currentWidth}\n .currentHeight=${currentHeight}\n .baseNavigationUrl=${baseNavigationUrl}\n .sortParam=${sortParam}\n .creatorFilter=${creatorFilter}\n .mobileBreakpoint=${mobileBreakpoint}\n .baseImageUrl=${this.baseImageUrl}\n .loggedIn=${this.loggedIn}\n >\n </tile-list>`;\n default:\n return nothing;\n }\n }\n\n static get styles() {\n return css`\n :host {\n display: block;\n height: 100%;\n }\n\n collection-tile {\n --tileBorderColor: #555555;\n --tileBackgroundColor: #666666;\n --imageBlockBackgroundColor: #666666;\n }\n\n account-tile {\n --tileBorderColor: #dddddd;\n --imageBlockBackgroundColor: #fcf5e6;\n }\n\n item-tile {\n --tileBorderColor: #dddddd;\n --imageBlockBackgroundColor: #f1f1f4;\n }\n\n search-tile {\n --tileBorderColor: #555555;\n --tileBackgroundColor: #666666;\n --imageBlockBackgroundColor: #666666;\n --iconFillColor: #2c2c2c;\n }\n\n #container {\n position: relative;\n height: 100%;\n border-radius: 4px;\n }\n\n #container.hoverable:hover {\n box-shadow: 0 0 6px 2px rgba(8, 8, 32, 0.8);\n transition: box-shadow 0.1s ease;\n }\n\n a {\n display: block;\n height: 100%;\n color: unset;\n text-decoration: none;\n transition: transform 0.05s ease;\n }\n\n a :first-child {\n display: block;\n height: 100%;\n }\n\n .manage-check {\n position: absolute;\n right: 0;\n top: 0;\n border: 5px solid #2c2c2c;\n border-radius: 3px;\n background-color: #2c2c2c;\n z-index: 1;\n }\n\n .manage-check > input[type='checkbox'] {\n display: block;\n margin: 0;\n }\n\n #touch-backdrop {\n position: fixed;\n width: 100vw;\n height: 100vh;\n top: 0;\n left: 0;\n z-index: 2;\n background: transparent;\n }\n\n tile-hover-pane {\n position: absolute;\n top: 0;\n left: -9999px;\n z-index: 2;\n }\n `;\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ import '../../../src/tiles/grid/search-tile';
@@ -0,0 +1,67 @@
1
+ /* eslint-disable import/no-duplicates */
2
+ import { expect, fixture } from '@open-wc/testing';
3
+ import { html } from 'lit';
4
+ import '../../../src/tiles/grid/search-tile';
5
+ describe('Search Tile', () => {
6
+ it('should render initial component', async () => {
7
+ var _a, _b, _c, _d;
8
+ const el = await fixture(html `<search-tile></search-tile>`);
9
+ const itemInfo = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('.item-info');
10
+ const itemImage = (_b = el.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('image-block');
11
+ const title = (_c = el.shadowRoot) === null || _c === void 0 ? void 0 : _c.querySelector('#title');
12
+ const itemStats = (_d = el.shadowRoot) === null || _d === void 0 ? void 0 : _d.querySelector('#item-stats');
13
+ expect(itemInfo).to.exist;
14
+ expect(itemImage).to.exist;
15
+ expect(title).to.exist;
16
+ expect(itemStats).not.exist; // search tiles doesn't have stats bar
17
+ });
18
+ it('should render with title element', async () => {
19
+ var _a, _b, _c;
20
+ const el = await fixture(html `
21
+ <search-tile
22
+ .model=${{
23
+ identifier: 'searched query',
24
+ title: 'searched query',
25
+ }}
26
+ >
27
+ </search-tile>
28
+ `);
29
+ await el.updateComplete;
30
+ const itemInfo = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('.item-info');
31
+ const itemTitle = (_b = el.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('#title');
32
+ expect(itemInfo).to.exist;
33
+ expect(itemTitle).to.exist;
34
+ expect((_c = itemTitle === null || itemTitle === void 0 ? void 0 : itemTitle.querySelector('.truncated')) === null || _c === void 0 ? void 0 : _c.textContent).to.equal('searched query');
35
+ });
36
+ it('should render with image-block element', async () => {
37
+ var _a;
38
+ const el = await fixture(html `
39
+ <search-tile
40
+ .model=${{
41
+ identifier: 'title:hello-world',
42
+ }}
43
+ >
44
+ </search-tile>
45
+ `);
46
+ await el.updateComplete;
47
+ const itemImageBlock = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('image-block');
48
+ expect(itemImageBlock).to.exist;
49
+ });
50
+ it('should not render with item stats element', async () => {
51
+ var _a;
52
+ const el = await fixture(html `
53
+ <search-tile
54
+ .model=${{
55
+ identifier: '@jack-sparrow',
56
+ itemCount: 14521,
57
+ collectionSize: 23222543,
58
+ }}
59
+ >
60
+ </search-tile>
61
+ `);
62
+ await el.updateComplete;
63
+ const itemStats = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('#item-stats');
64
+ expect(itemStats).not.exist;
65
+ });
66
+ });
67
+ //# sourceMappingURL=search-tile.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search-tile.test.js","sourceRoot":"","sources":["../../../../test/tiles/grid/search-tile.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,qCAAqC,CAAC;AAE7C,QAAQ,CAAC,aAAa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C,KAAK,CAAC;QAC1B,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC;QAC3B,MAAM,CAAC,MAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,aAAa,CAAC,YAAY,CAAC,0CAAE,WAAW,CAAC,CAAC,EAAE,CAAC,KAAK,CAClE,gBAAgB,CACjB,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,wCAAwC,EAAE,KAAK,IAAI,EAAE;;QACtD,MAAM,EAAE,GAAG,MAAM,OAAO,CAAa,IAAI,CAAA;;iBAE5B;YACP,UAAU,EAAE,mBAAmB;SAChC;;;KAGJ,CAAC,CAAC;QACH,MAAM,EAAE,CAAC,cAAc,CAAC;QAExB,MAAM,cAAc,GAAG,MAAA,EAAE,CAAC,UAAU,0CAAE,aAAa,CAAC,aAAa,CAAC,CAAC;QACnE,MAAM,CAAC,cAAc,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC;IAClC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,2CAA2C,EAAE,KAAK,IAAI,EAAE;;QACzD,MAAM,EAAE,GAAG,MAAM,OAAO,CAAa,IAAI,CAAA;;iBAE5B;YACP,UAAU,EAAE,eAAe;YAC3B,SAAS,EAAE,KAAK;YAChB,cAAc,EAAE,QAAQ;SACzB;;;KAGJ,CAAC,CAAC;QACH,MAAM,EAAE,CAAC,cAAc,CAAC;QAExB,MAAM,SAAS,GAAG,MAAA,EAAE,CAAC,UAAU,0CAAE,aAAa,CAAC,aAAa,CAAC,CAAC;QAC9D,MAAM,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC;IAC9B,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 type { SearchTile } from '../../../src/tiles/grid/search-tile';\n\nimport '../../../src/tiles/grid/search-tile';\n\ndescribe('Search Tile', () => {\n it('should render initial component', async () => {\n const el = await fixture<SearchTile>(html`<search-tile></search-tile>`);\n\n const itemInfo = el.shadowRoot?.querySelector('.item-info');\n const itemImage = el.shadowRoot?.querySelector('image-block');\n const title = el.shadowRoot?.querySelector('#title');\n const itemStats = el.shadowRoot?.querySelector('#item-stats');\n\n expect(itemInfo).to.exist;\n expect(itemImage).to.exist;\n expect(title).to.exist;\n expect(itemStats).not.exist; // search tiles doesn't have stats bar\n });\n\n it('should render with title element', async () => {\n const el = await fixture<SearchTile>(html`\n <search-tile\n .model=${{\n identifier: 'searched query',\n title: 'searched query',\n }}\n >\n </search-tile>\n `);\n await el.updateComplete;\n\n const itemInfo = el.shadowRoot?.querySelector('.item-info');\n const itemTitle = el.shadowRoot?.querySelector('#title');\n\n expect(itemInfo).to.exist;\n expect(itemTitle).to.exist;\n expect(itemTitle?.querySelector('.truncated')?.textContent).to.equal(\n 'searched query'\n );\n });\n\n it('should render with image-block element', async () => {\n const el = await fixture<SearchTile>(html`\n <search-tile\n .model=${{\n identifier: 'title:hello-world',\n }}\n >\n </search-tile>\n `);\n await el.updateComplete;\n\n const itemImageBlock = el.shadowRoot?.querySelector('image-block');\n expect(itemImageBlock).to.exist;\n });\n\n it('should not render with item stats element', async () => {\n const el = await fixture<SearchTile>(html`\n <search-tile\n .model=${{\n identifier: '@jack-sparrow',\n itemCount: 14521,\n collectionSize: 23222543,\n }}\n >\n </search-tile>\n `);\n await el.updateComplete;\n\n const itemStats = el.shadowRoot?.querySelector('#item-stats');\n expect(itemStats).not.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": "1.14.2",
6
+ "version": "1.14.3",
7
7
  "main": "dist/index.js",
8
8
  "module": "dist/index.js",
9
9
  "scripts": {
@@ -23,16 +23,16 @@
23
23
  "types": "dist/index.d.ts",
24
24
  "dependencies": {
25
25
  "@internetarchive/analytics-manager": "^0.1.2",
26
- "@internetarchive/collection-name-cache": "^0.2.13",
26
+ "@internetarchive/collection-name-cache": "^0.2.14",
27
27
  "@internetarchive/feature-feedback": "^0.1.4",
28
- "@internetarchive/field-parsers": "^0.1.3",
28
+ "@internetarchive/field-parsers": "^0.1.4",
29
29
  "@internetarchive/histogram-date-range": "^1.1.0",
30
30
  "@internetarchive/ia-activity-indicator": "^0.0.4",
31
31
  "@internetarchive/ia-dropdown": "^1.1.0",
32
32
  "@internetarchive/infinite-scroller": "^1.0.0",
33
33
  "@internetarchive/local-cache": "^0.2.1",
34
34
  "@internetarchive/modal-manager": "^0.2.8",
35
- "@internetarchive/search-service": "^1.2.0",
35
+ "@internetarchive/search-service": "^1.2.2",
36
36
  "@internetarchive/shared-resize-observer": "^0.2.0",
37
37
  "@lit/localize": "^0.11.2",
38
38
  "dompurify": "^2.3.6",
@@ -0,0 +1,14 @@
1
+ import { svg } from 'lit';
2
+
3
+ export const searchIcon = svg`
4
+ <svg
5
+ viewBox="0 0 100 100"
6
+ xmlns="http://www.w3.org/2000/svg">
7
+ <path
8
+ class="fill-color"
9
+ d="m17.0555551 41.3194459c0-12.7430552 10.3541664-23.1027772 23.0847216-23.1027772 12.7166664 0 23.0777773 10.359722 23.0777773 23.1027772 0 12.7361108-10.3611109 23.0986106-23.0777773 23.0986106-12.7305552 0-23.0847216-10.3624998-23.0847216-23.0986106zm-17.24305512 0c0 22.2916661 18.04583292 40.3472213 40.32777672 40.3472213 8.9208332 0 17.145833-2.9319449 23.8194439-7.8527776l24.1513883 24.0777771c1.2125 1.1402778 2.8430555 1.8430556 4.6374999 1.8430556 3.7444443 0 6.7805554-3.0361111 6.7805554-6.7791665 0-2.0652778-.9222222-3.9069444-2.3736111-5.1499999l-23.718055-23.7458328c4.4152777-6.4791665 7.0152776-14.3055552 7.0152776-22.7402772 0-22.2791661-18.0458328-40.34861006-40.312499-40.34861006-22.2819438 0-40.32777672 18.06944396-40.32777672 40.34861006z"
10
+ fill="#2c2c2c"
11
+ fill-rule="evenodd"
12
+ />
13
+ </svg>
14
+ `;
@@ -2163,7 +2163,7 @@ export class CollectionBrowser
2163
2163
  identifier: result.identifier,
2164
2164
  issue: result.issue?.value,
2165
2165
  itemCount: result.item_count?.value ?? 0,
2166
- mediatype: result.mediatype?.value ?? 'data',
2166
+ mediatype: this.getMediatype(result),
2167
2167
  snippets: result.highlight?.values ?? [],
2168
2168
  source: result.source?.value,
2169
2169
  subjects: result.subject?.values ?? [],
@@ -2184,6 +2184,25 @@ export class CollectionBrowser
2184
2184
  }
2185
2185
  }
2186
2186
 
2187
+ private getMediatype(result: SearchResult) {
2188
+ /**
2189
+ * hit_type == 'favorited_search' is basically a new hit_type
2190
+ * - we are getting from PPS.
2191
+ * - which gives response for fav- collection
2192
+ * - having favorited items like account/collection/item etc..
2193
+ * - as user can also favorite a search result (a search page)
2194
+ * - so we need to have response (having fav- items and fav- search results)
2195
+ *
2196
+ * if backend hit_type == 'favorited_search'
2197
+ * - let's assume a "search" as new mediatype
2198
+ */
2199
+ if (result?.rawMetadata?.hit_type === 'favorited_search') {
2200
+ return 'search';
2201
+ }
2202
+
2203
+ return result.mediatype?.value ?? 'data';
2204
+ }
2205
+
2187
2206
  /**
2188
2207
  * Returns the input string, but removing one set of quotes from all instances of
2189
2208
  * ""clauses wrapped in two sets of quotes"". This assumes the quotes are already
@@ -11,6 +11,7 @@ import { textsIcon } from '../assets/img/icons/mediatype/texts';
11
11
  import { tvIcon } from '../assets/img/icons/mediatype/tv';
12
12
  import { videoIcon } from '../assets/img/icons/mediatype/video';
13
13
  import { webIcon } from '../assets/img/icons/mediatype/web';
14
+ import { searchIcon } from '../assets/img/icons/mediatype/search';
14
15
 
15
16
  export const mediatypeConfig: { [key: string]: any } = {
16
17
  account: {
@@ -83,4 +84,9 @@ export const mediatypeConfig: { [key: string]: any } = {
83
84
  icon: webIcon,
84
85
  text: 'Web',
85
86
  },
87
+ search: {
88
+ color: '#000000',
89
+ icon: searchIcon,
90
+ text: 'Search',
91
+ },
86
92
  };
@@ -50,6 +50,10 @@ export const baseItemImageStyles = css`
50
50
  width: 100%;
51
51
  height: 160px;
52
52
  }
53
+
54
+ .list-box.search-image svg {
55
+ margin: 10px;
56
+ }
53
57
  `;
54
58
 
55
59
  /**
@@ -0,0 +1,87 @@
1
+ import { css, CSSResultGroup, html, TemplateResult } from 'lit';
2
+ import { customElement, property } from 'lit/decorators.js';
3
+ import { baseTileStyles } from './styles/tile-grid-shared-styles';
4
+ import { BaseTileComponent } from '../base-tile-component';
5
+ import '../image-block';
6
+
7
+ @customElement('search-tile')
8
+ export class SearchTile extends BaseTileComponent {
9
+ /*
10
+ * Reactive properties inherited from BaseTileComponent:
11
+ * - model?: TileModel;
12
+ * - currentWidth?: number;
13
+ * - currentHeight?: number;
14
+ * - baseNavigationUrl?: string;
15
+ * - baseImageUrl?: string;
16
+ * - collectionPagePath?: string;
17
+ * - sortParam: SortParam | null = null;
18
+ * - creatorFilter?: string;
19
+ * - mobileBreakpoint?: number;
20
+ * - loggedIn = false;
21
+ */
22
+
23
+ @property({ type: Boolean }) showInfoButton = false;
24
+
25
+ render() {
26
+ return html`
27
+ <div class="container">
28
+ <div class="tile-details">
29
+ <div class="item-info">
30
+ ${this.getImageBlockTemplate} ${this.getTitleTemplate}
31
+ </div>
32
+ </div>
33
+ </div>
34
+ `;
35
+ }
36
+
37
+ private get getImageBlockTemplate(): TemplateResult {
38
+ return html`
39
+ <image-block
40
+ .model=${this.model}
41
+ .baseImageUrl=${this.baseImageUrl}
42
+ .viewSize=${'grid'}
43
+ >
44
+ </image-block>
45
+ `;
46
+ }
47
+
48
+ private get getTitleTemplate() {
49
+ return html`<div id="title">
50
+ <h4 class="truncated">${this.model?.title}</h4>
51
+ </div>`;
52
+ }
53
+
54
+ static get styles(): CSSResultGroup {
55
+ const tileBorderColor = css`var(--tileBorderColor, #555555)`;
56
+ const tileBackgroundColor = css`var(--tileBackgroundColor, #666666)`;
57
+ const whiteColor = css`#fff`;
58
+
59
+ return [
60
+ baseTileStyles,
61
+ css`
62
+ .container {
63
+ background-color: ${tileBackgroundColor};
64
+ border: 1px solid ${tileBorderColor};
65
+ }
66
+
67
+ .item-info {
68
+ flex-grow: initial;
69
+ }
70
+
71
+ h4.truncated {
72
+ color: ${whiteColor};
73
+ -webkit-line-clamp: 4;
74
+ }
75
+
76
+ .container:hover > #title {
77
+ text-decoration: underline;
78
+ }
79
+
80
+ /* this is a workaround for Safari 15 where the hover effects are not working */
81
+ image-block:hover > #title {
82
+ text-decoration: underline;
83
+ }
84
+ `,
85
+ ];
86
+ }
87
+ }
@@ -46,6 +46,7 @@ export class ImageBlock extends LitElement {
46
46
  'list-compact': this.isListTile && this.isCompactTile,
47
47
  collection: this.model?.mediatype === 'collection', // fill the image in container
48
48
  [this.viewSize]: true,
49
+ 'search-image': this.model?.mediatype === 'search',
49
50
  };
50
51
  }
51
52
 
@@ -101,7 +102,8 @@ export class ImageBlock extends LitElement {
101
102
  border-radius: 4px 4px 0 0;
102
103
  }
103
104
 
104
- .collection.grid {
105
+ .collection.grid,
106
+ .grid.search-image {
105
107
  display: block;
106
108
  }
107
109
 
@@ -8,6 +8,7 @@ import {
8
8
  baseItemImageStyles,
9
9
  waveformGradientStyles,
10
10
  } from '../styles/item-image-styles';
11
+ import { searchIcon } from '../assets/img/icons/mediatype/search';
11
12
 
12
13
  @customElement('item-image')
13
14
  export class ItemImage extends LitElement {
@@ -27,14 +28,22 @@ export class ItemImage extends LitElement {
27
28
 
28
29
  render() {
29
30
  return html`
30
- <div class=${classMap(this.itemBaseClass)}>
31
- <img
32
- class=${classMap(this.itemImageClass)}
33
- src="${this.imageSrc}"
34
- alt=""
35
- @load=${this.onLoad}
36
- />
37
- </div>
31
+ <div class=${classMap(this.itemBaseClass)}>${this.imageTemplate}</div>
32
+ `;
33
+ }
34
+
35
+ private get imageTemplate() {
36
+ if (this.model?.mediatype === 'search') {
37
+ return html`${searchIcon}`;
38
+ }
39
+
40
+ return html`
41
+ <img
42
+ class=${classMap(this.itemImageClass)}
43
+ src="${this.imageSrc}"
44
+ alt=""
45
+ @load=${this.onLoad}
46
+ />
38
47
  `;
39
48
  }
40
49
 
@@ -69,6 +78,7 @@ export class ItemImage extends LitElement {
69
78
  return {
70
79
  'drop-shadow': true,
71
80
  'list-box': this.isListTile,
81
+ 'search-image': this.model?.mediatype === 'search',
72
82
  [this.hashBasedGradient]: this.isWaveform,
73
83
  };
74
84
  }
@@ -122,6 +132,19 @@ export class ItemImage extends LitElement {
122
132
  height: var(--imgHeight, 16rem);
123
133
  width: var(--imgWidth, 16rem);
124
134
  }
135
+
136
+ .search-image {
137
+ display: flex;
138
+ align-items: center;
139
+ justify-content: center;
140
+ background: rgb(245, 245, 247);
141
+ border-radius: 4px;
142
+ }
143
+
144
+ svg {
145
+ height: 10rem;
146
+ width: 10rem;
147
+ }
125
148
  `,
126
149
  ];
127
150
  }
@@ -239,6 +239,11 @@ export class TileList extends BaseTileComponent {
239
239
  ? this.model?.weeklyViewCount // weekly views
240
240
  : this.model?.viewCount; // all-time views
241
241
 
242
+ // when its a search-tile, we don't have any stats to show
243
+ if (this.model?.mediatype === 'search') {
244
+ return this.metadataTemplate('(Favorited search query)', '');
245
+ }
246
+
242
247
  return this.metadataTemplate(
243
248
  `${formatCount(viewCount ?? 0, this.formatSize)}`,
244
249
  msg('Views')
@@ -11,6 +11,7 @@ import type { TileDisplayMode } from '../models';
11
11
  import './grid/collection-tile';
12
12
  import './grid/item-tile';
13
13
  import './grid/account-tile';
14
+ import './grid/search-tile';
14
15
  import './hover/tile-hover-pane';
15
16
  import './list/tile-list';
16
17
  import './list/tile-list-compact';
@@ -181,7 +182,8 @@ export class TileDispatcher
181
182
  return (
182
183
  this.enableHoverPane &&
183
184
  !!this.tileDisplayMode &&
184
- TileDispatcher.HOVER_PANE_DISPLAY_MODES[this.tileDisplayMode]
185
+ TileDispatcher.HOVER_PANE_DISPLAY_MODES[this.tileDisplayMode] &&
186
+ this.model?.mediatype !== 'search' // don't show hover panes on search tiles
185
187
  );
186
188
  }
187
189
 
@@ -311,6 +313,19 @@ export class TileDispatcher
311
313
  @infoButtonPressed=${this.tileInfoButtonPressed}
312
314
  >
313
315
  </account-tile>`;
316
+ case 'search':
317
+ return html`<search-tile
318
+ .model=${model}
319
+ .collectionPagePath=${collectionPagePath}
320
+ .baseImageUrl=${this.baseImageUrl}
321
+ .currentWidth=${currentWidth}
322
+ .currentHeight=${currentHeight}
323
+ .creatorFilter=${creatorFilter}
324
+ .isManageView=${this.isManageView}
325
+ ?showInfoButton=${false}
326
+ @infoButtonPressed=${this.tileInfoButtonPressed}
327
+ >
328
+ </search-tile>`;
314
329
  default:
315
330
  return html`<item-tile
316
331
  .model=${model}
@@ -385,6 +400,13 @@ export class TileDispatcher
385
400
  --imageBlockBackgroundColor: #f1f1f4;
386
401
  }
387
402
 
403
+ search-tile {
404
+ --tileBorderColor: #555555;
405
+ --tileBackgroundColor: #666666;
406
+ --imageBlockBackgroundColor: #666666;
407
+ --iconFillColor: #2c2c2c;
408
+ }
409
+
388
410
  #container {
389
411
  position: relative;
390
412
  height: 100%;
@@ -0,0 +1,76 @@
1
+ /* eslint-disable import/no-duplicates */
2
+ import { expect, fixture } from '@open-wc/testing';
3
+ import { html } from 'lit';
4
+ import type { SearchTile } from '../../../src/tiles/grid/search-tile';
5
+
6
+ import '../../../src/tiles/grid/search-tile';
7
+
8
+ describe('Search Tile', () => {
9
+ it('should render initial component', async () => {
10
+ const el = await fixture<SearchTile>(html`<search-tile></search-tile>`);
11
+
12
+ const itemInfo = el.shadowRoot?.querySelector('.item-info');
13
+ const itemImage = el.shadowRoot?.querySelector('image-block');
14
+ const title = el.shadowRoot?.querySelector('#title');
15
+ const itemStats = el.shadowRoot?.querySelector('#item-stats');
16
+
17
+ expect(itemInfo).to.exist;
18
+ expect(itemImage).to.exist;
19
+ expect(title).to.exist;
20
+ expect(itemStats).not.exist; // search tiles doesn't have stats bar
21
+ });
22
+
23
+ it('should render with title element', async () => {
24
+ const el = await fixture<SearchTile>(html`
25
+ <search-tile
26
+ .model=${{
27
+ identifier: 'searched query',
28
+ title: 'searched query',
29
+ }}
30
+ >
31
+ </search-tile>
32
+ `);
33
+ await el.updateComplete;
34
+
35
+ const itemInfo = el.shadowRoot?.querySelector('.item-info');
36
+ const itemTitle = el.shadowRoot?.querySelector('#title');
37
+
38
+ expect(itemInfo).to.exist;
39
+ expect(itemTitle).to.exist;
40
+ expect(itemTitle?.querySelector('.truncated')?.textContent).to.equal(
41
+ 'searched query'
42
+ );
43
+ });
44
+
45
+ it('should render with image-block element', async () => {
46
+ const el = await fixture<SearchTile>(html`
47
+ <search-tile
48
+ .model=${{
49
+ identifier: 'title:hello-world',
50
+ }}
51
+ >
52
+ </search-tile>
53
+ `);
54
+ await el.updateComplete;
55
+
56
+ const itemImageBlock = el.shadowRoot?.querySelector('image-block');
57
+ expect(itemImageBlock).to.exist;
58
+ });
59
+
60
+ it('should not render with item stats element', async () => {
61
+ const el = await fixture<SearchTile>(html`
62
+ <search-tile
63
+ .model=${{
64
+ identifier: '@jack-sparrow',
65
+ itemCount: 14521,
66
+ collectionSize: 23222543,
67
+ }}
68
+ >
69
+ </search-tile>
70
+ `);
71
+ await el.updateComplete;
72
+
73
+ const itemStats = el.shadowRoot?.querySelector('#item-stats');
74
+ expect(itemStats).not.exist;
75
+ });
76
+ });