{
- if (openInModal) {
- if (tmdbId) {
- //openTitleModal({ type, id: tmdbId, provider: 'tmdb' });
- } else if (tvdbId) {
- //openTitleModal({ type, id: tvdbId, provider: 'tvdb' });
- }
- } else if (tmdbId || tvdbId) {
- navigate(`/${type}/${tmdbId || tvdbId}`);
+ if (tmdbId || tvdbId) {
+ navigate(`${type}/${tmdbId || tvdbId}`);
}
}}
class={classNames(
diff --git a/src/lib/components/Card/TmdbCard.svelte b/src/lib/components/Card/TmdbCard.svelte
new file mode 100644
index 0000000..d29d60d
--- /dev/null
+++ b/src/lib/components/Card/TmdbCard.svelte
@@ -0,0 +1,19 @@
+
+
+
diff --git a/src/lib/components/DetatchedPage/DetatchedPage.svelte b/src/lib/components/DetatchedPage/DetatchedPage.svelte
new file mode 100644
index 0000000..2c31353
--- /dev/null
+++ b/src/lib/components/DetatchedPage/DetatchedPage.svelte
@@ -0,0 +1,18 @@
+
+
+
{
+ console.log('Not called?');
+ history.back();
+ return false;
+ }
+ }}
+ focusOnMount
+ trapFocus
+ class="fixed inset-0"
+>
+
+
diff --git a/src/lib/components/HeroCarousel/HeroCarousel.svelte b/src/lib/components/HeroCarousel/HeroCarousel.svelte
index e4ae48c..ffea160 100644
--- a/src/lib/components/HeroCarousel/HeroCarousel.svelte
+++ b/src/lib/components/HeroCarousel/HeroCarousel.svelte
@@ -21,7 +21,7 @@
function onPrevious() {
if (index === 0) {
- Selectable.focusLeft();
+ return false;
} else {
index = (index - 1 + length) % length;
}
@@ -41,7 +41,7 @@
navigationActions={{
right: onNext,
left: onPrevious,
- up: () => Selectable.focusLeft() || true
+ up: () => Selectable.giveFocus('left') || true
}}
/>
diff --git a/src/lib/components/HeroShowcase/HeroShowcase.svelte b/src/lib/components/HeroShowcase/HeroShowcase.svelte
index 31cf2de..9cf3f42 100644
--- a/src/lib/components/HeroShowcase/HeroShowcase.svelte
+++ b/src/lib/components/HeroShowcase/HeroShowcase.svelte
@@ -25,7 +25,7 @@
function onPrevious() {
if (showcaseIndex === 0) {
- Selectable.focusLeft();
+ Selectable.giveFocus('left');
} else {
showcaseIndex = (showcaseIndex - 1 + showcaseLength) % showcaseLength;
}
diff --git a/src/lib/components/Sidebar/Sidebar.svelte b/src/lib/components/Sidebar/Sidebar.svelte
index bf1edf9..879be1c 100644
--- a/src/lib/components/Sidebar/Sidebar.svelte
+++ b/src/lib/components/Sidebar/Sidebar.svelte
@@ -40,7 +40,7 @@
-
navigate('/movie/359410')}>
+ navigate('movies')}>
diff --git a/src/lib/pages/BrowseSeriesPage.svelte b/src/lib/pages/BrowseSeriesPage.svelte
index 43d0eb0..4a72940 100644
--- a/src/lib/pages/BrowseSeriesPage.svelte
+++ b/src/lib/pages/BrowseSeriesPage.svelte
@@ -1,6 +1,6 @@
-MoviesPage
+
+
+
+
+
+
+
+ {$_('discover.streamingNow')}
+
+
+ {#await popularMovies}
+
+ {:then items}
+
+ {#each items as item (item.id)}
+
+
+
+ {/each}
+ {/await}
+
+
+
+
diff --git a/src/lib/selectable.ts b/src/lib/selectable.ts
index 69f07ee..4099de3 100644
--- a/src/lib/selectable.ts
+++ b/src/lib/selectable.ts
@@ -109,6 +109,7 @@ export class Selectable {
right: undefined
};
private focusByDefault: boolean = false;
+ private trapFocus: boolean = false;
private isInitialized: boolean = false;
private navigationActions: NavigationActions = {};
private isActive: boolean = true;
@@ -256,15 +257,33 @@ export class Selectable {
}
}
+ // if (this.navigationActions[direction]) {
+ // return this;
+ // } else
if (this.neighbors[direction]?.isFocusable()) {
return this.neighbors[direction];
- } else {
+ } else if (!this.trapFocus) {
return this.parent?.getFocusableNeighbor(direction);
}
+
+ return undefined;
}
- private giveFocus(direction: Direction) {
+ private giveFocus(direction: Direction): boolean {
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
+ let selectable: Selectable | undefined = this;
+ while (selectable) {
+ const action = selectable.navigationActions[direction];
+ if (action && action(this)) {
+ return true;
+ }
+ selectable = selectable.parent;
+ }
+
const neighbor = this.getFocusableNeighbor(direction);
+ // if (neighbor?.navigationActions?.[direction] && neighbor.navigationActions[direction]?.(this)) {
+ // return true;
+ // } else
if (neighbor) {
neighbor.focus();
return true;
@@ -273,24 +292,9 @@ export class Selectable {
}
}
- static focusUp() {
+ static giveFocus(direction: Direction) {
const currentlyFocusedObject = get(Selectable.focusedObject);
- return currentlyFocusedObject?.giveFocus('up');
- }
-
- static focusDown() {
- const currentlyFocusedObject = get(Selectable.focusedObject);
- return currentlyFocusedObject?.giveFocus('down');
- }
-
- static focusLeft() {
- const currentlyFocusedObject = get(Selectable.focusedObject);
- return currentlyFocusedObject?.giveFocus('left');
- }
-
- static focusRight() {
- const currentlyFocusedObject = get(Selectable.focusedObject);
- return currentlyFocusedObject?.giveFocus('right');
+ return currentlyFocusedObject?.giveFocus(direction);
}
_initializeSelectable() {
@@ -454,6 +458,11 @@ export class Selectable {
getScrollChildrenIntoView() {
return this.scrollChildrenIntoView;
}
+
+ setTrapFocus(trapFocus: boolean) {
+ this.trapFocus = trapFocus;
+ return this;
+ }
}
export function handleKeyboardNavigation(event: KeyboardEvent) {
@@ -472,21 +481,13 @@ export function handleKeyboardNavigation(event: KeyboardEvent) {
const navigationActions = currentlyFocusedObject.getNavigationActions();
if (event.key === 'ArrowUp') {
- if (navigationActions.up && navigationActions.up(currentlyFocusedObject))
- event.preventDefault();
- else if (Selectable.focusUp()) event.preventDefault();
+ if (Selectable.giveFocus('up')) event.preventDefault();
} else if (event.key === 'ArrowDown') {
- if (navigationActions.down && navigationActions.down(currentlyFocusedObject))
- event.preventDefault();
- else if (Selectable.focusDown()) event.preventDefault();
+ if (Selectable.giveFocus('down')) event.preventDefault();
} else if (event.key === 'ArrowLeft') {
- if (navigationActions.left && navigationActions.left(currentlyFocusedObject))
- event.preventDefault();
- else if (Selectable.focusLeft()) event.preventDefault();
+ if (Selectable.giveFocus('left')) event.preventDefault();
} else if (event.key === 'ArrowRight') {
- if (navigationActions.right && navigationActions.right(currentlyFocusedObject))
- event.preventDefault();
- else if (Selectable.focusRight()) event.preventDefault();
+ if (Selectable.giveFocus('right')) event.preventDefault();
} else if (event.key === 'Enter') {
if (navigationActions.enter && navigationActions.enter(currentlyFocusedObject))
event.preventDefault();