@internetarchive/collection-browser 2.6.5 → 2.6.6-alpha.1
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-facets/smart-facet-bar.d.ts +5 -1
- package/dist/src/collection-facets/smart-facet-bar.js +50 -2
- package/dist/src/collection-facets/smart-facet-bar.js.map +1 -1
- package/dist/src/collection-facets/smart-facet-button.d.ts +9 -0
- package/dist/src/collection-facets/smart-facet-button.js +55 -0
- package/dist/src/collection-facets/smart-facet-button.js.map +1 -0
- package/dist/src/collection-facets/smart-facet-dropdown.d.ts +0 -0
- package/dist/src/collection-facets/smart-facet-dropdown.js +2 -0
- package/dist/src/collection-facets/smart-facet-dropdown.js.map +1 -0
- package/package.json +2 -2
- package/src/collection-facets/smart-facet-bar.ts +60 -3
- package/src/collection-facets/smart-facet-button.ts +60 -0
- package/src/collection-facets/smart-facet-dropdown.ts +0 -0
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { LitElement, TemplateResult, CSSResultGroup } from 'lit';
|
|
2
2
|
import type { CollectionTitles } from '../data-source/models';
|
|
3
|
+
import type { Aggregation } from '@internetarchive/search-service';
|
|
4
|
+
import './smart-facet-button';
|
|
3
5
|
export declare class SmartFacetBar extends LitElement {
|
|
4
|
-
|
|
6
|
+
aggregations?: Record<string, Aggregation>;
|
|
7
|
+
/** The map from collection identifiers to their titles */
|
|
5
8
|
collectionTitles?: CollectionTitles;
|
|
6
9
|
render(): TemplateResult<1>;
|
|
10
|
+
private get facetsToDisplay();
|
|
7
11
|
static get styles(): CSSResultGroup;
|
|
8
12
|
}
|
|
@@ -1,22 +1,70 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { css, html, LitElement, } from 'lit';
|
|
3
|
+
import { map } from 'lit/directives/map.js';
|
|
3
4
|
import { customElement, property } from 'lit/decorators.js';
|
|
5
|
+
import './smart-facet-button';
|
|
6
|
+
function capitalize(str) {
|
|
7
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
8
|
+
}
|
|
4
9
|
let SmartFacetBar = class SmartFacetBar extends LitElement {
|
|
5
10
|
//
|
|
6
11
|
// COMPONENT LIFECYCLE METHODS
|
|
7
12
|
//
|
|
8
13
|
render() {
|
|
9
|
-
return html
|
|
14
|
+
return html `
|
|
15
|
+
<div id="smart-facets-container">
|
|
16
|
+
${map(this.facetsToDisplay, facet => html `
|
|
17
|
+
<smart-facet-button
|
|
18
|
+
.facetType=${facet.facetType}
|
|
19
|
+
.bucket=${facet.bucket}
|
|
20
|
+
></smart-facet-button>
|
|
21
|
+
`)}
|
|
22
|
+
</div>
|
|
23
|
+
`;
|
|
24
|
+
}
|
|
25
|
+
//
|
|
26
|
+
// OTHER METHODS
|
|
27
|
+
//
|
|
28
|
+
get facetsToDisplay() {
|
|
29
|
+
if (!this.aggregations)
|
|
30
|
+
return [];
|
|
31
|
+
const facets = [];
|
|
32
|
+
for (const [key, agg] of Object.entries(this.aggregations)) {
|
|
33
|
+
if (agg.buckets.length === 0)
|
|
34
|
+
continue;
|
|
35
|
+
if (['lending', 'year_histogram'].includes(key))
|
|
36
|
+
continue;
|
|
37
|
+
if (typeof agg.buckets[0] === 'number')
|
|
38
|
+
continue;
|
|
39
|
+
const buckets = agg.buckets;
|
|
40
|
+
facets.push({
|
|
41
|
+
facetType: key,
|
|
42
|
+
bucket: {
|
|
43
|
+
key: buckets[0].key.toString(),
|
|
44
|
+
displayText: capitalize(buckets[0].key.toString()),
|
|
45
|
+
count: buckets[0].doc_count,
|
|
46
|
+
state: 'none',
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
return facets;
|
|
10
51
|
}
|
|
11
52
|
//
|
|
12
53
|
// STYLES
|
|
13
54
|
//
|
|
14
55
|
static get styles() {
|
|
15
56
|
return css `
|
|
16
|
-
|
|
57
|
+
#smart-facets-container {
|
|
58
|
+
display: flex;
|
|
59
|
+
column-gap: 5px;
|
|
60
|
+
padding: 10px 0;
|
|
61
|
+
}
|
|
17
62
|
`;
|
|
18
63
|
}
|
|
19
64
|
};
|
|
65
|
+
__decorate([
|
|
66
|
+
property({ type: Object })
|
|
67
|
+
], SmartFacetBar.prototype, "aggregations", void 0);
|
|
20
68
|
__decorate([
|
|
21
69
|
property({ type: Object })
|
|
22
70
|
], SmartFacetBar.prototype, "collectionTitles", void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"smart-facet-bar.js","sourceRoot":"","sources":["../../../src/collection-facets/smart-facet-bar.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,GAAG,EACH,IAAI,EACJ,UAAU,GAIX,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"smart-facet-bar.js","sourceRoot":"","sources":["../../../src/collection-facets/smart-facet-bar.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,GAAG,EACH,IAAI,EACJ,UAAU,GAIX,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAK5D,OAAO,sBAAsB,CAAC;AAO9B,SAAS,UAAU,CAAC,GAAW;IAC7B,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACpD,CAAC;AAGD,IAAa,aAAa,GAA1B,MAAa,aAAc,SAAQ,UAAU;IAO3C,EAAE;IACF,8BAA8B;IAC9B,EAAE;IAEF,MAAM;QACJ,OAAO,IAAI,CAAA;;UAEL,GAAG,CAAC,IAAI,CAAC,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,IAAI,CAAA;;yBAExB,KAAK,CAAC,SAAS;sBAClB,KAAK,CAAC,MAAM;;SAEzB,CAAC;;KAEL,CAAC;IACJ,CAAC;IAED,EAAE;IACF,gBAAgB;IAChB,EAAE;IAEF,IAAY,eAAe;QACzB,IAAI,CAAC,IAAI,CAAC,YAAY;YAAE,OAAO,EAAE,CAAC;QAElC,MAAM,MAAM,GAAuB,EAAE,CAAC;QACtC,KAAK,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE;YAC1D,IAAI,GAAG,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC;gBAAE,SAAS;YACvC,IAAI,CAAC,SAAS,EAAE,gBAAgB,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC;gBAAE,SAAS;YAC1D,IAAI,OAAO,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,QAAQ;gBAAE,SAAS;YAEjD,MAAM,OAAO,GAAG,GAAG,CAAC,OAAmB,CAAC;YACxC,MAAM,CAAC,IAAI,CAAC;gBACV,SAAS,EAAE,GAAkB;gBAC7B,MAAM,EAAE;oBACN,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE;oBAC9B,WAAW,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;oBAClD,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS;oBAC3B,KAAK,EAAE,MAAM;iBACd;aACF,CAAC,CAAC;SACJ;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,EAAE;IACF,SAAS;IACT,EAAE;IAEF,MAAM,KAAK,MAAM;QACf,OAAO,GAAG,CAAA;;;;;;KAMT,CAAC;IACJ,CAAC;CACF,CAAA;AAhE6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;mDAA4C;AAIvE;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uDACS;AALzB,aAAa;IADzB,aAAa,CAAC,iBAAiB,CAAC;GACpB,aAAa,CAiEzB;SAjEY,aAAa","sourcesContent":["import {\n css,\n html,\n LitElement,\n TemplateResult,\n CSSResultGroup,\n nothing,\n} from 'lit';\nimport { map } from 'lit/directives/map.js';\nimport { customElement, property } from 'lit/decorators.js';\nimport type { CollectionTitles } from '../data-source/models';\nimport type { Aggregation, Bucket } from '@internetarchive/search-service';\nimport type { FacetBucket, FacetOption } from '../models';\n\nimport './smart-facet-button';\n\ninterface SmartFacetBucket {\n facetType: FacetOption;\n bucket: FacetBucket;\n}\n\nfunction capitalize(str: string) {\n return str.charAt(0).toUpperCase() + str.slice(1);\n}\n\n@customElement('smart-facet-bar')\nexport class SmartFacetBar extends LitElement {\n @property({ type: Object }) aggregations?: Record<string, Aggregation>;\n\n /** The map from collection identifiers to their titles */\n @property({ type: Object })\n collectionTitles?: CollectionTitles;\n\n //\n // COMPONENT LIFECYCLE METHODS\n //\n\n render() {\n return html`\n <div id=\"smart-facets-container\">\n ${map(this.facetsToDisplay, facet => html`\n <smart-facet-button\n .facetType=${facet.facetType}\n .bucket=${facet.bucket}\n ></smart-facet-button> \n `)}\n </div>\n `;\n }\n\n //\n // OTHER METHODS\n //\n\n private get facetsToDisplay(): SmartFacetBucket[] {\n if (!this.aggregations) return [];\n\n const facets: SmartFacetBucket[] = [];\n for (const [key, agg] of Object.entries(this.aggregations)) {\n if (agg.buckets.length === 0) continue;\n if (['lending', 'year_histogram'].includes(key)) continue;\n if (typeof agg.buckets[0] === 'number') continue;\n\n const buckets = agg.buckets as Bucket[];\n facets.push({\n facetType: key as FacetOption,\n bucket: {\n key: buckets[0].key.toString(),\n displayText: capitalize(buckets[0].key.toString()),\n count: buckets[0].doc_count,\n state: 'none',\n }\n });\n }\n\n return facets;\n }\n\n //\n // STYLES\n //\n\n static get styles(): CSSResultGroup {\n return css`\n #smart-facets-container {\n display: flex;\n column-gap: 5px;\n padding: 10px 0;\n }\n `;\n }\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { LitElement, TemplateResult, CSSResultGroup, nothing } from 'lit';
|
|
2
|
+
import type { FacetBucket, FacetOption } from '../models';
|
|
3
|
+
export declare class SmartFacetButton extends LitElement {
|
|
4
|
+
facetType?: FacetOption;
|
|
5
|
+
bucket?: FacetBucket;
|
|
6
|
+
render(): TemplateResult<1> | typeof nothing;
|
|
7
|
+
private get href();
|
|
8
|
+
static get styles(): CSSResultGroup;
|
|
9
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { css, html, LitElement, nothing, } from 'lit';
|
|
3
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
4
|
+
let SmartFacetButton = class SmartFacetButton extends LitElement {
|
|
5
|
+
//
|
|
6
|
+
// COMPONENT LIFECYCLE METHODS
|
|
7
|
+
//
|
|
8
|
+
render() {
|
|
9
|
+
var _a, _b, _c;
|
|
10
|
+
const displayText = (_b = (_a = this.bucket) === null || _a === void 0 ? void 0 : _a.displayText) !== null && _b !== void 0 ? _b : (_c = this.bucket) === null || _c === void 0 ? void 0 : _c.key;
|
|
11
|
+
if (!displayText)
|
|
12
|
+
return nothing;
|
|
13
|
+
return html `
|
|
14
|
+
<a class="smart-facet-button" href=${this.href}>
|
|
15
|
+
${displayText}
|
|
16
|
+
</a>
|
|
17
|
+
`;
|
|
18
|
+
}
|
|
19
|
+
//
|
|
20
|
+
// OTHER METHODS
|
|
21
|
+
//
|
|
22
|
+
get href() {
|
|
23
|
+
var _a;
|
|
24
|
+
const url = new URL(window.location.href);
|
|
25
|
+
url.searchParams.append('and[]', `${this.facetType}:"${(_a = this.bucket) === null || _a === void 0 ? void 0 : _a.key}"`);
|
|
26
|
+
return url.toString();
|
|
27
|
+
}
|
|
28
|
+
//
|
|
29
|
+
// STYLES
|
|
30
|
+
//
|
|
31
|
+
static get styles() {
|
|
32
|
+
return css `
|
|
33
|
+
.smart-facet-button {
|
|
34
|
+
padding: 5px 10px;
|
|
35
|
+
border-radius: 15px;
|
|
36
|
+
background: #194880;
|
|
37
|
+
color: white;
|
|
38
|
+
font-size: 1.4rem;
|
|
39
|
+
font-family: inherit;
|
|
40
|
+
text-decoration: none;
|
|
41
|
+
}
|
|
42
|
+
`;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
__decorate([
|
|
46
|
+
property({ type: String })
|
|
47
|
+
], SmartFacetButton.prototype, "facetType", void 0);
|
|
48
|
+
__decorate([
|
|
49
|
+
property({ type: Object })
|
|
50
|
+
], SmartFacetButton.prototype, "bucket", void 0);
|
|
51
|
+
SmartFacetButton = __decorate([
|
|
52
|
+
customElement('smart-facet-button')
|
|
53
|
+
], SmartFacetButton);
|
|
54
|
+
export { SmartFacetButton };
|
|
55
|
+
//# sourceMappingURL=smart-facet-button.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"smart-facet-button.js","sourceRoot":"","sources":["../../../src/collection-facets/smart-facet-button.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,GAAG,EACH,IAAI,EACJ,UAAU,EAGV,OAAO,GACR,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAI5D,IAAa,gBAAgB,GAA7B,MAAa,gBAAiB,SAAQ,UAAU;IAK9C,EAAE;IACF,8BAA8B;IAC9B,EAAE;IAEF,MAAM;;QACJ,MAAM,WAAW,GAAG,MAAA,MAAA,IAAI,CAAC,MAAM,0CAAE,WAAW,mCAAI,MAAA,IAAI,CAAC,MAAM,0CAAE,GAAG,CAAC;QACjE,IAAI,CAAC,WAAW;YAAE,OAAO,OAAO,CAAC;QAEjC,OAAO,IAAI,CAAA;2CAC4B,IAAI,CAAC,IAAI;UAC1C,WAAW;;KAEhB,CAAC;IACJ,CAAC;IAED,EAAE;IACF,gBAAgB;IAChB,EAAE;IAEF,IAAY,IAAI;;QACd,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAC1C,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,SAAS,KAAK,MAAA,IAAI,CAAC,MAAM,0CAAE,GAAG,GAAG,CAAC,CAAC;QAC5E,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC;IACxB,CAAC;IAED,EAAE;IACF,SAAS;IACT,EAAE;IAEF,MAAM,KAAK,MAAM;QACf,OAAO,GAAG,CAAA;;;;;;;;;;KAUT,CAAC;IACJ,CAAC;CACF,CAAA;AA9C6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;mDAAyB;AAExB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gDAAsB;AAHtC,gBAAgB;IAD5B,aAAa,CAAC,oBAAoB,CAAC;GACvB,gBAAgB,CA+C5B;SA/CY,gBAAgB","sourcesContent":["import {\n css,\n html,\n LitElement,\n TemplateResult,\n CSSResultGroup,\n nothing,\n} from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport type { FacetBucket, FacetOption } from '../models';\n\n@customElement('smart-facet-button')\nexport class SmartFacetButton extends LitElement {\n @property({ type: String }) facetType?: FacetOption;\n\n @property({ type: Object }) bucket?: FacetBucket;\n\n //\n // COMPONENT LIFECYCLE METHODS\n //\n\n render() {\n const displayText = this.bucket?.displayText ?? this.bucket?.key;\n if (!displayText) return nothing;\n\n return html`\n <a class=\"smart-facet-button\" href=${this.href}>\n ${displayText}\n </a>\n `;\n }\n\n //\n // OTHER METHODS\n //\n\n private get href(): string {\n const url = new URL(window.location.href);\n url.searchParams.append('and[]', `${this.facetType}:\"${this.bucket?.key}\"`);\n return url.toString();\n }\n\n //\n // STYLES\n //\n\n static get styles(): CSSResultGroup {\n return css`\n .smart-facet-button {\n padding: 5px 10px;\n border-radius: 15px;\n background: #194880;\n color: white;\n font-size: 1.4rem;\n font-family: inherit;\n text-decoration: none;\n }\n `;\n }\n}\n"]}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"smart-facet-dropdown.js","sourceRoot":"","sources":["../../../src/collection-facets/smart-facet-dropdown.ts"],"names":[],"mappings":"","sourcesContent":[""]}
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "The Internet Archive Collection Browser.",
|
|
4
4
|
"license": "AGPL-3.0-only",
|
|
5
5
|
"author": "Internet Archive",
|
|
6
|
-
"version": "2.6.
|
|
6
|
+
"version": "2.6.6-alpha.1",
|
|
7
7
|
"main": "dist/index.js",
|
|
8
8
|
"module": "dist/index.js",
|
|
9
9
|
"scripts": {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"@internetarchive/ia-dropdown": "^1.3.8",
|
|
32
32
|
"@internetarchive/infinite-scroller": "1.0.1",
|
|
33
33
|
"@internetarchive/modal-manager": "^0.2.8",
|
|
34
|
-
"@internetarchive/search-service": "
|
|
34
|
+
"@internetarchive/search-service": "1.3.4-alpha.1",
|
|
35
35
|
"@internetarchive/shared-resize-observer": "^0.2.0",
|
|
36
36
|
"@lit/localize": "^0.11.2",
|
|
37
37
|
"dompurify": "^2.3.6",
|
|
@@ -6,12 +6,28 @@ import {
|
|
|
6
6
|
CSSResultGroup,
|
|
7
7
|
nothing,
|
|
8
8
|
} from 'lit';
|
|
9
|
+
import { map } from 'lit/directives/map.js';
|
|
9
10
|
import { customElement, property } from 'lit/decorators.js';
|
|
10
11
|
import type { CollectionTitles } from '../data-source/models';
|
|
12
|
+
import type { Aggregation, Bucket } from '@internetarchive/search-service';
|
|
13
|
+
import type { FacetBucket, FacetOption } from '../models';
|
|
14
|
+
|
|
15
|
+
import './smart-facet-button';
|
|
16
|
+
|
|
17
|
+
interface SmartFacetBucket {
|
|
18
|
+
facetType: FacetOption;
|
|
19
|
+
bucket: FacetBucket;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function capitalize(str: string) {
|
|
23
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
24
|
+
}
|
|
11
25
|
|
|
12
26
|
@customElement('smart-facet-bar')
|
|
13
27
|
export class SmartFacetBar extends LitElement {
|
|
14
|
-
|
|
28
|
+
@property({ type: Object }) aggregations?: Record<string, Aggregation>;
|
|
29
|
+
|
|
30
|
+
/** The map from collection identifiers to their titles */
|
|
15
31
|
@property({ type: Object })
|
|
16
32
|
collectionTitles?: CollectionTitles;
|
|
17
33
|
|
|
@@ -20,7 +36,44 @@ export class SmartFacetBar extends LitElement {
|
|
|
20
36
|
//
|
|
21
37
|
|
|
22
38
|
render() {
|
|
23
|
-
return html
|
|
39
|
+
return html`
|
|
40
|
+
<div id="smart-facets-container">
|
|
41
|
+
${map(this.facetsToDisplay, facet => html`
|
|
42
|
+
<smart-facet-button
|
|
43
|
+
.facetType=${facet.facetType}
|
|
44
|
+
.bucket=${facet.bucket}
|
|
45
|
+
></smart-facet-button>
|
|
46
|
+
`)}
|
|
47
|
+
</div>
|
|
48
|
+
`;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
//
|
|
52
|
+
// OTHER METHODS
|
|
53
|
+
//
|
|
54
|
+
|
|
55
|
+
private get facetsToDisplay(): SmartFacetBucket[] {
|
|
56
|
+
if (!this.aggregations) return [];
|
|
57
|
+
|
|
58
|
+
const facets: SmartFacetBucket[] = [];
|
|
59
|
+
for (const [key, agg] of Object.entries(this.aggregations)) {
|
|
60
|
+
if (agg.buckets.length === 0) continue;
|
|
61
|
+
if (['lending', 'year_histogram'].includes(key)) continue;
|
|
62
|
+
if (typeof agg.buckets[0] === 'number') continue;
|
|
63
|
+
|
|
64
|
+
const buckets = agg.buckets as Bucket[];
|
|
65
|
+
facets.push({
|
|
66
|
+
facetType: key as FacetOption,
|
|
67
|
+
bucket: {
|
|
68
|
+
key: buckets[0].key.toString(),
|
|
69
|
+
displayText: capitalize(buckets[0].key.toString()),
|
|
70
|
+
count: buckets[0].doc_count,
|
|
71
|
+
state: 'none',
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return facets;
|
|
24
77
|
}
|
|
25
78
|
|
|
26
79
|
//
|
|
@@ -29,7 +82,11 @@ export class SmartFacetBar extends LitElement {
|
|
|
29
82
|
|
|
30
83
|
static get styles(): CSSResultGroup {
|
|
31
84
|
return css`
|
|
32
|
-
|
|
85
|
+
#smart-facets-container {
|
|
86
|
+
display: flex;
|
|
87
|
+
column-gap: 5px;
|
|
88
|
+
padding: 10px 0;
|
|
89
|
+
}
|
|
33
90
|
`;
|
|
34
91
|
}
|
|
35
92
|
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import {
|
|
2
|
+
css,
|
|
3
|
+
html,
|
|
4
|
+
LitElement,
|
|
5
|
+
TemplateResult,
|
|
6
|
+
CSSResultGroup,
|
|
7
|
+
nothing,
|
|
8
|
+
} from 'lit';
|
|
9
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
10
|
+
import type { FacetBucket, FacetOption } from '../models';
|
|
11
|
+
|
|
12
|
+
@customElement('smart-facet-button')
|
|
13
|
+
export class SmartFacetButton extends LitElement {
|
|
14
|
+
@property({ type: String }) facetType?: FacetOption;
|
|
15
|
+
|
|
16
|
+
@property({ type: Object }) bucket?: FacetBucket;
|
|
17
|
+
|
|
18
|
+
//
|
|
19
|
+
// COMPONENT LIFECYCLE METHODS
|
|
20
|
+
//
|
|
21
|
+
|
|
22
|
+
render() {
|
|
23
|
+
const displayText = this.bucket?.displayText ?? this.bucket?.key;
|
|
24
|
+
if (!displayText) return nothing;
|
|
25
|
+
|
|
26
|
+
return html`
|
|
27
|
+
<a class="smart-facet-button" href=${this.href}>
|
|
28
|
+
${displayText}
|
|
29
|
+
</a>
|
|
30
|
+
`;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
//
|
|
34
|
+
// OTHER METHODS
|
|
35
|
+
//
|
|
36
|
+
|
|
37
|
+
private get href(): string {
|
|
38
|
+
const url = new URL(window.location.href);
|
|
39
|
+
url.searchParams.append('and[]', `${this.facetType}:"${this.bucket?.key}"`);
|
|
40
|
+
return url.toString();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
//
|
|
44
|
+
// STYLES
|
|
45
|
+
//
|
|
46
|
+
|
|
47
|
+
static get styles(): CSSResultGroup {
|
|
48
|
+
return css`
|
|
49
|
+
.smart-facet-button {
|
|
50
|
+
padding: 5px 10px;
|
|
51
|
+
border-radius: 15px;
|
|
52
|
+
background: #194880;
|
|
53
|
+
color: white;
|
|
54
|
+
font-size: 1.4rem;
|
|
55
|
+
font-family: inherit;
|
|
56
|
+
text-decoration: none;
|
|
57
|
+
}
|
|
58
|
+
`;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
File without changes
|