@internetarchive/collection-browser 3.5.2-webdev-8178.0 → 3.5.3-alpha-webdev8156.0
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/.editorconfig +29 -29
- package/.github/workflows/ci.yml +27 -27
- package/.github/workflows/gh-pages-main.yml +39 -39
- package/.github/workflows/npm-publish.yml +39 -39
- package/.github/workflows/pr-preview.yml +38 -38
- package/.husky/pre-commit +4 -0
- package/.prettierignore +1 -1
- package/LICENSE +661 -661
- package/README.md +83 -83
- package/dist/src/app-root.js +606 -606
- package/dist/src/app-root.js.map +1 -1
- package/dist/src/collection-browser.js +8 -8
- package/dist/src/collection-browser.js.map +1 -1
- package/dist/src/data-source/collection-browser-query-state.d.ts +2 -1
- package/dist/src/data-source/collection-browser-query-state.js.map +1 -1
- package/dist/src/tiles/grid/collection-tile.js +77 -77
- package/dist/src/tiles/grid/collection-tile.js.map +1 -1
- package/dist/src/tiles/grid/item-tile.js +137 -137
- package/dist/src/tiles/grid/item-tile.js.map +1 -1
- package/dist/src/tiles/hover/hover-pane-controller.d.ts +8 -0
- package/dist/src/tiles/hover/hover-pane-controller.js +41 -29
- package/dist/src/tiles/hover/hover-pane-controller.js.map +1 -1
- package/dist/src/tiles/models.js.map +1 -1
- package/dist/src/tiles/tile-dispatcher.js +215 -215
- package/dist/src/tiles/tile-dispatcher.js.map +1 -1
- package/dist/test/collection-browser.test.js +1 -1
- package/dist/test/collection-browser.test.js.map +1 -1
- package/eslint.config.mjs +53 -53
- package/index.html +24 -24
- package/local.archive.org.cert +86 -86
- package/local.archive.org.key +27 -27
- package/package.json +119 -121
- package/renovate.json +6 -6
- package/src/app-root.ts +1140 -1140
- package/src/collection-browser.ts +9 -7
- package/src/data-source/collection-browser-query-state.ts +2 -1
- package/src/tiles/grid/collection-tile.ts +163 -163
- package/src/tiles/grid/item-tile.ts +340 -340
- package/src/tiles/hover/hover-pane-controller.ts +627 -613
- package/src/tiles/models.ts +1 -1
- package/src/tiles/tile-dispatcher.ts +517 -517
- package/test/collection-browser.test.ts +1 -1
- package/tsconfig.json +25 -25
- package/web-dev-server.config.mjs +30 -30
- package/web-test-runner.config.mjs +41 -52
|
@@ -1643,7 +1643,6 @@ export class CollectionBrowser
|
|
|
1643
1643
|
dataSource: CollectionBrowserDataSourceInterface,
|
|
1644
1644
|
queryState: CollectionBrowserQueryState,
|
|
1645
1645
|
): Promise<void> {
|
|
1646
|
-
log('Installing data source & query state in CB:', dataSource, queryState);
|
|
1647
1646
|
if (this.dataSource) this.removeController(this.dataSource);
|
|
1648
1647
|
this.dataSource = dataSource;
|
|
1649
1648
|
this.addController(this.dataSource);
|
|
@@ -1660,6 +1659,11 @@ export class CollectionBrowser
|
|
|
1660
1659
|
this.sortDirection = queryState.sortDirection;
|
|
1661
1660
|
this.selectedTitleFilter = queryState.selectedTitleFilter;
|
|
1662
1661
|
this.selectedCreatorFilter = queryState.selectedCreatorFilter;
|
|
1662
|
+
|
|
1663
|
+
if (queryState.defaultSortField)
|
|
1664
|
+
this.defaultSortField = queryState.defaultSortField;
|
|
1665
|
+
if (queryState.defaultSortDirection)
|
|
1666
|
+
this.defaultSortDirection = queryState.defaultSortDirection;
|
|
1663
1667
|
|
|
1664
1668
|
this.pagesToRender = this.initialPageNumber;
|
|
1665
1669
|
|
|
@@ -2103,6 +2107,8 @@ export class CollectionBrowser
|
|
|
2103
2107
|
maxSelectedDate: this.maxSelectedDate,
|
|
2104
2108
|
selectedSort: this.selectedSort,
|
|
2105
2109
|
sortDirection: this.sortDirection,
|
|
2110
|
+
defaultSortField: this.defaultSortField,
|
|
2111
|
+
defaultSortDirection: this.defaultSortDirection,
|
|
2106
2112
|
selectedTitleFilter: this.selectedTitleFilter,
|
|
2107
2113
|
selectedCreatorFilter: this.selectedCreatorFilter,
|
|
2108
2114
|
},
|
|
@@ -2259,12 +2265,8 @@ export class CollectionBrowser
|
|
|
2259
2265
|
this.displayMode = restorationState.displayMode;
|
|
2260
2266
|
if (!this.suppressURLSinParam && restorationState.searchType != null)
|
|
2261
2267
|
this.searchType = restorationState.searchType;
|
|
2262
|
-
this.selectedSort =
|
|
2263
|
-
|
|
2264
|
-
this.defaultSortField ??
|
|
2265
|
-
SortField.default;
|
|
2266
|
-
this.sortDirection =
|
|
2267
|
-
restorationState.sortDirection ?? this.defaultSortDirection ?? null;
|
|
2268
|
+
this.selectedSort = restorationState.selectedSort ?? SortField.default;
|
|
2269
|
+
this.sortDirection = restorationState.sortDirection ?? null;
|
|
2268
2270
|
this.selectedTitleFilter = restorationState.selectedTitleFilter ?? null;
|
|
2269
2271
|
this.selectedCreatorFilter = restorationState.selectedCreatorFilter ?? null;
|
|
2270
2272
|
this.selectedFacets = restorationState.selectedFacets;
|
|
@@ -27,6 +27,8 @@ export interface CollectionBrowserQueryState {
|
|
|
27
27
|
selectedCreatorFilter: string | null;
|
|
28
28
|
selectedSort?: SortField;
|
|
29
29
|
sortDirection: SortDirection | null;
|
|
30
|
+
defaultSortField?: Exclude<SortField, SortField.default>;
|
|
31
|
+
defaultSortDirection?: SortDirection | null;
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
/**
|
|
@@ -38,7 +40,6 @@ export interface CollectionBrowserSearchInterface
|
|
|
38
40
|
searchService?: SearchServiceInterface;
|
|
39
41
|
isTVCollection: boolean;
|
|
40
42
|
readonly sortParam: SortParam | null;
|
|
41
|
-
readonly defaultSortField: SortField | null;
|
|
42
43
|
readonly facetLoadStrategy: FacetLoadStrategy;
|
|
43
44
|
readonly initialPageNumber: number;
|
|
44
45
|
readonly maxPagesToManage: number;
|
|
@@ -1,163 +1,163 @@
|
|
|
1
|
-
import { css, CSSResultGroup, html, nothing, TemplateResult } from 'lit';
|
|
2
|
-
import { customElement, property } from 'lit/decorators.js';
|
|
3
|
-
import { msg } from '@lit/localize';
|
|
4
|
-
import { collectionIcon } from '../../assets/img/icons/mediatype/collection';
|
|
5
|
-
import { formatUnitSize } from '../../utils/format-unit-size';
|
|
6
|
-
import { baseTileStyles } from './styles/tile-grid-shared-styles';
|
|
7
|
-
import { BaseTileComponent } from '../base-tile-component';
|
|
8
|
-
import '../image-block';
|
|
9
|
-
|
|
10
|
-
@customElement('collection-tile')
|
|
11
|
-
export class CollectionTile extends BaseTileComponent {
|
|
12
|
-
/*
|
|
13
|
-
* Reactive properties inherited from BaseTileComponent:
|
|
14
|
-
* - model?: TileModel;
|
|
15
|
-
* - currentWidth?: number;
|
|
16
|
-
* - currentHeight?: number;
|
|
17
|
-
* - baseNavigationUrl?: string;
|
|
18
|
-
* - baseImageUrl?: string;
|
|
19
|
-
* - collectionPagePath?: string;
|
|
20
|
-
* - sortParam: SortParam | null = null;
|
|
21
|
-
* - creatorFilter?: string;
|
|
22
|
-
* - mobileBreakpoint?: number;
|
|
23
|
-
* - loggedIn = false;
|
|
24
|
-
* - suppressBlurring = false;
|
|
25
|
-
* - useLocalTime = false;
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
@property({ type: Boolean }) showInfoButton = false;
|
|
29
|
-
|
|
30
|
-
render() {
|
|
31
|
-
return html`
|
|
32
|
-
<div class="container">
|
|
33
|
-
${this.infoButtonTemplate}
|
|
34
|
-
<div class="tile-details">
|
|
35
|
-
<div class="item-info">
|
|
36
|
-
${this.getImageBlockTemplate} ${this.getTitleTemplate}
|
|
37
|
-
</div>
|
|
38
|
-
</div>
|
|
39
|
-
|
|
40
|
-
${this.getTileStatsTemplate}
|
|
41
|
-
</div>
|
|
42
|
-
`;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
private get getImageBlockTemplate(): TemplateResult {
|
|
46
|
-
return html`
|
|
47
|
-
<image-block
|
|
48
|
-
.model=${this.model}
|
|
49
|
-
.baseImageUrl=${this.baseImageUrl}
|
|
50
|
-
.viewSize=${'grid'}
|
|
51
|
-
.suppressBlurring=${this.suppressBlurring}
|
|
52
|
-
>
|
|
53
|
-
</image-block>
|
|
54
|
-
`;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
private get getTitleTemplate() {
|
|
58
|
-
return html`<div id="title">
|
|
59
|
-
<h3 class="truncated">${this.model?.title}</h3>
|
|
60
|
-
</div>`;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
private get getTileStatsTemplate() {
|
|
64
|
-
return html`
|
|
65
|
-
<div id="item-stats">
|
|
66
|
-
<div id="item-mediatype">${collectionIcon}</div>
|
|
67
|
-
|
|
68
|
-
<div id="stats-row">
|
|
69
|
-
${this.getItemsTemplate} ${this.getSizeTemplate}
|
|
70
|
-
</div>
|
|
71
|
-
</div>
|
|
72
|
-
`;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
private get getItemsTemplate() {
|
|
76
|
-
const collectionItems = this.model?.itemCount?.toLocaleString();
|
|
77
|
-
|
|
78
|
-
return html`<span id="item-count"
|
|
79
|
-
>${collectionItems} item${Number(collectionItems) !== 1 ? 's' : ''}</span
|
|
80
|
-
>`;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
private get getSizeTemplate() {
|
|
84
|
-
const collectionSize = this.model?.collectionSize ?? 0;
|
|
85
|
-
|
|
86
|
-
return collectionSize
|
|
87
|
-
? html`<span id="item-size">${formatUnitSize(collectionSize, 1)}</span>`
|
|
88
|
-
: ``;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
private get infoButtonTemplate(): TemplateResult | typeof nothing {
|
|
92
|
-
// ⓘ is an information icon
|
|
93
|
-
return this.showInfoButton
|
|
94
|
-
? html`<button class="info-button" @click=${this.infoButtonPressed}>
|
|
95
|
-
ⓘ
|
|
96
|
-
<span class="sr-only">${msg('More info')}</span>
|
|
97
|
-
</button>`
|
|
98
|
-
: nothing;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
private infoButtonPressed(e: PointerEvent) {
|
|
102
|
-
e.preventDefault();
|
|
103
|
-
const event = new CustomEvent<{ x: number; y: number }>(
|
|
104
|
-
'infoButtonPressed',
|
|
105
|
-
{ detail: { x: e.clientX, y: e.clientY } },
|
|
106
|
-
);
|
|
107
|
-
this.dispatchEvent(event);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
static get styles(): CSSResultGroup {
|
|
111
|
-
const tileBorderColor = css`var(--tileBorderColor, #555555)`;
|
|
112
|
-
const tileBackgroundColor = css`var(--tileBackgroundColor, #666666)`;
|
|
113
|
-
const whiteColor = css`#fff`;
|
|
114
|
-
|
|
115
|
-
return [
|
|
116
|
-
baseTileStyles,
|
|
117
|
-
css`
|
|
118
|
-
.container {
|
|
119
|
-
background-color: ${tileBackgroundColor};
|
|
120
|
-
border: 1px solid ${tileBorderColor};
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
.item-info {
|
|
124
|
-
flex-grow: initial;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
h4.truncated,
|
|
128
|
-
h3.truncated {
|
|
129
|
-
color: ${whiteColor};
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
#item-mediatype svg {
|
|
133
|
-
filter: invert(100%);
|
|
134
|
-
height: 2.5rem;
|
|
135
|
-
align-items: baseline;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
.container:hover > #title {
|
|
139
|
-
text-decoration: underline;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/* this is a workaround for Safari 15 where the hover effects are not working */
|
|
143
|
-
image-block:hover > #title {
|
|
144
|
-
text-decoration: underline;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
#item-stats {
|
|
148
|
-
display: flex;
|
|
149
|
-
padding: 0 5px 5px;
|
|
150
|
-
align-items: center;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
#stats-row {
|
|
154
|
-
display: flex;
|
|
155
|
-
align-items: baseline;
|
|
156
|
-
color: ${whiteColor};
|
|
157
|
-
flex-direction: column;
|
|
158
|
-
margin-left: 10px;
|
|
159
|
-
}
|
|
160
|
-
`,
|
|
161
|
-
];
|
|
162
|
-
}
|
|
163
|
-
}
|
|
1
|
+
import { css, CSSResultGroup, html, nothing, TemplateResult } from 'lit';
|
|
2
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
3
|
+
import { msg } from '@lit/localize';
|
|
4
|
+
import { collectionIcon } from '../../assets/img/icons/mediatype/collection';
|
|
5
|
+
import { formatUnitSize } from '../../utils/format-unit-size';
|
|
6
|
+
import { baseTileStyles } from './styles/tile-grid-shared-styles';
|
|
7
|
+
import { BaseTileComponent } from '../base-tile-component';
|
|
8
|
+
import '../image-block';
|
|
9
|
+
|
|
10
|
+
@customElement('collection-tile')
|
|
11
|
+
export class CollectionTile extends BaseTileComponent {
|
|
12
|
+
/*
|
|
13
|
+
* Reactive properties inherited from BaseTileComponent:
|
|
14
|
+
* - model?: TileModel;
|
|
15
|
+
* - currentWidth?: number;
|
|
16
|
+
* - currentHeight?: number;
|
|
17
|
+
* - baseNavigationUrl?: string;
|
|
18
|
+
* - baseImageUrl?: string;
|
|
19
|
+
* - collectionPagePath?: string;
|
|
20
|
+
* - sortParam: SortParam | null = null;
|
|
21
|
+
* - creatorFilter?: string;
|
|
22
|
+
* - mobileBreakpoint?: number;
|
|
23
|
+
* - loggedIn = false;
|
|
24
|
+
* - suppressBlurring = false;
|
|
25
|
+
* - useLocalTime = false;
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
@property({ type: Boolean }) showInfoButton = false;
|
|
29
|
+
|
|
30
|
+
render() {
|
|
31
|
+
return html`
|
|
32
|
+
<div class="container">
|
|
33
|
+
${this.infoButtonTemplate}
|
|
34
|
+
<div class="tile-details">
|
|
35
|
+
<div class="item-info">
|
|
36
|
+
${this.getImageBlockTemplate} ${this.getTitleTemplate}
|
|
37
|
+
</div>
|
|
38
|
+
</div>
|
|
39
|
+
|
|
40
|
+
${this.getTileStatsTemplate}
|
|
41
|
+
</div>
|
|
42
|
+
`;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
private get getImageBlockTemplate(): TemplateResult {
|
|
46
|
+
return html`
|
|
47
|
+
<image-block
|
|
48
|
+
.model=${this.model}
|
|
49
|
+
.baseImageUrl=${this.baseImageUrl}
|
|
50
|
+
.viewSize=${'grid'}
|
|
51
|
+
.suppressBlurring=${this.suppressBlurring}
|
|
52
|
+
>
|
|
53
|
+
</image-block>
|
|
54
|
+
`;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
private get getTitleTemplate() {
|
|
58
|
+
return html`<div id="title">
|
|
59
|
+
<h3 class="truncated">${this.model?.title}</h3>
|
|
60
|
+
</div>`;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
private get getTileStatsTemplate() {
|
|
64
|
+
return html`
|
|
65
|
+
<div id="item-stats">
|
|
66
|
+
<div id="item-mediatype">${collectionIcon}</div>
|
|
67
|
+
|
|
68
|
+
<div id="stats-row">
|
|
69
|
+
${this.getItemsTemplate} ${this.getSizeTemplate}
|
|
70
|
+
</div>
|
|
71
|
+
</div>
|
|
72
|
+
`;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
private get getItemsTemplate() {
|
|
76
|
+
const collectionItems = this.model?.itemCount?.toLocaleString();
|
|
77
|
+
|
|
78
|
+
return html`<span id="item-count"
|
|
79
|
+
>${collectionItems} item${Number(collectionItems) !== 1 ? 's' : ''}</span
|
|
80
|
+
>`;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
private get getSizeTemplate() {
|
|
84
|
+
const collectionSize = this.model?.collectionSize ?? 0;
|
|
85
|
+
|
|
86
|
+
return collectionSize
|
|
87
|
+
? html`<span id="item-size">${formatUnitSize(collectionSize, 1)}</span>`
|
|
88
|
+
: ``;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
private get infoButtonTemplate(): TemplateResult | typeof nothing {
|
|
92
|
+
// ⓘ is an information icon
|
|
93
|
+
return this.showInfoButton
|
|
94
|
+
? html`<button class="info-button" @click=${this.infoButtonPressed}>
|
|
95
|
+
ⓘ
|
|
96
|
+
<span class="sr-only">${msg('More info')}</span>
|
|
97
|
+
</button>`
|
|
98
|
+
: nothing;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
private infoButtonPressed(e: PointerEvent) {
|
|
102
|
+
e.preventDefault();
|
|
103
|
+
const event = new CustomEvent<{ x: number; y: number }>(
|
|
104
|
+
'infoButtonPressed',
|
|
105
|
+
{ detail: { x: e.clientX, y: e.clientY } },
|
|
106
|
+
);
|
|
107
|
+
this.dispatchEvent(event);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
static get styles(): CSSResultGroup {
|
|
111
|
+
const tileBorderColor = css`var(--tileBorderColor, #555555)`;
|
|
112
|
+
const tileBackgroundColor = css`var(--tileBackgroundColor, #666666)`;
|
|
113
|
+
const whiteColor = css`#fff`;
|
|
114
|
+
|
|
115
|
+
return [
|
|
116
|
+
baseTileStyles,
|
|
117
|
+
css`
|
|
118
|
+
.container {
|
|
119
|
+
background-color: ${tileBackgroundColor};
|
|
120
|
+
border: 1px solid ${tileBorderColor};
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.item-info {
|
|
124
|
+
flex-grow: initial;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
h4.truncated,
|
|
128
|
+
h3.truncated {
|
|
129
|
+
color: ${whiteColor};
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
#item-mediatype svg {
|
|
133
|
+
filter: invert(100%);
|
|
134
|
+
height: 2.5rem;
|
|
135
|
+
align-items: baseline;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.container:hover > #title {
|
|
139
|
+
text-decoration: underline;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/* this is a workaround for Safari 15 where the hover effects are not working */
|
|
143
|
+
image-block:hover > #title {
|
|
144
|
+
text-decoration: underline;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
#item-stats {
|
|
148
|
+
display: flex;
|
|
149
|
+
padding: 0 5px 5px;
|
|
150
|
+
align-items: center;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
#stats-row {
|
|
154
|
+
display: flex;
|
|
155
|
+
align-items: baseline;
|
|
156
|
+
color: ${whiteColor};
|
|
157
|
+
flex-direction: column;
|
|
158
|
+
margin-left: 10px;
|
|
159
|
+
}
|
|
160
|
+
`,
|
|
161
|
+
];
|
|
162
|
+
}
|
|
163
|
+
}
|