@internetarchive/collection-browser 0.0.1-alpha.13 → 0.0.1-alpha.16
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.
- package/demo/app-root.ts +0 -4
- package/dist/demo/app-root.js +0 -4
- package/dist/demo/app-root.js.map +1 -1
- package/dist/src/assets/img/icons/arrow-right.d.ts +2 -0
- package/dist/src/assets/img/icons/arrow-right.js +4 -0
- package/dist/src/assets/img/icons/arrow-right.js.map +1 -0
- package/dist/src/assets/img/icons/chevron.d.ts +2 -0
- package/dist/src/assets/img/icons/chevron.js +4 -0
- package/dist/src/assets/img/icons/chevron.js.map +1 -0
- package/dist/src/collection-browser.d.ts +13 -3
- package/dist/src/collection-browser.js +178 -32
- package/dist/src/collection-browser.js.map +1 -1
- package/dist/src/collection-facets.d.ts +4 -1
- package/dist/src/collection-facets.js +88 -9
- package/dist/src/collection-facets.js.map +1 -1
- package/dist/src/mediatype-icon.js +2 -2
- package/dist/src/mediatype-icon.js.map +1 -1
- package/dist/src/models.d.ts +14 -2
- package/dist/src/models.js +31 -7
- package/dist/src/models.js.map +1 -1
- package/dist/src/sort-filter-bar/alpha-bar.js +1 -1
- package/dist/src/sort-filter-bar/alpha-bar.js.map +1 -1
- package/dist/src/sort-filter-bar/sort-filter-bar.d.ts +38 -4
- package/dist/src/sort-filter-bar/sort-filter-bar.js +297 -200
- package/dist/src/sort-filter-bar/sort-filter-bar.js.map +1 -1
- package/dist/src/tiles/list/tile-list-compact-header.d.ts +11 -0
- package/dist/src/tiles/list/tile-list-compact-header.js +77 -0
- package/dist/src/tiles/list/tile-list-compact-header.js.map +1 -0
- package/dist/src/tiles/list/tile-list-compact.d.ts +1 -1
- package/dist/src/tiles/list/tile-list-compact.js +12 -12
- package/dist/src/tiles/list/tile-list-compact.js.map +1 -1
- package/dist/src/tiles/list/tile-list.d.ts +10 -10
- package/dist/src/tiles/list/tile-list.js +41 -36
- package/dist/src/tiles/list/tile-list.js.map +1 -1
- package/dist/src/tiles/tile-dispatcher.d.ts +3 -0
- package/dist/src/tiles/tile-dispatcher.js +31 -12
- package/dist/src/tiles/tile-dispatcher.js.map +1 -1
- package/package.json +1 -1
- package/src/assets/img/icons/chevron.ts +4 -0
- package/src/collection-browser.ts +187 -38
- package/src/collection-facets.ts +87 -11
- package/src/mediatype-icon.ts +2 -2
- package/src/models.ts +35 -17
- package/src/sort-filter-bar/alpha-bar.ts +1 -1
- package/src/sort-filter-bar/sort-filter-bar.ts +339 -208
- package/src/tiles/list/tile-list-compact-header.ts +73 -0
- package/src/tiles/list/tile-list-compact.ts +12 -12
- package/src/tiles/list/tile-list.ts +41 -39
- package/src/tiles/tile-dispatcher.ts +33 -12
|
@@ -7,25 +7,44 @@ import './grid/item-tile';
|
|
|
7
7
|
import './grid/account-tile';
|
|
8
8
|
import './list/tile-list';
|
|
9
9
|
import './list/tile-list-compact';
|
|
10
|
+
import './list/tile-list-compact-header';
|
|
10
11
|
let TileDispatcher = class TileDispatcher extends LitElement {
|
|
11
12
|
constructor() {
|
|
12
13
|
super(...arguments);
|
|
13
14
|
this.showDeleteButton = false;
|
|
14
15
|
}
|
|
15
16
|
render() {
|
|
16
|
-
var _a, _b;
|
|
17
17
|
return html `
|
|
18
18
|
<div id="container">
|
|
19
|
-
${this.
|
|
19
|
+
${this.displayMode === 'list-header'
|
|
20
|
+
? this.headerTemplate
|
|
21
|
+
: this.tileTemplate}
|
|
22
|
+
</div>
|
|
23
|
+
`;
|
|
24
|
+
}
|
|
25
|
+
get headerTemplate() {
|
|
26
|
+
const { currentWidth, sortParam } = this;
|
|
27
|
+
return html `
|
|
28
|
+
<tile-list-compact-header
|
|
29
|
+
class="header"
|
|
30
|
+
.currentWidth=${currentWidth}
|
|
31
|
+
.sortParam=${sortParam}
|
|
32
|
+
>
|
|
33
|
+
</tile-list-compact-header>
|
|
34
|
+
`;
|
|
35
|
+
}
|
|
36
|
+
get tileTemplate() {
|
|
37
|
+
var _a, _b;
|
|
38
|
+
return html `
|
|
39
|
+
${this.showDeleteButton
|
|
20
40
|
? html `<button id="delete-button">X</button>`
|
|
21
41
|
: nothing}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
</div>
|
|
42
|
+
<a
|
|
43
|
+
href="${this.baseNavigationUrl}/details/${(_a = this.model) === null || _a === void 0 ? void 0 : _a.identifier}"
|
|
44
|
+
title=${ifDefined((_b = this.model) === null || _b === void 0 ? void 0 : _b.title)}
|
|
45
|
+
>
|
|
46
|
+
${this.tile}
|
|
47
|
+
</a>
|
|
29
48
|
`;
|
|
30
49
|
}
|
|
31
50
|
handleResize(entry) {
|
|
@@ -79,9 +98,9 @@ let TileDispatcher = class TileDispatcher extends LitElement {
|
|
|
79
98
|
default:
|
|
80
99
|
return html `<item-tile
|
|
81
100
|
.model=${model}
|
|
82
|
-
.baseNavigationUrl=${
|
|
83
|
-
.currentWidth=${
|
|
84
|
-
.currentHeight=${
|
|
101
|
+
.baseNavigationUrl=${baseNavigationUrl}
|
|
102
|
+
.currentWidth=${currentWidth}
|
|
103
|
+
.currentHeight=${currentHeight}
|
|
85
104
|
></item-tile>`;
|
|
86
105
|
}
|
|
87
106
|
case 'list-compact':
|
|
@@ -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,UAAU,EAAE,OAAO,EAAkB,MAAM,KAAK,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAOzD,OAAO,wBAAwB,CAAC;AAChC,OAAO,kBAAkB,CAAC;AAC1B,OAAO,qBAAqB,CAAC;AAC7B,OAAO,kBAAkB,CAAC;AAC1B,OAAO,0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AAC;iDAAoC;AApB7C,cAAc;IAD1B,aAAa,CAAC,iBAAiB,CAAC;GACpB,cAAc,CA2K1B;SA3KY,cAAc","sourcesContent":["import { css, html, LitElement, nothing, PropertyValues } from 'lit';\nimport { customElement, property, query } from 'lit/decorators.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport {\n SharedResizeObserverInterface,\n SharedResizeObserverResizeHandlerInterface,\n} from '@internetarchive/shared-resize-observer';\nimport { SortParam } from '@internetarchive/search-service';\nimport type { CollectionDisplayMode, TileModel } from '../models';\nimport './grid/collection-tile';\nimport './grid/item-tile';\nimport './grid/account-tile';\nimport './list/tile-list';\nimport './list/tile-list-compact';\nimport './list/tile-list-compact-header';\n\n@customElement('tile-dispatcher')\nexport class TileDispatcher\n extends LitElement\n implements SharedResizeObserverResizeHandlerInterface\n{\n @property({ type: String }) displayMode?: CollectionDisplayMode;\n\n @property({ type: Object }) model?: TileModel;\n\n @property({ type: String }) baseNavigationUrl?: string;\n\n @property({ type: Boolean }) showDeleteButton = false;\n\n @property({ type: Number }) currentWidth?: number;\n\n @property({ type: Number }) currentHeight?: number;\n\n @property({ type: Object }) resizeObserver?: SharedResizeObserverInterface;\n\n @property({ type: Object }) sortParam?: SortParam;\n\n @query('#container') private container!: HTMLDivElement;\n\n render() {\n return html`\n <div id=\"container\">\n ${this.displayMode === 'list-header'\n ? this.headerTemplate\n : this.tileTemplate}\n </div>\n `;\n }\n\n private get headerTemplate() {\n const { currentWidth, sortParam } = this;\n return html`\n <tile-list-compact-header\n class=\"header\"\n .currentWidth=${currentWidth}\n .sortParam=${sortParam}\n >\n </tile-list-compact-header>\n `;\n }\n\n private get tileTemplate() {\n return html`\n ${this.showDeleteButton\n ? html`<button id=\"delete-button\">X</button>`\n : nothing}\n <a\n href=\"${this.baseNavigationUrl}/details/${this.model?.identifier}\"\n title=${ifDefined(this.model?.title)}\n >\n ${this.tile}\n </a>\n `;\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 private get tile() {\n const { model, baseNavigationUrl, currentWidth, currentHeight, sortParam } =\n this;\n\n if (!model) return nothing;\n\n switch (this.displayMode) {\n case 'grid':\n switch (model.mediatype) {\n case 'collection':\n return html`<collection-tile\n .model=${model}\n .currentWidth=${currentWidth}\n .currentHeight=${currentHeight}\n >\n </collection-tile>`;\n case 'account':\n return html`<account-tile\n .model=${model}\n .currentWidth=${currentWidth}\n .currentHeight=${currentHeight}\n ></account-tile>`;\n default:\n return html`<item-tile\n .model=${model}\n .baseNavigationUrl=${baseNavigationUrl}\n .currentWidth=${currentWidth}\n .currentHeight=${currentHeight}\n ></item-tile>`;\n }\n case 'list-compact':\n return html`<tile-list-compact\n .model=${model}\n .currentWidth=${currentWidth}\n .currentHeight=${currentHeight}\n .baseNavigationUrl=${baseNavigationUrl}\n .sortParam=${sortParam}\n ></tile-list-compact>`;\n case 'list-detail':\n return html`<tile-list\n .model=${model}\n .currentWidth=${currentWidth}\n .currentHeight=${currentHeight}\n .baseNavigationUrl=${baseNavigationUrl}\n .sortParam=${sortParam}\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 #container {\n height: 100%;\n }\n\n #delete-button {\n float: right;\n }\n\n a {\n display: block;\n height: 100%;\n color: unset;\n text-decoration: none;\n }\n\n a :first-child {\n display: block;\n height: 100%;\n }\n `;\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { svg } from 'lit';
|
|
2
|
+
|
|
3
|
+
export default svg`<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"><path d="m79.8883285 50.0035012.1116715-.1085359-43.1159942-46.61088155c-2.401537-2.18938917-4.6902018-3.28408375-6.8659943-3.28408375s-4.1642651.63837733-5.9654178 1.91513199c-1.8011528 1.27675467-3.1520173 2.97248092-4.0525937 5.08717877l39.4020173 42.99768924-39.4020173 42.9976892c.9005764 2.1146979 2.2514409 3.8104241 4.0525937 5.0871788 1.8011527 1.2767547 3.7896253 1.915132 5.9654178 1.915132 2.1013449 0 4.3900096-1.0573489 6.8659943-3.1720468l43.1159942-46.7194174z"/></svg>
|
|
4
|
+
`;
|
|
@@ -24,7 +24,10 @@ import {
|
|
|
24
24
|
AggregateSearchParams,
|
|
25
25
|
SortParam,
|
|
26
26
|
} from '@internetarchive/search-service';
|
|
27
|
-
import {
|
|
27
|
+
import {
|
|
28
|
+
SharedResizeObserverInterface,
|
|
29
|
+
SharedResizeObserverResizeHandlerInterface,
|
|
30
|
+
} from '@internetarchive/shared-resize-observer';
|
|
28
31
|
import type { TileModel, CollectionDisplayMode } from './models';
|
|
29
32
|
import '@internetarchive/infinite-scroller';
|
|
30
33
|
import './tiles/tile-dispatcher';
|
|
@@ -45,11 +48,14 @@ import {
|
|
|
45
48
|
RestorationStateHandler,
|
|
46
49
|
RestorationState,
|
|
47
50
|
} from './restoration-state-handler';
|
|
51
|
+
import chevronIcon from './assets/img/icons/chevron';
|
|
48
52
|
|
|
49
53
|
@customElement('collection-browser')
|
|
50
54
|
export class CollectionBrowser
|
|
51
55
|
extends LitElement
|
|
52
|
-
implements
|
|
56
|
+
implements
|
|
57
|
+
InfiniteScrollerCellProviderInterface,
|
|
58
|
+
SharedResizeObserverResizeHandlerInterface
|
|
53
59
|
{
|
|
54
60
|
@property({ type: String }) baseNavigationUrl?: string;
|
|
55
61
|
|
|
@@ -63,7 +69,7 @@ export class CollectionBrowser
|
|
|
63
69
|
|
|
64
70
|
@property({ type: Object }) sortParam: SortParam | null = null;
|
|
65
71
|
|
|
66
|
-
@property({ type: String }) selectedSort: SortField =
|
|
72
|
+
@property({ type: String }) selectedSort: SortField = SortField.relevance;
|
|
67
73
|
|
|
68
74
|
@property({ type: String }) selectedTitleFilter: string | null = null;
|
|
69
75
|
|
|
@@ -98,6 +104,8 @@ export class CollectionBrowser
|
|
|
98
104
|
}
|
|
99
105
|
);
|
|
100
106
|
|
|
107
|
+
@property({ type: Number }) mobileBreakpoint = 530;
|
|
108
|
+
|
|
101
109
|
/**
|
|
102
110
|
* The page that the consumer wants to load.
|
|
103
111
|
*/
|
|
@@ -123,6 +131,12 @@ export class CollectionBrowser
|
|
|
123
131
|
|
|
124
132
|
@state() private totalResults?: number;
|
|
125
133
|
|
|
134
|
+
@state() private mobileView = false;
|
|
135
|
+
|
|
136
|
+
@state() private mobileFacetsVisible = false;
|
|
137
|
+
|
|
138
|
+
@query('#content-container') private contentContainer!: HTMLDivElement;
|
|
139
|
+
|
|
126
140
|
/**
|
|
127
141
|
* When we're animated scrolling to the page, we don't want to fetch
|
|
128
142
|
* all of the pages as it scrolls so this lets us know if we're scrolling
|
|
@@ -201,30 +215,48 @@ export class CollectionBrowser
|
|
|
201
215
|
|
|
202
216
|
render() {
|
|
203
217
|
return html`
|
|
204
|
-
<div id="content-container">
|
|
218
|
+
<div id="content-container" class=${this.mobileView ? 'mobile' : ''}>
|
|
205
219
|
<div id="left-column" class="column">
|
|
206
|
-
<div id="
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
220
|
+
<div id="mobile-header-container">
|
|
221
|
+
${this.mobileView
|
|
222
|
+
? html`
|
|
223
|
+
<div id="mobile-filter-collapse">
|
|
224
|
+
<h1
|
|
225
|
+
@click=${() => {
|
|
226
|
+
this.mobileFacetsVisible = !this.mobileFacetsVisible;
|
|
227
|
+
}}
|
|
228
|
+
@keyup=${() => {
|
|
229
|
+
this.mobileFacetsVisible = !this.mobileFacetsVisible;
|
|
230
|
+
}}
|
|
231
|
+
>
|
|
232
|
+
<span
|
|
233
|
+
class="collapser ${this.mobileFacetsVisible
|
|
234
|
+
? 'open'
|
|
235
|
+
: ''}"
|
|
236
|
+
>
|
|
237
|
+
${chevronIcon}
|
|
238
|
+
</span>
|
|
239
|
+
Filters
|
|
240
|
+
</h1>
|
|
241
|
+
</div>
|
|
242
|
+
`
|
|
243
|
+
: nothing}
|
|
244
|
+
<div id="results-total">
|
|
245
|
+
<span id="big-results-count"
|
|
246
|
+
>${this.totalResults
|
|
247
|
+
? this.totalResults.toLocaleString()
|
|
248
|
+
: '-'}</span
|
|
249
|
+
>
|
|
250
|
+
<span id="big-results-label">Results</span>
|
|
251
|
+
</div>
|
|
213
252
|
</div>
|
|
214
|
-
<div
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
.fullYearsHistogramAggregation}
|
|
222
|
-
.minSelectedDate=${this.minSelectedDate}
|
|
223
|
-
.maxSelectedDate=${this.maxSelectedDate}
|
|
224
|
-
.selectedFacets=${this.selectedFacets}
|
|
225
|
-
?facetsLoading=${this.facetDataLoading}
|
|
226
|
-
?fullYearAggregationLoading=${this.fullYearAggregationLoading}
|
|
227
|
-
></collection-facets>
|
|
253
|
+
<div
|
|
254
|
+
id="facets-container"
|
|
255
|
+
class=${!this.mobileView || this.mobileFacetsVisible
|
|
256
|
+
? 'expanded'
|
|
257
|
+
: ''}
|
|
258
|
+
>
|
|
259
|
+
${this.facetsTemplate}
|
|
228
260
|
</div>
|
|
229
261
|
</div>
|
|
230
262
|
<div id="right-column" class="column">
|
|
@@ -235,12 +267,17 @@ export class CollectionBrowser
|
|
|
235
267
|
.displayMode=${this.displayMode}
|
|
236
268
|
.selectedTitleFilter=${this.selectedTitleFilter}
|
|
237
269
|
.selectedCreatorFilter=${this.selectedCreatorFilter}
|
|
238
|
-
|
|
270
|
+
.resizeObserver=${this.resizeObserver}
|
|
271
|
+
@sortChanged=${this.userChangedSort}
|
|
239
272
|
@displayModeChanged=${this.displayModeChanged}
|
|
240
273
|
@titleLetterChanged=${this.titleLetterSelected}
|
|
241
274
|
@creatorLetterChanged=${this.creatorLetterSelected}
|
|
242
275
|
></sort-filter-bar>
|
|
243
276
|
|
|
277
|
+
${this.displayMode === `list-compact`
|
|
278
|
+
? this.listHeaderTemplate
|
|
279
|
+
: nothing}
|
|
280
|
+
|
|
244
281
|
<infinite-scroller
|
|
245
282
|
class="${ifDefined(this.displayMode)}"
|
|
246
283
|
.cellProvider=${this}
|
|
@@ -254,7 +291,7 @@ export class CollectionBrowser
|
|
|
254
291
|
`;
|
|
255
292
|
}
|
|
256
293
|
|
|
257
|
-
private
|
|
294
|
+
private userChangedSort(
|
|
258
295
|
e: CustomEvent<{
|
|
259
296
|
selectedSort: SortField;
|
|
260
297
|
sortDirection: SortDirection | null;
|
|
@@ -263,6 +300,11 @@ export class CollectionBrowser
|
|
|
263
300
|
const { selectedSort, sortDirection } = e.detail;
|
|
264
301
|
this.selectedSort = selectedSort;
|
|
265
302
|
this.sortDirection = sortDirection;
|
|
303
|
+
|
|
304
|
+
if ((this.currentPage ?? 1) > 1) {
|
|
305
|
+
this.goToPage(1);
|
|
306
|
+
}
|
|
307
|
+
this.currentPage = 1;
|
|
266
308
|
}
|
|
267
309
|
|
|
268
310
|
private selectedSortChanged() {
|
|
@@ -270,17 +312,9 @@ export class CollectionBrowser
|
|
|
270
312
|
this.sortParam = null;
|
|
271
313
|
return;
|
|
272
314
|
}
|
|
273
|
-
|
|
274
315
|
const sortField = SortFieldToMetadataField[this.selectedSort];
|
|
275
|
-
|
|
276
316
|
if (!sortField) return;
|
|
277
|
-
|
|
278
317
|
this.sortParam = new SortParam(sortField, this.sortDirection);
|
|
279
|
-
|
|
280
|
-
if ((this.currentPage ?? 1) > 1) {
|
|
281
|
-
this.goToPage(1);
|
|
282
|
-
}
|
|
283
|
-
this.currentPage = 1;
|
|
284
318
|
}
|
|
285
319
|
|
|
286
320
|
private displayModeChanged(
|
|
@@ -313,6 +347,24 @@ export class CollectionBrowser
|
|
|
313
347
|
return this.facetsLoading || this.fullYearAggregationLoading;
|
|
314
348
|
}
|
|
315
349
|
|
|
350
|
+
private get facetsTemplate() {
|
|
351
|
+
return html`
|
|
352
|
+
${this.facetsLoading ? this.loadingTemplate : nothing}
|
|
353
|
+
<collection-facets
|
|
354
|
+
@facetsChanged=${this.facetsChanged}
|
|
355
|
+
@histogramDateRangeUpdated=${this.histogramDateRangeUpdated}
|
|
356
|
+
.aggregations=${this.aggregations}
|
|
357
|
+
.fullYearsHistogramAggregation=${this.fullYearsHistogramAggregation}
|
|
358
|
+
.minSelectedDate=${this.minSelectedDate}
|
|
359
|
+
.maxSelectedDate=${this.maxSelectedDate}
|
|
360
|
+
.selectedFacets=${this.selectedFacets}
|
|
361
|
+
?collapsableFacets=${this.mobileView}
|
|
362
|
+
?facetsLoading=${this.facetDataLoading}
|
|
363
|
+
?fullYearAggregationLoading=${this.fullYearAggregationLoading}
|
|
364
|
+
></collection-facets>
|
|
365
|
+
`;
|
|
366
|
+
}
|
|
367
|
+
|
|
316
368
|
private get loadingTemplate() {
|
|
317
369
|
return html`
|
|
318
370
|
<div class="loading-cover">
|
|
@@ -321,6 +373,17 @@ export class CollectionBrowser
|
|
|
321
373
|
`;
|
|
322
374
|
}
|
|
323
375
|
|
|
376
|
+
private get listHeaderTemplate() {
|
|
377
|
+
return html`
|
|
378
|
+
<tile-dispatcher
|
|
379
|
+
.displayMode=${'list-header'}
|
|
380
|
+
.resizeObserver=${this.resizeObserver}
|
|
381
|
+
.sortParam=${this.sortParam}
|
|
382
|
+
>
|
|
383
|
+
</tile-dispatcher>
|
|
384
|
+
`;
|
|
385
|
+
}
|
|
386
|
+
|
|
324
387
|
private get queryDebuggingTemplate() {
|
|
325
388
|
return html`
|
|
326
389
|
<div>
|
|
@@ -386,6 +449,42 @@ export class CollectionBrowser
|
|
|
386
449
|
this.infiniteScroller.itemCount = this.estimatedTileCount;
|
|
387
450
|
}
|
|
388
451
|
}
|
|
452
|
+
if (changed.has('resizeObserver')) {
|
|
453
|
+
const oldObserver = changed.get(
|
|
454
|
+
'resizeObserver'
|
|
455
|
+
) as SharedResizeObserverInterface;
|
|
456
|
+
if (oldObserver) this.disconnectResizeObserver(oldObserver);
|
|
457
|
+
this.setupResizeObserver();
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
disconnectedCallback(): void {
|
|
462
|
+
if (this.resizeObserver) {
|
|
463
|
+
this.disconnectResizeObserver(this.resizeObserver);
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
handleResize(entry: ResizeObserverEntry): void {
|
|
468
|
+
if (entry.target === this.contentContainer) {
|
|
469
|
+
this.mobileView = entry.contentRect.width < 600;
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
private disconnectResizeObserver(
|
|
474
|
+
resizeObserver: SharedResizeObserverInterface
|
|
475
|
+
) {
|
|
476
|
+
resizeObserver.removeObserver({
|
|
477
|
+
target: this.contentContainer,
|
|
478
|
+
handler: this,
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
private setupResizeObserver() {
|
|
483
|
+
if (!this.resizeObserver) return;
|
|
484
|
+
this.resizeObserver.addObserver({
|
|
485
|
+
target: this.contentContainer,
|
|
486
|
+
handler: this,
|
|
487
|
+
});
|
|
389
488
|
}
|
|
390
489
|
|
|
391
490
|
/**
|
|
@@ -449,7 +548,7 @@ export class CollectionBrowser
|
|
|
449
548
|
private restoreState() {
|
|
450
549
|
const restorationState = this.restorationStateHandler.getRestorationState();
|
|
451
550
|
this.displayMode = restorationState.displayMode;
|
|
452
|
-
this.selectedSort = restorationState.selectedSort ??
|
|
551
|
+
this.selectedSort = restorationState.selectedSort ?? SortField.relevance;
|
|
453
552
|
this.sortDirection = restorationState.sortDirection ?? null;
|
|
454
553
|
this.selectedTitleFilter = restorationState.selectedTitleFilter ?? null;
|
|
455
554
|
this.selectedCreatorFilter = restorationState.selectedCreatorFilter ?? null;
|
|
@@ -860,23 +959,69 @@ export class CollectionBrowser
|
|
|
860
959
|
display: flex;
|
|
861
960
|
}
|
|
862
961
|
|
|
962
|
+
.collapser {
|
|
963
|
+
display: inline-block;
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
.collapser svg {
|
|
967
|
+
width: 10px;
|
|
968
|
+
height: 10px;
|
|
969
|
+
transition: transform 0.2s ease-out;
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
.collapser.open svg {
|
|
973
|
+
transform: rotate(90deg);
|
|
974
|
+
}
|
|
975
|
+
|
|
976
|
+
#mobile-filter-collapse h1 {
|
|
977
|
+
cursor: pointer;
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
#content-container.mobile {
|
|
981
|
+
display: block;
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
.column {
|
|
985
|
+
padding-top: 2rem;
|
|
986
|
+
}
|
|
987
|
+
|
|
863
988
|
#right-column {
|
|
864
989
|
flex: 1;
|
|
865
990
|
position: relative;
|
|
866
991
|
border-left: 1px solid rgb(232, 232, 232);
|
|
992
|
+
padding-left: 1rem;
|
|
993
|
+
}
|
|
994
|
+
|
|
995
|
+
.mobile #right-column {
|
|
996
|
+
border-left: none;
|
|
997
|
+
padding: 0;
|
|
867
998
|
}
|
|
868
999
|
|
|
869
1000
|
#left-column {
|
|
870
1001
|
width: 18rem;
|
|
871
1002
|
padding-right: 12px;
|
|
1003
|
+
padding-right: 1rem;
|
|
872
1004
|
}
|
|
873
1005
|
|
|
874
|
-
.column {
|
|
875
|
-
|
|
1006
|
+
.mobile #left-column {
|
|
1007
|
+
width: 100%;
|
|
1008
|
+
padding: 0;
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
#mobile-header-container {
|
|
1012
|
+
display: flex;
|
|
1013
|
+
justify-content: space-between;
|
|
876
1014
|
}
|
|
877
1015
|
|
|
878
1016
|
#facets-container {
|
|
879
1017
|
position: relative;
|
|
1018
|
+
max-height: 0;
|
|
1019
|
+
transition: max-height 0.2s ease-in-out;
|
|
1020
|
+
overflow: hidden;
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1023
|
+
#facets-container.expanded {
|
|
1024
|
+
max-height: 2000px;
|
|
880
1025
|
}
|
|
881
1026
|
|
|
882
1027
|
#results-total {
|
|
@@ -885,6 +1030,10 @@ export class CollectionBrowser
|
|
|
885
1030
|
margin-bottom: 5rem;
|
|
886
1031
|
}
|
|
887
1032
|
|
|
1033
|
+
.mobile #results-total {
|
|
1034
|
+
margin-bottom: 0;
|
|
1035
|
+
}
|
|
1036
|
+
|
|
888
1037
|
#big-results-count {
|
|
889
1038
|
font-size: 2.4rem;
|
|
890
1039
|
font-weight: 500;
|
package/src/collection-facets.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { css, html, LitElement, PropertyValues } from 'lit';
|
|
2
|
-
import { customElement, property } from 'lit/decorators.js';
|
|
1
|
+
import { css, html, LitElement, PropertyValues, nothing } from 'lit';
|
|
2
|
+
import { customElement, property, state } from 'lit/decorators.js';
|
|
3
3
|
import { repeat } from 'lit/directives/repeat.js';
|
|
4
4
|
import { Aggregation, Bucket } from '@internetarchive/search-service';
|
|
5
5
|
import '@internetarchive/histogram-date-range';
|
|
6
6
|
import '@internetarchive/feature-feedback';
|
|
7
7
|
import eyeIcon from './assets/img/icons/eye';
|
|
8
8
|
import eyeClosedIcon from './assets/img/icons/eye-closed';
|
|
9
|
+
import chevronIcon from './assets/img/icons/chevron';
|
|
9
10
|
import {
|
|
10
11
|
FacetOption,
|
|
11
12
|
SelectedFacets,
|
|
@@ -57,6 +58,17 @@ export class CollectionFacets extends LitElement {
|
|
|
57
58
|
|
|
58
59
|
@property({ type: Object }) selectedFacets?: SelectedFacets;
|
|
59
60
|
|
|
61
|
+
@property({ type: Boolean }) collapsableFacets = false;
|
|
62
|
+
|
|
63
|
+
@state() openFacets: Record<FacetOption, boolean> = {
|
|
64
|
+
subject: false,
|
|
65
|
+
mediatype: false,
|
|
66
|
+
language: false,
|
|
67
|
+
creator: false,
|
|
68
|
+
collection: false,
|
|
69
|
+
year: false,
|
|
70
|
+
};
|
|
71
|
+
|
|
60
72
|
render() {
|
|
61
73
|
return html`
|
|
62
74
|
<div id="container" class="${this.facetsLoading ? 'loading' : ''}">
|
|
@@ -65,14 +77,8 @@ export class CollectionFacets extends LitElement {
|
|
|
65
77
|
${this.histogramTemplate}
|
|
66
78
|
</div>
|
|
67
79
|
|
|
68
|
-
${this.mergedFacets.map(
|
|
69
|
-
facetGroup
|
|
70
|
-
html`
|
|
71
|
-
<div class="facet-group">
|
|
72
|
-
<h1>${facetGroup.title}</h1>
|
|
73
|
-
${this.getFacetTemplate(facetGroup)}
|
|
74
|
-
</div>
|
|
75
|
-
`
|
|
80
|
+
${this.mergedFacets.map(facetGroup =>
|
|
81
|
+
this.getFacetGroupTemplate(facetGroup)
|
|
76
82
|
)}
|
|
77
83
|
</div>
|
|
78
84
|
`;
|
|
@@ -236,6 +242,36 @@ export class CollectionFacets extends LitElement {
|
|
|
236
242
|
return facetGroups;
|
|
237
243
|
}
|
|
238
244
|
|
|
245
|
+
private getFacetGroupTemplate(facetGroup: FacetGroup) {
|
|
246
|
+
const { key } = facetGroup;
|
|
247
|
+
const isOpen = this.openFacets[key];
|
|
248
|
+
const collapser = html`
|
|
249
|
+
<span class="collapser ${isOpen ? 'open' : ''}"> ${chevronIcon} </span>
|
|
250
|
+
`;
|
|
251
|
+
|
|
252
|
+
return html`
|
|
253
|
+
<div class="facet-group ${this.collapsableFacets ? 'mobile' : ''}">
|
|
254
|
+
<h1
|
|
255
|
+
@click=${() => {
|
|
256
|
+
const newOpenFacets = { ...this.openFacets };
|
|
257
|
+
newOpenFacets[key] = !isOpen;
|
|
258
|
+
this.openFacets = newOpenFacets;
|
|
259
|
+
}}
|
|
260
|
+
@keyup=${() => {
|
|
261
|
+
const newOpenFacets = { ...this.openFacets };
|
|
262
|
+
newOpenFacets[key] = !isOpen;
|
|
263
|
+
this.openFacets = newOpenFacets;
|
|
264
|
+
}}
|
|
265
|
+
>
|
|
266
|
+
${this.collapsableFacets ? collapser : nothing} ${facetGroup.title}
|
|
267
|
+
</h1>
|
|
268
|
+
<div class="facet-group-content ${isOpen ? 'open' : ''}">
|
|
269
|
+
${this.getFacetTemplate(facetGroup)}
|
|
270
|
+
</div>
|
|
271
|
+
</div>
|
|
272
|
+
`;
|
|
273
|
+
}
|
|
274
|
+
|
|
239
275
|
private getFacetTemplate(facetGroup: FacetGroup) {
|
|
240
276
|
return html`
|
|
241
277
|
<ul class="facet-list">
|
|
@@ -348,12 +384,52 @@ export class CollectionFacets extends LitElement {
|
|
|
348
384
|
opacity: 0.5;
|
|
349
385
|
}
|
|
350
386
|
|
|
387
|
+
.collapser {
|
|
388
|
+
display: inline-block;
|
|
389
|
+
cursor: pointer;
|
|
390
|
+
width: 10px;
|
|
391
|
+
height: 10px;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
.collapser svg {
|
|
395
|
+
transition: transform 0.2s ease-in-out;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
.collapser.open svg {
|
|
399
|
+
transform: rotate(90deg);
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
.facet-group {
|
|
403
|
+
margin-bottom: 2rem;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
.facet-group h1 {
|
|
407
|
+
margin-bottom: 0.7rem;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
.facet-group.mobile h1 {
|
|
411
|
+
cursor: pointer;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
.facet-group-content {
|
|
415
|
+
transition: max-height 0.2s ease-in-out;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
.facet-group.mobile .facet-group-content {
|
|
419
|
+
max-height: 0;
|
|
420
|
+
overflow: hidden;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
.facet-group.mobile .facet-group-content.open {
|
|
424
|
+
max-height: 2000px;
|
|
425
|
+
}
|
|
426
|
+
|
|
351
427
|
h1 {
|
|
352
428
|
font-size: 1.4rem;
|
|
353
429
|
font-weight: 200;
|
|
354
430
|
border-bottom: 1px solid rgb(232, 232, 232);
|
|
355
431
|
padding-bottom: 3px;
|
|
356
|
-
margin:
|
|
432
|
+
margin: 0;
|
|
357
433
|
}
|
|
358
434
|
|
|
359
435
|
ul.facet-list {
|