@internetarchive/bookreader 5.0.0-32 → 5.0.0-33

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/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ # 5.0.0-33
2
+ Fix: restricted books get cover image @iisa
3
+
1
4
  # 5.0.0-32
2
5
  Fix: fetch bookmarks from service when logged in @iisa
3
6
  Fix: adjust css to help shadydom render properly @iisa
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@internetarchive/bookreader",
3
- "version": "5.0.0-32",
3
+ "version": "5.0.0-33",
4
4
  "description": "The Internet Archive BookReader.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -3,6 +3,7 @@ import { SharedResizeObserver } from '@internetarchive/shared-resize-observer';
3
3
  // eslint-disable-next-line no-unused-vars
4
4
  import { ModalManager } from '@internetarchive/modal-manager';
5
5
  import { css, html, LitElement } from 'lit-element';
6
+ import { nothing } from 'lit-html';
6
7
  import SearchProvider from './search/search-provider.js';
7
8
  import DownloadProvider from './downloads/downloads-provider.js';
8
9
  import VisualAdjustmentProvider from './visual-adjustments/visual-adjustments-provider.js';
@@ -417,6 +418,7 @@ export class BookNavigator extends LitElement {
417
418
  this.lendingStatus = lendingStatus;
418
419
  this.isAdmin = isAdmin;
419
420
  this.bookReaderCannotLoad = previewType === 'singlePagePreview';
421
+ this.emitLoadingStatusUpdate(true);
420
422
  });
421
423
  window.addEventListener('BRJSIA:PostInit', ({ detail }) => {
422
424
  const { isRestricted, downloadURLs } = detail;
@@ -491,20 +493,20 @@ export class BookNavigator extends LitElement {
491
493
  this.dispatchEvent(event);
492
494
  }
493
495
 
494
- get loadingClass() {
495
- return !this.bookReaderLoaded ? 'loading' : '';
496
+ get itemImage() {
497
+ const identifier = this.itemMD?.metadata.identifier;
498
+ const url = `https://${this.baseHost}/services/img/${identifier}`;
499
+ return html`<img class="cover-img" src=${url} alt="cover image for ${identifier}">`;
496
500
  }
497
501
 
498
- get itemImage() {
499
- const url = `https://${this.baseHost}/services/img/${this.item.metadata.identifier}`;
500
- return html`<img class="cover-img" src=${url} alt="cover image for ${this.item.metadata.identifier}">`;
502
+ get placeholder() {
503
+ return html`<div class="placeholder">${this.itemImage}</div>`;
501
504
  }
502
505
 
503
506
  render() {
504
- const placeholder = this.bookReaderCannotLoad ? this.itemImage : this.loader;
505
- return html`<div id="book-navigator" class="${this.loadingClass}">
506
- ${placeholder}
507
- <slot name="main"></slot>
507
+ return html`<div id="book-navigator__root">
508
+ ${this.bookReaderCannotLoad ? this.placeholder : nothing}
509
+ ${!this.bookReaderCannotLoad ? html`<slot name="main"></slot>` : nothing}
508
510
  </div>
509
511
  `;
510
512
  }
@@ -512,13 +514,20 @@ export class BookNavigator extends LitElement {
512
514
  static get styles() {
513
515
  return css`
514
516
  :host,
515
- #book-navigator,
517
+ #book-navigator__root,
516
518
  slot,
517
519
  slot > * {
518
520
  display: block;
519
521
  height: inherit;
520
522
  width: inherit;
521
523
  }
524
+ .placeholder {
525
+ display: flex;
526
+ align-items: center;
527
+ justify-content: center;
528
+ flex-direction: column;
529
+ margin: 5%;
530
+ }
522
531
  .cover-img {
523
532
  max-height: 300px;
524
533
  }
@@ -111,11 +111,6 @@ describe('<book-navigator>', () => {
111
111
 
112
112
  it('creates an item image from metadata', async () => {
113
113
  const el = fixtureSync(container());
114
- el.item = {
115
- metadata: { identifier: 'foo' },
116
- };
117
- await elementUpdated(el);
118
-
119
114
  const itemImage = fixtureSync(el.itemImage);
120
115
  expect(itemImage).to.be.instanceOf(HTMLImageElement);
121
116
  expect(itemImage.getAttribute('class')).to.equal('cover-img');