templates/order/index.html.twig line 1

Open in your IDE?
  1. {% extends 'base.html.twig' %}
  2. {% block title %}Pedir - Restaurante{% endblock %}
  3. {% block body %}
  4. <style>
  5.     #confirmation-message{
  6.         transition: opacity 0.5s ease;
  7.     }
  8.     /* Estilo general del contenedor */
  9.     .filter-container {
  10.       position: sticky;
  11.       z-index: 1000;
  12.       background: rgba(255, 255, 255, 0.1); /* Fondo transparente */
  13.       padding: 15px;
  14.       border-radius: 10px;
  15.     }
  16.     /* Título del dropdown con separador negro y flecha */
  17.     .filter-title {
  18.       background: none;
  19.       border: none;
  20.       font-size: 16px;
  21.       font-weight: bold;
  22.       cursor: pointer;
  23.       width: 100%;
  24.       text-align: left;
  25.       padding: 10px;
  26.       display: flex;
  27.       justify-content: space-between;
  28.       align-items: center;
  29.       border-bottom: 2px solid black; /* Línea separadora negra */
  30.     }
  31.     .filter-title:hover {
  32.       background: rgba(255, 255, 255, 0.1);
  33.     }
  34.     /* Icono de la flecha */
  35.     .filter-title .arrow {
  36.       transition: transform 0.3s ease;
  37.     }
  38.     /* Rango de precio */
  39.     .slider-container {
  40.       padding: 10px;
  41.     }
  42.     input[type="range"] {
  43.       width: 100%;
  44.       accent-color: red;
  45.     }
  46.     input[type="range"]::-webkit-slider-thumb {
  47.       background: black;
  48.     }
  49.     /* Checkboxes */
  50.     .checkbox-container {
  51.       padding: 10px;
  52.     }
  53.     .form-check-label {
  54.         margin-bottom: 10px;
  55.     }
  56.     .filter-container .btn-search{
  57.         border-start-end-radius: 30px;
  58.         border-end-end-radius: 30px;
  59.         background: white;
  60.         border: 0px;
  61.     }
  62.     
  63.     /* Personalización del checkbox */
  64.     .category-checkbox {
  65.         appearance: none; /* Elimina el diseño predeterminado */
  66.         width: 18px;
  67.         height: 18px;
  68.         border: 2px solid #E63946; /* Borde rojo */
  69.         border-radius: 4px;
  70.         display: inline-block;
  71.         position: relative;
  72.         cursor: pointer;
  73.     }
  74.     /* Cuando está marcado, cambiar fondo y mostrar un check */
  75.     .category-checkbox:checked {
  76.         background-color: #E63946; /* Fondo rojo */
  77.         border: 2px solid #E63946;
  78.     }
  79.     /* Agregar un icono de check al marcar */
  80.     .category-checkbox:checked::after {
  81.         color: white;
  82.         font-size: 14px;
  83.         font-weight: bold;
  84.         position: absolute;
  85.         top: 50%;
  86.         left: 50%;
  87.         transform: translate(-50%, -50%);
  88.     }
  89.   </style>
  90. <body>
  91. <!-- Header -->
  92. {{ render(controller('App\\Controller\\HeaderController::index')) }}
  93. <div class="container container-custom order-container mt-4">
  94.     <div id="confirmation-message" class="container alert alert-success d-none fixed-top" role="alert" style="margin-top: 90px">
  95.         ¡Producto añadido al carrito correctamente!
  96.     </div>
  97.     <div class="row">
  98.         <div class="col-12 mb-3 title-block">
  99.             <nav aria-label="breadcrumb">
  100.                 <ol class="breadcrumb">
  101.                     <li class="breadcrumb-item"><a class="text-decoration-none section-title" href="/">Home</a></li>
  102.                     
  103.                     {% if app.request.get('category') %}
  104.                         {% set selectedCategoryId = app.request.get('category') %}
  105.                         {% set selectedCategory = categories|filter(c => c.id == selectedCategoryId)|first %}
  106.                         
  107.                         <li class="breadcrumb-item"><a class="text-decoration-none section-title" href="{{ path('app_order') }}">Productos</a></li>
  108.                         {% if selectedCategory %}
  109.                             <li class="breadcrumb-item active" aria-current="page">{{ selectedCategory.name }}</li>
  110.                         {% endif %}
  111.                     {% else %}
  112.                         <li class="breadcrumb-item active" aria-current="page">Productos</li>
  113.                     {% endif %}
  114.                 </ol>
  115.             </nav>
  116.             <h1 class="section-title category-section my-4 ">Nuestros Productos</h1>
  117.         </div>
  118.         <!-- Productos -->
  119.         <div class="col-12 col-lg-12" style="min-height: 50vh">
  120.             <div class="row align-items-start" >
  121.                     {% include "components/products.html.twig" with {'products': products} %}
  122.             </div>
  123.         </div>
  124.     </div>
  125. </div>
  126.     
  127.     
  128. {# Botón flotante para abrir el offcanvas de filtros #}
  129. <button class="btn btn-primary rounded-circle position-fixed " 
  130.         style="bottom: 20px; left: 20px; z-index: 1050; width: 50px; height: 50px;" 
  131.         type="button" 
  132.         data-bs-toggle="offcanvas" 
  133.         data-bs-target="#filterOffcanvas" 
  134.         aria-controls="filterOffcanvas">
  135.     <i class="bi bi-filter" style="font-size: 1.5rem;"></i>
  136. </button>
  137. {# Offcanvas que contendrá los filtros #}
  138. <div class="offcanvas offcanvas-start" tabindex="-1" id="filterOffcanvas" aria-labelledby="filterOffcanvasLabel">
  139.   <div class="offcanvas-header">
  140.     <h5 class="offcanvas-title" id="filterOffcanvasLabel">Filtros</h5>
  141.     <button type="button" class="btn-close text-reset" data-bs-dismiss="offcanvas" aria-label="Close"></button>
  142.   </div>
  143.   <div class="offcanvas-body">
  144.       <div class="filter-container pt-0">
  145.           <form method="GET" action="{{ path('app_order') }}">
  146.               <button type="submit" class="btn btn-primary w-100 mb-3">Filtrar</button>
  147.               <!-- Filtro de Buscador -->
  148.               <button class="filter-title" data-bs-toggle="collapse" data-bs-target="#filter-search" aria-expanded="true" type="button">
  149.                   Filtrar por Nombre <span class="arrow">▼</span>
  150.               </button>
  151.               <div id="filter-search" class="collapse show">
  152.                   <div class="my-3 d-flex">
  153.                       <div class="input-group input-group-lg">
  154.                           <input type="search" name="search" class="form-control fs-6 bar-search" placeholder="Nombre..." 
  155.                               aria-label="Nombre" value="{{ app.request.get('search') }}">
  156.                       </div>
  157.                   </div>
  158.               </div>
  159.               <!-- Filtro de Precio -->
  160.               <button class="filter-title" data-bs-toggle="collapse" data-bs-target="#filter-price" aria-expanded="true" type="button">
  161.                   Filtrar por Precio <span class="arrow">▼</span>
  162.               </button>
  163.               <div id="filter-price" class="collapse show">
  164.                   <div class="slider-container">
  165.                       <input type="range" name="price" min="0" max="{{ max_price }}" step="1" id="priceRange"
  166.                           value="{{ app.request.get('price') ?: max_price }}">
  167.                       <p class="fs-6">Precio: <span id="priceValue">{{ app.request.get('price') ?: max_price }}</span>€</p>
  168.                   </div>
  169.               </div>
  170.               <!-- Filtro de Categorías -->
  171.               <button class="filter-title" data-bs-toggle="collapse" data-bs-target="#filter-category" aria-expanded="true" type="button">
  172.                   Filtrar por Categorías <span class="arrow">▼</span>
  173.               </button>
  174.               <div id="filter-category" class="collapse show">
  175.                   <div class="checkbox-container">
  176.                       {% for category in categories %}
  177.                           <div class="form-check">
  178.                               <input class="form-check-input category-checkbox" type="checkbox" name="category" id="cat{{ category.id }}" value="{{ category.id }}"
  179.                                   {% if app.request.get('category') == category.id|trans %}checked{% endif %}>
  180.                               <label class="form-check-label" for="cat{{ category.id }}">{{ category.name }}</label>
  181.                           </div>
  182.                       {% endfor %}
  183.                   </div>
  184.               </div>
  185.           </form>
  186.       </div>
  187.   </div>
  188. </div>
  189.     
  190.     
  191. </body>
  192. <script>
  193.     document.getElementById('priceRange').addEventListener('input', function() {
  194.         document.getElementById('priceValue').innerText = this.value;
  195.     });
  196. </script>
  197. <script>
  198.     document.addEventListener("DOMContentLoaded", function () {
  199.         const checkboxes = document.querySelectorAll(".category-checkbox");
  200.         checkboxes.forEach(checkbox => {
  201.             checkbox.addEventListener("click", function () {
  202.                 if (this.checked) {
  203.                     checkboxes.forEach(cb => {
  204.                         if (cb !== this) cb.checked = false; // Desmarca los otros
  205.                     });
  206.                 }
  207.             });
  208.         });
  209.     });
  210. </script>
  211. {% endblock %}