@internetarchive/ia-item-navigator 0.0.0-a8 → 0.0.2-a1
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +29 -19
- package/demo/app-root.ts +50 -50
- package/demo/index.html +1 -0
- package/dist/demo/app-root.d.ts +19 -15
- package/dist/demo/app-root.js +36 -39
- package/dist/demo/app-root.js.map +1 -1
- package/dist/src/interfaces/custom-theater-interface.d.ts +20 -0
- package/dist/src/interfaces/custom-theater-interface.js +2 -0
- package/dist/src/interfaces/custom-theater-interface.js.map +1 -0
- package/dist/src/interfaces/event-interfaces.d.ts +11 -11
- package/dist/src/interfaces/event-interfaces.js.map +1 -1
- package/dist/src/interfaces/menu-interfaces.d.ts +6 -7
- package/dist/src/interfaces/menu-interfaces.js.map +1 -1
- package/dist/src/interfaces/nav-controller-interface.d.ts +11 -6
- package/dist/src/interfaces/nav-controller-interface.js.map +1 -1
- package/dist/src/item-inspector/item-inspector.d.ts +0 -47
- package/dist/src/item-inspector/item-inspector.js +253 -270
- package/dist/src/item-inspector/item-inspector.js.map +1 -1
- package/dist/src/item-navigator.d.ts +45 -28
- package/dist/src/item-navigator.js +122 -115
- package/dist/src/item-navigator.js.map +1 -1
- package/dist/src/loader.d.ts +5 -0
- package/dist/src/loader.js +8 -2
- package/dist/src/loader.js.map +1 -1
- package/dist/src/no-theater-available.d.ts +9 -0
- package/dist/src/no-theater-available.js +79 -0
- package/dist/src/no-theater-available.js.map +1 -0
- package/dist/test/book-nav-stub.d.ts +22 -0
- package/dist/test/book-nav-stub.js +49 -0
- package/dist/test/book-nav-stub.js.map +1 -0
- package/dist/test/ia-item-navigator.test.d.ts +2 -0
- package/dist/test/ia-item-navigator.test.js +317 -0
- package/dist/test/ia-item-navigator.test.js.map +1 -0
- package/dist/test/ia-stub-goody.d.ts +210 -0
- package/dist/test/ia-stub-goody.js +276 -0
- package/dist/test/ia-stub-goody.js.map +1 -0
- package/dist/test/ia-stub.d.ts +22 -0
- package/dist/test/ia-stub.js +35 -0
- package/dist/test/ia-stub.js.map +1 -0
- package/dist/test/no-theater-available.test.d.ts +1 -0
- package/dist/test/no-theater-available.test.js +27 -0
- package/dist/test/no-theater-available.test.js.map +1 -0
- package/package.json +4 -3
- package/src/interfaces/custom-theater-interface.ts +28 -0
- package/src/interfaces/event-interfaces.ts +15 -11
- package/src/interfaces/menu-interfaces.ts +9 -10
- package/src/item-navigator.ts +165 -145
- package/src/loader.ts +9 -2
- package/src/no-theater-available.ts +85 -0
- package/test/book-nav-stub.ts +47 -0
- package/test/ia-item-navigator.test.ts +438 -0
- package/test/ia-stub.ts +79 -0
- package/test/no-theater-available.test.ts +32 -0
- package/demo/demo-book-manifest.json +0 -1163
- package/src/interfaces/nav-controller-interface.ts +0 -18
- package/src/item-inspector/files-by-type/files-by-type-provider.ts +0 -43
- package/src/item-inspector/files-by-type/ia-files-by-type.ts +0 -100
- package/src/item-inspector/item-inspector.ts +0 -295
- package/src/item-inspector/share-provider.ts +0 -51
- package/src/item-inspector/visual-mod-provider.ts +0 -65
- package/src/item-navigator-js.js +0 -372
- package/test/your-webcomponent.test.ts +0 -40
package/README.md
CHANGED
@@ -1,21 +1,37 @@
|
|
1
|
-
[![Build Status](https://travis-ci.com/internetarchive/iaux-
|
1
|
+
[![Build Status](https://travis-ci.com/internetarchive/iaux-item-navigator.svg?branch=master)](https://travis-ci.com/internetarchive/iaux-item-navigator) [![codecov](https://codecov.io/gh/internetarchive/iaux-item-navigator/branch/master/graph/badge.svg)](https://codecov.io/gh/internetarchive/iaux-item-navigator)
|
2
2
|
|
3
|
-
# Internet Archive
|
3
|
+
# Internet Archive Item Navigator - theater menu manager
|
4
4
|
|
5
|
-
|
5
|
+
`<ia-item-navigator>` is a custom web component that makes an item's details theater.
|
6
|
+
The Item Navigator helps instantiate all of the components one needs to create an item theater:
|
7
|
+
- side menu
|
8
|
+
- menu shortcuts
|
9
|
+
- fullscreen management
|
10
|
+
- receives/creates a shared resize observer
|
11
|
+
- receives/shares a `<modal-manager>`
|
12
|
+
- slots for custom theater & header loads
|
6
13
|
|
7
|
-
|
14
|
+
The Item Navigator's primary responsibility is to display the side menus, shortcuts, and the theater in browser window immersion "fullscreen".
|
8
15
|
|
9
|
-
|
10
|
-
|
16
|
+
The only business logic that is housed is determining which theater navigator to use given an `itemType`.
|
17
|
+
Currently supported:
|
18
|
+
- bookreader's `<book-navigator>`
|
19
|
+
- no theater available
|
11
20
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
21
|
+
## Usage
|
22
|
+
Generic:
|
23
|
+
```
|
24
|
+
const iaItem = <MetadataResponse>;
|
25
|
+
<ia-item-navigator .item=${iaItem}></ia-item-navigator>
|
26
|
+
```
|
27
|
+
For `<book-navigator>`:
|
28
|
+
```
|
29
|
+
const iaItem = <MetadataResponse>;
|
30
|
+
<ia-item-navigator .item=${iaItem} .itemType="bookreader">
|
31
|
+
<div slot="theater-header"><p>foo header</p></div>
|
32
|
+
<div slot="theater-main"><div id="BookReader"></div></div>
|
33
|
+
</ia-item-navigator>
|
34
|
+
```
|
19
35
|
|
20
36
|
## Local Demo with `web-dev-server`
|
21
37
|
```bash
|
@@ -61,9 +77,3 @@ yarn run format:eslint
|
|
61
77
|
```bash
|
62
78
|
yarn run format:prettier
|
63
79
|
```
|
64
|
-
|
65
|
-
## Tooling configs
|
66
|
-
|
67
|
-
For most of the tools, the configuration is in the `package.json` to reduce the amount of files in your project.
|
68
|
-
|
69
|
-
If you customize the configuration a lot, you can consider moving them to individual files.
|
package/demo/app-root.ts
CHANGED
@@ -6,42 +6,45 @@ import {
|
|
6
6
|
customElement,
|
7
7
|
property,
|
8
8
|
query,
|
9
|
+
TemplateResult,
|
9
10
|
} from 'lit-element';
|
10
|
-
import '../src/item-inspector/item-inspector';
|
11
11
|
import {
|
12
12
|
MetadataResponse,
|
13
13
|
SearchService,
|
14
14
|
} from '@internetarchive/search-service';
|
15
|
-
import '
|
15
|
+
import { SharedResizeObserver } from '@internetarchive/shared-resize-observer';
|
16
|
+
import { ModalManager } from '@internetarchive/modal-manager';
|
16
17
|
import '@internetarchive/modal-manager';
|
17
|
-
import {
|
18
|
-
|
19
|
-
// SharedResizeObserverInterface,
|
20
|
-
// SharedResizeObserverResizeHandlerInterface,
|
21
|
-
} from '@internetarchive/shared-resize-observer';
|
22
|
-
|
18
|
+
import { ItemNavigator } from '../src/item-navigator';
|
19
|
+
import '../src/item-navigator';
|
23
20
|
@customElement('app-root')
|
24
21
|
export class AppRoot extends LitElement {
|
22
|
+
/**
|
23
|
+
* Example controller to connect to `<ia-item-navigator>`
|
24
|
+
*/
|
25
25
|
@property({ type: Object }) itemMD: MetadataResponse | undefined = undefined;
|
26
26
|
|
27
|
-
@property({ type: Object }) bookManifest = {};
|
28
|
-
|
29
27
|
@property({ type: String }) encodedManifest = '';
|
30
28
|
|
31
|
-
@query('item-navigator') private itemNav!:
|
29
|
+
@query('ia-item-navigator') private itemNav!: ItemNavigator;
|
32
30
|
|
33
|
-
@query('modal-manager') modalMgr!:
|
31
|
+
@query('modal-manager') modalMgr!: ModalManager;
|
34
32
|
|
35
33
|
@property({ attribute: false }) sharedObserver = new SharedResizeObserver();
|
36
34
|
|
35
|
+
@property({ type: Boolean, reflect: true, attribute: true }) fullscreen:
|
36
|
+
| boolean
|
37
|
+
| null = null;
|
38
|
+
|
37
39
|
firstUpdated() {
|
38
40
|
this.fetchItemMD();
|
39
|
-
console.log(
|
41
|
+
console.log(
|
42
|
+
'<app-root> component has loaded',
|
43
|
+
this.modalMgr,
|
44
|
+
this.sharedObserver
|
45
|
+
);
|
40
46
|
}
|
41
47
|
|
42
|
-
/**
|
43
|
-
* @inheritdoc
|
44
|
-
*/
|
45
48
|
updated(changed: any) {
|
46
49
|
console.log('changed', changed);
|
47
50
|
if (changed.has('itemMD')) {
|
@@ -49,19 +52,8 @@ export class AppRoot extends LitElement {
|
|
49
52
|
}
|
50
53
|
}
|
51
54
|
|
52
|
-
get theaterReady(): boolean {
|
53
|
-
return this.modalMgr && this.sharedObserver && this.itemMD;
|
54
|
-
}
|
55
|
-
|
56
|
-
fullscreenCheck() {
|
57
|
-
if (this.showFullscreen && this.itemNav) {
|
58
|
-
this.itemNav.viewportInFullscreen = true;
|
59
|
-
}
|
60
|
-
}
|
61
|
-
|
62
55
|
async fetchItemMD() {
|
63
56
|
const searchService = SearchService.default;
|
64
|
-
|
65
57
|
const mdResponse = await searchService.fetchMetadata('ux-team-books');
|
66
58
|
|
67
59
|
if (mdResponse.error) {
|
@@ -72,32 +64,25 @@ export class AppRoot extends LitElement {
|
|
72
64
|
return;
|
73
65
|
}
|
74
66
|
|
67
|
+
console.log('mdResponse.success', JSON.stringify(mdResponse.success));
|
75
68
|
this.itemMD = mdResponse.success;
|
76
69
|
}
|
77
70
|
|
71
|
+
get theaterReady(): boolean {
|
72
|
+
return this.modalMgr && this.sharedObserver && !!this.itemMD;
|
73
|
+
}
|
74
|
+
|
78
75
|
get urlParams(): URLSearchParams {
|
79
76
|
return new URLSearchParams(location.search.slice(1));
|
80
77
|
}
|
81
78
|
|
79
|
+
/** Fullscreen */
|
82
80
|
get showFullscreen(): boolean {
|
83
81
|
return this.urlParams.get('view') === 'theater';
|
84
82
|
}
|
85
83
|
|
86
|
-
|
87
|
-
|
88
|
-
// eslint-disable-next-line guard-for-in, no-restricted-syntax
|
89
|
-
for (const md in this.itemMD) {
|
90
|
-
const val = (this.itemMD as any)[md];
|
91
|
-
x.push(
|
92
|
-
html`<dt>${md}</dt>
|
93
|
-
:
|
94
|
-
<dd>${val}</dd>`
|
95
|
-
);
|
96
|
-
}
|
97
|
-
return html`<dl>${[...x]}</dl>`;
|
98
|
-
}
|
99
|
-
|
100
|
-
toggleFS() {
|
84
|
+
/** sets url query param `view=theater` to toggle fullscreen */
|
85
|
+
toggleFS(): void {
|
101
86
|
if (this.urlParams.get('view')) {
|
102
87
|
location.search = '';
|
103
88
|
} else {
|
@@ -105,28 +90,38 @@ export class AppRoot extends LitElement {
|
|
105
90
|
}
|
106
91
|
}
|
107
92
|
|
108
|
-
|
93
|
+
/** toggles attr: `<ia-item-navigator viewportinfullscreen>` */
|
94
|
+
fullscreenCheck(): void {
|
95
|
+
if (this.showFullscreen && this.itemNav) {
|
96
|
+
this.fullscreen = true;
|
97
|
+
// this.itemNav.viewportInFullscreen = true;
|
98
|
+
}
|
99
|
+
}
|
100
|
+
/** End fullscreen */
|
101
|
+
|
102
|
+
/** Views */
|
103
|
+
get theaterBlock(): TemplateResult {
|
109
104
|
return html`
|
110
|
-
<item-navigator
|
105
|
+
<ia-item-navigator
|
111
106
|
baseHost="https://archive.org"
|
112
107
|
.item=${this.itemMD}
|
113
108
|
.modal=${this.modalMgr}
|
114
109
|
.sharedObserver=${this.sharedObserver}
|
115
110
|
@ViewportInFullScreen=${this.toggleFS}
|
116
|
-
|
111
|
+
.viewportInFullscreen=${this.fullscreen}
|
112
|
+
></ia-item-navigator>
|
117
113
|
`;
|
118
114
|
}
|
119
115
|
|
120
|
-
get placeholder() {
|
116
|
+
get placeholder(): TemplateResult {
|
121
117
|
return html`<h2>Please hold as we fetch an item for ya</h2>`;
|
122
118
|
}
|
123
119
|
|
124
|
-
render() {
|
120
|
+
render(): TemplateResult {
|
125
121
|
const theater = this.theaterReady ? this.theaterBlock : this.placeholder;
|
126
122
|
return html`
|
127
123
|
<h1>theater, in page</h1>
|
128
124
|
${theater}
|
129
|
-
<section>${this.renderMD}</section>
|
130
125
|
<modal-manager></modal-manager>
|
131
126
|
`;
|
132
127
|
}
|
@@ -137,15 +132,20 @@ export class AppRoot extends LitElement {
|
|
137
132
|
color: #222;
|
138
133
|
}
|
139
134
|
|
135
|
+
:host([fullscreen]) {
|
136
|
+
height: 100vh;
|
137
|
+
width: 100vw;
|
138
|
+
}
|
139
|
+
|
140
140
|
:host,
|
141
|
-
item-navigator {
|
141
|
+
ia-item-navigator {
|
142
142
|
display: block;
|
143
143
|
position: relative;
|
144
144
|
width: 100%;
|
145
145
|
min-height: 64vh;
|
146
146
|
height: 64vh;
|
147
147
|
}
|
148
|
-
item-navigator {
|
148
|
+
ia-item-navigator {
|
149
149
|
height: inherit;
|
150
150
|
min-height: inherit;
|
151
151
|
}
|
package/demo/index.html
CHANGED
@@ -58,6 +58,7 @@
|
|
58
58
|
<body>
|
59
59
|
<app-root></app-root>
|
60
60
|
<script type="module">
|
61
|
+
/* eslint-disable no-restricted-globals */
|
61
62
|
const params = new URLSearchParams(location.search.slice(1));
|
62
63
|
if (params.get('view') === 'theater') {
|
63
64
|
const body = document.querySelector('body');
|
package/dist/demo/app-root.d.ts
CHANGED
@@ -1,30 +1,34 @@
|
|
1
|
-
import { LitElement } from 'lit-element';
|
2
|
-
import '../src/item-inspector/item-inspector';
|
1
|
+
import { LitElement, TemplateResult } from 'lit-element';
|
3
2
|
import { MetadataResponse } from '@internetarchive/search-service';
|
4
|
-
import '../src/item-navigator';
|
5
|
-
import '@internetarchive/modal-manager';
|
6
3
|
import { SharedResizeObserver } from '@internetarchive/shared-resize-observer';
|
4
|
+
import { ModalManager } from '@internetarchive/modal-manager';
|
5
|
+
import '@internetarchive/modal-manager';
|
6
|
+
import '../src/item-navigator';
|
7
7
|
export declare class AppRoot extends LitElement {
|
8
|
+
/**
|
9
|
+
* Example controller to connect to `<ia-item-navigator>`
|
10
|
+
*/
|
8
11
|
itemMD: MetadataResponse | undefined;
|
9
|
-
bookManifest: {};
|
10
12
|
encodedManifest: string;
|
11
13
|
private itemNav;
|
12
|
-
modalMgr:
|
14
|
+
modalMgr: ModalManager;
|
13
15
|
sharedObserver: SharedResizeObserver;
|
16
|
+
fullscreen: boolean | null;
|
14
17
|
firstUpdated(): void;
|
15
|
-
/**
|
16
|
-
* @inheritdoc
|
17
|
-
*/
|
18
18
|
updated(changed: any): void;
|
19
|
-
get theaterReady(): boolean;
|
20
|
-
fullscreenCheck(): void;
|
21
19
|
fetchItemMD(): Promise<void>;
|
20
|
+
get theaterReady(): boolean;
|
22
21
|
get urlParams(): URLSearchParams;
|
22
|
+
/** Fullscreen */
|
23
23
|
get showFullscreen(): boolean;
|
24
|
-
|
24
|
+
/** sets url query param `view=theater` to toggle fullscreen */
|
25
25
|
toggleFS(): void;
|
26
|
-
|
27
|
-
|
28
|
-
|
26
|
+
/** toggles attr: `<ia-item-navigator viewportinfullscreen>` */
|
27
|
+
fullscreenCheck(): void;
|
28
|
+
/** End fullscreen */
|
29
|
+
/** Views */
|
30
|
+
get theaterBlock(): TemplateResult;
|
31
|
+
get placeholder(): TemplateResult;
|
32
|
+
render(): TemplateResult;
|
29
33
|
static styles: import("lit-element").CSSResult;
|
30
34
|
}
|
package/dist/demo/app-root.js
CHANGED
@@ -1,43 +1,31 @@
|
|
1
1
|
import { __decorate } from "tslib";
|
2
2
|
/* eslint-disable no-restricted-globals */
|
3
3
|
import { html, css, LitElement, customElement, property, query, } from 'lit-element';
|
4
|
-
import '../src/item-inspector/item-inspector';
|
5
4
|
import { SearchService, } from '@internetarchive/search-service';
|
6
|
-
import '
|
5
|
+
import { SharedResizeObserver } from '@internetarchive/shared-resize-observer';
|
7
6
|
import '@internetarchive/modal-manager';
|
8
|
-
import
|
9
|
-
// SharedResizeObserverInterface,
|
10
|
-
// SharedResizeObserverResizeHandlerInterface,
|
11
|
-
} from '@internetarchive/shared-resize-observer';
|
7
|
+
import '../src/item-navigator';
|
12
8
|
let AppRoot = class AppRoot extends LitElement {
|
13
9
|
constructor() {
|
14
10
|
super(...arguments);
|
11
|
+
/**
|
12
|
+
* Example controller to connect to `<ia-item-navigator>`
|
13
|
+
*/
|
15
14
|
this.itemMD = undefined;
|
16
|
-
this.bookManifest = {};
|
17
15
|
this.encodedManifest = '';
|
18
16
|
this.sharedObserver = new SharedResizeObserver();
|
17
|
+
this.fullscreen = null;
|
19
18
|
}
|
20
19
|
firstUpdated() {
|
21
20
|
this.fetchItemMD();
|
22
|
-
console.log('
|
21
|
+
console.log('<app-root> component has loaded', this.modalMgr, this.sharedObserver);
|
23
22
|
}
|
24
|
-
/**
|
25
|
-
* @inheritdoc
|
26
|
-
*/
|
27
23
|
updated(changed) {
|
28
24
|
console.log('changed', changed);
|
29
25
|
if (changed.has('itemMD')) {
|
30
26
|
this.fullscreenCheck();
|
31
27
|
}
|
32
28
|
}
|
33
|
-
get theaterReady() {
|
34
|
-
return this.modalMgr && this.sharedObserver && this.itemMD;
|
35
|
-
}
|
36
|
-
fullscreenCheck() {
|
37
|
-
if (this.showFullscreen && this.itemNav) {
|
38
|
-
this.itemNav.viewportInFullscreen = true;
|
39
|
-
}
|
40
|
-
}
|
41
29
|
async fetchItemMD() {
|
42
30
|
const searchService = SearchService.default;
|
43
31
|
const mdResponse = await searchService.fetchMetadata('ux-team-books');
|
@@ -46,25 +34,20 @@ let AppRoot = class AppRoot extends LitElement {
|
|
46
34
|
window.confirm('There was an error fetching response, please check dev console');
|
47
35
|
return;
|
48
36
|
}
|
37
|
+
console.log('mdResponse.success', JSON.stringify(mdResponse.success));
|
49
38
|
this.itemMD = mdResponse.success;
|
50
39
|
}
|
40
|
+
get theaterReady() {
|
41
|
+
return this.modalMgr && this.sharedObserver && !!this.itemMD;
|
42
|
+
}
|
51
43
|
get urlParams() {
|
52
44
|
return new URLSearchParams(location.search.slice(1));
|
53
45
|
}
|
46
|
+
/** Fullscreen */
|
54
47
|
get showFullscreen() {
|
55
48
|
return this.urlParams.get('view') === 'theater';
|
56
49
|
}
|
57
|
-
|
58
|
-
const x = [];
|
59
|
-
// eslint-disable-next-line guard-for-in, no-restricted-syntax
|
60
|
-
for (const md in this.itemMD) {
|
61
|
-
const val = this.itemMD[md];
|
62
|
-
x.push(html `<dt>${md}</dt>
|
63
|
-
:
|
64
|
-
<dd>${val}</dd>`);
|
65
|
-
}
|
66
|
-
return html `<dl>${[...x]}</dl>`;
|
67
|
-
}
|
50
|
+
/** sets url query param `view=theater` to toggle fullscreen */
|
68
51
|
toggleFS() {
|
69
52
|
if (this.urlParams.get('view')) {
|
70
53
|
location.search = '';
|
@@ -73,15 +56,25 @@ let AppRoot = class AppRoot extends LitElement {
|
|
73
56
|
location.search = 'view=theater';
|
74
57
|
}
|
75
58
|
}
|
59
|
+
/** toggles attr: `<ia-item-navigator viewportinfullscreen>` */
|
60
|
+
fullscreenCheck() {
|
61
|
+
if (this.showFullscreen && this.itemNav) {
|
62
|
+
this.fullscreen = true;
|
63
|
+
// this.itemNav.viewportInFullscreen = true;
|
64
|
+
}
|
65
|
+
}
|
66
|
+
/** End fullscreen */
|
67
|
+
/** Views */
|
76
68
|
get theaterBlock() {
|
77
69
|
return html `
|
78
|
-
<item-navigator
|
70
|
+
<ia-item-navigator
|
79
71
|
baseHost="https://archive.org"
|
80
72
|
.item=${this.itemMD}
|
81
73
|
.modal=${this.modalMgr}
|
82
74
|
.sharedObserver=${this.sharedObserver}
|
83
75
|
@ViewportInFullScreen=${this.toggleFS}
|
84
|
-
|
76
|
+
.viewportInFullscreen=${this.fullscreen}
|
77
|
+
></ia-item-navigator>
|
85
78
|
`;
|
86
79
|
}
|
87
80
|
get placeholder() {
|
@@ -92,7 +85,6 @@ let AppRoot = class AppRoot extends LitElement {
|
|
92
85
|
return html `
|
93
86
|
<h1>theater, in page</h1>
|
94
87
|
${theater}
|
95
|
-
<section>${this.renderMD}</section>
|
96
88
|
<modal-manager></modal-manager>
|
97
89
|
`;
|
98
90
|
}
|
@@ -103,15 +95,20 @@ AppRoot.styles = css `
|
|
103
95
|
color: #222;
|
104
96
|
}
|
105
97
|
|
98
|
+
:host([fullscreen]) {
|
99
|
+
height: 100vh;
|
100
|
+
width: 100vw;
|
101
|
+
}
|
102
|
+
|
106
103
|
:host,
|
107
|
-
item-navigator {
|
104
|
+
ia-item-navigator {
|
108
105
|
display: block;
|
109
106
|
position: relative;
|
110
107
|
width: 100%;
|
111
108
|
min-height: 64vh;
|
112
109
|
height: 64vh;
|
113
110
|
}
|
114
|
-
item-navigator {
|
111
|
+
ia-item-navigator {
|
115
112
|
height: inherit;
|
116
113
|
min-height: inherit;
|
117
114
|
}
|
@@ -129,14 +126,11 @@ AppRoot.styles = css `
|
|
129
126
|
__decorate([
|
130
127
|
property({ type: Object })
|
131
128
|
], AppRoot.prototype, "itemMD", void 0);
|
132
|
-
__decorate([
|
133
|
-
property({ type: Object })
|
134
|
-
], AppRoot.prototype, "bookManifest", void 0);
|
135
129
|
__decorate([
|
136
130
|
property({ type: String })
|
137
131
|
], AppRoot.prototype, "encodedManifest", void 0);
|
138
132
|
__decorate([
|
139
|
-
query('item-navigator')
|
133
|
+
query('ia-item-navigator')
|
140
134
|
], AppRoot.prototype, "itemNav", void 0);
|
141
135
|
__decorate([
|
142
136
|
query('modal-manager')
|
@@ -144,6 +138,9 @@ __decorate([
|
|
144
138
|
__decorate([
|
145
139
|
property({ attribute: false })
|
146
140
|
], AppRoot.prototype, "sharedObserver", void 0);
|
141
|
+
__decorate([
|
142
|
+
property({ type: Boolean, reflect: true, attribute: true })
|
143
|
+
], AppRoot.prototype, "fullscreen", void 0);
|
147
144
|
AppRoot = __decorate([
|
148
145
|
customElement('app-root')
|
149
146
|
], AppRoot);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"app-root.js","sourceRoot":"","sources":["../../demo/app-root.ts"],"names":[],"mappings":";AAAA,0CAA0C;AAC1C,OAAO,EACL,IAAI,EACJ,GAAG,EACH,UAAU,EACV,aAAa,EACb,QAAQ,EACR,KAAK,
|
1
|
+
{"version":3,"file":"app-root.js","sourceRoot":"","sources":["../../demo/app-root.ts"],"names":[],"mappings":";AAAA,0CAA0C;AAC1C,OAAO,EACL,IAAI,EACJ,GAAG,EACH,UAAU,EACV,aAAa,EACb,QAAQ,EACR,KAAK,GAEN,MAAM,aAAa,CAAC;AACrB,OAAO,EAEL,aAAa,GACd,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,yCAAyC,CAAC;AAE/E,OAAO,gCAAgC,CAAC;AAExC,OAAO,uBAAuB,CAAC;AAE/B,IAAa,OAAO,GAApB,MAAa,OAAQ,SAAQ,UAAU;IAAvC;;QACE;;WAEG;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A3B,KAAK,CAAC,mBAAmB,CAAC;wCAAiC;AAEpC;IAAvB,KAAK,CAAC,eAAe,CAAC;yCAAyB;AAEhB;IAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;+CAA6C;AAEf;IAA5D,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;2CAE5C;AAhBL,OAAO;IADnB,aAAa,CAAC,UAAU,CAAC;GACb,OAAO,CA8InB;SA9IY,OAAO","sourcesContent":["/* eslint-disable no-restricted-globals */\nimport {\n html,\n css,\n LitElement,\n customElement,\n property,\n query,\n TemplateResult,\n} from 'lit-element';\nimport {\n MetadataResponse,\n SearchService,\n} from '@internetarchive/search-service';\nimport { SharedResizeObserver } from '@internetarchive/shared-resize-observer';\nimport { ModalManager } from '@internetarchive/modal-manager';\nimport '@internetarchive/modal-manager';\nimport { ItemNavigator } from '../src/item-navigator';\nimport '../src/item-navigator';\n@customElement('app-root')\nexport class AppRoot extends LitElement {\n /**\n * Example controller to connect to `<ia-item-navigator>`\n */\n @property({ type: Object }) itemMD: MetadataResponse | undefined = undefined;\n\n @property({ type: String }) encodedManifest = '';\n\n @query('ia-item-navigator') private itemNav!: ItemNavigator;\n\n @query('modal-manager') modalMgr!: ModalManager;\n\n @property({ attribute: false }) sharedObserver = new SharedResizeObserver();\n\n @property({ type: Boolean, reflect: true, attribute: true }) fullscreen:\n | boolean\n | null = null;\n\n firstUpdated() {\n this.fetchItemMD();\n console.log(\n '<app-root> component has loaded',\n this.modalMgr,\n this.sharedObserver\n );\n }\n\n updated(changed: any) {\n console.log('changed', changed);\n if (changed.has('itemMD')) {\n this.fullscreenCheck();\n }\n }\n\n async fetchItemMD() {\n const searchService = SearchService.default;\n const mdResponse = await searchService.fetchMetadata('ux-team-books');\n\n if (mdResponse.error) {\n console.log('MD Fetch error: ', mdResponse.error);\n (window as any).confirm(\n 'There was an error fetching response, please check dev console'\n );\n return;\n }\n\n console.log('mdResponse.success', JSON.stringify(mdResponse.success));\n this.itemMD = mdResponse.success;\n }\n\n get theaterReady(): boolean {\n return this.modalMgr && this.sharedObserver && !!this.itemMD;\n }\n\n get urlParams(): URLSearchParams {\n return new URLSearchParams(location.search.slice(1));\n }\n\n /** Fullscreen */\n get showFullscreen(): boolean {\n return this.urlParams.get('view') === 'theater';\n }\n\n /** sets url query param `view=theater` to toggle fullscreen */\n toggleFS(): void {\n if (this.urlParams.get('view')) {\n location.search = '';\n } else {\n location.search = 'view=theater';\n }\n }\n\n /** toggles attr: `<ia-item-navigator viewportinfullscreen>` */\n fullscreenCheck(): void {\n if (this.showFullscreen && this.itemNav) {\n this.fullscreen = true;\n // this.itemNav.viewportInFullscreen = true;\n }\n }\n /** End fullscreen */\n\n /** Views */\n get theaterBlock(): TemplateResult {\n return html`\n <ia-item-navigator\n baseHost=\"https://archive.org\"\n .item=${this.itemMD}\n .modal=${this.modalMgr}\n .sharedObserver=${this.sharedObserver}\n @ViewportInFullScreen=${this.toggleFS}\n .viewportInFullscreen=${this.fullscreen}\n ></ia-item-navigator>\n `;\n }\n\n get placeholder(): TemplateResult {\n return html`<h2>Please hold as we fetch an item for ya</h2>`;\n }\n\n render(): TemplateResult {\n const theater = this.theaterReady ? this.theaterBlock : this.placeholder;\n return html`\n <h1>theater, in page</h1>\n ${theater}\n <modal-manager></modal-manager>\n `;\n }\n\n static styles = css`\n :host {\n border: 1px solid pink;\n color: #222;\n }\n\n :host([fullscreen]) {\n height: 100vh;\n width: 100vw;\n }\n\n :host,\n ia-item-navigator {\n display: block;\n position: relative;\n width: 100%;\n min-height: 64vh;\n height: 64vh;\n }\n ia-item-navigator {\n height: inherit;\n min-height: inherit;\n }\n div {\n position: relative;\n overflow: hidden;\n height: 100%;\n min-height: inherit;\n }\n\n modal-manager[mode='closed'] {\n display: none;\n }\n `;\n}\n"]}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import { LitElement } from 'lit-element';
|
2
|
+
import { MetadataResponse } from '@internetarchive/search-service';
|
3
|
+
import { ModalManager } from '@internetarchive/modal-manager';
|
4
|
+
import { SharedResizeObserver } from '@internetarchive/shared-resize-observer';
|
5
|
+
import { MenuProviderInterface, MenuShortcutInterface } from './menu-interfaces';
|
6
|
+
export interface CustomTheaterInterface extends LitElement {
|
7
|
+
baseHost?: string;
|
8
|
+
itemMD?: MetadataResponse;
|
9
|
+
menuProviders?: MenuProviderInterface[];
|
10
|
+
menuShortcuts?: MenuShortcutInterface[];
|
11
|
+
sideMenuOpen: boolean;
|
12
|
+
signedIn?: boolean | null;
|
13
|
+
sharedObserver?: SharedResizeObserver;
|
14
|
+
modal?: ModalManager;
|
15
|
+
emitLoadingStatusUpdate: (loaded: boolean) => void;
|
16
|
+
addMenuShortcut: (menuId: string) => void;
|
17
|
+
removeMenuShortcut: (menuId: string) => void;
|
18
|
+
sortMenuShortcuts: () => void;
|
19
|
+
emitMenuShortcutsUpdated: () => void;
|
20
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"custom-theater-interface.js","sourceRoot":"","sources":["../../../src/interfaces/custom-theater-interface.ts"],"names":[],"mappings":"","sourcesContent":["import { LitElement } from 'lit-element';\nimport { MetadataResponse } from '@internetarchive/search-service';\nimport { ModalManager } from '@internetarchive/modal-manager';\nimport { SharedResizeObserver } from '@internetarchive/shared-resize-observer';\nimport {\n MenuProviderInterface,\n MenuShortcutInterface,\n} from './menu-interfaces';\n\nexport interface CustomTheaterInterface extends LitElement {\n baseHost?: string;\n itemMD?: MetadataResponse;\n menuProviders?: MenuProviderInterface[];\n menuShortcuts?: MenuShortcutInterface[];\n sideMenuOpen: boolean;\n\n signedIn?: boolean | null;\n\n sharedObserver?: SharedResizeObserver;\n modal?: ModalManager;\n\n emitLoadingStatusUpdate: (loaded: boolean) => void;\n\n addMenuShortcut: (menuId: string) => void;\n removeMenuShortcut: (menuId: string) => void;\n sortMenuShortcuts: () => void;\n emitMenuShortcutsUpdated: () => void;\n}\n"]}
|
@@ -1,38 +1,38 @@
|
|
1
|
-
import {
|
1
|
+
import { MenuProviderInterface, MenuShortcutInterface, MenuId } from './menu-interfaces';
|
2
2
|
/** Toggles Menu && Sets open panel */
|
3
|
-
export interface
|
3
|
+
export interface ToggleSideMenuOpenEvent extends CustomEvent {
|
4
4
|
type: 'updateSideMenu';
|
5
5
|
detail: {
|
6
|
-
menuId:
|
6
|
+
menuId: MenuId | undefined | '';
|
7
7
|
action: 'open' | 'toggle' | '';
|
8
8
|
};
|
9
9
|
}
|
10
10
|
/** Sets open panel */
|
11
|
-
export interface
|
11
|
+
export interface ToggleSidePanelOpenEvent extends CustomEvent {
|
12
12
|
type: 'menuTypeSelected';
|
13
13
|
detail: {
|
14
|
-
id:
|
14
|
+
id: MenuId | '';
|
15
15
|
};
|
16
16
|
}
|
17
17
|
/** Sets menu order that is displayed */
|
18
|
-
export interface
|
18
|
+
export interface SetSideMenuContentsEvent extends CustomEvent {
|
19
19
|
type: 'menuUpdated';
|
20
|
-
detail:
|
20
|
+
detail: MenuProviderInterface[];
|
21
21
|
}
|
22
22
|
/** Sets menu shortcuts that is displayed */
|
23
|
-
export interface
|
23
|
+
export interface SetSideMenuShortcutsEvent extends CustomEvent {
|
24
24
|
type: 'menuUpdated';
|
25
|
-
detail:
|
25
|
+
detail: MenuShortcutInterface[];
|
26
26
|
}
|
27
27
|
/** Toggles fullscreen mode */
|
28
|
-
export interface
|
28
|
+
export interface ManageFullscreenEvent extends CustomEvent {
|
29
29
|
type: 'ViewportInFullScreen';
|
30
30
|
detail: {
|
31
31
|
isFullScreen: boolean;
|
32
32
|
};
|
33
33
|
}
|
34
34
|
/** Toggles loading view */
|
35
|
-
export interface
|
35
|
+
export interface loadingStateUpdatedEvent extends CustomEvent {
|
36
36
|
type: 'loadingStateUpdated';
|
37
37
|
detail: {
|
38
38
|
loaded: boolean;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"event-interfaces.js","sourceRoot":"","sources":["../../../src/interfaces/event-interfaces.ts"],"names":[],"mappings":"","sourcesContent":["import {
|
1
|
+
{"version":3,"file":"event-interfaces.js","sourceRoot":"","sources":["../../../src/interfaces/event-interfaces.ts"],"names":[],"mappings":"","sourcesContent":["import {\n MenuProviderInterface,\n MenuShortcutInterface,\n MenuId,\n} from './menu-interfaces';\n\n/** Toggles Menu && Sets open panel */\nexport interface ToggleSideMenuOpenEvent extends CustomEvent {\n type: 'updateSideMenu';\n detail: {\n menuId: MenuId | undefined | '';\n action: 'open' | 'toggle' | '';\n };\n}\n\n/** Sets open panel */\nexport interface ToggleSidePanelOpenEvent extends CustomEvent {\n type: 'menuTypeSelected';\n detail: {\n id: MenuId | '';\n };\n}\n\n/** Sets menu order that is displayed */\nexport interface SetSideMenuContentsEvent extends CustomEvent {\n type: 'menuUpdated';\n detail: MenuProviderInterface[];\n}\n\n/** Sets menu shortcuts that is displayed */\nexport interface SetSideMenuShortcutsEvent extends CustomEvent {\n type: 'menuUpdated';\n detail: MenuShortcutInterface[];\n}\n\n/** Toggles fullscreen mode */\nexport interface ManageFullscreenEvent extends CustomEvent {\n type: 'ViewportInFullScreen';\n detail: {\n isFullScreen: boolean;\n };\n}\n\n/** Toggles loading view */\nexport interface loadingStateUpdatedEvent extends CustomEvent {\n type: 'loadingStateUpdated';\n detail: {\n loaded: boolean;\n };\n}\n"]}
|
@@ -1,23 +1,22 @@
|
|
1
1
|
import { TemplateResult } from 'lit-html';
|
2
2
|
import { MetadataResponse } from '@internetarchive/search-service';
|
3
|
-
export
|
3
|
+
export declare type MenuId = string;
|
4
|
+
export interface MenuShortcutInterface {
|
4
5
|
icon: TemplateResult;
|
5
|
-
id:
|
6
|
+
id: MenuId;
|
6
7
|
}
|
7
|
-
export interface
|
8
|
-
icon: TemplateResult;
|
9
|
-
id: string;
|
8
|
+
export interface MenuDetailsInterface extends MenuShortcutInterface {
|
10
9
|
label: string;
|
11
10
|
menuDetails?: TemplateResult;
|
12
11
|
selected?: boolean;
|
13
12
|
followable?: boolean;
|
14
13
|
href?: string;
|
15
14
|
}
|
16
|
-
export interface
|
15
|
+
export interface MenuProviderBaseConfigInterface {
|
17
16
|
item: MetadataResponse;
|
18
17
|
baseHost: string;
|
19
18
|
subPrefix: string;
|
20
19
|
updated?: any;
|
21
20
|
}
|
22
|
-
export interface
|
21
|
+
export interface MenuProviderInterface extends MenuProviderBaseConfigInterface, MenuDetailsInterface, MenuShortcutInterface {
|
23
22
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"menu-interfaces.js","sourceRoot":"","sources":["../../../src/interfaces/menu-interfaces.ts"],"names":[],"mappings":"","sourcesContent":["import { TemplateResult } from 'lit-html';\nimport { MetadataResponse } from '@internetarchive/search-service';\n\nexport interface
|
1
|
+
{"version":3,"file":"menu-interfaces.js","sourceRoot":"","sources":["../../../src/interfaces/menu-interfaces.ts"],"names":[],"mappings":"","sourcesContent":["import { TemplateResult } from 'lit-html';\nimport { MetadataResponse } from '@internetarchive/search-service';\n\nexport type MenuId = string;\nexport interface MenuShortcutInterface {\n icon: TemplateResult;\n id: MenuId;\n}\n\nexport interface MenuDetailsInterface extends MenuShortcutInterface {\n label: string;\n menuDetails?: TemplateResult;\n selected?: boolean;\n followable?: boolean;\n href?: string;\n}\n\nexport interface MenuProviderBaseConfigInterface {\n item: MetadataResponse;\n baseHost: string;\n subPrefix: string;\n updated?: any;\n}\nexport interface MenuProviderInterface\n extends MenuProviderBaseConfigInterface,\n MenuDetailsInterface,\n MenuShortcutInterface {}\n"]}
|