{% extends "@UVDeskSupportCenter/Templates/layout.html.twig" %}
{% block title %}Base de Conocimientos{% endblock %}
{% block body %}
<div class="frequent-topics-container">
<div class="frequent-topics-wrapper">
<!-- Search Bar -->
<div class="topics-search-container">
<div class="topics-search-wrapper">
<span class="topics-search-icon">🔍</span>
<input type="text"
id="topics-search-input"
class="topics-search-input"
placeholder="Quiero saber sobre...."
autocomplete="off">
</div>
</div>
<!-- Frequent Topics Title -->
<h2 class="frequent-topics-title">Temas frecuentes</h2>
<!-- Topics Cards Grid -->
<div class="topics-cards-grid">
{% for topic in frequentTopics %}
<div class="topic-card" data-topic-id="{{ topic.id }}" data-topic-name="{{ topic.name }}">
<div class="topic-card-image">
{% if topic.image %}
<img src="{{ app.request.scheme ~'://' ~ app.request.httpHost ~ asset('') }}{{ topic.image }}"
alt="{{ topic.name }}">
{% else %}
<div class="topic-card-placeholder">
{{ topic.name|slice(0, 2)|upper }}
</div>
{% endif %}
</div>
<div class="topic-card-label">{{ topic.name }}</div>
</div>
{% endfor %}
</div>
</div>
</div>
<style>
.frequent-topics-container {
width: 100%;
min-height: calc(100vh - 200px);
background: #f5f5f5;
padding: 40px 20px;
display: flex;
justify-content: center;
align-items: flex-start;
}
.frequent-topics-wrapper {
max-width: 1200px;
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
}
/* Search Bar Styles */
.topics-search-container {
width: 100%;
max-width: 900px;
margin-bottom: 40px;
}
.topics-search-wrapper {
position: relative;
width: 100%;
}
.topics-search-icon {
position: absolute;
left: 16px;
top: 50%;
transform: translateY(-50%);
color: #7f8c8d;
font-size: 18px;
pointer-events: none;
z-index: 1;
}
.topics-search-input {
width: 100%;
padding: 14px 20px 14px 50px;
background: #ffffff;
border: 2px solid #e0e0e0;
border-radius: 8px;
font-size: 16px;
color: #2c3e50;
box-sizing: border-box;
transition: border-color 0.2s, box-shadow 0.2s;
}
.topics-search-input:focus {
outline: none;
border-color: #3498db;
box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}
.topics-search-input::placeholder {
color: #95a5a6;
}
/* Frequent Topics Title */
.frequent-topics-title {
font-size: 28px;
font-weight: 700;
color: #2c3e50;
margin: 0 0 30px 0;
text-align: center;
}
/* Topics Cards Grid */
.topics-cards-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
gap: 24px;
width: 100%;
max-width: 1200px;
}
.topic-card {
background: #ffffff;
border-radius: 12px;
padding: 20px;
text-align: center;
cursor: pointer;
transition: transform 0.2s, box-shadow 0.2s;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
display: flex;
flex-direction: column;
align-items: center;
gap: 12px;
}
.topic-card:hover {
transform: translateY(-4px);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
.topic-card-image {
width: 100%;
height: 140px;
display: flex;
align-items: center;
justify-content: center;
border-radius: 8px;
overflow: hidden;
background: #f8f9fa;
}
.topic-card-image img {
width: 100%;
height: 100%;
object-fit: cover;
}
.topic-card-placeholder {
width: 100%;
height: 100%;
background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
display: flex;
align-items: center;
justify-content: center;
font-size: 32px;
font-weight: bold;
color: #ffffff;
}
.topic-card-label {
font-size: 16px;
font-weight: 600;
color: #2c3e50;
margin-top: 8px;
}
/* Responsive */
@media (max-width: 768px) {
.topics-cards-grid {
grid-template-columns: repeat(2, 1fr);
gap: 16px;
}
.topic-card-image {
height: 120px;
}
.frequent-topics-title {
font-size: 24px;
}
}
@media (max-width: 480px) {
.topics-cards-grid {
grid-template-columns: 1fr;
}
.frequent-topics-container {
padding: 20px 15px;
}
}
</style>
<script>
(function() {
'use strict';
// Initialize when DOM is ready
function initializeTopics() {
// Handle topic card clicks
const topicCards = document.querySelectorAll('.topic-card');
topicCards.forEach(function(card) {
card.addEventListener('click', function(e) {
e.preventDefault();
const topicId = this.dataset.topicId;
const topicName = this.dataset.topicName;
// Navigate to knowledgebase view with topic filter
const baseUrl = window.location.origin + window.location.pathname;
const url = new URL(baseUrl);
url.searchParams.set('view', 'categories');
if (topicId && topicId !== 'undefined') {
url.searchParams.set('topic', topicId);
}
window.location.href = url.toString();
});
});
// Handle search functionality
const searchInput = document.getElementById('topics-search-input');
if (searchInput) {
searchInput.addEventListener('keydown', function(e) {
if (e.key === 'Enter') {
e.preventDefault();
const searchTerm = this.value.trim();
if (searchTerm) {
// Navigate to knowledgebase with search
const baseUrl = window.location.origin + window.location.pathname;
const url = new URL(baseUrl);
url.searchParams.set('view', 'categories');
url.searchParams.set('search', searchTerm);
window.location.href = url.toString();
} else {
// If no search term, just go to categories view
const baseUrl = window.location.origin + window.location.pathname;
const url = new URL(baseUrl);
url.searchParams.set('view', 'categories');
window.location.href = url.toString();
}
}
});
}
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', initializeTopics);
} else {
initializeTopics();
}
})();
</script>
{% endblock %}