@internetarchive/collection-browser 2.18.0 → 2.18.1-alpha-webdev7768.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.
@@ -1,175 +1,175 @@
1
- import { css, html, LitElement, CSSResultGroup, TemplateResult } from 'lit';
2
- import { customElement, property } from 'lit/decorators.js';
3
- import { ifDefined } from 'lit/directives/if-defined.js';
4
- import { msg } from '@lit/localize';
5
- import type { ModalManagerInterface } from '@internetarchive/modal-manager';
6
- import type { AnalyticsManagerInterface } from '@internetarchive/analytics-manager';
7
- import { BinSnappingInterval } from '@internetarchive/histogram-date-range';
8
- import {
9
- analyticsActions,
10
- analyticsCategories,
11
- } from './utils/analytics-events';
12
-
13
- import '@internetarchive/histogram-date-range';
14
-
15
- @customElement('expanded-date-picker')
16
- export class ExpandedDatePicker extends LitElement {
17
- @property({ type: String }) minDate?: string;
18
-
19
- @property({ type: String }) maxDate?: string;
20
-
21
- @property({ type: String }) minSelectedDate?: string;
22
-
23
- @property({ type: String }) maxSelectedDate?: string;
24
-
25
- @property({ type: Array }) buckets?: number[];
26
-
27
- @property({ type: String }) dateFormat: string = 'YYYY';
28
-
29
- @property({ type: String }) tooltipDateFormat?: string;
30
-
31
- @property({ type: String }) binSnapping?: BinSnappingInterval;
32
-
33
- @property({ type: Object, attribute: false })
34
- modalManager?: ModalManagerInterface;
35
-
36
- @property({ type: Object, attribute: false })
37
- analyticsHandler?: AnalyticsManagerInterface;
38
-
39
- render(): TemplateResult {
40
- return html`
41
- <div id="container">
42
- <histogram-date-range
43
- id="date-picker"
44
- .minDate=${this.minDate}
45
- .maxDate=${this.maxDate}
46
- .minSelectedDate=${this.minSelectedDate ?? this.minDate}
47
- .maxSelectedDate=${this.maxSelectedDate ?? this.maxDate}
48
- .dateFormat=${this.dateFormat}
49
- tooltipDateFormat=${ifDefined(this.tooltipDateFormat)}
50
- binSnapping=${ifDefined(this.binSnapping)}
51
- .updateDelay=${0}
52
- updateWhileFocused
53
- missingDataMessage="..."
54
- .width=${560}
55
- .height=${120}
56
- .bins=${this.buckets}
57
- @histogramDateRangeUpdated=${this.histogramDateRangeUpdated}
58
- >
59
- <button
60
- id="apply-btn"
61
- slot="inputs-right-side"
62
- @click=${this.applyBtnClicked}
63
- >
64
- ${msg('Apply date range')}
65
- </button>
66
- </histogram-date-range>
67
- </div>
68
- `;
69
- }
70
-
71
- connectedCallback(): void {
72
- super.connectedCallback?.();
73
- this.setupEscapeListener();
74
- }
75
-
76
- disconnectedCallback(): void {
77
- super.disconnectedCallback?.();
78
- this.removeEscapeListener();
79
- }
80
-
81
- /**
82
- * Add an event listener to close the date picker modal when the Esc key is pressed
83
- */
84
- private setupEscapeListener() {
85
- document.addEventListener('keydown', this.boundEscapeListener);
86
- }
87
-
88
- /**
89
- * Remove the Esc key listener that was previously added
90
- */
91
- private removeEscapeListener() {
92
- document.removeEventListener('keydown', this.boundEscapeListener);
93
- }
94
-
95
- /**
96
- * Closes the modal dialog if the given event is pressing the Esc key.
97
- * Arrow function to ensure `this` remains bound to the current component.
98
- */
99
- private boundEscapeListener = (e: KeyboardEvent) => {
100
- if (e.key === 'Escape') {
101
- this.closeModal();
102
- }
103
- };
104
-
105
- /**
106
- * When the histogram is updated, keep track of the newly selected date range.
107
- * We don't commit to the new range until the apply button is clicked.
108
- */
109
- private histogramDateRangeUpdated(
110
- e: CustomEvent<{
111
- minDate: string;
112
- maxDate: string;
113
- }>,
114
- ): void {
115
- this.minSelectedDate = e.detail.minDate;
116
- this.maxSelectedDate = e.detail.maxDate;
117
- }
118
-
119
- /**
120
- * When the Apply button is clicked, emit the current date range and close the modal.
121
- */
122
- private applyBtnClicked(): void {
123
- const event = new CustomEvent('histogramDateRangeApplied', {
124
- detail: {
125
- minDate: this.minSelectedDate,
126
- maxDate: this.maxSelectedDate,
127
- },
128
- });
129
- this.dispatchEvent(event);
130
- this.closeModal();
131
-
132
- this.analyticsHandler?.sendEvent({
133
- category: analyticsCategories.default,
134
- action: analyticsActions.histogramChangedFromModal,
135
- label: window.location.href,
136
- });
137
- }
138
-
139
- /**
140
- * Closes the modal associated with this component (if it exists) and dispatches a
141
- * modalClosed event.
142
- */
143
- private closeModal(): void {
144
- if (this.modalManager) {
145
- this.modalManager.closeModal();
146
- this.dispatchEvent(new CustomEvent('modalClosed'));
147
- }
148
- }
149
-
150
- static get styles(): CSSResultGroup {
151
- return css`
152
- #container {
153
- display: flex;
154
- justify-content: center;
155
- padding: 40px 10px 10px;
156
- overflow: hidden;
157
- }
158
-
159
- #date-picker {
160
- --histogramDateRangeInputWidth: 50px;
161
- --histogramDateRangeInputRowMargin: 5px 0 0 0;
162
- }
163
-
164
- #apply-btn {
165
- margin: 0 0 0 5px;
166
- padding: 8px 10px;
167
- border: 0;
168
- border-radius: 4px;
169
- background: var(--primaryButtonBGColor, #194880);
170
- color: white;
171
- cursor: pointer;
172
- }
173
- `;
174
- }
175
- }
1
+ import { css, html, LitElement, CSSResultGroup, TemplateResult } from 'lit';
2
+ import { customElement, property } from 'lit/decorators.js';
3
+ import { ifDefined } from 'lit/directives/if-defined.js';
4
+ import { msg } from '@lit/localize';
5
+ import type { ModalManagerInterface } from '@internetarchive/modal-manager';
6
+ import type { AnalyticsManagerInterface } from '@internetarchive/analytics-manager';
7
+ import { BinSnappingInterval } from '@internetarchive/histogram-date-range';
8
+ import {
9
+ analyticsActions,
10
+ analyticsCategories,
11
+ } from './utils/analytics-events';
12
+
13
+ import '@internetarchive/histogram-date-range';
14
+
15
+ @customElement('expanded-date-picker')
16
+ export class ExpandedDatePicker extends LitElement {
17
+ @property({ type: String }) minDate?: string;
18
+
19
+ @property({ type: String }) maxDate?: string;
20
+
21
+ @property({ type: String }) minSelectedDate?: string;
22
+
23
+ @property({ type: String }) maxSelectedDate?: string;
24
+
25
+ @property({ type: Array }) buckets?: number[];
26
+
27
+ @property({ type: String }) dateFormat: string = 'YYYY';
28
+
29
+ @property({ type: String }) tooltipDateFormat?: string;
30
+
31
+ @property({ type: String }) binSnapping?: BinSnappingInterval;
32
+
33
+ @property({ type: Object, attribute: false })
34
+ modalManager?: ModalManagerInterface;
35
+
36
+ @property({ type: Object, attribute: false })
37
+ analyticsHandler?: AnalyticsManagerInterface;
38
+
39
+ render(): TemplateResult {
40
+ return html`
41
+ <div id="container">
42
+ <histogram-date-range
43
+ id="date-picker"
44
+ .minDate=${this.minDate}
45
+ .maxDate=${this.maxDate}
46
+ .minSelectedDate=${this.minSelectedDate ?? this.minDate}
47
+ .maxSelectedDate=${this.maxSelectedDate ?? this.maxDate}
48
+ .dateFormat=${this.dateFormat}
49
+ tooltipDateFormat=${ifDefined(this.tooltipDateFormat)}
50
+ binSnapping=${ifDefined(this.binSnapping)}
51
+ .updateDelay=${0}
52
+ updateWhileFocused
53
+ missingDataMessage="..."
54
+ .width=${560}
55
+ .height=${120}
56
+ .bins=${this.buckets}
57
+ @histogramDateRangeUpdated=${this.histogramDateRangeUpdated}
58
+ >
59
+ <button
60
+ id="apply-btn"
61
+ slot="inputs-right-side"
62
+ @click=${this.applyBtnClicked}
63
+ >
64
+ ${msg('Apply date range')}
65
+ </button>
66
+ </histogram-date-range>
67
+ </div>
68
+ `;
69
+ }
70
+
71
+ connectedCallback(): void {
72
+ super.connectedCallback?.();
73
+ this.setupEscapeListener();
74
+ }
75
+
76
+ disconnectedCallback(): void {
77
+ super.disconnectedCallback?.();
78
+ this.removeEscapeListener();
79
+ }
80
+
81
+ /**
82
+ * Add an event listener to close the date picker modal when the Esc key is pressed
83
+ */
84
+ private setupEscapeListener() {
85
+ document.addEventListener('keydown', this.boundEscapeListener);
86
+ }
87
+
88
+ /**
89
+ * Remove the Esc key listener that was previously added
90
+ */
91
+ private removeEscapeListener() {
92
+ document.removeEventListener('keydown', this.boundEscapeListener);
93
+ }
94
+
95
+ /**
96
+ * Closes the modal dialog if the given event is pressing the Esc key.
97
+ * Arrow function to ensure `this` remains bound to the current component.
98
+ */
99
+ private boundEscapeListener = (e: KeyboardEvent) => {
100
+ if (e.key === 'Escape') {
101
+ this.closeModal();
102
+ }
103
+ };
104
+
105
+ /**
106
+ * When the histogram is updated, keep track of the newly selected date range.
107
+ * We don't commit to the new range until the apply button is clicked.
108
+ */
109
+ private histogramDateRangeUpdated(
110
+ e: CustomEvent<{
111
+ minDate: string;
112
+ maxDate: string;
113
+ }>,
114
+ ): void {
115
+ this.minSelectedDate = e.detail.minDate;
116
+ this.maxSelectedDate = e.detail.maxDate;
117
+ }
118
+
119
+ /**
120
+ * When the Apply button is clicked, emit the current date range and close the modal.
121
+ */
122
+ private applyBtnClicked(): void {
123
+ const event = new CustomEvent('histogramDateRangeApplied', {
124
+ detail: {
125
+ minDate: this.minSelectedDate,
126
+ maxDate: this.maxSelectedDate,
127
+ },
128
+ });
129
+ this.dispatchEvent(event);
130
+ this.closeModal();
131
+
132
+ this.analyticsHandler?.sendEvent({
133
+ category: analyticsCategories.default,
134
+ action: analyticsActions.histogramChangedFromModal,
135
+ label: window.location.href,
136
+ });
137
+ }
138
+
139
+ /**
140
+ * Closes the modal associated with this component (if it exists) and dispatches a
141
+ * modalClosed event.
142
+ */
143
+ private closeModal(): void {
144
+ if (this.modalManager) {
145
+ this.modalManager.closeModal();
146
+ this.dispatchEvent(new CustomEvent('modalClosed'));
147
+ }
148
+ }
149
+
150
+ static get styles(): CSSResultGroup {
151
+ return css`
152
+ #container {
153
+ display: flex;
154
+ justify-content: center;
155
+ padding: 40px 10px 10px;
156
+ overflow: hidden;
157
+ }
158
+
159
+ #date-picker {
160
+ --histogramDateRangeInputWidth: 50px;
161
+ --histogramDateRangeInputRowMargin: 5px 0 0 0;
162
+ }
163
+
164
+ #apply-btn {
165
+ margin: 0 0 0 5px;
166
+ padding: 8px 10px;
167
+ border: 0;
168
+ border-radius: 4px;
169
+ background: var(--primaryButtonBGColor, #194880);
170
+ color: white;
171
+ cursor: pointer;
172
+ }
173
+ `;
174
+ }
175
+ }
@@ -16,7 +16,7 @@ export const baseTileStyles = css`
16
16
  background-color: ${tileBackgroundColor};
17
17
  border: 1px #2c2c2c;
18
18
  border-radius: ${tileCornerRadius};
19
- box-shadow: 1px 1px 2px 0;
19
+ /*box-shadow: 1px 1px 2px 0;*/
20
20
  box-sizing: border-box;
21
21
  height: 100%;
22
22
  display: flex;
@@ -433,7 +433,7 @@ export class TileDispatcher
433
433
  }
434
434
 
435
435
  #container.hoverable:hover {
436
- box-shadow: 0 0 6px 2px rgba(8, 8, 32, 0.8);
436
+ box-shadow: 0 0 10px 0px rgba(8, 8, 32, 0.15);
437
437
  transition: box-shadow 0.1s ease;
438
438
  }
439
439
 
package/tsconfig.json CHANGED
@@ -1,20 +1,20 @@
1
- {
2
- "compilerOptions": {
3
- "target": "es2018",
4
- "module": "esnext",
5
- "moduleResolution": "node",
6
- "noEmitOnError": true,
7
- "lib": ["es2017", "dom"],
8
- "strict": true,
9
- "esModuleInterop": false,
10
- "allowSyntheticDefaultImports": true,
11
- "experimentalDecorators": true,
12
- "importHelpers": true,
13
- "outDir": "dist",
14
- "sourceMap": true,
15
- "inlineSources": true,
16
- "rootDir": "./",
17
- "declaration": true,
18
- },
19
- "include": ["src", "test", "index.ts", "types"],
20
- }
1
+ {
2
+ "compilerOptions": {
3
+ "target": "es2018",
4
+ "module": "esnext",
5
+ "moduleResolution": "node",
6
+ "noEmitOnError": true,
7
+ "lib": ["es2017", "dom"],
8
+ "strict": true,
9
+ "esModuleInterop": false,
10
+ "allowSyntheticDefaultImports": true,
11
+ "experimentalDecorators": true,
12
+ "importHelpers": true,
13
+ "outDir": "dist",
14
+ "sourceMap": true,
15
+ "inlineSources": true,
16
+ "rootDir": "./",
17
+ "declaration": true,
18
+ },
19
+ "include": ["src", "test", "index.ts", "types"],
20
+ }