@internetarchive/ia-item-navigator 0.0.0-a7 → 0.0.1
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/README.md +29 -19
- package/demo/app-root.ts +70 -41
- package/demo/index.html +1 -2
- package/dist/demo/app-root.d.ts +20 -9
- package/dist/demo/app-root.js +61 -36
- 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 -21
- 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 -41
- package/dist/src/item-inspector/item-inspector.js +253 -222
- package/dist/src/item-inspector/item-inspector.js.map +1 -1
- package/dist/src/item-inspector/visual-mod-provider.d.ts +2 -0
- package/dist/src/item-inspector/visual-mod-provider.js +3 -0
- package/dist/src/item-inspector/visual-mod-provider.js.map +1 -1
- package/dist/src/item-navigator.d.ts +45 -30
- package/dist/src/item-navigator.js +113 -120
- 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 -22
- package/src/interfaces/menu-interfaces.ts +9 -10
- package/src/item-navigator.ts +154 -151
- 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 -242
- package/src/item-inspector/share-provider.ts +0 -51
- package/src/item-inspector/visual-mod-provider.ts +0 -60
- 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
|
-
[](https://travis-ci.com/internetarchive/iaux-item-navigator) [](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,47 +6,54 @@ 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 { SharedResizeObserver } from '@internetarchive/shared-resize-observer';
|
16
|
+
import { ModalManager } from '@internetarchive/modal-manager';
|
17
|
+
import '@internetarchive/modal-manager';
|
18
|
+
import { ItemNavigator } from '../src/item-navigator';
|
15
19
|
import '../src/item-navigator';
|
16
|
-
|
17
20
|
@customElement('app-root')
|
18
21
|
export class AppRoot extends LitElement {
|
22
|
+
/**
|
23
|
+
* Example controller to connect to `<ia-item-navigator>`
|
24
|
+
*/
|
19
25
|
@property({ type: Object }) itemMD: MetadataResponse | undefined = undefined;
|
20
26
|
|
21
|
-
@property({ type: Object }) bookManifest = {};
|
22
|
-
|
23
27
|
@property({ type: String }) encodedManifest = '';
|
24
28
|
|
25
|
-
@query('item-navigator') private itemNav!:
|
29
|
+
@query('ia-item-navigator') private itemNav!: ItemNavigator;
|
30
|
+
|
31
|
+
@query('modal-manager') modalMgr!: ModalManager;
|
32
|
+
|
33
|
+
@property({ attribute: false }) sharedObserver = new SharedResizeObserver();
|
34
|
+
|
35
|
+
@property({ type: Boolean, reflect: true, attribute: true }) fullscreen:
|
36
|
+
| boolean
|
37
|
+
| null = null;
|
26
38
|
|
27
39
|
firstUpdated() {
|
28
40
|
this.fetchItemMD();
|
29
|
-
|
41
|
+
console.log(
|
42
|
+
'<app-root> component has loaded',
|
43
|
+
this.modalMgr,
|
44
|
+
this.sharedObserver
|
45
|
+
);
|
30
46
|
}
|
31
47
|
|
32
|
-
/**
|
33
|
-
* @inheritdoc
|
34
|
-
*/
|
35
48
|
updated(changed: any) {
|
49
|
+
console.log('changed', changed);
|
36
50
|
if (changed.has('itemMD')) {
|
37
51
|
this.fullscreenCheck();
|
38
52
|
}
|
39
53
|
}
|
40
54
|
|
41
|
-
fullscreenCheck() {
|
42
|
-
if (this.showFullscreen && this.itemNav) {
|
43
|
-
this.itemNav.viewportInFullscreen = true;
|
44
|
-
}
|
45
|
-
}
|
46
|
-
|
47
55
|
async fetchItemMD() {
|
48
56
|
const searchService = SearchService.default;
|
49
|
-
|
50
57
|
const mdResponse = await searchService.fetchMetadata('ux-team-books');
|
51
58
|
|
52
59
|
if (mdResponse.error) {
|
@@ -57,32 +64,25 @@ export class AppRoot extends LitElement {
|
|
57
64
|
return;
|
58
65
|
}
|
59
66
|
|
67
|
+
console.log('mdResponse.success', JSON.stringify(mdResponse.success));
|
60
68
|
this.itemMD = mdResponse.success;
|
61
69
|
}
|
62
70
|
|
71
|
+
get theaterReady(): boolean {
|
72
|
+
return this.modalMgr && this.sharedObserver && !!this.itemMD;
|
73
|
+
}
|
74
|
+
|
63
75
|
get urlParams(): URLSearchParams {
|
64
76
|
return new URLSearchParams(location.search.slice(1));
|
65
77
|
}
|
66
78
|
|
79
|
+
/** Fullscreen */
|
67
80
|
get showFullscreen(): boolean {
|
68
81
|
return this.urlParams.get('view') === 'theater';
|
69
82
|
}
|
70
83
|
|
71
|
-
|
72
|
-
|
73
|
-
// eslint-disable-next-line guard-for-in, no-restricted-syntax
|
74
|
-
for (const md in this.itemMD) {
|
75
|
-
const val = (this.itemMD as any)[md];
|
76
|
-
x.push(
|
77
|
-
html`<dt>${md}</dt>
|
78
|
-
:
|
79
|
-
<dd>${val}</dd>`
|
80
|
-
);
|
81
|
-
}
|
82
|
-
return html`<dl>${[...x]}</dl>`;
|
83
|
-
}
|
84
|
-
|
85
|
-
toggleFS() {
|
84
|
+
/** sets url query param `view=theater` to toggle fullscreen */
|
85
|
+
toggleFS(): void {
|
86
86
|
if (this.urlParams.get('view')) {
|
87
87
|
location.search = '';
|
88
88
|
} else {
|
@@ -90,19 +90,39 @@ export class AppRoot extends LitElement {
|
|
90
90
|
}
|
91
91
|
}
|
92
92
|
|
93
|
-
|
94
|
-
|
95
|
-
|
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;
|
96
98
|
}
|
99
|
+
}
|
100
|
+
/** End fullscreen */
|
101
|
+
|
102
|
+
/** Views */
|
103
|
+
get theaterBlock(): TemplateResult {
|
97
104
|
return html`
|
98
|
-
<
|
99
|
-
<item-navigator
|
105
|
+
<ia-item-navigator
|
100
106
|
baseHost="https://archive.org"
|
101
107
|
.item=${this.itemMD}
|
108
|
+
.modal=${this.modalMgr}
|
109
|
+
.sharedObserver=${this.sharedObserver}
|
102
110
|
@ViewportInFullScreen=${this.toggleFS}
|
103
|
-
|
104
|
-
|
105
|
-
|
111
|
+
.viewportInFullscreen=${this.fullscreen}
|
112
|
+
></ia-item-navigator>
|
113
|
+
`;
|
114
|
+
}
|
115
|
+
|
116
|
+
get placeholder(): TemplateResult {
|
117
|
+
return html`<h2>Please hold as we fetch an item for ya</h2>`;
|
118
|
+
}
|
119
|
+
|
120
|
+
render(): TemplateResult {
|
121
|
+
const theater = this.theaterReady ? this.theaterBlock : this.placeholder;
|
122
|
+
return html`
|
123
|
+
<h1>theater, in page</h1>
|
124
|
+
${theater}
|
125
|
+
<modal-manager></modal-manager>
|
106
126
|
`;
|
107
127
|
}
|
108
128
|
|
@@ -112,15 +132,20 @@ export class AppRoot extends LitElement {
|
|
112
132
|
color: #222;
|
113
133
|
}
|
114
134
|
|
135
|
+
:host([fullscreen]) {
|
136
|
+
height: 100vh;
|
137
|
+
width: 100vw;
|
138
|
+
}
|
139
|
+
|
115
140
|
:host,
|
116
|
-
item-navigator {
|
141
|
+
ia-item-navigator {
|
117
142
|
display: block;
|
118
143
|
position: relative;
|
119
144
|
width: 100%;
|
120
145
|
min-height: 64vh;
|
121
146
|
height: 64vh;
|
122
147
|
}
|
123
|
-
item-navigator {
|
148
|
+
ia-item-navigator {
|
124
149
|
height: inherit;
|
125
150
|
min-height: inherit;
|
126
151
|
}
|
@@ -130,5 +155,9 @@ export class AppRoot extends LitElement {
|
|
130
155
|
height: 100%;
|
131
156
|
min-height: inherit;
|
132
157
|
}
|
158
|
+
|
159
|
+
modal-manager[mode='closed'] {
|
160
|
+
display: none;
|
161
|
+
}
|
133
162
|
`;
|
134
163
|
}
|
package/demo/index.html
CHANGED
@@ -58,8 +58,7 @@
|
|
58
58
|
<body>
|
59
59
|
<app-root></app-root>
|
60
60
|
<script type="module">
|
61
|
-
|
62
|
-
|
61
|
+
/* eslint-disable no-restricted-globals */
|
63
62
|
const params = new URLSearchParams(location.search.slice(1));
|
64
63
|
if (params.get('view') === 'theater') {
|
65
64
|
const body = document.querySelector('body');
|
package/dist/demo/app-root.d.ts
CHANGED
@@ -1,23 +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';
|
3
|
+
import { SharedResizeObserver } from '@internetarchive/shared-resize-observer';
|
4
|
+
import { ModalManager } from '@internetarchive/modal-manager';
|
5
|
+
import '@internetarchive/modal-manager';
|
4
6
|
import '../src/item-navigator';
|
5
7
|
export declare class AppRoot extends LitElement {
|
8
|
+
/**
|
9
|
+
* Example controller to connect to `<ia-item-navigator>`
|
10
|
+
*/
|
6
11
|
itemMD: MetadataResponse | undefined;
|
7
|
-
bookManifest: {};
|
8
12
|
encodedManifest: string;
|
9
13
|
private itemNav;
|
14
|
+
modalMgr: ModalManager;
|
15
|
+
sharedObserver: SharedResizeObserver;
|
16
|
+
fullscreen: boolean | null;
|
10
17
|
firstUpdated(): void;
|
11
|
-
/**
|
12
|
-
* @inheritdoc
|
13
|
-
*/
|
14
18
|
updated(changed: any): void;
|
15
|
-
fullscreenCheck(): void;
|
16
19
|
fetchItemMD(): Promise<void>;
|
20
|
+
get theaterReady(): boolean;
|
17
21
|
get urlParams(): URLSearchParams;
|
22
|
+
/** Fullscreen */
|
18
23
|
get showFullscreen(): boolean;
|
19
|
-
|
24
|
+
/** sets url query param `view=theater` to toggle fullscreen */
|
20
25
|
toggleFS(): void;
|
21
|
-
|
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;
|
22
33
|
static styles: import("lit-element").CSSResult;
|
23
34
|
}
|
package/dist/demo/app-root.js
CHANGED
@@ -1,33 +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';
|
5
|
+
import { SharedResizeObserver } from '@internetarchive/shared-resize-observer';
|
6
|
+
import '@internetarchive/modal-manager';
|
6
7
|
import '../src/item-navigator';
|
7
8
|
let AppRoot = class AppRoot extends LitElement {
|
8
9
|
constructor() {
|
9
10
|
super(...arguments);
|
11
|
+
/**
|
12
|
+
* Example controller to connect to `<ia-item-navigator>`
|
13
|
+
*/
|
10
14
|
this.itemMD = undefined;
|
11
|
-
this.bookManifest = {};
|
12
15
|
this.encodedManifest = '';
|
16
|
+
this.sharedObserver = new SharedResizeObserver();
|
17
|
+
this.fullscreen = null;
|
13
18
|
}
|
14
19
|
firstUpdated() {
|
15
20
|
this.fetchItemMD();
|
16
|
-
|
21
|
+
console.log('<app-root> component has loaded', this.modalMgr, this.sharedObserver);
|
17
22
|
}
|
18
|
-
/**
|
19
|
-
* @inheritdoc
|
20
|
-
*/
|
21
23
|
updated(changed) {
|
24
|
+
console.log('changed', changed);
|
22
25
|
if (changed.has('itemMD')) {
|
23
26
|
this.fullscreenCheck();
|
24
27
|
}
|
25
28
|
}
|
26
|
-
fullscreenCheck() {
|
27
|
-
if (this.showFullscreen && this.itemNav) {
|
28
|
-
this.itemNav.viewportInFullscreen = true;
|
29
|
-
}
|
30
|
-
}
|
31
29
|
async fetchItemMD() {
|
32
30
|
const searchService = SearchService.default;
|
33
31
|
const mdResponse = await searchService.fetchMetadata('ux-team-books');
|
@@ -36,25 +34,20 @@ let AppRoot = class AppRoot extends LitElement {
|
|
36
34
|
window.confirm('There was an error fetching response, please check dev console');
|
37
35
|
return;
|
38
36
|
}
|
37
|
+
console.log('mdResponse.success', JSON.stringify(mdResponse.success));
|
39
38
|
this.itemMD = mdResponse.success;
|
40
39
|
}
|
40
|
+
get theaterReady() {
|
41
|
+
return this.modalMgr && this.sharedObserver && !!this.itemMD;
|
42
|
+
}
|
41
43
|
get urlParams() {
|
42
44
|
return new URLSearchParams(location.search.slice(1));
|
43
45
|
}
|
46
|
+
/** Fullscreen */
|
44
47
|
get showFullscreen() {
|
45
48
|
return this.urlParams.get('view') === 'theater';
|
46
49
|
}
|
47
|
-
|
48
|
-
const x = [];
|
49
|
-
// eslint-disable-next-line guard-for-in, no-restricted-syntax
|
50
|
-
for (const md in this.itemMD) {
|
51
|
-
const val = this.itemMD[md];
|
52
|
-
x.push(html `<dt>${md}</dt>
|
53
|
-
:
|
54
|
-
<dd>${val}</dd>`);
|
55
|
-
}
|
56
|
-
return html `<dl>${[...x]}</dl>`;
|
57
|
-
}
|
50
|
+
/** sets url query param `view=theater` to toggle fullscreen */
|
58
51
|
toggleFS() {
|
59
52
|
if (this.urlParams.get('view')) {
|
60
53
|
location.search = '';
|
@@ -63,19 +56,36 @@ let AppRoot = class AppRoot extends LitElement {
|
|
63
56
|
location.search = 'view=theater';
|
64
57
|
}
|
65
58
|
}
|
66
|
-
|
67
|
-
|
68
|
-
|
59
|
+
/** toggles attr: `<ia-item-navigator viewportinfullscreen>` */
|
60
|
+
fullscreenCheck() {
|
61
|
+
if (this.showFullscreen && this.itemNav) {
|
62
|
+
this.fullscreen = true;
|
63
|
+
// this.itemNav.viewportInFullscreen = true;
|
69
64
|
}
|
65
|
+
}
|
66
|
+
/** End fullscreen */
|
67
|
+
/** Views */
|
68
|
+
get theaterBlock() {
|
70
69
|
return html `
|
71
|
-
<
|
72
|
-
<item-navigator
|
70
|
+
<ia-item-navigator
|
73
71
|
baseHost="https://archive.org"
|
74
72
|
.item=${this.itemMD}
|
73
|
+
.modal=${this.modalMgr}
|
74
|
+
.sharedObserver=${this.sharedObserver}
|
75
75
|
@ViewportInFullScreen=${this.toggleFS}
|
76
|
-
|
77
|
-
|
78
|
-
|
76
|
+
.viewportInFullscreen=${this.fullscreen}
|
77
|
+
></ia-item-navigator>
|
78
|
+
`;
|
79
|
+
}
|
80
|
+
get placeholder() {
|
81
|
+
return html `<h2>Please hold as we fetch an item for ya</h2>`;
|
82
|
+
}
|
83
|
+
render() {
|
84
|
+
const theater = this.theaterReady ? this.theaterBlock : this.placeholder;
|
85
|
+
return html `
|
86
|
+
<h1>theater, in page</h1>
|
87
|
+
${theater}
|
88
|
+
<modal-manager></modal-manager>
|
79
89
|
`;
|
80
90
|
}
|
81
91
|
};
|
@@ -85,15 +95,20 @@ AppRoot.styles = css `
|
|
85
95
|
color: #222;
|
86
96
|
}
|
87
97
|
|
98
|
+
:host([fullscreen]) {
|
99
|
+
height: 100vh;
|
100
|
+
width: 100vw;
|
101
|
+
}
|
102
|
+
|
88
103
|
:host,
|
89
|
-
item-navigator {
|
104
|
+
ia-item-navigator {
|
90
105
|
display: block;
|
91
106
|
position: relative;
|
92
107
|
width: 100%;
|
93
108
|
min-height: 64vh;
|
94
109
|
height: 64vh;
|
95
110
|
}
|
96
|
-
item-navigator {
|
111
|
+
ia-item-navigator {
|
97
112
|
height: inherit;
|
98
113
|
min-height: inherit;
|
99
114
|
}
|
@@ -103,19 +118,29 @@ AppRoot.styles = css `
|
|
103
118
|
height: 100%;
|
104
119
|
min-height: inherit;
|
105
120
|
}
|
121
|
+
|
122
|
+
modal-manager[mode='closed'] {
|
123
|
+
display: none;
|
124
|
+
}
|
106
125
|
`;
|
107
126
|
__decorate([
|
108
127
|
property({ type: Object })
|
109
128
|
], AppRoot.prototype, "itemMD", void 0);
|
110
|
-
__decorate([
|
111
|
-
property({ type: Object })
|
112
|
-
], AppRoot.prototype, "bookManifest", void 0);
|
113
129
|
__decorate([
|
114
130
|
property({ type: String })
|
115
131
|
], AppRoot.prototype, "encodedManifest", void 0);
|
116
132
|
__decorate([
|
117
|
-
query('item-navigator')
|
133
|
+
query('ia-item-navigator')
|
118
134
|
], AppRoot.prototype, "itemNav", void 0);
|
135
|
+
__decorate([
|
136
|
+
query('modal-manager')
|
137
|
+
], AppRoot.prototype, "modalMgr", void 0);
|
138
|
+
__decorate([
|
139
|
+
property({ attribute: false })
|
140
|
+
], AppRoot.prototype, "sharedObserver", void 0);
|
141
|
+
__decorate([
|
142
|
+
property({ type: Boolean, reflect: true, attribute: true })
|
143
|
+
], AppRoot.prototype, "fullscreen", void 0);
|
119
144
|
AppRoot = __decorate([
|
120
145
|
customElement('app-root')
|
121
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;QACyB,WAAM,GAAiC,SAAS,CAAC;QAEjD,oBAAe,GAAG,EAAE,CAAC;QAMjB,mBAAc,GAAG,IAAI,oBAAoB,EAAE,CAAC;QAEf,eAAU,GAE5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AAE,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,48 +1,38 @@
|
|
1
|
-
import {
|
2
|
-
import { ModalConfig } from '@internetarchive/modal-manager';
|
3
|
-
import { IntMenuProvider, IntMenuShortcut } from './menu-interfaces';
|
1
|
+
import { MenuProviderInterface, MenuShortcutInterface, MenuId } from './menu-interfaces';
|
4
2
|
/** Toggles Menu && Sets open panel */
|
5
|
-
export interface
|
3
|
+
export interface ToggleSideMenuOpenEvent extends CustomEvent {
|
6
4
|
type: 'updateSideMenu';
|
7
5
|
detail: {
|
8
|
-
menuId:
|
6
|
+
menuId: MenuId | undefined | '';
|
9
7
|
action: 'open' | 'toggle' | '';
|
10
8
|
};
|
11
9
|
}
|
12
10
|
/** Sets open panel */
|
13
|
-
export interface
|
11
|
+
export interface ToggleSidePanelOpenEvent extends CustomEvent {
|
14
12
|
type: 'menuTypeSelected';
|
15
13
|
detail: {
|
16
|
-
id:
|
14
|
+
id: MenuId | '';
|
17
15
|
};
|
18
16
|
}
|
19
17
|
/** Sets menu order that is displayed */
|
20
|
-
export interface
|
18
|
+
export interface SetSideMenuContentsEvent extends CustomEvent {
|
21
19
|
type: 'menuUpdated';
|
22
|
-
detail:
|
20
|
+
detail: MenuProviderInterface[];
|
23
21
|
}
|
24
22
|
/** Sets menu shortcuts that is displayed */
|
25
|
-
export interface
|
23
|
+
export interface SetSideMenuShortcutsEvent extends CustomEvent {
|
26
24
|
type: 'menuUpdated';
|
27
|
-
detail:
|
25
|
+
detail: MenuShortcutInterface[];
|
28
26
|
}
|
29
27
|
/** Toggles fullscreen mode */
|
30
|
-
export interface
|
28
|
+
export interface ManageFullscreenEvent extends CustomEvent {
|
31
29
|
type: 'ViewportInFullScreen';
|
32
30
|
detail: {
|
33
31
|
isFullScreen: boolean;
|
34
32
|
};
|
35
33
|
}
|
36
|
-
/** Toggles modal & sets contents */
|
37
|
-
export interface IntOpenModalEvent extends CustomEvent {
|
38
|
-
type: 'showItemNavigatorModal';
|
39
|
-
detail: {
|
40
|
-
config: ModalConfig;
|
41
|
-
customModalContent: TemplateResult;
|
42
|
-
};
|
43
|
-
}
|
44
34
|
/** Toggles loading view */
|
45
|
-
export interface
|
35
|
+
export interface loadingStateUpdatedEvent extends CustomEvent {
|
46
36
|
type: 'loadingStateUpdated';
|
47
37
|
detail: {
|
48
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
|
}
|