{#if $appState.user === undefined}
diff --git a/src/Container.svelte b/src/Container.svelte
index 7771350..fc57c30 100644
--- a/src/Container.svelte
+++ b/src/Container.svelte
@@ -4,7 +4,8 @@
import classNames from 'classnames';
export let name: string = '';
- export let horizontal = false;
+ export let direction: 'vertical' | 'horizontal' | 'grid' = 'vertical';
+ export let gridCols: number = 1;
export let focusOnMount = false;
export let debugOutline = false;
@@ -13,7 +14,8 @@
export let navigationActions: NavigationActions = {};
const { registerer, ...rest } = new Selectable(name)
- .setDirection(horizontal ? 'horizontal' : 'vertical')
+ .setDirection(direction === 'grid' ? 'horizontal' : direction)
+ .setGridColumns(gridCols)
.setNavigationActions(navigationActions)
.getStores();
export const container = rest.container;
@@ -24,6 +26,7 @@
export let tag = 'div';
$: container.setIsActive(active);
+ $: container.setGridColumns(gridCols);
onMount(() => {
rest.container._initializeSelectable();
diff --git a/src/lib/components/Card/JellyfinCard.svelte b/src/lib/components/Card/JellyfinCard.svelte
index d692e83..f251224 100644
--- a/src/lib/components/Card/JellyfinCard.svelte
+++ b/src/lib/components/Card/JellyfinCard.svelte
@@ -3,18 +3,6 @@
import Card from './Card.svelte';
export let item: JellyfinItem;
-
- // return {
- // tmdbId: Number(item.ProviderIds?.Tmdb) || 0,
- // jellyfinId: item.Id,
- // title: item.Name || undefined,
- // subtitle: item.Genres?.join(', ') || undefined,
- // backdropUrl: getJellyfinPosterUrl(item, 80),
- // size: 'dynamic',
- // ...(item.Type === 'Movie' ? { type: 'movie' } : { type: 'series' }),
- // orientation: 'portrait',
- // rating: item.CommunityRating || undefined
- // };
+
+
+
-
+
+
+
diff --git a/src/lib/components/Carousel/Carousel.svelte b/src/lib/components/Carousel/Carousel.svelte
index d6bd310..ef0eb56 100644
--- a/src/lib/components/Carousel/Carousel.svelte
+++ b/src/lib/components/Carousel/Carousel.svelte
@@ -44,7 +44,7 @@
-
+
= writable(undefined);
@@ -149,17 +150,42 @@ export class Selectable {
return false;
}
+ // TODO: Clean this up
getFocusableNeighbor(direction: Direction): Selectable | undefined {
const focusIndex = get(this.focusIndex);
+ const isGrid = this.gridColumns > 0;
+
const canCycleSiblings =
(this.direction === 'vertical' &&
((direction === 'up' && focusIndex !== 0) ||
(direction === 'down' && focusIndex !== this.children.length - 1))) ||
(this.direction === 'horizontal' &&
((direction === 'left' && focusIndex !== 0) ||
- (direction === 'right' && focusIndex !== this.children.length - 1)));
+ (direction === 'right' && focusIndex !== this.children.length - 1))) ||
+ (isGrid &&
+ this.direction === 'horizontal' &&
+ ((direction === 'up' && focusIndex >= this.gridColumns) ||
+ (direction === 'down' && focusIndex < this.children.length - this.gridColumns)));
if (this.children.length > 0 && canCycleSiblings) {
+ if (isGrid && direction === 'up') {
+ let index = focusIndex - this.gridColumns;
+ while (index >= 0) {
+ if (this.children[index]?.isFocusable()) {
+ return this.children[index];
+ }
+ index -= this.gridColumns;
+ }
+ } else if (isGrid && direction === 'down') {
+ let index = focusIndex + this.gridColumns;
+ while (index < this.children.length) {
+ if (this.children[index]?.isFocusable()) {
+ return this.children[index];
+ }
+ index += this.gridColumns;
+ }
+ }
+
if (direction === 'up' || direction === 'left') {
let index = focusIndex - 1;
while (index >= 0) {
@@ -350,6 +376,15 @@ export class Selectable {
this.isActive = isActive;
return this;
}
+
+ setGridColumns(columns: number) {
+ this.gridColumns = columns;
+ return this;
+ }
+
+ getGridColumns() {
+ return this.gridColumns;
+ }
}
export function handleKeyboardNavigation(event: KeyboardEvent) {
@@ -366,8 +401,6 @@ export function handleKeyboardNavigation(event: KeyboardEvent) {
return;
}
- // console.log('Currently focused object: ', currentlyFocusedObject.name, currentlyFocusedObject);
-
const navigationActions = currentlyFocusedObject.getNavigationActions();
if (event.key === 'ArrowUp') {
if (navigationActions.up && navigationActions.up(currentlyFocusedObject))