Skip to content

Commit 7f4831d

Browse files
WEBDEV-7036 Integrate smart results into collection browser (#404)
* Add slot and styling for smart results * Update to new search service
1 parent 908c361 commit 7f4831d

File tree

3 files changed

+60
-18
lines changed

3 files changed

+60
-18
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"@internetarchive/ia-dropdown": "^1.3.8",
3232
"@internetarchive/infinite-scroller": "1.0.1",
3333
"@internetarchive/modal-manager": "^0.2.8",
34-
"@internetarchive/search-service": "^1.4.0",
34+
"@internetarchive/search-service": "^1.4.1",
3535
"@internetarchive/shared-resize-observer": "^0.2.0",
3636
"@lit/localize": "^0.11.2",
3737
"dompurify": "^2.3.6",

src/collection-browser.ts

+55-13
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,9 @@ export class CollectionBrowser
245245
/** Whether to replace the default sort options with a slot for customization (default: false) */
246246
@property({ type: Boolean }) enableSortOptionsSlot = false;
247247

248+
/** Whether to display a smart results carousel above the full results */
249+
@property({ type: Boolean, reflect: true }) showSmartResults = false;
250+
248251
/**
249252
* The results per page so we can paginate.
250253
*
@@ -652,18 +655,31 @@ export class CollectionBrowser
652655
*/
653656
private get rightColumnTemplate(): TemplateResult {
654657
return html`
655-
<div id="right-column" class="column">
656-
<div id="cb-top-view">
657-
<slot name="cb-top-slot"></slot>
658-
</div>
659-
${this.isManageView
660-
? this.manageBarTemplate
661-
: this.sortFilterBarTemplate}
662-
<slot name="cb-results"></slot>
663-
${this.displayMode === `list-compact` && this.totalResults
664-
? this.listHeaderTemplate
658+
<div
659+
id="right-column"
660+
class="column ${this.showSmartResults ? 'smart-results-spacing' : ''}"
661+
>
662+
${this.showSmartResults
663+
? html`<slot name="smart-results"></slot>`
665664
: nothing}
666-
${this.suppressResultTiles ? nothing : this.infiniteScrollerTemplate}
665+
<section id="results">
666+
${this.showSmartResults
667+
? html`<h2 class="results-section-heading">
668+
${msg('All results')}
669+
</h2>`
670+
: nothing}
671+
<div id="cb-top-view">
672+
<slot name="cb-top-slot"></slot>
673+
</div>
674+
${this.isManageView
675+
? this.manageBarTemplate
676+
: this.sortFilterBarTemplate}
677+
<slot name="cb-results"></slot>
678+
${this.displayMode === `list-compact` && this.totalResults
679+
? this.listHeaderTemplate
680+
: nothing}
681+
${this.suppressResultTiles ? nothing : this.infiniteScrollerTemplate}
682+
</section>
667683
</div>
668684
`;
669685
}
@@ -2072,14 +2088,34 @@ export class CollectionBrowser
20722088
min-height: 90vh;
20732089
border-left: 1px solid rgb(232, 232, 232);
20742090
border-right: 1px solid rgb(232, 232, 232);
2075-
padding-left: 1rem;
2076-
padding-right: 1rem;
20772091
margin-top: var(--rightColumnMarginTop, 0);
20782092
background: #fff;
20792093
}
20802094
2095+
#right-column.smart-results-spacing {
2096+
padding-top: 0.5rem;
2097+
border-right: none;
2098+
background: transparent;
2099+
min-width: 0;
2100+
}
2101+
2102+
#results {
2103+
background: #fff;
2104+
padding-left: 1rem;
2105+
padding-right: 1rem;
2106+
}
2107+
2108+
#right-column.smart-results-spacing #results {
2109+
border-radius: 10px 10px 0px 0px;
2110+
padding-top: 0.5rem;
2111+
margin-top: 1rem;
2112+
}
2113+
20812114
.mobile #right-column {
20822115
border-left: none;
2116+
}
2117+
2118+
.mobile #results {
20832119
padding: 5px 5px 0;
20842120
}
20852121
@@ -2268,6 +2304,12 @@ export class CollectionBrowser
22682304
max-height: 2000px;
22692305
}
22702306
2307+
.results-section-heading {
2308+
margin: 0.5rem 0.3rem;
2309+
font-size: 2rem;
2310+
line-height: 25px;
2311+
}
2312+
22712313
#results-total {
22722314
display: flex;
22732315
align-items: baseline;

yarn.lock

+4-4
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,10 @@
211211
resolved "https://registry.npmjs.org/@internetarchive/result-type/-/result-type-0.0.1.tgz"
212212
integrity sha512-sWahff5oP1xAK1CwAu1/5GTG2RXsdx/sQKn4SSOWH0r0vU2QoX9kAom/jSXeBsmgK0IjTc+9Ty9407SMORi+nQ==
213213

214-
"@internetarchive/search-service@^1.4.0":
215-
version "1.4.0"
216-
resolved "https://registry.yarnpkg.com/@internetarchive/search-service/-/search-service-1.4.0.tgz#e8fea0609eaf832b3fcdb02acb21e1a6c79bf028"
217-
integrity sha512-6+GH5NbDLE1v+JfY5Ryo1GnsTUbpkbX/B0NCkoB25iYQZA82AbiNEyb6M6X332/5mUDRTGx6HKi+74CcJpDVEw==
214+
"@internetarchive/search-service@^1.4.1":
215+
version "1.4.1"
216+
resolved "https://registry.yarnpkg.com/@internetarchive/search-service/-/search-service-1.4.1.tgz#c68e2d285066137b879d49009c34caf8cfa96437"
217+
integrity sha512-csXL1ikZGROss2wxKyyKZpZx4STv7W+RN1/Dw8hh2Jvd1vKYJjVv/ah9P9CnG/QarStvZuVVGA1m2Rru6m3O2w==
218218
dependencies:
219219
"@internetarchive/field-parsers" "^0.1.4"
220220
"@internetarchive/result-type" "^0.0.1"

0 commit comments

Comments
 (0)