@internetarchive/ia-item-navigator 0.0.0-a7 → 0.0.1
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 +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
@@ -1,55 +1,48 @@
|
|
1
|
-
import {
|
2
|
-
|
3
|
-
|
1
|
+
import {
|
2
|
+
MenuProviderInterface,
|
3
|
+
MenuShortcutInterface,
|
4
|
+
MenuId,
|
5
|
+
} from './menu-interfaces';
|
4
6
|
|
5
7
|
/** Toggles Menu && Sets open panel */
|
6
|
-
export interface
|
8
|
+
export interface ToggleSideMenuOpenEvent extends CustomEvent {
|
7
9
|
type: 'updateSideMenu';
|
8
10
|
detail: {
|
9
|
-
menuId:
|
11
|
+
menuId: MenuId | undefined | '';
|
10
12
|
action: 'open' | 'toggle' | '';
|
11
13
|
};
|
12
14
|
}
|
13
15
|
|
14
16
|
/** Sets open panel */
|
15
|
-
export interface
|
17
|
+
export interface ToggleSidePanelOpenEvent extends CustomEvent {
|
16
18
|
type: 'menuTypeSelected';
|
17
19
|
detail: {
|
18
|
-
id:
|
20
|
+
id: MenuId | '';
|
19
21
|
};
|
20
22
|
}
|
21
23
|
|
22
24
|
/** Sets menu order that is displayed */
|
23
|
-
export interface
|
25
|
+
export interface SetSideMenuContentsEvent extends CustomEvent {
|
24
26
|
type: 'menuUpdated';
|
25
|
-
detail:
|
27
|
+
detail: MenuProviderInterface[];
|
26
28
|
}
|
27
29
|
|
28
30
|
/** Sets menu shortcuts that is displayed */
|
29
|
-
export interface
|
31
|
+
export interface SetSideMenuShortcutsEvent extends CustomEvent {
|
30
32
|
type: 'menuUpdated';
|
31
|
-
detail:
|
33
|
+
detail: MenuShortcutInterface[];
|
32
34
|
}
|
33
35
|
|
34
36
|
/** Toggles fullscreen mode */
|
35
|
-
export interface
|
37
|
+
export interface ManageFullscreenEvent extends CustomEvent {
|
36
38
|
type: 'ViewportInFullScreen';
|
37
39
|
detail: {
|
38
40
|
isFullScreen: boolean;
|
39
41
|
};
|
40
42
|
}
|
41
43
|
|
42
|
-
/** Toggles modal & sets contents */
|
43
|
-
export interface IntOpenModalEvent extends CustomEvent {
|
44
|
-
type: 'showItemNavigatorModal';
|
45
|
-
detail: {
|
46
|
-
config: ModalConfig;
|
47
|
-
customModalContent: TemplateResult;
|
48
|
-
};
|
49
|
-
}
|
50
|
-
|
51
44
|
/** Toggles loading view */
|
52
|
-
export interface
|
45
|
+
export interface loadingStateUpdatedEvent extends CustomEvent {
|
53
46
|
type: 'loadingStateUpdated';
|
54
47
|
detail: {
|
55
48
|
loaded: boolean;
|
@@ -1,14 +1,13 @@
|
|
1
1
|
import { TemplateResult } from 'lit-html';
|
2
2
|
import { MetadataResponse } from '@internetarchive/search-service';
|
3
3
|
|
4
|
-
export
|
4
|
+
export type MenuId = string;
|
5
|
+
export interface MenuShortcutInterface {
|
5
6
|
icon: TemplateResult;
|
6
|
-
id:
|
7
|
+
id: MenuId;
|
7
8
|
}
|
8
9
|
|
9
|
-
export interface
|
10
|
-
icon: TemplateResult;
|
11
|
-
id: string;
|
10
|
+
export interface MenuDetailsInterface extends MenuShortcutInterface {
|
12
11
|
label: string;
|
13
12
|
menuDetails?: TemplateResult;
|
14
13
|
selected?: boolean;
|
@@ -16,13 +15,13 @@ export interface IntMenuIconAndDetails extends IntMenuShortcut {
|
|
16
15
|
href?: string;
|
17
16
|
}
|
18
17
|
|
19
|
-
export interface
|
18
|
+
export interface MenuProviderBaseConfigInterface {
|
20
19
|
item: MetadataResponse;
|
21
20
|
baseHost: string;
|
22
21
|
subPrefix: string;
|
23
22
|
updated?: any;
|
24
23
|
}
|
25
|
-
export interface
|
26
|
-
extends
|
27
|
-
|
28
|
-
|
24
|
+
export interface MenuProviderInterface
|
25
|
+
extends MenuProviderBaseConfigInterface,
|
26
|
+
MenuDetailsInterface,
|
27
|
+
MenuShortcutInterface {}
|
package/src/item-navigator.ts
CHANGED
@@ -6,34 +6,41 @@ import {
|
|
6
6
|
property,
|
7
7
|
state,
|
8
8
|
query,
|
9
|
+
PropertyValues,
|
10
|
+
CSSResult,
|
9
11
|
} from 'lit-element';
|
10
12
|
import { nothing, TemplateResult } from 'lit-html';
|
11
13
|
import { MetadataResponse } from '@internetarchive/search-service';
|
12
|
-
import { PromisedSingleton } from '@internetarchive/promised-singleton';
|
13
14
|
import {
|
14
15
|
SharedResizeObserver,
|
15
|
-
SharedResizeObserverInterface,
|
16
16
|
SharedResizeObserverResizeHandlerInterface,
|
17
17
|
} from '@internetarchive/shared-resize-observer';
|
18
|
-
|
19
|
-
|
20
|
-
import {
|
18
|
+
import '@internetarchive/ia-menu-slider';
|
19
|
+
|
20
|
+
import { ModalManager } from '@internetarchive/modal-manager';
|
21
21
|
import '@internetarchive/icon-ellipses/icon-ellipses';
|
22
22
|
import './loader';
|
23
23
|
|
24
24
|
import {
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
IntManageFullscreenEvent,
|
25
|
+
ToggleSideMenuOpenEvent,
|
26
|
+
ToggleSidePanelOpenEvent,
|
27
|
+
SetSideMenuContentsEvent,
|
28
|
+
SetSideMenuShortcutsEvent,
|
29
|
+
loadingStateUpdatedEvent,
|
30
|
+
ManageFullscreenEvent,
|
32
31
|
} from './interfaces/event-interfaces';
|
33
32
|
|
34
|
-
import {
|
35
|
-
|
36
|
-
|
33
|
+
import {
|
34
|
+
MenuProviderInterface,
|
35
|
+
MenuShortcutInterface,
|
36
|
+
MenuId,
|
37
|
+
} from './interfaces/menu-interfaces';
|
38
|
+
import './no-theater-available';
|
39
|
+
|
40
|
+
export enum ItemType {
|
41
|
+
BOOK = 'bookreader',
|
42
|
+
}
|
43
|
+
@customElement('ia-item-navigator')
|
37
44
|
export class ItemNavigator
|
38
45
|
extends LitElement
|
39
46
|
implements SharedResizeObserverResizeHandlerInterface {
|
@@ -46,9 +53,9 @@ export class ItemNavigator
|
|
46
53
|
return value as MetadataResponse;
|
47
54
|
},
|
48
55
|
})
|
49
|
-
item
|
56
|
+
item?: MetadataResponse;
|
50
57
|
|
51
|
-
@property({ type: String }) itemType
|
58
|
+
@property({ type: String }) itemType?: ItemType;
|
52
59
|
|
53
60
|
@property({ type: String }) baseHost = 'archive.org';
|
54
61
|
|
@@ -62,53 +69,44 @@ export class ItemNavigator
|
|
62
69
|
})
|
63
70
|
signedIn = false;
|
64
71
|
|
65
|
-
@property({
|
66
|
-
type: Array,
|
67
|
-
hasChanged: (newVal: Array<object>, oldVal: Array<object>) => {
|
68
|
-
if (newVal !== oldVal) {
|
69
|
-
return true;
|
70
|
-
}
|
71
|
-
return false;
|
72
|
-
},
|
73
|
-
})
|
74
|
-
@property({ type: Array })
|
75
|
-
menuContents: IntMenuProvider[] = [];
|
72
|
+
@property({ type: Array }) menuContents: MenuProviderInterface[] = [];
|
76
73
|
|
77
|
-
@property({ type: Array }) menuShortcuts:
|
74
|
+
@property({ type: Array }) menuShortcuts: MenuShortcutInterface[] = [];
|
78
75
|
|
79
|
-
@property({ type: Boolean, reflect: true })
|
76
|
+
@property({ type: Boolean, reflect: true, attribute: true })
|
77
|
+
viewportInFullscreen: boolean | null = null;
|
80
78
|
|
81
79
|
@property({ type: Boolean }) menuOpened = false;
|
82
80
|
|
83
|
-
@property({ type: String }) openMenu
|
81
|
+
@property({ type: String }) openMenu?: MenuId;
|
84
82
|
|
85
|
-
@property({
|
86
|
-
| ModalManagerInterface
|
87
|
-
| undefined = undefined;
|
83
|
+
@property({ attribute: false }) modal?: ModalManager;
|
88
84
|
|
89
|
-
@property({ attribute: false })
|
85
|
+
@property({ attribute: false }) sharedObserver?: SharedResizeObserver;
|
90
86
|
|
91
|
-
@
|
87
|
+
@property({ type: Boolean, reflect: true, attribute: true }) loaded:
|
88
|
+
| true
|
89
|
+
| null = null;
|
92
90
|
|
93
|
-
@state()
|
91
|
+
@state() openMenuState: 'overlay' | 'shift' = 'shift';
|
94
92
|
|
95
93
|
@query('#frame') private frame!: HTMLDivElement;
|
96
94
|
|
95
|
+
@query('slot[name="theater-header"]') private headerSlot!: HTMLDivElement;
|
96
|
+
|
97
97
|
disconnectedCallback() {
|
98
|
-
this.
|
99
|
-
handler: this,
|
100
|
-
target: this.frame,
|
101
|
-
});
|
98
|
+
this.removeResizeObserver();
|
102
99
|
}
|
103
100
|
|
104
|
-
|
105
|
-
if (
|
106
|
-
|
101
|
+
updated(changed: PropertyValues) {
|
102
|
+
if (changed.has('sharedObserver')) {
|
103
|
+
const oldObserver = changed.get('sharedObserver') as SharedResizeObserver;
|
104
|
+
oldObserver?.removeObserver(this.resizeObserverConfig);
|
105
|
+
this.setResizeObserver();
|
107
106
|
}
|
108
|
-
|
109
|
-
this.startResizeObserver();
|
110
107
|
}
|
111
108
|
|
109
|
+
/** Shared observer */
|
112
110
|
handleResize(entry: ResizeObserverEntry): void {
|
113
111
|
const { width } = entry.contentRect;
|
114
112
|
if (width <= 600) {
|
@@ -118,52 +116,85 @@ export class ItemNavigator
|
|
118
116
|
this.openMenuState = 'shift';
|
119
117
|
}
|
120
118
|
|
121
|
-
private
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
119
|
+
private setResizeObserver(): void {
|
120
|
+
this.sharedObserver?.addObserver(this.resizeObserverConfig);
|
121
|
+
}
|
122
|
+
|
123
|
+
private removeResizeObserver(): void {
|
124
|
+
this.sharedObserver?.removeObserver(this.resizeObserverConfig);
|
125
|
+
}
|
127
126
|
|
128
|
-
|
129
|
-
|
127
|
+
get resizeObserverConfig(): {
|
128
|
+
handler: SharedResizeObserverResizeHandlerInterface;
|
129
|
+
target: Element;
|
130
|
+
} {
|
131
|
+
return {
|
130
132
|
handler: this,
|
131
133
|
target: this.frame,
|
132
|
-
}
|
134
|
+
};
|
135
|
+
}
|
136
|
+
/** End shared observer */
|
137
|
+
|
138
|
+
get loaderTitle() {
|
139
|
+
return this.viewportInFullscreen ? 'Internet Archive' : '';
|
140
|
+
}
|
141
|
+
|
142
|
+
get readerHeightStyle(): string {
|
143
|
+
const calcFSHeight = `calc(100vh - ${this.headerSlot?.offsetHeight}px)`;
|
144
|
+
return this.viewportInFullscreen ? `height: ${calcFSHeight}` : '';
|
145
|
+
}
|
146
|
+
|
147
|
+
get loadingArea() {
|
148
|
+
return html`
|
149
|
+
<div class="loading-area">
|
150
|
+
<div class="loading-view">
|
151
|
+
<ia-itemnav-loader .title=${this.loaderTitle}></ia-itemnav-loader>
|
152
|
+
</div>
|
153
|
+
</div>
|
154
|
+
`;
|
133
155
|
}
|
134
156
|
|
135
157
|
render(): TemplateResult {
|
136
158
|
const displayReaderClass = this.loaded ? '' : 'hide';
|
137
159
|
return html`
|
138
|
-
<div id="frame" class=${this.menuClass}>
|
139
|
-
<slot name="item-nav-header"></slot>
|
160
|
+
<div id="frame" class=${`${this.menuClass}`}>
|
140
161
|
<div class="menu-and-reader">
|
141
162
|
${this.shouldRenderMenu ? this.renderSideMenu : nothing}
|
142
|
-
<
|
163
|
+
<slot name="theater-header"></slot>
|
164
|
+
<div
|
165
|
+
id="reader"
|
166
|
+
class=${displayReaderClass}
|
167
|
+
style=${this.readerHeightStyle}
|
168
|
+
>
|
143
169
|
${this.renderViewport}
|
144
170
|
</div>
|
145
|
-
|
146
|
-
<div class="loading-view">
|
147
|
-
<ia-itemnav-loader></ia-itemnav-loader>
|
148
|
-
</div>
|
149
|
-
</div>
|
171
|
+
${!this.loaded ? this.loadingArea : nothing}
|
150
172
|
</div>
|
151
|
-
${!this.loaded
|
152
|
-
? html` <div class="loading-area">
|
153
|
-
<div class="loading-view">
|
154
|
-
<ia-itemnav-loader></ia-itemnav-loader>
|
155
|
-
</div>
|
156
|
-
</div>`
|
157
|
-
: nothing}
|
158
173
|
</div>
|
159
174
|
`;
|
160
175
|
}
|
161
176
|
|
162
|
-
get
|
177
|
+
get noTheaterView() {
|
178
|
+
return html`<ia-no-theater-available
|
179
|
+
.identifier=${this.item?.metadata?.identifier}
|
180
|
+
@loadingStateUpdated=${this.loadingStateUpdated}
|
181
|
+
></ia-no-theater-available>`;
|
182
|
+
}
|
183
|
+
|
184
|
+
get theaterSlot() {
|
185
|
+
return html`
|
186
|
+
<slot name="theater-main" style=${this.readerHeightStyle}></slot>
|
187
|
+
`;
|
188
|
+
}
|
189
|
+
|
190
|
+
get booksViewer(): TemplateResult {
|
191
|
+
const slotVisibility = !this.loaded ? 'opacity: 0;' : 'opacity: 1;';
|
192
|
+
|
163
193
|
return html`
|
164
194
|
<book-navigator
|
195
|
+
.modal=${this.modal}
|
165
196
|
.baseHost=${this.baseHost}
|
166
|
-
.
|
197
|
+
.itemMD=${this.item}
|
167
198
|
?signedIn=${this.signedIn}
|
168
199
|
?sideMenuOpen=${this.menuOpened}
|
169
200
|
.sharedObserver=${this.sharedObserver}
|
@@ -172,11 +203,9 @@ export class ItemNavigator
|
|
172
203
|
@updateSideMenu=${this.manageSideMenuEvents}
|
173
204
|
@menuUpdated=${this.setMenuContents}
|
174
205
|
@menuShortcutsUpdated=${this.setMenuShortcuts}
|
175
|
-
@openModal=${this.openModal}
|
176
|
-
@closeModal=${this.closeModal}
|
177
206
|
>
|
178
|
-
<div slot="
|
179
|
-
|
207
|
+
<div slot="theater-main" style=${slotVisibility}>
|
208
|
+
${this.theaterSlot}
|
180
209
|
</div>
|
181
210
|
</book-navigator>
|
182
211
|
`;
|
@@ -186,60 +215,27 @@ export class ItemNavigator
|
|
186
215
|
if (!this.item) {
|
187
216
|
return nothing;
|
188
217
|
}
|
189
|
-
if (this.itemType ===
|
190
|
-
return this.
|
218
|
+
if (this.itemType === ItemType.BOOK) {
|
219
|
+
return this.booksViewer;
|
191
220
|
}
|
192
|
-
return
|
193
|
-
.itemMD=${this.item}
|
194
|
-
@updateSideMenu=${this.manageSideMenuEvents}
|
195
|
-
@menuUpdated=${this.setMenuContents}
|
196
|
-
@ViewportInFullScreen=${this.manageViewportFullscreen}
|
197
|
-
@menuShortcutsUpdated=${this.setMenuShortcuts}
|
198
|
-
@openModal=${this.openModal}
|
199
|
-
@closeModal=${this.closeModal}
|
200
|
-
@loadingStateUpdated=${this.loadingStateUpdated}
|
201
|
-
></ia-item-inspector>`;
|
221
|
+
return this.noTheaterView;
|
202
222
|
}
|
203
223
|
|
204
|
-
loadingStateUpdated(e:
|
224
|
+
loadingStateUpdated(e: loadingStateUpdatedEvent): void {
|
205
225
|
const { loaded } = e.detail;
|
206
|
-
this.loaded =
|
207
|
-
}
|
208
|
-
|
209
|
-
/* Modal management */
|
210
|
-
openModal(e: IntOpenModalEvent): void {
|
211
|
-
const { config, customModalContent } = e.detail;
|
212
|
-
if (!config || !customModalContent) {
|
213
|
-
return;
|
214
|
-
}
|
215
|
-
|
216
|
-
this.modal?.showModal({
|
217
|
-
config,
|
218
|
-
customModalContent,
|
219
|
-
});
|
226
|
+
this.loaded = loaded || null;
|
220
227
|
}
|
221
228
|
|
222
|
-
|
223
|
-
|
224
|
-
|
229
|
+
/** Fullscreen Management */
|
230
|
+
manageViewportFullscreen(e: ManageFullscreenEvent): void {
|
231
|
+
const fullscreenStatus = !!e.detail.isFullScreen;
|
232
|
+
this.viewportInFullscreen = !fullscreenStatus ? null : fullscreenStatus;
|
225
233
|
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
'modal-manager'
|
230
|
-
) as ModalManagerInterface;
|
231
|
-
document.body.appendChild(this.modal);
|
232
|
-
}
|
233
|
-
/* End Modal management */
|
234
|
+
const event = new CustomEvent('fullscreenToggled', {
|
235
|
+
detail: e.detail,
|
236
|
+
}) as ManageFullscreenEvent;
|
234
237
|
|
235
|
-
|
236
|
-
manageViewportFullscreen(e: IntManageFullscreenEvent): void {
|
237
|
-
this.viewportInFullscreen = !!e.detail.isFullScreen;
|
238
|
-
this.dispatchEvent(
|
239
|
-
new CustomEvent('ViewportInFullScreen', {
|
240
|
-
detail: e.detail,
|
241
|
-
}) as IntManageFullscreenEvent
|
242
|
-
);
|
238
|
+
this.dispatchEvent(event);
|
243
239
|
}
|
244
240
|
/** End Fullscreen Management */
|
245
241
|
|
@@ -256,35 +252,36 @@ export class ItemNavigator
|
|
256
252
|
this.menuOpened = false;
|
257
253
|
}
|
258
254
|
|
259
|
-
setOpenMenu(e:
|
255
|
+
setOpenMenu(e: ToggleSidePanelOpenEvent): void {
|
260
256
|
const { id } = e.detail;
|
261
|
-
this.openMenu = id
|
257
|
+
this.openMenu = id !== this.openMenu ? id : undefined;
|
262
258
|
}
|
263
259
|
|
264
|
-
setMenuContents(e:
|
260
|
+
setMenuContents(e: SetSideMenuContentsEvent): void {
|
265
261
|
const updatedContents = [...e.detail];
|
266
262
|
this.menuContents = updatedContents;
|
267
263
|
}
|
268
264
|
|
269
|
-
setMenuShortcuts(e:
|
265
|
+
setMenuShortcuts(e: SetSideMenuShortcutsEvent) {
|
270
266
|
this.menuShortcuts = [...e.detail];
|
271
267
|
}
|
272
268
|
|
273
269
|
/** Toggles Side Menu & Sets viewable subpanel */
|
274
|
-
manageSideMenuEvents(e:
|
270
|
+
manageSideMenuEvents(e: ToggleSideMenuOpenEvent): void {
|
275
271
|
const { menuId, action } = e.detail;
|
276
|
-
if (menuId) {
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
272
|
+
if (!menuId) {
|
273
|
+
return;
|
274
|
+
}
|
275
|
+
|
276
|
+
if (action === 'open') {
|
277
|
+
this.openShortcut(menuId);
|
278
|
+
} else if (action === 'toggle') {
|
279
|
+
this.openMenu = menuId;
|
280
|
+
this.toggleMenu();
|
283
281
|
}
|
284
282
|
}
|
285
283
|
|
286
284
|
get menuToggleButton() {
|
287
|
-
// <ia-icon icon="ellipses" style="width: var(--iconWidth); height: var(--iconHeight);"></ia-icon>
|
288
285
|
return html`
|
289
286
|
<button
|
290
287
|
class="toggle-menu"
|
@@ -300,16 +297,19 @@ export class ItemNavigator
|
|
300
297
|
`;
|
301
298
|
}
|
302
299
|
|
300
|
+
get selectedMenuId(): MenuId | '' {
|
301
|
+
return this.openMenu || '';
|
302
|
+
}
|
303
|
+
|
303
304
|
get renderSideMenu(): TemplateResult {
|
304
305
|
const drawerState = this.menuOpened ? '' : 'hidden';
|
305
|
-
|
306
306
|
return html`
|
307
307
|
<nav>
|
308
308
|
<div class="minimized">${this.shortcuts} ${this.menuToggleButton}</div>
|
309
309
|
<div id="menu" class=${drawerState}>
|
310
310
|
<ia-menu-slider
|
311
311
|
.menus=${this.menuContents}
|
312
|
-
.selectedMenu=${this.
|
312
|
+
.selectedMenu=${this.selectedMenuId}
|
313
313
|
@menuTypeSelected=${this.setOpenMenu}
|
314
314
|
@menuSliderClosed=${this.closeMenu}
|
315
315
|
manuallyHandleClose
|
@@ -322,19 +322,23 @@ export class ItemNavigator
|
|
322
322
|
/** End Side menu */
|
323
323
|
|
324
324
|
/** Menu Shortcuts */
|
325
|
-
openShortcut(selectedMenuId = ''): void {
|
325
|
+
openShortcut(selectedMenuId: MenuId = ''): void {
|
326
326
|
this.openMenu = selectedMenuId;
|
327
327
|
this.menuOpened = true;
|
328
328
|
}
|
329
329
|
|
330
330
|
get shortcuts(): TemplateResult {
|
331
|
-
const shortcuts = this.menuShortcuts.map(
|
332
|
-
(
|
331
|
+
const shortcuts = this.menuShortcuts.map(({ icon, id }) => {
|
332
|
+
if (id === 'fullscreen') {
|
333
|
+
return html`${icon}`;
|
334
|
+
}
|
335
|
+
|
336
|
+
return html`
|
333
337
|
<button class="shortcut ${id}" @click="${() => this.openShortcut(id)}">
|
334
338
|
${icon}
|
335
339
|
</button>
|
336
|
-
|
337
|
-
);
|
340
|
+
`;
|
341
|
+
});
|
338
342
|
return html`<div class="shortcuts">${shortcuts}</div>`;
|
339
343
|
}
|
340
344
|
/** End Menu Shortcuts */
|
@@ -346,7 +350,7 @@ export class ItemNavigator
|
|
346
350
|
return `${drawerState} ${fullscreenState} ${this.openMenuState}`;
|
347
351
|
}
|
348
352
|
|
349
|
-
static get styles() {
|
353
|
+
static get styles(): CSSResult {
|
350
354
|
const subnavWidth = css`var(--menuWidth, 320px)`;
|
351
355
|
const transitionTiming = css`var(--animationTiming, 200ms)`;
|
352
356
|
const transitionEffect = css`transform ${transitionTiming} ease-out`;
|
@@ -356,7 +360,6 @@ export class ItemNavigator
|
|
356
360
|
return css`
|
357
361
|
:host,
|
358
362
|
#frame,
|
359
|
-
#reader,
|
360
363
|
.menu-and-reader {
|
361
364
|
min-height: inherit;
|
362
365
|
height: inherit;
|
@@ -365,8 +368,14 @@ export class ItemNavigator
|
|
365
368
|
display: block;
|
366
369
|
}
|
367
370
|
|
371
|
+
slot {
|
372
|
+
display: block;
|
373
|
+
overflow: hidden;
|
374
|
+
}
|
375
|
+
|
368
376
|
#frame {
|
369
377
|
background-color: ${theaterBg};
|
378
|
+
color-scheme: dark;
|
370
379
|
}
|
371
380
|
|
372
381
|
#frame.fullscreen {
|
@@ -378,11 +387,6 @@ export class ItemNavigator
|
|
378
387
|
z-index: 9;
|
379
388
|
}
|
380
389
|
|
381
|
-
#frame.fullscreen,
|
382
|
-
#frame.fullscreen #reader {
|
383
|
-
height: 100vh;
|
384
|
-
}
|
385
|
-
|
386
390
|
.loading-area {
|
387
391
|
position: absolute;
|
388
392
|
top: 0;
|
@@ -499,6 +503,7 @@ export class ItemNavigator
|
|
499
503
|
transition: ${transitionEffect};
|
500
504
|
}
|
501
505
|
|
506
|
+
.open.shift slot[name='theater-header'],
|
502
507
|
.open.shift #reader {
|
503
508
|
width: calc(100% - var(--menuWidth));
|
504
509
|
float: right;
|
@@ -507,5 +512,3 @@ export class ItemNavigator
|
|
507
512
|
`;
|
508
513
|
}
|
509
514
|
}
|
510
|
-
|
511
|
-
customElements.define('ia-menu-slider', IAMenuSlider);
|
package/src/loader.ts
CHANGED
@@ -1,9 +1,15 @@
|
|
1
1
|
/* eslint-disable class-methods-use-this */
|
2
2
|
import { css, html, LitElement, customElement } from 'lit-element';
|
3
|
-
import { svg } from 'lit-html';
|
3
|
+
import { svg, nothing } from 'lit-html';
|
4
4
|
|
5
5
|
@customElement('ia-itemnav-loader')
|
6
6
|
export class IAItemNavLoader extends LitElement {
|
7
|
+
static get properties() {
|
8
|
+
return {
|
9
|
+
title: { type: String },
|
10
|
+
};
|
11
|
+
}
|
12
|
+
|
7
13
|
get bookIconSvg() {
|
8
14
|
return svg`
|
9
15
|
<g class="bookIcon" transform="matrix(1 0 0 -1 28 67.362264)">
|
@@ -42,9 +48,10 @@ export class IAItemNavLoader extends LitElement {
|
|
42
48
|
}
|
43
49
|
|
44
50
|
render() {
|
51
|
+
const title = this.title ? html`<h2>${this.title}</h2>` : nothing;
|
45
52
|
return html`
|
46
53
|
<div class="place-holder">
|
47
|
-
${this.loader}
|
54
|
+
${title} ${this.loader}
|
48
55
|
<h3>Loading viewer</h3>
|
49
56
|
</div>
|
50
57
|
`;
|