@internetarchive/ia-book-actions 0.0.19-1 → 0.0.19-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.19-1",
3
+ "version": "0.0.19-2",
4
4
  "description": "Bookreader actions for borrowable book",
5
5
  "author": "Internet Archive",
6
6
  "license": "AGPL-3.0-only",
@@ -14,12 +14,15 @@ export default css`
14
14
  align-items: center;
15
15
  }
16
16
  .action-buttons .ia-button {
17
- margin: 0 3px;
17
+ margin: 0;
18
18
  height: 3.5rem;
19
19
  }
20
20
  .primary,
21
21
  .secondary {
22
22
  position: relative;
23
+ background: var(--white);
24
+ border-radius: 5px;
25
+ margin: 0 3px;
23
26
  }
24
27
  .primary .initial {
25
28
  border-radius: 0.4rem 0 0 0.4rem;
@@ -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') && this.isBelowTabletContainer) ||
55
+ changed.has('disabled')
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}"