@internetarchive/collection-browser 2.22.1 → 3.0.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.
Files changed (71) hide show
  1. package/.editorconfig +29 -29
  2. package/.github/workflows/ci.yml +27 -27
  3. package/.github/workflows/gh-pages-main.yml +39 -39
  4. package/.github/workflows/npm-publish.yml +39 -39
  5. package/.github/workflows/pr-preview.yml +38 -38
  6. package/.husky/pre-commit +4 -4
  7. package/.prettierignore +1 -1
  8. package/LICENSE +661 -661
  9. package/README.md +83 -83
  10. package/dist/src/collection-browser.d.ts +1 -2
  11. package/dist/src/collection-browser.js +681 -687
  12. package/dist/src/collection-browser.js.map +1 -1
  13. package/dist/src/collection-facets/facet-row.js +130 -130
  14. package/dist/src/collection-facets/facet-row.js.map +1 -1
  15. package/dist/src/collection-facets/smart-facets/smart-facet-bar.js +75 -75
  16. package/dist/src/collection-facets/smart-facets/smart-facet-bar.js.map +1 -1
  17. package/dist/src/collection-facets.js +263 -263
  18. package/dist/src/collection-facets.js.map +1 -1
  19. package/dist/src/data-source/collection-browser-data-source.js.map +1 -1
  20. package/dist/src/data-source/collection-browser-query-state.js.map +1 -1
  21. package/dist/src/data-source/models.js.map +1 -1
  22. package/dist/src/models.js.map +1 -1
  23. package/dist/src/restoration-state-handler.js.map +1 -1
  24. package/dist/src/tiles/base-tile-component.js.map +1 -1
  25. package/dist/src/tiles/grid/item-tile.js +139 -139
  26. package/dist/src/tiles/grid/item-tile.js.map +1 -1
  27. package/dist/src/tiles/hover/hover-pane-controller.js +21 -21
  28. package/dist/src/tiles/hover/hover-pane-controller.js.map +1 -1
  29. package/dist/src/tiles/hover/tile-hover-pane.js +108 -108
  30. package/dist/src/tiles/hover/tile-hover-pane.js.map +1 -1
  31. package/dist/src/tiles/list/tile-list-compact-header.js +45 -45
  32. package/dist/src/tiles/list/tile-list-compact-header.js.map +1 -1
  33. package/dist/src/tiles/list/tile-list-compact.js +97 -97
  34. package/dist/src/tiles/list/tile-list-compact.js.map +1 -1
  35. package/dist/src/tiles/list/tile-list.js +289 -289
  36. package/dist/src/tiles/list/tile-list.js.map +1 -1
  37. package/dist/src/tiles/tile-dispatcher.js +200 -200
  38. package/dist/src/tiles/tile-dispatcher.js.map +1 -1
  39. package/dist/src/tiles/tile-display-value-provider.js.map +1 -1
  40. package/dist/test/collection-browser.test.js +183 -197
  41. package/dist/test/collection-browser.test.js.map +1 -1
  42. package/dist/test/restoration-state-handler.test.js.map +1 -1
  43. package/eslint.config.mjs +53 -53
  44. package/index.html +24 -24
  45. package/local.archive.org.cert +86 -86
  46. package/local.archive.org.key +27 -27
  47. package/package.json +117 -117
  48. package/renovate.json +6 -6
  49. package/src/collection-browser.ts +2775 -2779
  50. package/src/collection-facets/facet-row.ts +282 -282
  51. package/src/collection-facets/smart-facets/smart-facet-bar.ts +437 -437
  52. package/src/collection-facets.ts +990 -990
  53. package/src/data-source/collection-browser-data-source.ts +1390 -1390
  54. package/src/data-source/collection-browser-query-state.ts +63 -63
  55. package/src/data-source/models.ts +43 -43
  56. package/src/models.ts +870 -870
  57. package/src/restoration-state-handler.ts +544 -544
  58. package/src/tiles/base-tile-component.ts +53 -53
  59. package/src/tiles/grid/item-tile.ts +339 -339
  60. package/src/tiles/hover/hover-pane-controller.ts +517 -517
  61. package/src/tiles/hover/tile-hover-pane.ts +180 -180
  62. package/src/tiles/list/tile-list-compact-header.ts +86 -86
  63. package/src/tiles/list/tile-list-compact.ts +236 -236
  64. package/src/tiles/list/tile-list.ts +688 -688
  65. package/src/tiles/tile-dispatcher.ts +486 -486
  66. package/src/tiles/tile-display-value-provider.ts +124 -124
  67. package/test/collection-browser.test.ts +2340 -2359
  68. package/test/restoration-state-handler.test.ts +510 -510
  69. package/tsconfig.json +20 -20
  70. package/web-dev-server.config.mjs +30 -30
  71. package/web-test-runner.config.mjs +41 -41
@@ -1,180 +1,180 @@
1
- import type { SortParam } from '@internetarchive/search-service';
2
- import {
3
- css,
4
- CSSResultGroup,
5
- html,
6
- LitElement,
7
- nothing,
8
- TemplateResult,
9
- } from 'lit';
10
- import { customElement, property } from 'lit/decorators.js';
11
- import { suppressedCollections, type TileModel } from '../../models';
12
- import type { CollectionTitles } from '../../data-source/models';
13
- import '../list/tile-list';
14
-
15
- @customElement('tile-hover-pane')
16
- export class TileHoverPane extends LitElement {
17
- @property({ type: Object }) model?: TileModel;
18
-
19
- @property({ type: String }) baseNavigationUrl?: string;
20
-
21
- @property({ type: String }) baseImageUrl?: string;
22
-
23
- @property({ type: Boolean }) loggedIn: boolean = false;
24
-
25
- @property({ type: Boolean }) suppressBlurring: boolean = false;
26
-
27
- @property({ type: Object }) sortParam?: SortParam;
28
-
29
- @property({ type: Number }) mobileBreakpoint?: number;
30
-
31
- @property({ type: Number }) currentWidth?: number;
32
-
33
- @property({ type: Object })
34
- collectionTitles?: CollectionTitles;
35
-
36
- protected render(): TemplateResult {
37
- return html`
38
- <div id="container">
39
- ${this.headerTemplate}
40
- <div id="hover-tile-list">
41
- <tile-list
42
- .model=${this.model}
43
- .baseNavigationUrl=${this.baseNavigationUrl}
44
- .baseImageUrl=${this.baseImageUrl}
45
- .loggedIn=${this.loggedIn}
46
- .suppressBlurring=${this.suppressBlurring}
47
- .sortParam=${this.sortParam}
48
- .collectionTitles=${this.collectionTitles}
49
- .mobileBreakpoint=${this.mobileBreakpoint}
50
- .currentWidth=${this.currentWidth}
51
- ></tile-list>
52
- </div>
53
- </div>
54
- `;
55
- }
56
-
57
- private get headerTemplate(): TemplateResult | typeof nothing {
58
- // early return if item does't have parent collection
59
- if (this.model?.collections.length === 0) return nothing;
60
-
61
- let collectionTitle = '';
62
- let collectionIdentifier = '';
63
-
64
- for (const collection of this.model?.collections || []) {
65
- if (
66
- !suppressedCollections[collection] &&
67
- !collection.startsWith('fav-')
68
- ) {
69
- collectionTitle = this.collectionTitles?.get(collection) ?? collection;
70
- collectionIdentifier = collection;
71
- break;
72
- }
73
- }
74
-
75
- // sometimes item does have collections but they are in suppressed or favorite list,
76
- // let's not render that
77
- if (!collectionIdentifier) return nothing;
78
-
79
- return html`
80
- <div id="list-line-header">
81
- <a href="${this.baseNavigationUrl}/details/${collectionIdentifier}">
82
- <img
83
- src="${this.baseImageUrl}/services/img/${collectionIdentifier}"
84
- alt=""
85
- /><span>${collectionTitle}</span>
86
- </a>
87
- </div>
88
- `;
89
- }
90
-
91
- static get styles(): CSSResultGroup {
92
- const hoverPaneHeaderBGColor = css`var(--hoverPaneHeaderBGColor, #edf0ff)`;
93
- const iaLinkColor = css`var(--ia-theme-link-color, #4b64ff)`;
94
- const iaFontFamily = css`var(--ia-theme-base-font-family, "Helvetica Neue", Helvetica, Arial, sans-serif);`;
95
-
96
- return css`
97
- :host {
98
- margin: 0;
99
- border: 0;
100
- padding: 0;
101
- overflow: visible;
102
- color: inherit;
103
- background: none;
104
- visibility: hidden;
105
- opacity: 0;
106
- transform: translateY(8px);
107
- transition:
108
- opacity 0.1s ease-in,
109
- transform 0.1s ease-in;
110
- --image-width: auto;
111
- }
112
-
113
- :host(.visible) {
114
- visibility: visible;
115
- }
116
-
117
- :host(.fade-in) {
118
- opacity: 1;
119
- transform: translateY(0);
120
- }
121
-
122
- @media (prefers-reduced-motion: reduce) {
123
- :host {
124
- transition-duration: 0.001s !important; /* Imperceptibly fast */
125
- }
126
- }
127
-
128
- #container {
129
- width: max-content;
130
- max-width: min(45vw, 600px);
131
- border: 1px solid #ddd;
132
- border-radius: 4px;
133
- box-shadow: 4px 4px 8px 0 rgba(0, 0, 0, 0.8);
134
- background: white;
135
- }
136
-
137
- @media screen and (max-width: 600px) {
138
- #container {
139
- max-width: 80vw;
140
- }
141
- }
142
-
143
- /* main tile-list container */
144
- #hover-tile-list {
145
- padding: 10px;
146
- }
147
-
148
- /* header on hover panel to show collection icon and title */
149
- #list-line-header {
150
- background: ${hoverPaneHeaderBGColor};
151
- }
152
- #list-line-header a {
153
- display: flex;
154
- align-items: center;
155
- column-gap: 5px;
156
- height: 3.4rem;
157
- padding: 0 10px;
158
- border-radius: 4px 4px 0 0;
159
- width: fit-content;
160
- font-size: 1.4rem;
161
- color: ${iaLinkColor};
162
- font-family: ${iaFontFamily};
163
- text-decoration: none;
164
- width: auto;
165
- }
166
- #list-line-header a span {
167
- white-space: nowrap;
168
- overflow: hidden;
169
- text-overflow: ellipsis;
170
- }
171
- #list-line-header a:hover {
172
- text-decoration: underline;
173
- }
174
- #list-line-header a img {
175
- width: 30px;
176
- max-height: 30px;
177
- }
178
- `;
179
- }
180
- }
1
+ import type { SortParam } from '@internetarchive/search-service';
2
+ import {
3
+ css,
4
+ CSSResultGroup,
5
+ html,
6
+ LitElement,
7
+ nothing,
8
+ TemplateResult,
9
+ } from 'lit';
10
+ import { customElement, property } from 'lit/decorators.js';
11
+ import { suppressedCollections, type TileModel } from '../../models';
12
+ import type { CollectionTitles } from '../../data-source/models';
13
+ import '../list/tile-list';
14
+
15
+ @customElement('tile-hover-pane')
16
+ export class TileHoverPane extends LitElement {
17
+ @property({ type: Object }) model?: TileModel;
18
+
19
+ @property({ type: String }) baseNavigationUrl?: string;
20
+
21
+ @property({ type: String }) baseImageUrl?: string;
22
+
23
+ @property({ type: Boolean }) loggedIn: boolean = false;
24
+
25
+ @property({ type: Boolean }) suppressBlurring: boolean = false;
26
+
27
+ @property({ type: Object }) sortParam?: SortParam;
28
+
29
+ @property({ type: Number }) mobileBreakpoint?: number;
30
+
31
+ @property({ type: Number }) currentWidth?: number;
32
+
33
+ @property({ type: Object })
34
+ collectionTitles?: CollectionTitles;
35
+
36
+ protected render(): TemplateResult {
37
+ return html`
38
+ <div id="container">
39
+ ${this.headerTemplate}
40
+ <div id="hover-tile-list">
41
+ <tile-list
42
+ .model=${this.model}
43
+ .baseNavigationUrl=${this.baseNavigationUrl}
44
+ .baseImageUrl=${this.baseImageUrl}
45
+ .loggedIn=${this.loggedIn}
46
+ .suppressBlurring=${this.suppressBlurring}
47
+ .sortParam=${this.sortParam}
48
+ .collectionTitles=${this.collectionTitles}
49
+ .mobileBreakpoint=${this.mobileBreakpoint}
50
+ .currentWidth=${this.currentWidth}
51
+ ></tile-list>
52
+ </div>
53
+ </div>
54
+ `;
55
+ }
56
+
57
+ private get headerTemplate(): TemplateResult | typeof nothing {
58
+ // early return if item does't have parent collection
59
+ if (this.model?.collections.length === 0) return nothing;
60
+
61
+ let collectionTitle = '';
62
+ let collectionIdentifier = '';
63
+
64
+ for (const collection of this.model?.collections || []) {
65
+ if (
66
+ !suppressedCollections[collection] &&
67
+ !collection.startsWith('fav-')
68
+ ) {
69
+ collectionTitle = this.collectionTitles?.get(collection) ?? collection;
70
+ collectionIdentifier = collection;
71
+ break;
72
+ }
73
+ }
74
+
75
+ // sometimes item does have collections but they are in suppressed or favorite list,
76
+ // let's not render that
77
+ if (!collectionIdentifier) return nothing;
78
+
79
+ return html`
80
+ <div id="list-line-header">
81
+ <a href="${this.baseNavigationUrl}/details/${collectionIdentifier}">
82
+ <img
83
+ src="${this.baseImageUrl}/services/img/${collectionIdentifier}"
84
+ alt=""
85
+ /><span>${collectionTitle}</span>
86
+ </a>
87
+ </div>
88
+ `;
89
+ }
90
+
91
+ static get styles(): CSSResultGroup {
92
+ const hoverPaneHeaderBGColor = css`var(--hoverPaneHeaderBGColor, #edf0ff)`;
93
+ const iaLinkColor = css`var(--ia-theme-link-color, #4b64ff)`;
94
+ const iaFontFamily = css`var(--ia-theme-base-font-family, "Helvetica Neue", Helvetica, Arial, sans-serif);`;
95
+
96
+ return css`
97
+ :host {
98
+ margin: 0;
99
+ border: 0;
100
+ padding: 0;
101
+ overflow: visible;
102
+ color: inherit;
103
+ background: none;
104
+ visibility: hidden;
105
+ opacity: 0;
106
+ transform: translateY(8px);
107
+ transition:
108
+ opacity 0.1s ease-in,
109
+ transform 0.1s ease-in;
110
+ --image-width: auto;
111
+ }
112
+
113
+ :host(.visible) {
114
+ visibility: visible;
115
+ }
116
+
117
+ :host(.fade-in) {
118
+ opacity: 1;
119
+ transform: translateY(0);
120
+ }
121
+
122
+ @media (prefers-reduced-motion: reduce) {
123
+ :host {
124
+ transition-duration: 0.001s !important; /* Imperceptibly fast */
125
+ }
126
+ }
127
+
128
+ #container {
129
+ width: max-content;
130
+ max-width: min(45vw, 600px);
131
+ border: 1px solid #ddd;
132
+ border-radius: 4px;
133
+ box-shadow: 4px 4px 8px 0 rgba(0, 0, 0, 0.8);
134
+ background: white;
135
+ }
136
+
137
+ @media screen and (max-width: 600px) {
138
+ #container {
139
+ max-width: 80vw;
140
+ }
141
+ }
142
+
143
+ /* main tile-list container */
144
+ #hover-tile-list {
145
+ padding: 10px;
146
+ }
147
+
148
+ /* header on hover panel to show collection icon and title */
149
+ #list-line-header {
150
+ background: ${hoverPaneHeaderBGColor};
151
+ }
152
+ #list-line-header a {
153
+ display: flex;
154
+ align-items: center;
155
+ column-gap: 5px;
156
+ height: 3.4rem;
157
+ padding: 0 10px;
158
+ border-radius: 4px 4px 0 0;
159
+ width: fit-content;
160
+ font-size: 1.4rem;
161
+ color: ${iaLinkColor};
162
+ font-family: ${iaFontFamily};
163
+ text-decoration: none;
164
+ width: auto;
165
+ }
166
+ #list-line-header a span {
167
+ white-space: nowrap;
168
+ overflow: hidden;
169
+ text-overflow: ellipsis;
170
+ }
171
+ #list-line-header a:hover {
172
+ text-decoration: underline;
173
+ }
174
+ #list-line-header a img {
175
+ width: 30px;
176
+ max-height: 30px;
177
+ }
178
+ `;
179
+ }
180
+ }
@@ -1,86 +1,86 @@
1
- import { css, html } from 'lit';
2
- import { customElement } from 'lit/decorators.js';
3
- import { msg } from '@lit/localize';
4
- import { BaseTileComponent } from '../base-tile-component';
5
-
6
- @customElement('tile-list-compact-header')
7
- export class TileListCompactHeader extends BaseTileComponent {
8
- /*
9
- * Reactive properties inherited from BaseTileComponent:
10
- * - model?: TileModel;
11
- * - currentWidth?: number;
12
- * - currentHeight?: number;
13
- * - baseNavigationUrl?: string;
14
- * - baseImageUrl?: string;
15
- * - collectionPagePath?: string;
16
- * - sortParam: SortParam | null = null;
17
- * - creatorFilter?: string;
18
- * - mobileBreakpoint?: number;
19
- * - loggedIn = false;
20
- * - suppressBlurring = false;
21
- */
22
-
23
- render() {
24
- return html`
25
- <div id="list-line-header" class="${this.classSize}">
26
- <div id="thumb"></div>
27
- <div id="title">${msg('Title')}</div>
28
- <div id="creator">${msg('Creator')}</div>
29
- <div id="date">
30
- ${this.displayValueProvider.dateLabel || msg('Published')}
31
- </div>
32
- <div id="icon">${msg('Type')}</div>
33
- <div id="views">${msg('Views')}</div>
34
- </div>
35
- `;
36
- }
37
-
38
- private get classSize(): string {
39
- if (
40
- this.mobileBreakpoint &&
41
- this.currentWidth &&
42
- this.currentWidth < this.mobileBreakpoint
43
- ) {
44
- return 'mobile';
45
- }
46
- return 'desktop';
47
- }
48
-
49
- static get styles() {
50
- return css`
51
- html {
52
- font-size: unset;
53
- }
54
-
55
- div {
56
- font-size: 14px;
57
- font-weight: bold;
58
- line-height: 20px;
59
- }
60
-
61
- .mobile #views {
62
- display: none;
63
- }
64
-
65
- #views {
66
- text-align: right;
67
- padding-right: 8px;
68
- }
69
-
70
- #list-line-header {
71
- display: grid;
72
- column-gap: 10px;
73
- align-items: flex-end;
74
- padding-bottom: 2px;
75
- }
76
-
77
- #list-line-header.mobile {
78
- grid-template-columns: 36px 3fr 2fr 68px 35px;
79
- }
80
-
81
- #list-line-header.desktop {
82
- grid-template-columns: 51px 3fr 2fr 95px 30px 60px;
83
- }
84
- `;
85
- }
86
- }
1
+ import { css, html } from 'lit';
2
+ import { customElement } from 'lit/decorators.js';
3
+ import { msg } from '@lit/localize';
4
+ import { BaseTileComponent } from '../base-tile-component';
5
+
6
+ @customElement('tile-list-compact-header')
7
+ export class TileListCompactHeader extends BaseTileComponent {
8
+ /*
9
+ * Reactive properties inherited from BaseTileComponent:
10
+ * - model?: TileModel;
11
+ * - currentWidth?: number;
12
+ * - currentHeight?: number;
13
+ * - baseNavigationUrl?: string;
14
+ * - baseImageUrl?: string;
15
+ * - collectionPagePath?: string;
16
+ * - sortParam: SortParam | null = null;
17
+ * - creatorFilter?: string;
18
+ * - mobileBreakpoint?: number;
19
+ * - loggedIn = false;
20
+ * - suppressBlurring = false;
21
+ */
22
+
23
+ render() {
24
+ return html`
25
+ <div id="list-line-header" class="${this.classSize}">
26
+ <div id="thumb"></div>
27
+ <div id="title">${msg('Title')}</div>
28
+ <div id="creator">${msg('Creator')}</div>
29
+ <div id="date">
30
+ ${this.displayValueProvider.dateLabel || msg('Published')}
31
+ </div>
32
+ <div id="icon">${msg('Type')}</div>
33
+ <div id="views">${msg('Views')}</div>
34
+ </div>
35
+ `;
36
+ }
37
+
38
+ private get classSize(): string {
39
+ if (
40
+ this.mobileBreakpoint &&
41
+ this.currentWidth &&
42
+ this.currentWidth < this.mobileBreakpoint
43
+ ) {
44
+ return 'mobile';
45
+ }
46
+ return 'desktop';
47
+ }
48
+
49
+ static get styles() {
50
+ return css`
51
+ html {
52
+ font-size: unset;
53
+ }
54
+
55
+ div {
56
+ font-size: 14px;
57
+ font-weight: bold;
58
+ line-height: 20px;
59
+ }
60
+
61
+ .mobile #views {
62
+ display: none;
63
+ }
64
+
65
+ #views {
66
+ text-align: right;
67
+ padding-right: 8px;
68
+ }
69
+
70
+ #list-line-header {
71
+ display: grid;
72
+ column-gap: 10px;
73
+ align-items: flex-end;
74
+ padding-bottom: 2px;
75
+ }
76
+
77
+ #list-line-header.mobile {
78
+ grid-template-columns: 36px 3fr 2fr 68px 35px;
79
+ }
80
+
81
+ #list-line-header.desktop {
82
+ grid-template-columns: 51px 3fr 2fr 95px 30px 60px;
83
+ }
84
+ `;
85
+ }
86
+ }