Files
MediaCollectorLibary/resources/views/games/index.twig
Lars Behrends 1b053148f0 xbvr sync
2025-11-14 02:42:44 +01:00

747 lines
48 KiB
Twig

{% extends "layouts/app.twig" %}
{% block nav_controls %}
<!-- Search form -->
<form method="GET" class="flex gap-2">
<input type="hidden" name="view" value="{{ view_mode }}">
<input type="hidden" name="per_page" value="{{ pagination.per_page }}">
{% for genre in filters.genres %}
<input type="hidden" name="genres[]" value="{{ genre }}">
{% endfor %}
{% for platform in filters.platforms %}
<input type="hidden" name="platforms[]" value="{{ platform }}">
{% endfor %}
{% for feature in filters.features %}
<input type="hidden" name="features[]" value="{{ feature }}">
{% endfor %}
{% if filters.playtime %}
<input type="hidden" name="playtime" value="{{ filters.playtime }}">
{% endif %}
</form>
<!-- Enhanced View mode switcher -->
<div class="flex gap-1 bg-gray-100 rounded-lg p-1" role="group">
{% for mode in view_modes %}
<a
href="?view={{ mode }}{% if search %}&search={{ search }}{% endif %}{% if pagination.per_page != 24 %}&per_page={{ pagination.per_page }}{% endif %}{% for genre in filters.genres %}&genres[]={{ genre }}{% endfor %}{% for platform in filters.platforms %}&platforms[]={{ platform }}{% endfor %}{% for feature in filters.features %}&features[]={{ feature }}{% endfor %}{% if filters.playtime %}&playtime={{ filters.playtime }}{% endif %}"
class="inline-flex items-center px-3 py-2 text-sm font-medium rounded-md transition-all duration-200 {{ view_mode == mode ? 'bg-white text-blue-600 shadow-sm' : 'text-gray-600 hover:text-gray-900 hover:bg-gray-200' }}"
title="{{ mode|title }} View"
>
{% if mode == 'grid' %}
<svg class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2H6a2 2 0 01-2-2V6zM14 6a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2h-2a2 2 0 01-2-2V6zM4 16a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2H6a2 2 0 01-2-2v-2zM14 16a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2h-2a2 2 0 01-2-2v-2z"/>
</svg>
{% endif %}
{% if mode == 'list' %}
<svg class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 10h16M4 14h16M4 18h16"/>
</svg>
{% endif %}
{% if mode == 'covers' %}
<svg class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"/>
</svg>
{% endif %}
<span class="hidden sm:inline ml-1">{{ mode|title }}</span>
</a>
{% endfor %}
</div>
<!-- Genre filter -->
{% if available_filters.genres %}
<div class="relative gap-1 bg-gray-100 rounded-lg p-1" x-data="{ open: false }">
<button @click="open = !open" class="inline-flex items-center px-3 py-2 text-sm font-medium rounded-md transition-all duration-200 text-gray-600 hover:text-gray-900 hover:bg-gray-200">
<svg class="mr-1 h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 7h.01M7 3h5c.512 0 1.024.195 1.414.586l7 7a2 2 0 010 2.828l-7 7a.997.997 0 01-1.414 0l-7-7A1.994 1.994 0 013 12V7a4 4 0 014-4z"/>
</svg>
<span class="hidden sm:inline">Genre</span>
{% if filters.genres %}
<span class="ml-1 bg-blue-600 text-white text-xs px-1 rounded">{{ filters.genres|length }}</span>
{% endif %}
</button>
<div x-show="open" @click.away="open = false" class="absolute right-0 z-50 mt-2 w-64 bg-white rounded-md shadow-lg ring-1 ring-black ring-opacity-5 max-h-64 overflow-y-auto">
<div class="py-1">
<form method="GET" class="px-4 py-2">
<input type="hidden" name="view" value="{{ view_mode }}">
<input type="hidden" name="per_page" value="{{ pagination.per_page }}">
<input type="hidden" name="search" value="{{ search }}">
{% for platform in filters.platforms %}
<input type="hidden" name="platforms[]" value="{{ platform }}">
{% endfor %}
{% for feature in filters.features %}
<input type="hidden" name="features[]" value="{{ feature }}">
{% endfor %}
{% if filters.playtime %}
<input type="hidden" name="playtime" value="{{ filters.playtime }}">
{% endif %}
<div class="space-y-2">
{% for genre in available_filters.genres %}
<label class="flex items-center">
<input type="checkbox" name="genres[]" value="{{ genre }}" {{ genre in filters.genres ? 'checked' : '' }} class="rounded border-gray-300 text-blue-600 focus:ring-blue-500">
<span class="ml-2 text-sm text-gray-700">{{ genre }}</span>
</label>
{% endfor %}
</div>
<div class="mt-3 pt-2 border-t border-gray-200">
<button type="submit" class="w-full bg-blue-600 text-white px-3 py-2 rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 text-sm">
Apply Genres
</button>
</div>
</form>
</div>
</div>
</div>
{% endif %}
<!-- Feature filter -->
{% if available_filters.features %}
<div class="relative gap-1 bg-gray-100 rounded-lg p-1" x-data="{ open: false }">
<button @click="open = !open" class="inline-flex items-center px-3 py-2 text-sm font-medium rounded-md transition-all duration-200 text-gray-600 hover:text-gray-900 hover:bg-gray-200">
<svg class="mr-1 h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"/>
</svg>
<span class="hidden sm:inline">Features</span>
{% if filters.features %}
<span class="ml-1 bg-green-600 text-white text-xs px-1 rounded">{{ filters.features|length }}</span>
{% endif %}
</button>
<div x-show="open" @click.away="open = false" class="absolute right-0 z-50 mt-2 w-64 bg-white rounded-md shadow-lg ring-1 ring-black ring-opacity-5 max-h-64 overflow-y-auto">
<div class="py-1">
<form method="GET" class="px-4 py-2">
<input type="hidden" name="view" value="{{ view_mode }}">
<input type="hidden" name="per_page" value="{{ pagination.per_page }}">
<input type="hidden" name="search" value="{{ search }}">
{% for genre in filters.genres %}
<input type="hidden" name="genres[]" value="{{ genre }}">
{% endfor %}
{% for platform in filters.platforms %}
<input type="hidden" name="platforms[]" value="{{ platform }}">
{% endfor %}
{% if filters.playtime %}
<input type="hidden" name="playtime" value="{{ filters.playtime }}">
{% endif %}
<div class="space-y-2">
{% for feature in available_filters.features %}
<label class="flex items-center">
<input type="checkbox" name="features[]" value="{{ feature }}" {{ feature in filters.features ? 'checked' : '' }} class="rounded border-gray-300 text-blue-600 focus:ring-blue-500">
<span class="ml-2 text-sm text-gray-700">{{ feature }}</span>
</label>
{% endfor %}
</div>
<div class="mt-3 pt-2 border-t border-gray-200">
<button type="submit" class="w-full bg-blue-600 text-white px-3 py-2 rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 text-sm">
Apply Features
</button>
</div>
</form>
</div>
</div>
</div>
{% endif %}
<!-- Size slider -->
<div class="flex items-center gap-2 bg-gray-100 rounded-lg px-3 py-2" x-data="{
size: localStorage.getItem('gameCardSize') || 'medium',
sizes: {
small: { label: 'S', cols: 'grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6', scale: 'scale-90' },
medium: { label: 'M', cols: 'grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4', scale: 'scale-100' },
large: { label: 'L', cols: 'grid-cols-1 md:grid-cols-2 lg:grid-cols-3', scale: 'scale-110' },
xlarge: { label: 'XL', cols: 'grid-cols-1 md:grid-cols-2', scale: 'scale-125' }
},
updateSize(newSize) {
this.size = newSize;
localStorage.setItem('gameCardSize', newSize);
// Dispatch custom event to update grid
window.dispatchEvent(new CustomEvent('gameCardSizeChanged', { detail: { sizeKey: newSize, sizeData: this.sizes[newSize] } }));
}
}" @mounted="updateSize(size)">
<svg class="h-4 w-4 text-gray-600" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4"/>
</svg>
<span class="text-xs font-medium text-gray-600 hidden sm:inline mr-1">Size:</span>
<div class="flex items-center gap-1">
<template x-for="(sizeData, sizeKey) in sizes" :key="sizeKey">
<button
@click="updateSize(sizeKey)"
:class="size === sizeKey ? 'bg-blue-600 text-white shadow-sm' : 'text-gray-600 hover:text-gray-900 hover:bg-gray-200'"
class="px-2 py-1 text-xs font-medium rounded transition-all duration-200"
:title="'Set card size to ' + sizeKey"
>
<span x-text="sizeData.label"></span>
</button>
</template>
</div>
</div>
<!-- Sort dropdown -->
<div class="relative gap-1 bg-gray-100 rounded-lg p-1" x-data="{ open: false }">
<button @click="open = !open" class="inline-flex items-center px-3 py-2 text-sm font-medium rounded-md transition-all duration-200 {{ view_mode == mode ? 'bg-white text-blue-600 shadow-sm' : 'text-gray-600 hover:text-gray-900 hover:bg-gray-200' }}">
<svg class="mr-1 h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 4h14M3 8h9m-9 4h6m4 0l4-4m0 0l4 4m-4-4v12"/>
</svg>
<span class="hidden sm:inline">Sort</span>
</button>
<div x-show="open" @click.away="open = false" class="absolute right-0 z-50 mt-2 w-56 bg-white rounded-md shadow-lg ring-1 ring-black ring-opacity-5">
<div class="py-1">
{% for key, label in sort_options %}
<a class="flex items-center justify-between px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 {{ sort == key ? 'bg-gray-50' : '' }}"
href="?sort={{ key }}&view={{ view_mode }}{% if search %}&search={{ search }}{% endif %}{% if pagination.per_page != 24 %}&per_page={{ pagination.per_page }}{% endif %}{% for genre in filters.genres %}&genres[]={{ genre }}{% endfor %}{% for platform in filters.platforms %}&platforms[]={{ platform }}{% endfor %}{% for feature in filters.features %}&features[]={{ feature }}{% endfor %}{% if filters.playtime %}&playtime={{ filters.playtime }}{% endif %}">
{{ label }}
{% if sort == key %}
<svg class="h-4 w-4 text-blue-600" fill="currentColor" viewBox="0 0 16 16">
<path d="M12.5 15a.5.5 0 0 1-.5-.5v-13a.5.5 0 0 1 1 0v13a.5.5 0 0 1-.5.5zM10 8a.5.5 0 0 1-.5.5H3.707l2.147 2.146a.5.5 0 0 1-.708.708l-3-3a.5.5 0 0 1 0-.708l3-3a.5.5 0 1 1 .708.708L3.707 7.5H9.5a.5.5 0 0 1 .5.5z"/>
</svg>
{% endif %}
</a>
{% endfor %}
</div>
</div>
</div>
{% endblock %}
{% block sidebar %}
<div class="space-y-4">
<!-- Filters -->
<div class="bg-gray-50 rounded-lg p-4">
<h3 class="text-sm font-medium text-gray-900 mb-4">Filters</h3>
<!-- Filter form -->
<form method="GET" id="filterForm">
<input type="hidden" name="view" value="{{ view_mode }}">
<input type="hidden" name="per_page" value="{{ pagination.per_page }}">
<input type="hidden" name="search" value="{{ search }}">
<!-- Genre filter -->
{% if available_filters.genres %}
<div class="mb-4">
<label class="block text-xs font-medium text-gray-700 mb-1">Genres</label>
<select class="select2 w-full text-sm border border-gray-300 rounded focus:ring-blue-500 focus:border-blue-500" name="genres[]" multiple data-placeholder="Select genres...">
{% for genre in available_filters.genres %}
<option value="{{ genre }}" {{ genre in filters.genres ? 'selected' : '' }}>
{{ genre }}
</option>
{% endfor %}
</select>
</div>
{% endif %}
<!-- Platform filter -->
{% if available_filters.platforms %}
<div class="mb-4">
<label class="block text-xs font-medium text-gray-700 mb-1">Platforms</label>
<select class="select2 w-full text-sm border border-gray-300 rounded focus:ring-blue-500 focus:border-blue-500" name="platforms[]" multiple data-placeholder="Select platforms...">
{% for platform in available_filters.platforms %}
<option value="{{ platform }}" {{ platform in filters.platforms ? 'selected' : '' }}>
{{ platform }}
</option>
{% endfor %}
</select>
</div>
{% endif %}
<!-- Features filter -->
{% if available_filters.features %}
<div class="mb-4">
<label class="block text-xs font-medium text-gray-700 mb-1">Features</label>
<select class="select2 w-full text-sm border border-gray-300 rounded focus:ring-blue-500 focus:border-blue-500" name="features[]" multiple data-placeholder="Select features...">
{% for feature in available_filters.features %}
<option value="{{ feature }}" {{ feature in filters.features ? 'selected' : '' }}>
{{ feature }}
</option>
{% endfor %}
</select>
</div>
{% endif %}
<!-- Playtime filter -->
<div class="mb-4">
<label class="block text-xs font-medium text-gray-700 mb-1">Playtime</label>
<select class="w-full text-sm border border-gray-300 rounded focus:ring-blue-500 focus:border-blue-500" name="playtime">
<option value="">All games</option>
<option value="none" {{ filters.playtime == 'none' ? 'selected' : '' }}>No playtime</option>
<option value="under_1h" {{ filters.playtime == 'under_1h' ? 'selected' : '' }}>Under 1 hour</option>
<option value="1h_5h" {{ filters.playtime == '1h_5h' ? 'selected' : '' }}>1-5 hours</option>
<option value="5h_10h" {{ filters.playtime == '5h_10h' ? 'selected' : '' }}>5-10 hours</option>
<option value="10h_20h" {{ filters.playtime == '10h_20h' ? 'selected' : '' }}>10-20 hours</option>
<option value="over_20h" {{ filters.playtime == 'over_20h' ? 'selected' : '' }}>Over 20 hours</option>
</select>
</div>
<!-- Filter actions -->
<div class="space-y-2">
<button type="submit" class="w-full bg-blue-600 text-white px-3 py-2 rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 text-sm">
Apply Filters
</button>
<a href="{{ path_for('games.index') }}" class="w-full bg-gray-100 text-gray-700 px-3 py-2 rounded-md hover:bg-gray-200 focus:outline-none focus:ring-2 focus:ring-gray-500 focus:ring-offset-2 block text-center text-sm">
Clear All
</a>
</div>
</form>
</div>
<!-- Active Filters Summary -->
{% if filters.genres or filters.platforms or filters.features or filters.playtime or search %}
<div class="bg-blue-50 rounded-lg p-4">
<h3 class="text-sm font-medium text-gray-900 mb-3">Active Filters</h3>
<div class="space-y-2">
{% if search %}
<div class="flex items-center justify-between">
<span class="text-sm text-gray-600">Search: "{{ search }}"</span>
<a href="?{% if pagination.per_page != 24 %}per_page={{ pagination.per_page }}&{% endif %}view={{ view_mode }}{% for genre in filters.genres %}&genres[]={{ genre }}{% endfor %}{% for platform in filters.platforms %}&platforms[]={{ platform }}{% endfor %}{% for feature in filters.features %}&features[]={{ feature }}{% endfor %}{% if filters.playtime %}&playtime={{ filters.playtime }}{% endif %}" class="text-blue-600 hover:text-blue-800">
<svg class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
</svg>
</a>
</div>
{% endif %}
{% for genre in filters.genres %}
<div class="flex items-center justify-between">
<span class="text-sm text-gray-600">Genre: {{ genre }}</span>
<a href="?{% if search %}search={{ search }}&{% endif %}{% if pagination.per_page != 24 %}per_page={{ pagination.per_page }}&{% endif %}view={{ view_mode }}{% for g in filters.genres %}{% if g != genre %}&genres[]={{ g }}{% endif %}{% endfor %}{% for platform in filters.platforms %}&platforms[]={{ platform }}{% endfor %}{% for feature in filters.features %}&features[]={{ feature }}{% endfor %}{% if filters.playtime %}&playtime={{ filters.playtime }}{% endif %}" class="text-blue-600 hover:text-blue-800">
<svg class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
</svg>
</a>
</div>
{% endfor %}
{% for platform in filters.platforms %}
<div class="flex items-center justify-between">
<span class="text-sm text-gray-600">Platform: {{ platform }}</span>
<a href="?{% if search %}search={{ search }}&{% endif %}{% if pagination.per_page != 24 %}per_page={{ pagination.per_page }}&{% endif %}view={{ view_mode }}{% for genre in filters.genres %}&genres[]={{ genre }}{% endfor %}{% for p in filters.platforms %}{% if p != platform %}&platforms[]={{ p }}{% endif %}{% endfor %}{% for feature in filters.features %}&features[]={{ feature }}{% endfor %}{% if filters.playtime %}&playtime={{ filters.playtime }}{% endif %}" class="text-blue-600 hover:text-blue-800">
<svg class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
</svg>
</a>
</div>
{% endfor %}
{% for feature in filters.features %}
<div class="flex items-center justify-between">
<span class="text-sm text-gray-600">Feature: {{ feature }}</span>
<a href="?{% if search %}search={{ search }}&{% endif %}{% if pagination.per_page != 24 %}per_page={{ pagination.per_page }}&{% endif %}view={{ view_mode }}{% for genre in filters.genres %}&genres[]={{ genre }}{% endfor %}{% for platform in filters.platforms %}&platforms[]={{ platform }}{% endfor %}{% for f in filters.features %}{% if f != feature %}&features[]={{ f }}{% endif %}{% endfor %}{% if filters.playtime %}&playtime={{ filters.playtime }}{% endif %}" class="text-blue-600 hover:text-blue-800">
<svg class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
</svg>
</a>
</div>
{% endfor %}
{% if filters.playtime %}
<div class="flex items-center justify-between">
<span class="text-sm text-gray-600">Playtime: {% if filters.playtime == 'none' %}No playtime{% elseif filters.playtime == 'under_1h' %}Under 1 hour{% elseif filters.playtime == '1h_5h' %}1-5 hours{% elseif filters.playtime == '5h_10h' %}5-10 hours{% elseif filters.playtime == '10h_20h' %}10-20 hours{% elseif filters.playtime == 'over_20h' %}Over 20 hours{% endif %}</span>
<a href="?{% if search %}search={{ search }}&{% endif %}{% if pagination.per_page != 24 %}per_page={{ pagination.per_page }}&{% endif %}view={{ view_mode }}{% for genre in filters.genres %}&genres[]={{ genre }}{% endfor %}{% for platform in filters.platforms %}&platforms[]={{ platform }}{% endfor %}{% for feature in filters.features %}&features[]={{ feature }}{% endfor %}" class="text-blue-600 hover:text-blue-800">
<svg class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
</svg>
</a>
</div>
{% endif %}
</div>
</div>
{% endif %}
<!-- Quick Stats -->
<div class="bg-gray-50 rounded-lg p-4">
<h3 class="text-sm font-medium text-gray-900 mb-3">Quick Stats</h3>
<div class="space-y-2">
<div class="flex justify-between text-sm">
<span class="text-gray-600">Total Games</span>
<span class="font-medium text-gray-900">{{ pagination.total_items }}</span>
</div>
<div class="flex justify-between text-sm">
<span class="text-gray-600">This Page</span>
<span class="font-medium text-gray-900">{{ games|length }}</span>
</div>
{% if pagination.total_pages > 1 %}
<div class="flex justify-between text-sm">
<span class="text-gray-600">Page</span>
<span class="font-medium text-gray-900">{{ pagination.current_page }} of {{ pagination.total_pages }}</span>
</div>
{% endif %}
</div>
</div>
</div>
{% endblock %}
{% block content %}
<!-- Main content area -->
<div class="min-h-screen bg-gradient-to-br from-slate-50 via-blue-50 to-indigo-50">
<div class="p-6">
<!-- Header -->
<div class="mb-8">
<div class="flex items-center justify-between">
<div>
<h1 class="text-4xl font-bold bg-gradient-to-r from-slate-900 via-blue-900 to-indigo-900 bg-clip-text text-transparent">Games Library</h1>
{% if pagination.total_items > 0 %}
<div class="text-slate-600 text-sm mt-2 flex items-center gap-2">
<svg class="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"/>
</svg>
{{ pagination.total_items }} games from {{ games|reduce((carry, game) => carry + game.platform_count, 0) }} platforms
{% if search %}
<span class="inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-blue-100 text-blue-800">
<svg class="w-3 h-3 mr-1" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"/>
</svg>
"{{ search }}"
</span>
{% endif %}
</div>
{% endif %}
</div>
{% if pagination.total_items > 0 %}
<div class="flex flex-wrap gap-2">
{% if filters.genres %}
<span class="inline-flex items-center px-3 py-1 rounded-full text-xs font-medium bg-gradient-to-r from-blue-500 to-blue-600 text-white shadow-sm">
<svg class="w-3 h-3 mr-1" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 7h.01M7 3h5c.512 0 1.024.195 1.414.586l7 7a2 2 0 010 2.828l-7 7a.997.997 0 01-1.414 0l-7-7A1.994 1.994 0 013 12V7a4 4 0 014-4z"/>
</svg>
{{ filters.genres|join(', ') }}
</span>
{% endif %}
{% if filters.platforms %}
<span class="inline-flex items-center px-3 py-1 rounded-full text-xs font-medium bg-gradient-to-r from-gray-500 to-gray-600 text-white shadow-sm">
<svg class="w-3 h-3 mr-1" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9.75 17L9 20l-1 1h8l-1-1-.75-3M3 13h18M5 17h14a2 2 0 002-2V5a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"/>
</svg>
{{ filters.platforms|join(', ') }}
</span>
{% endif %}
{% if filters.features %}
<span class="inline-flex items-center px-3 py-1 rounded-full text-xs font-medium bg-gradient-to-r from-green-500 to-green-600 text-white shadow-sm">
<svg class="w-3 h-3 mr-1" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"/>
</svg>
{{ filters.features|join(', ') }}
</span>
{% endif %}
{% if filters.playtime %}
<span class="inline-flex items-center px-3 py-1 rounded-full text-xs font-medium bg-gradient-to-r from-purple-500 to-purple-600 text-white shadow-sm">
<svg class="w-3 h-3 mr-1" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"/>
</svg>
{% if filters.playtime == 'none' %}No playtime{% elseif filters.playtime == 'under_1h' %}Under 1h{% elseif filters.playtime == '1h_5h' %}1-5h{% elseif filters.playtime == '5h_10h' %}5-10h{% elseif filters.playtime == '10h_20h' %}10-20h{% elseif filters.playtime == 'over_20h' %}20h+{% endif %}
</span>
{% endif %}
</div>
{% endif %}
</div>
</div>
{% if games is empty %}
<!-- Enhanced empty state -->
<div class="flex flex-col items-center justify-center py-16 px-4">
<div class="relative mb-8">
<!-- Animated background circles -->
<div class="absolute inset-0 flex items-center justify-center">
<div class="w-32 h-32 bg-gradient-to-br from-blue-100 to-indigo-100 rounded-full animate-pulse"></div>
<div class="absolute w-24 h-24 bg-gradient-to-br from-indigo-100 to-purple-100 rounded-full animate-pulse animation-delay-1000"></div>
<div class="absolute w-16 h-16 bg-gradient-to-br from-purple-100 to-pink-100 rounded-full animate-pulse animation-delay-2000"></div>
</div>
<!-- Main icon -->
<div class="relative bg-white rounded-2xl shadow-xl p-8 border border-gray-100">
<svg class="w-20 h-20 text-slate-400 mx-auto" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M14.828 14.828a4 4 0 01-5.656 0M9 10h1m4 0h1m-7 8h12a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z"/>
</svg>
</div>
</div>
<div class="text-center max-w-md">
<h3 class="text-2xl font-bold text-gray-900 mb-3">
{% if search or filters.genres or filters.platforms or filters.features or filters.playtime %}
No games found
{% else %}
Your library is empty
{% endif %}
</h3>
<p class="text-slate-600 text-lg mb-8 leading-relaxed">
{% if search or filters.genres or filters.platforms or filters.features or filters.playtime %}
We couldn't find any games matching your current search and filter criteria. Try adjusting your filters or search terms to discover more games.
{% else %}
Start building your gaming library by syncing with Playnite or other gaming platforms. Your games will appear here once synced.
{% endif %}
</p>
<div class="flex flex-col sm:flex-row gap-4 justify-center">
{% if search or filters.genres or filters.platforms or filters.features or filters.playtime %}
<a href="{{ path_for('games.index') }}"
class="inline-flex items-center px-6 py-3 bg-gradient-to-r from-blue-600 to-blue-700 text-white font-semibold rounded-xl hover:from-blue-700 hover:to-blue-800 transition-all duration-200 shadow-lg hover:shadow-xl transform hover:-translate-y-0.5">
<svg class="w-5 h-5 mr-2" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"/>
</svg>
Clear Filters
</a>
{% else %}
<a href="{{ path_for('admin.index') }}"
class="inline-flex items-center px-6 py-3 bg-gradient-to-r from-indigo-600 to-purple-600 text-white font-semibold rounded-xl hover:from-indigo-700 hover:to-purple-700 transition-all duration-200 shadow-lg hover:shadow-xl transform hover:-translate-y-0.5">
<svg class="w-5 h-5 mr-2" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"/>
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"/>
</svg>
Setup Sync
</a>
{% endif %}
<a href="{{ path_for('search.index') }}"
class="inline-flex items-center px-6 py-3 bg-white text-gray-700 font-semibold rounded-xl border-2 border-gray-200 hover:border-gray-300 hover:bg-gray-50 transition-all duration-200 shadow-sm hover:shadow-md">
<svg class="w-5 h-5 mr-2" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"/>
</svg>
Search All Media
</a>
</div>
<!-- Additional help text -->
{% if not (search or filters.genres or filters.platforms or filters.features or filters.playtime) %}
<div class="mt-8 p-4 bg-blue-50 rounded-lg border border-blue-200">
<div class="flex items-start">
<svg class="w-5 h-5 text-blue-600 mt-0.5 mr-3 flex-shrink-0" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"/>
</svg>
<div class="text-left">
<p class="text-sm font-medium text-blue-900 mb-1">Need help getting started?</p>
<p class="text-sm text-blue-700">Check out the Playnite plugin documentation or contact support for assistance with syncing your gaming libraries.</p>
</div>
</div>
</div>
{% endif %}
</div>
</div>
{% else %}
<!-- Games content based on view mode -->
{% if view_mode == 'list' %}
<!-- Enhanced list view using component -->
<div class="bg-white rounded-xl shadow-lg border border-gray-100 overflow-hidden">
<ul class="divide-y divide-gray-100">
{% for game in games %}
{% include 'components/game-card.twig' with {'game': game, 'view_mode': 'list'} %}
{% endfor %}
</ul>
</div>
{% elseif view_mode == 'covers' %}
<!-- Enhanced cover grid view using component with dynamic sizing -->
<div
class="grid gap-6 transition-all duration-300"
x-data="{
currentSize: localStorage.getItem('gameCardSize') || 'medium',
sizeClasses: {
small: 'grid-cols-3 sm:grid-cols-4 md:grid-cols-5 lg:grid-cols-6 xl:grid-cols-8',
medium: 'grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6',
large: 'grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5',
xlarge: 'grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4'
}
}"
:class="sizeClasses[currentSize]"
x-init="
window.addEventListener('gameCardSizeChanged', (e) => {
currentSize = e.detail.sizeKey;
});
// Set initial class
$el.classList.add(...sizeClasses[currentSize].split(' '));
"
>
{% for game in games %}
{% include 'components/game-card.twig' with {'game': game, 'view_mode': 'covers'} %}
{% endfor %}
</div>
{% else %}
<!-- Enhanced grid view using component with dynamic sizing -->
<div
class="grid gap-6 transition-all duration-300"
x-data="{
currentSize: localStorage.getItem('gameCardSize') || 'medium',
sizeClasses: {
small: 'grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6',
medium: 'grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4',
large: 'grid-cols-1 md:grid-cols-2 lg:grid-cols-3',
xlarge: 'grid-cols-1 md:grid-cols-2'
}
}"
:class="sizeClasses[currentSize]"
x-init="
window.addEventListener('gameCardSizeChanged', (e) => {
currentSize = e.detail.sizeKey;
});
// Set initial class
$el.classList.add(...sizeClasses[currentSize].split(' '));
"
>
{% for game in games %}
{% include 'components/game-card.twig' with {'game': game, 'view_mode': 'grid'} %}
{% endfor %}
</div>
{% endif %}
<!-- Top Pagination & Controls -->
{% if pagination.total_pages > 1 %}
<div class="flex items-center justify-between mb-6 p-4 bg-gray-50 rounded-lg">
<div class="flex items-center gap-4">
<div class="text-sm text-gray-700">
Showing {{ (pagination.current_page - 1) * pagination.per_page + 1 }} to {{ min(pagination.current_page * pagination.per_page, pagination.total_items) }} of {{ pagination.total_items }} games
</div>
<div class="flex items-center gap-2">
<label for="per_page_top" class="text-sm font-medium text-gray-700">Show:</label>
<select id="per_page_top" class="text-sm border border-gray-300 rounded px-2 py-1 focus:ring-blue-500 focus:border-blue-500">
<option value="12" {{ pagination.per_page == 12 ? 'selected' : '' }}>12</option>
<option value="24" {{ pagination.per_page == 24 ? 'selected' : '' }}>24</option>
<option value="48" {{ pagination.per_page == 48 ? 'selected' : '' }}>48</option>
<option value="100" {{ pagination.per_page == 100 ? 'selected' : '' }}>100</option>
</select>
<span class="text-sm text-gray-600">per page</span>
</div>
</div>
<div class="flex items-center space-x-2">
<!-- Previous Button -->
{% if pagination.has_prev %}
<a href="?page={{ pagination.prev_page }}{% if search %}&search={{ search }}{% endif %}{% if pagination.per_page != 24 %}&per_page={{ pagination.per_page }}{% endif %}&view={{ view_mode }}{% for genre in filters.genres %}&genres[]={{ genre }}{% endfor %}{% for platform in filters.platforms %}&platforms[]={{ platform }}{% endfor %}{% for feature in filters.features %}&features[]={{ feature }}{% endfor %}{% if filters.playtime %}&playtime={{ filters.playtime }}{% endif %}"
class="px-3 py-2 text-sm font-medium text-gray-500 bg-white border border-gray-300 rounded-lg hover:bg-gray-50 hover:text-gray-700 transition-colors flex items-center">
<svg class="w-4 h-4 mr-1" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7"/>
</svg>
Previous
</a>
{% else %}
<span class="px-3 py-2 text-sm font-medium text-gray-300 bg-gray-100 border border-gray-200 rounded-lg cursor-not-allowed flex items-center">
<svg class="w-4 h-4 mr-1" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7"/>
</svg>
Previous
</span>
{% endif %}
<!-- Page Numbers -->
{% set start_page = max(1, pagination.current_page - 2) %}
{% set end_page = min(pagination.total_pages, pagination.current_page + 2) %}
{% if start_page > 1 %}
<a href="?page=1{% if search %}&search={{ search }}{% endif %}{% if pagination.per_page != 24 %}&per_page={{ pagination.per_page }}{% endif %}&view={{ view_mode }}{% for genre in filters.genres %}&genres[]={{ genre }}{% endfor %}{% for platform in filters.platforms %}&platforms[]={{ platform }}{% endfor %}{% for feature in filters.features %}&features[]={{ feature }}{% endfor %}{% if filters.playtime %}&playtime={{ filters.playtime }}{% endif %}"
class="px-3 py-2 text-sm font-medium text-gray-500 bg-white border border-gray-300 rounded-lg hover:bg-gray-50 hover:text-gray-700 transition-colors">1</a>
{% if start_page > 2 %}
<span class="px-2 py-2 text-sm font-medium text-gray-500">...</span>
{% endif %}
{% endif %}
{% for page_num in start_page..end_page %}
{% if page_num == pagination.current_page %}
<span class="px-3 py-2 text-sm font-medium text-white bg-blue-600 border border-blue-600 rounded-lg">{{ page_num }}</span>
{% else %}
<a href="?page={{ page_num }}{% if search %}&search={{ search }}{% endif %}{% if pagination.per_page != 24 %}&per_page={{ pagination.per_page }}{% endif %}&view={{ view_mode }}{% for genre in filters.genres %}&genres[]={{ genre }}{% endfor %}{% for platform in filters.platforms %}&platforms[]={{ platform }}{% endfor %}{% for feature in filters.features %}&features[]={{ feature }}{% endfor %}{% if filters.playtime %}&playtime={{ filters.playtime }}{% endif %}"
class="px-3 py-2 text-sm font-medium text-gray-500 bg-white border border-gray-300 rounded-lg hover:bg-gray-50 hover:text-gray-700 transition-colors">{{ page_num }}</a>
{% endif %}
{% endfor %}
{% if end_page < pagination.total_pages %}
{% if end_page < pagination.total_pages - 1 %}
<span class="px-2 py-2 text-sm font-medium text-gray-500">...</span>
{% endif %}
<a href="?page={{ pagination.total_pages }}{% if search %}&search={{ search }}{% endif %}{% if pagination.per_page != 24 %}&per_page={{ pagination.per_page }}{% endif %}&view={{ view_mode }}{% for genre in filters.genres %}&genres[]={{ genre }}{% endfor %}{% for platform in filters.platforms %}&platforms[]={{ platform }}{% endfor %}{% for feature in filters.features %}&features[]={{ feature }}{% endfor %}{% if filters.playtime %}&playtime={{ filters.playtime }}{% endif %}"
class="px-3 py-2 text-sm font-medium text-gray-500 bg-white border border-gray-300 rounded-lg hover:bg-gray-50 hover:text-gray-700 transition-colors">{{ pagination.total_pages }}</a>
{% endif %}
<!-- Next Button -->
{% if pagination.has_next %}
<a href="?page={{ pagination.next_page }}{% if search %}&search={{ search }}{% endif %}{% if pagination.per_page != 24 %}&per_page={{ pagination.per_page }}{% endif %}&view={{ view_mode }}{% for genre in filters.genres %}&genres[]={{ genre }}{% endfor %}{% for platform in filters.platforms %}&platforms[]={{ platform }}{% endfor %}{% for feature in filters.features %}&features[]={{ feature }}{% endfor %}{% if filters.playtime %}&playtime={{ filters.playtime }}{% endif %}"
class="px-3 py-2 text-sm font-medium text-gray-500 bg-white border border-gray-300 rounded-lg hover:bg-gray-50 hover:text-gray-700 transition-colors flex items-center">
Next
<svg class="w-4 h-4 ml-1" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7"/>
</svg>
</a>
{% else %}
<span class="px-3 py-2 text-sm font-medium text-gray-300 bg-gray-100 border border-gray-200 rounded-lg cursor-not-allowed flex items-center">
Next
<svg class="w-4 h-4 ml-1" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7"/>
</svg>
</span>
{% endif %}
</div>
</div>
{% endif %}
{% endif %}
</div>
</div>
</div>
</div>
<style>
/* Custom styles for Select2 integration */
.select2-container {
z-index: 1050; /* Ensure Select2 dropdown appears above other elements */
}
.select2-selection {
min-height: 38px;
}
.select2-selection__choice {
background-color: #0d6efd !important;
border: none !important;
color: white !important;
}
.select2-selection__choice__remove {
color: white !important;
margin-right: 5px;
}
.select2-selection__choice__remove:hover {
color: #f8f9fa !important;
}
/* Animation delays for empty state */
.animation-delay-1000 {
animation-delay: 1s;
}
.animation-delay-2000 {
animation-delay: 2s;
}
/* Line clamping utilities */
.line-clamp-2 {
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
}
</style>
<script>
$(document).ready(function() {
// Initialize Select2 for all select2 elements
$('.select2').select2({
width: '100%',
allowClear: true,
placeholder: function() {
return $(this).data('placeholder');
}
});
// Auto-submit filter form when Select2 selection changes
$('.select2').on('change', function() {
document.getElementById('filterForm').submit();
});
});
document.getElementById('per_page')?.addEventListener('change', function() {
const url = new URL(window.location);
url.searchParams.set('per_page', this.value);
url.searchParams.set('page', '1'); // Reset to first page
window.location = url.toString();
});
document.getElementById('per_page_top')?.addEventListener('change', function() {
const url = new URL(window.location);
url.searchParams.set('per_page', this.value);
url.searchParams.set('page', '1'); // Reset to first page
window.location = url.toString();
});
</script>
{% endblock %}