{% extends 'base.html.twig' %}
{% block title %}Pedir - Restaurante{% endblock %}
{% block body %}
<style>
#confirmation-message{
transition: opacity 0.5s ease;
}
/* Estilo general del contenedor */
.filter-container {
position: sticky;
z-index: 1000;
background: rgba(255, 255, 255, 0.1); /* Fondo transparente */
padding: 15px;
border-radius: 10px;
}
/* Título del dropdown con separador negro y flecha */
.filter-title {
background: none;
border: none;
font-size: 16px;
font-weight: bold;
cursor: pointer;
width: 100%;
text-align: left;
padding: 10px;
display: flex;
justify-content: space-between;
align-items: center;
border-bottom: 2px solid black; /* Línea separadora negra */
}
.filter-title:hover {
background: rgba(255, 255, 255, 0.1);
}
/* Icono de la flecha */
.filter-title .arrow {
transition: transform 0.3s ease;
}
/* Rango de precio */
.slider-container {
padding: 10px;
}
input[type="range"] {
width: 100%;
accent-color: red;
}
input[type="range"]::-webkit-slider-thumb {
background: black;
}
/* Checkboxes */
.checkbox-container {
padding: 10px;
}
.form-check-label {
margin-bottom: 10px;
}
.filter-container .btn-search{
border-start-end-radius: 30px;
border-end-end-radius: 30px;
background: white;
border: 0px;
}
/* Personalización del checkbox */
.category-checkbox {
appearance: none; /* Elimina el diseño predeterminado */
width: 18px;
height: 18px;
border: 2px solid #E63946; /* Borde rojo */
border-radius: 4px;
display: inline-block;
position: relative;
cursor: pointer;
}
/* Cuando está marcado, cambiar fondo y mostrar un check */
.category-checkbox:checked {
background-color: #E63946; /* Fondo rojo */
border: 2px solid #E63946;
}
/* Agregar un icono de check al marcar */
.category-checkbox:checked::after {
color: white;
font-size: 14px;
font-weight: bold;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
</style>
<body>
<!-- Header -->
{{ render(controller('App\\Controller\\HeaderController::index')) }}
<div class="container container-custom order-container mt-4">
<div id="confirmation-message" class="container alert alert-success d-none fixed-top" role="alert" style="margin-top: 90px">
¡Producto añadido al carrito correctamente!
</div>
<div class="row">
<div class="col-12 mb-3 title-block">
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a class="text-decoration-none section-title" href="/">Home</a></li>
{% if app.request.get('category') %}
{% set selectedCategoryId = app.request.get('category') %}
{% set selectedCategory = categories|filter(c => c.id == selectedCategoryId)|first %}
<li class="breadcrumb-item"><a class="text-decoration-none section-title" href="{{ path('app_order') }}">Productos</a></li>
{% if selectedCategory %}
<li class="breadcrumb-item active" aria-current="page">{{ selectedCategory.name }}</li>
{% endif %}
{% else %}
<li class="breadcrumb-item active" aria-current="page">Productos</li>
{% endif %}
</ol>
</nav>
<h1 class="section-title category-section my-4 ">Nuestros Productos</h1>
</div>
<!-- Productos -->
<div class="col-12 col-lg-12" style="min-height: 50vh">
<div class="row align-items-start" >
{% include "components/products.html.twig" with {'products': products} %}
</div>
</div>
</div>
</div>
{# Botón flotante para abrir el offcanvas de filtros #}
<button class="btn btn-primary rounded-circle position-fixed "
style="bottom: 20px; left: 20px; z-index: 1050; width: 50px; height: 50px;"
type="button"
data-bs-toggle="offcanvas"
data-bs-target="#filterOffcanvas"
aria-controls="filterOffcanvas">
<i class="bi bi-filter" style="font-size: 1.5rem;"></i>
</button>
{# Offcanvas que contendrá los filtros #}
<div class="offcanvas offcanvas-start" tabindex="-1" id="filterOffcanvas" aria-labelledby="filterOffcanvasLabel">
<div class="offcanvas-header">
<h5 class="offcanvas-title" id="filterOffcanvasLabel">Filtros</h5>
<button type="button" class="btn-close text-reset" data-bs-dismiss="offcanvas" aria-label="Close"></button>
</div>
<div class="offcanvas-body">
<div class="filter-container pt-0">
<form method="GET" action="{{ path('app_order') }}">
<button type="submit" class="btn btn-primary w-100 mb-3">Filtrar</button>
<!-- Filtro de Buscador -->
<button class="filter-title" data-bs-toggle="collapse" data-bs-target="#filter-search" aria-expanded="true" type="button">
Filtrar por Nombre <span class="arrow">▼</span>
</button>
<div id="filter-search" class="collapse show">
<div class="my-3 d-flex">
<div class="input-group input-group-lg">
<input type="search" name="search" class="form-control fs-6 bar-search" placeholder="Nombre..."
aria-label="Nombre" value="{{ app.request.get('search') }}">
</div>
</div>
</div>
<!-- Filtro de Precio -->
<button class="filter-title" data-bs-toggle="collapse" data-bs-target="#filter-price" aria-expanded="true" type="button">
Filtrar por Precio <span class="arrow">▼</span>
</button>
<div id="filter-price" class="collapse show">
<div class="slider-container">
<input type="range" name="price" min="0" max="{{ max_price }}" step="1" id="priceRange"
value="{{ app.request.get('price') ?: max_price }}">
<p class="fs-6">Precio: <span id="priceValue">{{ app.request.get('price') ?: max_price }}</span>€</p>
</div>
</div>
<!-- Filtro de Categorías -->
<button class="filter-title" data-bs-toggle="collapse" data-bs-target="#filter-category" aria-expanded="true" type="button">
Filtrar por Categorías <span class="arrow">▼</span>
</button>
<div id="filter-category" class="collapse show">
<div class="checkbox-container">
{% for category in categories %}
<div class="form-check">
<input class="form-check-input category-checkbox" type="checkbox" name="category" id="cat{{ category.id }}" value="{{ category.id }}"
{% if app.request.get('category') == category.id|trans %}checked{% endif %}>
<label class="form-check-label" for="cat{{ category.id }}">{{ category.name }}</label>
</div>
{% endfor %}
</div>
</div>
</form>
</div>
</div>
</div>
</body>
<script>
document.getElementById('priceRange').addEventListener('input', function() {
document.getElementById('priceValue').innerText = this.value;
});
</script>
<script>
document.addEventListener("DOMContentLoaded", function () {
const checkboxes = document.querySelectorAll(".category-checkbox");
checkboxes.forEach(checkbox => {
checkbox.addEventListener("click", function () {
if (this.checked) {
checkboxes.forEach(cb => {
if (cb !== this) cb.checked = false; // Desmarca los otros
});
}
});
});
});
</script>
{% endblock %}