@internetarchive/collection-browser 2.18.3-alpha-webdev7768.0 → 2.18.3-alpha-webdev7768.2
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/dist/src/collection-browser.d.ts +7 -0
- package/dist/src/collection-browser.js +689 -682
- package/dist/src/collection-browser.js.map +1 -1
- package/dist/src/collection-facets/smart-facets/smart-facet-bar.d.ts +5 -0
- package/dist/src/collection-facets/smart-facets/smart-facet-bar.js +43 -7
- package/dist/src/collection-facets/smart-facets/smart-facet-bar.js.map +1 -1
- package/dist/src/collection-facets/smart-facets/smart-facet-dropdown.d.ts +12 -0
- package/dist/src/collection-facets/smart-facets/smart-facet-dropdown.js +24 -4
- package/dist/src/collection-facets/smart-facets/smart-facet-dropdown.js.map +1 -1
- package/dist/src/tiles/grid/styles/tile-grid-shared-styles.js +118 -118
- package/dist/src/tiles/grid/styles/tile-grid-shared-styles.js.map +1 -1
- package/dist/src/tiles/tile-dispatcher.js +200 -200
- package/dist/src/tiles/tile-dispatcher.js.map +1 -1
- package/package.json +1 -1
- package/src/collection-browser.ts +2722 -2712
- package/src/collection-facets/smart-facets/smart-facet-bar.ts +52 -10
- package/src/collection-facets/smart-facets/smart-facet-dropdown.ts +25 -4
- package/src/tiles/grid/styles/tile-grid-shared-styles.ts +129 -129
- package/src/tiles/tile-dispatcher.ts +486 -486
|
@@ -12,7 +12,12 @@ import { customElement, property, state } from 'lit/decorators.js';
|
|
|
12
12
|
import { msg } from '@lit/localize';
|
|
13
13
|
import type { Aggregation, Bucket } from '@internetarchive/search-service';
|
|
14
14
|
import type { CollectionTitles } from '../../data-source/models';
|
|
15
|
-
import type {
|
|
15
|
+
import type {
|
|
16
|
+
FacetEventDetails,
|
|
17
|
+
FacetOption,
|
|
18
|
+
FacetState,
|
|
19
|
+
SelectedFacets,
|
|
20
|
+
} from '../../models';
|
|
16
21
|
import { updateSelectedFacetBucket } from '../../utils/facet-utils';
|
|
17
22
|
import { SmartQueryHeuristicGroup } from './smart-facet-heuristics';
|
|
18
23
|
import type { SmartFacetDropdown } from './smart-facet-dropdown';
|
|
@@ -49,6 +54,8 @@ export class SmartFacetBar extends LitElement {
|
|
|
49
54
|
|
|
50
55
|
@property({ type: Boolean }) filterToggleActive = false;
|
|
51
56
|
|
|
57
|
+
@property({ type: String }) label?: string;
|
|
58
|
+
|
|
52
59
|
@state() private heuristicRecs: SmartFacet[] = [];
|
|
53
60
|
|
|
54
61
|
@state() private smartFacets: SmartFacet[][] = [];
|
|
@@ -62,9 +69,13 @@ export class SmartFacetBar extends LitElement {
|
|
|
62
69
|
render() {
|
|
63
70
|
if (!this.query) return nothing;
|
|
64
71
|
|
|
72
|
+
const shouldShowLabel = !!this.label && this.smartFacets.length > 0;
|
|
65
73
|
return html`
|
|
66
74
|
<div id="smart-facets-container">
|
|
67
75
|
${this.filtersToggleTemplate}
|
|
76
|
+
${shouldShowLabel
|
|
77
|
+
? html`<p id="filters-label">${this.label}</p>`
|
|
78
|
+
: nothing}
|
|
68
79
|
${repeat(
|
|
69
80
|
this.smartFacets,
|
|
70
81
|
f =>
|
|
@@ -255,19 +266,36 @@ export class SmartFacetBar extends LitElement {
|
|
|
255
266
|
} as SmartFacet;
|
|
256
267
|
}
|
|
257
268
|
|
|
258
|
-
|
|
259
|
-
|
|
269
|
+
/**
|
|
270
|
+
* Toggles the state of the given smart facet, and updates the selected facets accordingly.
|
|
271
|
+
*/
|
|
272
|
+
private toggleSmartFacet(
|
|
273
|
+
facet: SmartFacet,
|
|
274
|
+
details: FacetEventDetails[],
|
|
275
|
+
): void {
|
|
276
|
+
let newState: FacetState;
|
|
277
|
+
if (facet.selected) {
|
|
278
|
+
// When deselected, leave the smart facet where it is
|
|
279
|
+
newState = 'none';
|
|
280
|
+
this.smartFacets = this.smartFacets.map(f => {
|
|
281
|
+
if (f[0] === facet) return [{ ...facet, selected: false }];
|
|
282
|
+
return f;
|
|
283
|
+
});
|
|
284
|
+
} else {
|
|
285
|
+
// When selected, move the toggled smart facet to the front of the list
|
|
286
|
+
newState = 'selected';
|
|
260
287
|
this.smartFacets = [
|
|
261
|
-
[{ ...
|
|
262
|
-
...this.smartFacets.filter(f => f[0] !==
|
|
288
|
+
[{ ...facet, selected: true }],
|
|
289
|
+
...this.smartFacets.filter(f => f[0] !== facet),
|
|
263
290
|
];
|
|
264
291
|
}
|
|
265
292
|
|
|
266
|
-
|
|
293
|
+
// Update the selected facets
|
|
294
|
+
for (const facet of details) {
|
|
267
295
|
this.selectedFacets = updateSelectedFacetBucket(
|
|
268
296
|
this.selectedFacets,
|
|
269
297
|
facet.facetType,
|
|
270
|
-
facet.bucket,
|
|
298
|
+
{ ...facet.bucket, state: newState },
|
|
271
299
|
true,
|
|
272
300
|
);
|
|
273
301
|
}
|
|
@@ -278,13 +306,21 @@ export class SmartFacetBar extends LitElement {
|
|
|
278
306
|
this.dispatchEvent(event);
|
|
279
307
|
}
|
|
280
308
|
|
|
309
|
+
private facetClicked(e: CustomEvent<SmartFacetEvent>): void {
|
|
310
|
+
this.toggleSmartFacet(e.detail.smartFacet, e.detail.details);
|
|
311
|
+
}
|
|
312
|
+
|
|
281
313
|
private facetDropdownClicked(e: CustomEvent<SmartFacetEvent>): void {
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
)
|
|
314
|
+
const existingFacet = this.smartFacets.find(
|
|
315
|
+
sf => sf.length === 1 && smartFacetEquals(sf[0], e.detail.smartFacet),
|
|
316
|
+
);
|
|
317
|
+
if (existingFacet) {
|
|
318
|
+
// The facet already exists outside the dropdown, so just select it there
|
|
319
|
+
this.toggleSmartFacet(existingFacet[0], e.detail.details);
|
|
285
320
|
return;
|
|
286
321
|
}
|
|
287
322
|
|
|
323
|
+
// Otherwise, prepend a new smart facet for the selected option
|
|
288
324
|
this.smartFacets = [
|
|
289
325
|
[{ ...e.detail.smartFacet, selected: true }],
|
|
290
326
|
...this.smartFacets,
|
|
@@ -363,6 +399,12 @@ export class SmartFacetBar extends LitElement {
|
|
|
363
399
|
#filters-toggle.active > svg {
|
|
364
400
|
filter: invert(1);
|
|
365
401
|
}
|
|
402
|
+
|
|
403
|
+
#filters-label {
|
|
404
|
+
font-size: 1.4rem;
|
|
405
|
+
font-weight: bold;
|
|
406
|
+
margin: 0 -5px 0 0;
|
|
407
|
+
}
|
|
366
408
|
`;
|
|
367
409
|
}
|
|
368
410
|
}
|
|
@@ -31,17 +31,20 @@ export class SmartFacetDropdown extends LitElement {
|
|
|
31
31
|
<ia-dropdown
|
|
32
32
|
class="dropdown"
|
|
33
33
|
displayCaret
|
|
34
|
-
openViaButton
|
|
35
34
|
closeOnSelect
|
|
36
35
|
closeOnEscape
|
|
37
36
|
closeOnBackdropClick
|
|
38
37
|
includeSelectedOption
|
|
39
38
|
.options=${this.dropdownOptions}
|
|
40
39
|
.selectedOption=${this.activeDropdownOption}
|
|
40
|
+
.openViaButton=${false}
|
|
41
41
|
@optionSelected=${this.optionSelected}
|
|
42
42
|
@click=${this.onDropdownClick}
|
|
43
43
|
>
|
|
44
|
-
<span
|
|
44
|
+
<span
|
|
45
|
+
class="dropdown-label"
|
|
46
|
+
slot="dropdown-label"
|
|
47
|
+
@click=${this.defaultOptionSelected}
|
|
45
48
|
>${this.labelPrefix ?? nothing} ${displayText}</span
|
|
46
49
|
>
|
|
47
50
|
</ia-dropdown>
|
|
@@ -76,13 +79,31 @@ export class SmartFacetDropdown extends LitElement {
|
|
|
76
79
|
);
|
|
77
80
|
}
|
|
78
81
|
|
|
82
|
+
/**
|
|
83
|
+
* Handler for when the default option on the dropdown button is clicked
|
|
84
|
+
*/
|
|
85
|
+
private defaultOptionSelected(): void {
|
|
86
|
+
this.handleSelection(this.activeFacetRef?.bucketKey);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Handler for when an option in the dropdown menu is selected
|
|
91
|
+
*/
|
|
79
92
|
private optionSelected(e: CustomEvent<{ option: optionInterface }>): void {
|
|
80
|
-
|
|
93
|
+
this.handleSelection(e.detail.option.id);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Responds to a dropdown selection by emitting a `facetClick` event with
|
|
98
|
+
* the appropriate facet details.
|
|
99
|
+
*/
|
|
100
|
+
private handleSelection(bucketKey?: string): void {
|
|
101
|
+
if (!bucketKey || !this.facetInfo || !this.activeFacetRef) return;
|
|
81
102
|
|
|
82
103
|
let selectedSmartFacet;
|
|
83
104
|
for (const smartFacet of this.facetInfo) {
|
|
84
105
|
const selectedRef = smartFacet.facets.find(
|
|
85
|
-
b => b.bucketKey ===
|
|
106
|
+
b => b.bucketKey === bucketKey,
|
|
86
107
|
);
|
|
87
108
|
if (selectedRef) {
|
|
88
109
|
this.activeFacetRef = selectedRef;
|
|
@@ -1,129 +1,129 @@
|
|
|
1
|
-
import { css } from 'lit';
|
|
2
|
-
import { srOnlyStyle } from '../../../styles/sr-only';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Base tile styles
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
const tileBackgroundColor = css`var(--tileBackgroundColor, #ffffff)`;
|
|
9
|
-
const tileCornerRadius = css`var(--tileCornerRadius, 4px)`;
|
|
10
|
-
|
|
11
|
-
export const baseTileStyles = css`
|
|
12
|
-
/* Include .sr-only styles for all tiles */
|
|
13
|
-
${srOnlyStyle}
|
|
14
|
-
|
|
15
|
-
.container {
|
|
16
|
-
background-color: ${tileBackgroundColor};
|
|
17
|
-
border: 1px #2c2c2c;
|
|
18
|
-
border-radius: ${tileCornerRadius};
|
|
19
|
-
box-shadow: var(--tileBoxShadow, 1px 1px 2px 0);
|
|
20
|
-
box-sizing: border-box;
|
|
21
|
-
height: 100%;
|
|
22
|
-
display: flex;
|
|
23
|
-
flex-direction: column;
|
|
24
|
-
width: 100%;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
image-block {
|
|
28
|
-
display: block;
|
|
29
|
-
position: relative;
|
|
30
|
-
text-align: center;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
.tile-details {
|
|
34
|
-
display: flex;
|
|
35
|
-
flex-direction: column;
|
|
36
|
-
height: 100%;
|
|
37
|
-
row-gap: 10px;
|
|
38
|
-
font-family: 'Helvetica Neue', ui-sans-serif, system-ui, sans-serif;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
.item-info {
|
|
42
|
-
display: flex;
|
|
43
|
-
flex-direction: column;
|
|
44
|
-
row-gap: 5px;
|
|
45
|
-
flex-grow: 1;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
#title {
|
|
49
|
-
padding: 0 5px;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
.created-by,
|
|
53
|
-
.date-sorted-by,
|
|
54
|
-
.volume-issue,
|
|
55
|
-
.archivist-since {
|
|
56
|
-
display: flex;
|
|
57
|
-
justify-content: left;
|
|
58
|
-
align-items: flex-start;
|
|
59
|
-
padding: 0 5px;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
.truncated {
|
|
63
|
-
flex: 1;
|
|
64
|
-
color: #2c2c2c;
|
|
65
|
-
min-width: 0; /* Important for long words! */
|
|
66
|
-
text-align: left;
|
|
67
|
-
line-height: 15px;
|
|
68
|
-
text-overflow: ellipsis;
|
|
69
|
-
overflow: hidden;
|
|
70
|
-
word-wrap: break-word;
|
|
71
|
-
-webkit-line-clamp: 3;
|
|
72
|
-
-webkit-box-orient: vertical;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
h4.truncated {
|
|
76
|
-
display: -webkit-box;
|
|
77
|
-
margin: 0px;
|
|
78
|
-
line-height: 15px;
|
|
79
|
-
font-size: 14px;
|
|
80
|
-
font-weight: 500;
|
|
81
|
-
padding-bottom: 1px;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
span {
|
|
85
|
-
display: -webkit-box;
|
|
86
|
-
font-size: 1.4rem;
|
|
87
|
-
line-height: 15px;
|
|
88
|
-
overflow: hidden;
|
|
89
|
-
word-wrap: break-word;
|
|
90
|
-
-webkit-line-clamp: 1;
|
|
91
|
-
-webkit-box-orient: vertical;
|
|
92
|
-
padding-bottom: 1px;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
.container:hover > .tile-details > .item-info > #title > .truncated {
|
|
96
|
-
text-decoration: underline;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/** this is a workaround for Safari 15 where the hover effects are not working */
|
|
100
|
-
#title:hover > .truncated {
|
|
101
|
-
text-decoration: underline;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
.info-button {
|
|
105
|
-
position: absolute;
|
|
106
|
-
right: 10px;
|
|
107
|
-
top: 10px;
|
|
108
|
-
margin: 0;
|
|
109
|
-
padding: 0;
|
|
110
|
-
border: none;
|
|
111
|
-
border-radius: 50%;
|
|
112
|
-
display: flex;
|
|
113
|
-
justify-content: center;
|
|
114
|
-
align-items: center;
|
|
115
|
-
background: rgba(220, 220, 220, 0.5);
|
|
116
|
-
color: white;
|
|
117
|
-
font-size: 2rem;
|
|
118
|
-
font-weight: bold;
|
|
119
|
-
line-height: 1;
|
|
120
|
-
text-shadow: black 1px 1px 3px;
|
|
121
|
-
overflow: visible;
|
|
122
|
-
aspect-ratio: 1 / 1;
|
|
123
|
-
z-index: 1;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
.hidden {
|
|
127
|
-
display: none;
|
|
128
|
-
}
|
|
129
|
-
`;
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
import { srOnlyStyle } from '../../../styles/sr-only';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Base tile styles
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const tileBackgroundColor = css`var(--tileBackgroundColor, #ffffff)`;
|
|
9
|
+
const tileCornerRadius = css`var(--tileCornerRadius, 4px)`;
|
|
10
|
+
|
|
11
|
+
export const baseTileStyles = css`
|
|
12
|
+
/* Include .sr-only styles for all tiles */
|
|
13
|
+
${srOnlyStyle}
|
|
14
|
+
|
|
15
|
+
.container {
|
|
16
|
+
background-color: ${tileBackgroundColor};
|
|
17
|
+
border: 1px #2c2c2c;
|
|
18
|
+
border-radius: ${tileCornerRadius};
|
|
19
|
+
box-shadow: var(--tileBoxShadow, 1px 1px 2px 0);
|
|
20
|
+
box-sizing: border-box;
|
|
21
|
+
height: 100%;
|
|
22
|
+
display: flex;
|
|
23
|
+
flex-direction: column;
|
|
24
|
+
width: 100%;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
image-block {
|
|
28
|
+
display: block;
|
|
29
|
+
position: relative;
|
|
30
|
+
text-align: center;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.tile-details {
|
|
34
|
+
display: flex;
|
|
35
|
+
flex-direction: column;
|
|
36
|
+
height: 100%;
|
|
37
|
+
row-gap: 10px;
|
|
38
|
+
font-family: 'Helvetica Neue', ui-sans-serif, system-ui, sans-serif;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.item-info {
|
|
42
|
+
display: flex;
|
|
43
|
+
flex-direction: column;
|
|
44
|
+
row-gap: 5px;
|
|
45
|
+
flex-grow: 1;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
#title {
|
|
49
|
+
padding: 0 5px;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.created-by,
|
|
53
|
+
.date-sorted-by,
|
|
54
|
+
.volume-issue,
|
|
55
|
+
.archivist-since {
|
|
56
|
+
display: flex;
|
|
57
|
+
justify-content: left;
|
|
58
|
+
align-items: flex-start;
|
|
59
|
+
padding: 0 5px;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.truncated {
|
|
63
|
+
flex: 1;
|
|
64
|
+
color: #2c2c2c;
|
|
65
|
+
min-width: 0; /* Important for long words! */
|
|
66
|
+
text-align: left;
|
|
67
|
+
line-height: 15px;
|
|
68
|
+
text-overflow: ellipsis;
|
|
69
|
+
overflow: hidden;
|
|
70
|
+
word-wrap: break-word;
|
|
71
|
+
-webkit-line-clamp: 3;
|
|
72
|
+
-webkit-box-orient: vertical;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
h4.truncated {
|
|
76
|
+
display: -webkit-box;
|
|
77
|
+
margin: 0px;
|
|
78
|
+
line-height: 15px;
|
|
79
|
+
font-size: 14px;
|
|
80
|
+
font-weight: 500;
|
|
81
|
+
padding-bottom: 1px;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
span {
|
|
85
|
+
display: -webkit-box;
|
|
86
|
+
font-size: 1.4rem;
|
|
87
|
+
line-height: 15px;
|
|
88
|
+
overflow: hidden;
|
|
89
|
+
word-wrap: break-word;
|
|
90
|
+
-webkit-line-clamp: 1;
|
|
91
|
+
-webkit-box-orient: vertical;
|
|
92
|
+
padding-bottom: 1px;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.container:hover > .tile-details > .item-info > #title > .truncated {
|
|
96
|
+
text-decoration: underline;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** this is a workaround for Safari 15 where the hover effects are not working */
|
|
100
|
+
#title:hover > .truncated {
|
|
101
|
+
text-decoration: underline;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.info-button {
|
|
105
|
+
position: absolute;
|
|
106
|
+
right: 10px;
|
|
107
|
+
top: 10px;
|
|
108
|
+
margin: 0;
|
|
109
|
+
padding: 0;
|
|
110
|
+
border: none;
|
|
111
|
+
border-radius: 50%;
|
|
112
|
+
display: flex;
|
|
113
|
+
justify-content: center;
|
|
114
|
+
align-items: center;
|
|
115
|
+
background: rgba(220, 220, 220, 0.5);
|
|
116
|
+
color: white;
|
|
117
|
+
font-size: 2rem;
|
|
118
|
+
font-weight: bold;
|
|
119
|
+
line-height: 1;
|
|
120
|
+
text-shadow: black 1px 1px 3px;
|
|
121
|
+
overflow: visible;
|
|
122
|
+
aspect-ratio: 1 / 1;
|
|
123
|
+
z-index: 1;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.hidden {
|
|
127
|
+
display: none;
|
|
128
|
+
}
|
|
129
|
+
`;
|