@internetarchive/ia-book-actions 0.0.20 → 0.0.22-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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@internetarchive/ia-book-actions",
3
- "version": "0.0.20",
3
+ "version": "0.0.22-2",
4
4
  "description": "Bookreader actions for borrowable book",
5
5
  "author": "Internet Archive",
6
6
  "license": "AGPL-3.0-only",
@@ -20,7 +20,7 @@
20
20
  "dependencies": {
21
21
  "@internetarchive/icon-info": "^1.2.6",
22
22
  "@internetarchive/local-cache": "^0.2.0",
23
- "@internetarchive/modal-manager": "^0.1.0",
23
+ "@internetarchive/modal-manager": "^0.2.1",
24
24
  "@internetarchive/shared-resize-observer": "^0.2.0",
25
25
  "lit": "^2.2.1"
26
26
  },
@@ -14,18 +14,15 @@ export default css`
14
14
  align-items: center;
15
15
  }
16
16
  .action-buttons .ia-button {
17
- display: inline-flex;
18
- align-items: center;
19
- vertical-align: middle;
17
+ margin: 0;
20
18
  height: 3.5rem;
21
- transition: all 0.1s ease 0s;
22
- vertical-align: middle;
23
- padding: 0 1rem;
24
- margin: 0 3px;
25
19
  }
26
20
  .primary,
27
21
  .secondary {
28
22
  position: relative;
23
+ background-color: var(--white, #fff);
24
+ border-radius: 5px;
25
+ margin: 0 3px;
29
26
  }
30
27
  .primary .initial {
31
28
  border-radius: 0.4rem 0 0 0.4rem;
@@ -51,9 +48,9 @@ export default css`
51
48
  }
52
49
  .dropdown-content .ia-button {
53
50
  background: none;
51
+ color: var(--primaryTextColor, #fff);
54
52
  border: none;
55
53
  box-sizing: border-box;
56
- display: block;
57
54
  width: 100%;
58
55
  text-align: left;
59
56
  height: 3rem;
@@ -61,6 +58,9 @@ export default css`
61
58
  padding: 0.6rem 1.2rem;
62
59
  margin: 0;
63
60
  }
61
+ .dropdown-content .ia-button:is(:focus-visible, :hover) {
62
+ background: unset;
63
+ }
64
64
  .dropdown-content li .ia-button {
65
65
  border-radius: 0;
66
66
  }
@@ -115,6 +115,9 @@ export default css`
115
115
  display: inline-block;
116
116
  vertical-align: middle;
117
117
  }
118
+ .secondary .ia-button.exit-admin {
119
+ background-color: var(--primaryBGColor);
120
+ }
118
121
  .purchase small {
119
122
  display: block;
120
123
  font-size: 1rem;
@@ -3,63 +3,88 @@ import { css } from 'lit';
3
3
  export default css`
4
4
  .ia-button {
5
5
  min-height: 3rem;
6
- border: none;
7
- outline: none;
8
6
  cursor: pointer;
9
- color: #fff;
7
+ color: var(--primaryTextColor, #fff);
10
8
  line-height: normal;
11
9
  border-radius: 0.4rem;
12
- text-align: center;
13
- vertical-align: middle;
14
10
  font-size: 1.4rem;
15
11
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
16
- display: inline-block;
17
- padding: 0.85rem 1.2rem;
18
12
  border: 1px solid transparent;
19
13
  white-space: nowrap;
20
14
  appearance: auto;
21
15
  box-sizing: border-box;
16
+ display: flex;
17
+ align-items: center;
18
+ transition: all 0.1s ease 0s;
19
+ vertical-align: middle;
20
+ padding: 0 1rem;
21
+ outline-color: var(--primaryTextColor, #fff);
22
+ outline-offset: -4px;
23
+ user-select: none;
24
+ text-decoration: none;
25
+ width: fit-content;
22
26
  -webkit-user-select: none;
23
27
  -moz-user-select: none;
24
28
  -ms-user-select: none;
25
29
  -o-user-select: none;
26
- user-select: none;
27
30
  }
28
- .ia-button:disabled,
29
- .ia-button.disabled {
31
+ .ia-button:focus-visible {
32
+ outline-style: double;
33
+ }
34
+
35
+ .ia-button:disabled {
30
36
  cursor: not-allowed;
31
37
  background-color: var(--primaryDisableCTAFill, #767676);
32
38
  border: 1px solid var(--secondaryCTABorder, #999);
33
- color: var(--primaryTextColor, #fff);
34
39
  }
35
40
  .ia-button.transparent {
36
41
  background-color: transparent;
37
42
  }
38
43
 
39
- .ia-button.slim {
40
- padding: 0;
44
+ .ia-button.warning {
45
+ background-color: #ee8950;
46
+ border-color: #ec7939;
41
47
  }
48
+
42
49
  .ia-button.primary {
43
- background-color: #194880;
50
+ background-color: var(--primaryCTAFill, #194880);
44
51
  border-color: #c5d1df;
45
52
  }
46
- .ia-button.dark {
47
- color: #fff;
48
- background-color: #333;
49
- border-color: #979797;
53
+ .ia-button.primary:hover {
54
+ background-color: rgba(27, 72, 128, 0.9);
50
55
  }
56
+ .ia-button.primary:focus-visible {
57
+ background-color: rgba(27, 72, 128, 0.8);
58
+ }
59
+ .ia-button.primary:active {
60
+ background-color: rgba(27, 72, 128, 0.7);
61
+ }
62
+
51
63
  .ia-button.danger {
52
- color: #fff;
53
- background-color: #d9534f;
64
+ background-color: var(--primaryErrorCTAFill, #e51c26);
54
65
  border-color: #d43f3a;
55
66
  }
56
- .ia-button.warning {
57
- color: #fff;
58
- background-color: #ee8950;
59
- border-color: #ec7939;
67
+ .ia-button.danger:hover {
68
+ background-color: rgba(229, 28, 38, 0.9);
69
+ }
70
+ .ia-button.danger:focus-visible {
71
+ background-color: rgba(229, 28, 38, 0.8);
72
+ }
73
+ .ia-button.danger:active {
74
+ background-color: rgba(229, 28, 38, 0.7);
75
+ }
76
+
77
+ .ia-button.dark {
78
+ background-color: var(--secondaryCTAFill, #333);
79
+ border-color: #979797;
80
+ }
81
+ .ia-button.dark:hover {
82
+ background-color: rgba(51, 51, 51, 0.9);
83
+ }
84
+ .ia-button.dark:focus-visible {
85
+ background-color: rgba(51, 51, 51, 0.8);
60
86
  }
61
- .ia-button.cancel {
62
- background-color: #e51c26;
63
- border-color: #f8c6c8;
87
+ .ia-button.dark:active {
88
+ background-color: rgba(51, 51, 51, 0.7);
64
89
  }
65
90
  `;
@@ -50,7 +50,10 @@ export class CollapsibleActionGroup extends ActionsHandler {
50
50
  }
51
51
 
52
52
  updated(changed) {
53
- if (changed.has('width') && this.isBelowTabletContainer) {
53
+ if (
54
+ (changed.has('width') || changed.has('disabled')) &&
55
+ this.isBelowTabletContainer
56
+ ) {
54
57
  this.resetActions();
55
58
  }
56
59
  }
@@ -110,6 +113,9 @@ export class CollapsibleActionGroup extends ActionsHandler {
110
113
  <section class="action-buttons secondary">
111
114
  ${this.renderSecondaryActions}
112
115
  </section>
116
+ <section class="action-buttons secondary purchase">
117
+ ${this.renderPurchaseAction}
118
+ </section>
113
119
  </div>
114
120
  `;
115
121
  }
@@ -147,13 +153,27 @@ export class CollapsibleActionGroup extends ActionsHandler {
147
153
  return this.secondaryActions.map(action => this.renderActionLink(action));
148
154
  }
149
155
 
156
+ get renderPurchaseAction() {
157
+ if (!this.secondaryActions.length) return nothing;
158
+
159
+ if (this.secondaryActions.length === 2) {
160
+ return this.renderActionLink(this.secondaryActions[1], true);
161
+ }
162
+ if (this.secondaryActions[0].id === 'purchaseBook') {
163
+ return this.renderActionLink(this.secondaryActions[0], true);
164
+ }
165
+ return nothing;
166
+ }
167
+
150
168
  /**
151
- * Render action as a link for secondary actions like admin, purchase, printdisability links.
169
+ * Render action as a link for secondary actions like admin, printdisability links.
152
170
  * @param { Object } action
153
171
  * @param { Boolean } initialButton
154
172
  * @returns { HTMLElement }
155
173
  */
156
174
  renderActionLink(action, initialButton = false) {
175
+ if (!initialButton && action?.id === 'purchaseBook') return nothing; // handle purchase action differerntly
176
+
157
177
  return html`<a
158
178
  class="ia-button ${action.className} ${initialButton ? 'initial' : ''}"
159
179
  href="${action.url}"
@@ -8,6 +8,7 @@ export class URLHelper {
8
8
  try {
9
9
  return window.self !== window.top;
10
10
  } catch (e) {
11
+ window?.Sentry?.captureException(e);
11
12
  return true;
12
13
  }
13
14
  }
@@ -226,7 +226,7 @@ export default class ActionsConfig {
226
226
  text: message,
227
227
  url: URLHelper.getBackHref(),
228
228
  target: '_self',
229
- className: 'ia-button',
229
+ className: 'exit-admin',
230
230
  analyticsEvent: {
231
231
  category: this.analyticsCategories.adminAccess,
232
232
  action: this.analyticsActions.doneBorrowing,
@@ -64,5 +64,7 @@ export default async function ActionsHandlerService(options) {
64
64
  option?.error(data);
65
65
  }
66
66
  });
67
- } catch (err) {}
67
+ } catch (err) {
68
+ window?.Sentry?.captureException(err);
69
+ }
68
70
  }
@@ -22,8 +22,6 @@ export default class ActionsHandler extends LitElement {
22
22
  }
23
23
 
24
24
  sendEvent(eventCategory, eventAction) {
25
- // eslint-disable-next-line no-console
26
- console?.log('Book action: ', { eventCategory, eventAction });
27
25
  window?.archive_analytics?.send_event_no_sampling(
28
26
  eventCategory,
29
27
  eventAction,
@@ -258,6 +256,7 @@ export default class ActionsHandler extends LitElement {
258
256
  // set new value
259
257
  Cookies.setItem(storageKey, newCount, date, '/');
260
258
  } catch (error) {
259
+ window?.Sentry?.captureException(error);
261
260
  this.sendEvent('Cookies-Error-Actions', error);
262
261
  }
263
262
  }
@@ -439,8 +439,6 @@ export class GetLendingActions {
439
439
  lendingActions = this.restrictedAction();
440
440
  }
441
441
 
442
- // debugging console
443
- console.log(lendingActions.primaryTitle);
444
442
  return lendingActions;
445
443
  }
446
444
  }
@@ -21,6 +21,9 @@ export class LoanTokenPoller {
21
21
  disconnectedInterval() {
22
22
  clearInterval(this.loanTokenInterval);
23
23
  this.loanTokenInterval = undefined;
24
+ if (window.Sentry) {
25
+ window?.Sentry?.captureMessage('loan token interval cleared');
26
+ }
24
27
  }
25
28
 
26
29
  async enableBookAccess() {
@@ -35,6 +38,7 @@ export class LoanTokenPoller {
35
38
  );
36
39
  consecutiveLoanCounts = existingCount ?? 1;
37
40
  } catch (error) {
41
+ window?.Sentry?.captureException(error);
38
42
  this.sendEvent('Cookies-Error-Token', error);
39
43
  }
40
44
  }
@@ -54,14 +58,13 @@ export class LoanTokenPoller {
54
58
 
55
59
  this.sendEvent(category, action);
56
60
  } else {
61
+ window?.Sentry?.captureMessage('enableBookAccess error');
57
62
  // if book is not browsed, just clear token polling interval
58
63
  this.disconnectedInterval(); // stop token fetch api
59
64
  }
60
65
  }
61
66
 
62
67
  sendEvent(eventCategory, eventAction) {
63
- // eslint-disable-next-line no-console
64
- console?.log('Book action: ', { eventCategory, eventAction });
65
68
  window?.archive_analytics?.send_event_no_sampling(
66
69
  eventCategory,
67
70
  eventAction,
@@ -75,8 +78,11 @@ export class LoanTokenPoller {
75
78
  identifier: this.identifier,
76
79
  action,
77
80
  error: data => {
81
+ window?.Sentry?.captureMessage('handleLoanTokenPoller error');
78
82
  this.disconnectedInterval(); // stop token fetch api
79
83
  this.errorCallback({ detail: { action, data } });
84
+ // send LendingServiceError to GA
85
+ this.sendEvent('LendingServiceLoanError', action);
80
86
  },
81
87
  success: () => {
82
88
  if (isInitial) this.successCallback();
@@ -66,6 +66,8 @@ export default class IABookActions extends LitElement {
66
66
  }
67
67
 
68
68
  disconnectedCallback() {
69
+ this.tokenPoller?.disconnectedInterval();
70
+ window?.Sentry?.captureMessage('disconnectedCallback');
69
71
  this.disconnectResizeObserver();
70
72
  }
71
73
 
@@ -167,6 +169,7 @@ export default class IABookActions extends LitElement {
167
169
  'browsingExpired' in this.lendingStatus &&
168
170
  this.lendingStatus?.browsingExpired;
169
171
  if (hasExpired) {
172
+ window?.Sentry?.captureMessage('setupLendingToolbarActions hasExpired');
170
173
  this.tokenPoller?.disconnectedInterval();
171
174
  /** Global event - always fire */
172
175
  this.dispatchEvent(
@@ -239,6 +242,7 @@ export default class IABookActions extends LitElement {
239
242
  */
240
243
  startLoanTokenPoller() {
241
244
  if (this.tokenPoller) {
245
+ window?.Sentry?.captureMessage('startLoanTokenPoller clearing interval');
242
246
  this.tokenPoller.disconnectedInterval();
243
247
  }
244
248
  const successCallback = () => {