feat(filtros): adicionar filtro multi-select por selos no ranking
- Backend: extrair selos de detalhes e filtrar por eles - API: endpoint /ranking/selos e parâmetro selos em /ranking/paginado - Frontend: componente FiltroSelos com dropdown e seleção múltipla - Selos disponíveis: funções, premiações, orientações
This commit is contained in:
244
frontend/src/components/FiltroSelos.css
Normal file
244
frontend/src/components/FiltroSelos.css
Normal file
@@ -0,0 +1,244 @@
|
||||
.filtro-selos {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.filtro-selos-trigger {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
padding: 0.5rem 0.9rem;
|
||||
background: rgba(255, 255, 255, 0.06);
|
||||
border: 1px solid var(--stroke);
|
||||
border-radius: 8px;
|
||||
color: var(--text);
|
||||
font-size: 0.9rem;
|
||||
cursor: pointer;
|
||||
transition: all 200ms ease;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.filtro-selos-trigger:hover {
|
||||
border-color: var(--accent-2);
|
||||
background: rgba(255, 255, 255, 0.08);
|
||||
}
|
||||
|
||||
.filtro-selos-trigger.ativo {
|
||||
border-color: var(--accent);
|
||||
background: rgba(79, 70, 229, 0.15);
|
||||
}
|
||||
|
||||
.filtro-icone {
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.filtro-label {
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.filtro-seta {
|
||||
font-size: 0.7rem;
|
||||
color: var(--muted);
|
||||
transition: transform 200ms ease;
|
||||
}
|
||||
|
||||
.filtro-seta.aberto {
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
|
||||
.filtro-limpar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
font-size: 0.7rem;
|
||||
background: rgba(255, 59, 48, 0.2);
|
||||
color: #ff6b6b;
|
||||
border-radius: 50%;
|
||||
margin-left: 0.25rem;
|
||||
transition: all 150ms ease;
|
||||
}
|
||||
|
||||
.filtro-limpar:hover {
|
||||
background: rgba(255, 59, 48, 0.4);
|
||||
}
|
||||
|
||||
.filtro-selos-dropdown {
|
||||
position: absolute;
|
||||
top: calc(100% + 8px);
|
||||
left: 0;
|
||||
min-width: 340px;
|
||||
max-width: 420px;
|
||||
background: linear-gradient(165deg, rgba(15, 23, 42, 0.98), rgba(30, 41, 59, 0.98));
|
||||
border: 1px solid var(--stroke);
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 15px 40px rgba(0, 0, 0, 0.4), 0 0 20px rgba(79, 70, 229, 0.1);
|
||||
z-index: 100;
|
||||
backdrop-filter: blur(12px);
|
||||
animation: dropdownSlide 200ms ease;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
@keyframes dropdownSlide {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(-8px);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
.filtro-selos-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 0.75rem 1rem;
|
||||
border-bottom: 1px solid var(--stroke);
|
||||
font-size: 0.85rem;
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.filtro-limpar-todos {
|
||||
padding: 0.3rem 0.6rem;
|
||||
background: rgba(255, 59, 48, 0.15);
|
||||
border: 1px solid rgba(255, 59, 48, 0.3);
|
||||
border-radius: 6px;
|
||||
color: #ff6b6b;
|
||||
font-size: 0.75rem;
|
||||
cursor: pointer;
|
||||
transition: all 150ms ease;
|
||||
}
|
||||
|
||||
.filtro-limpar-todos:hover {
|
||||
background: rgba(255, 59, 48, 0.25);
|
||||
}
|
||||
|
||||
.filtro-selos-grupos {
|
||||
max-height: 320px;
|
||||
overflow-y: auto;
|
||||
padding: 0.5rem;
|
||||
}
|
||||
|
||||
.filtro-selos-grupos::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
}
|
||||
|
||||
.filtro-selos-grupos::-webkit-scrollbar-track {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.filtro-selos-grupos::-webkit-scrollbar-thumb {
|
||||
background: var(--stroke);
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.filtro-grupo {
|
||||
margin-bottom: 0.75rem;
|
||||
}
|
||||
|
||||
.filtro-grupo:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.filtro-grupo-titulo {
|
||||
font-size: 0.7rem;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
color: var(--accent-2);
|
||||
padding: 0.4rem 0.5rem 0.3rem;
|
||||
margin-bottom: 0.25rem;
|
||||
}
|
||||
|
||||
.filtro-grupo-selos {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.4rem;
|
||||
}
|
||||
|
||||
.filtro-selo-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.35rem;
|
||||
padding: 0.4rem 0.65rem;
|
||||
background: rgba(255, 255, 255, 0.04);
|
||||
border: 1px solid transparent;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
transition: all 150ms ease;
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
|
||||
.filtro-selo-item:hover {
|
||||
background: rgba(255, 255, 255, 0.08);
|
||||
border-color: var(--stroke);
|
||||
}
|
||||
|
||||
.filtro-selo-item.selecionado {
|
||||
background: rgba(79, 70, 229, 0.2);
|
||||
border-color: var(--accent);
|
||||
}
|
||||
|
||||
.filtro-selo-item input {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.filtro-selo-item .selo-icone {
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.filtro-selo-item .selo-label {
|
||||
color: var(--text);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.filtro-selos-footer {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 0.75rem 1rem;
|
||||
border-top: 1px solid var(--stroke);
|
||||
background: rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
.filtro-info {
|
||||
font-size: 0.8rem;
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.filtro-aplicar {
|
||||
padding: 0.45rem 1rem;
|
||||
background: linear-gradient(145deg, var(--accent), var(--accent-2));
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
color: white;
|
||||
font-size: 0.85rem;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
transition: all 150ms ease;
|
||||
}
|
||||
|
||||
.filtro-aplicar:hover {
|
||||
filter: brightness(1.1);
|
||||
box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
|
||||
}
|
||||
|
||||
@media (max-width: 480px) {
|
||||
.filtro-selos-dropdown {
|
||||
position: fixed;
|
||||
top: auto;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
min-width: 100%;
|
||||
max-width: 100%;
|
||||
border-radius: 16px 16px 0 0;
|
||||
max-height: 70vh;
|
||||
}
|
||||
|
||||
.filtro-selos-grupos {
|
||||
max-height: 50vh;
|
||||
}
|
||||
}
|
||||
138
frontend/src/components/FiltroSelos.jsx
Normal file
138
frontend/src/components/FiltroSelos.jsx
Normal file
@@ -0,0 +1,138 @@
|
||||
import { useState, useRef, useEffect } from 'react';
|
||||
import './FiltroSelos.css';
|
||||
|
||||
const SELOS_CONFIG = {
|
||||
funcoes: {
|
||||
label: 'Funções',
|
||||
selos: [
|
||||
{ codigo: 'PRESID_CAMARA', label: 'Presidente Câmara', icone: '👑' },
|
||||
{ codigo: 'COORD_PPG', label: 'Coord. PPG', icone: '🎓' },
|
||||
{ codigo: 'BPQ', label: 'Bolsista PQ', icone: '🏅' },
|
||||
],
|
||||
},
|
||||
premiacoes: {
|
||||
label: 'Premiações',
|
||||
selos: [
|
||||
{ codigo: 'AUTOR_GP', label: 'Autor GP', icone: '🏆' },
|
||||
{ codigo: 'AUTOR_PREMIO', label: 'Autor Prêmio', icone: '🥇' },
|
||||
{ codigo: 'AUTOR_MENCAO', label: 'Autor Menção', icone: '🥈' },
|
||||
{ codigo: 'ORIENT_GP', label: 'Orient. GP', icone: '🏆' },
|
||||
{ codigo: 'ORIENT_PREMIO', label: 'Orient. Prêmio', icone: '🎖️' },
|
||||
{ codigo: 'ORIENT_MENCAO', label: 'Orient. Menção', icone: '📜' },
|
||||
],
|
||||
},
|
||||
orientacoes: {
|
||||
label: 'Orientações',
|
||||
selos: [
|
||||
{ codigo: 'ORIENT_POS_DOC', label: 'Pós-Doc', icone: '🔬' },
|
||||
{ codigo: 'ORIENT_TESE', label: 'Tese', icone: '📚' },
|
||||
{ codigo: 'ORIENT_DISS', label: 'Dissertação', icone: '📄' },
|
||||
{ codigo: 'CO_ORIENT_POS_DOC', label: 'Co-orient. Pós-Doc', icone: '🔬' },
|
||||
{ codigo: 'CO_ORIENT_TESE', label: 'Co-orient. Tese', icone: '📚' },
|
||||
{ codigo: 'CO_ORIENT_DISS', label: 'Co-orient. Diss.', icone: '📄' },
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
function FiltroSelos({ selecionados, onChange }) {
|
||||
const [aberto, setAberto] = useState(false);
|
||||
const ref = useRef(null);
|
||||
|
||||
useEffect(() => {
|
||||
const handleClickOutside = (e) => {
|
||||
if (ref.current && !ref.current.contains(e.target)) {
|
||||
setAberto(false);
|
||||
}
|
||||
};
|
||||
document.addEventListener('mousedown', handleClickOutside);
|
||||
return () => document.removeEventListener('mousedown', handleClickOutside);
|
||||
}, []);
|
||||
|
||||
const toggleSelo = (codigo) => {
|
||||
if (selecionados.includes(codigo)) {
|
||||
onChange(selecionados.filter((s) => s !== codigo));
|
||||
} else {
|
||||
onChange([...selecionados, codigo]);
|
||||
}
|
||||
};
|
||||
|
||||
const limparFiltros = (e) => {
|
||||
e.stopPropagation();
|
||||
onChange([]);
|
||||
};
|
||||
|
||||
const totalSelos = Object.values(SELOS_CONFIG).reduce(
|
||||
(acc, g) => acc + g.selos.length,
|
||||
0
|
||||
);
|
||||
|
||||
return (
|
||||
<div className="filtro-selos" ref={ref}>
|
||||
<button
|
||||
className={`filtro-selos-trigger ${selecionados.length > 0 ? 'ativo' : ''}`}
|
||||
onClick={() => setAberto(!aberto)}
|
||||
>
|
||||
<span className="filtro-icone">🏷️</span>
|
||||
<span className="filtro-label">
|
||||
{selecionados.length > 0
|
||||
? `${selecionados.length} selo${selecionados.length > 1 ? 's' : ''}`
|
||||
: 'Filtrar por selos'}
|
||||
</span>
|
||||
<span className={`filtro-seta ${aberto ? 'aberto' : ''}`}>▼</span>
|
||||
{selecionados.length > 0 && (
|
||||
<span className="filtro-limpar" onClick={limparFiltros} title="Limpar filtros">
|
||||
✕
|
||||
</span>
|
||||
)}
|
||||
</button>
|
||||
|
||||
{aberto && (
|
||||
<div className="filtro-selos-dropdown">
|
||||
<div className="filtro-selos-header">
|
||||
<span>Selecione os selos para filtrar</span>
|
||||
{selecionados.length > 0 && (
|
||||
<button className="filtro-limpar-todos" onClick={limparFiltros}>
|
||||
Limpar ({selecionados.length})
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="filtro-selos-grupos">
|
||||
{Object.entries(SELOS_CONFIG).map(([grupoKey, grupo]) => (
|
||||
<div key={grupoKey} className="filtro-grupo">
|
||||
<div className="filtro-grupo-titulo">{grupo.label}</div>
|
||||
<div className="filtro-grupo-selos">
|
||||
{grupo.selos.map((selo) => (
|
||||
<label
|
||||
key={selo.codigo}
|
||||
className={`filtro-selo-item ${selecionados.includes(selo.codigo) ? 'selecionado' : ''}`}
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={selecionados.includes(selo.codigo)}
|
||||
onChange={() => toggleSelo(selo.codigo)}
|
||||
/>
|
||||
<span className="selo-icone">{selo.icone}</span>
|
||||
<span className="selo-label">{selo.label}</span>
|
||||
</label>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div className="filtro-selos-footer">
|
||||
<span className="filtro-info">
|
||||
{selecionados.length} de {totalSelos} selecionado{selecionados.length !== 1 ? 's' : ''}
|
||||
</span>
|
||||
<button className="filtro-aplicar" onClick={() => setAberto(false)}>
|
||||
Aplicar
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default FiltroSelos;
|
||||
Reference in New Issue
Block a user