Podopieczni: dopracowany select sortowania (ikona, chevron z animacja, naglowek panelu, check przy aktywnej opcji)

This commit is contained in:
tisachi
2026-09-11 16:21:25 +02:00
parent 688113f69f
commit 4e8ee47e75

View File

@@ -1,7 +1,7 @@
import { useEffect, useMemo, useState } from 'react';
import { useNavigate } from 'react-router-dom';
import { useQueryClient } from '@tanstack/react-query';
import { ChevronDown, Flame, Plus, Users } from 'lucide-react';
import { ArrowUpDown, Check, ChevronDown, Flame, Plus, Users } from 'lucide-react';
import {
sendInvitation,
useIsTrainer,
@@ -119,7 +119,7 @@ export default function Trainees() {
title: 'Podopieczni',
search: 'trainees',
filters: [
/* sortowanie: jeden przycisk „Sortuj: <wartość>” + rozwijany select (kompaktowo w grupie filtrów) */
/* sortowanie: przycisk „Sortuj: <wartość>” + rozwijany select (kompaktowo w grupie filtrów) */
<div key="sort" className="relative">
<Button
size="sm"
@@ -128,13 +128,17 @@ export default function Trainees() {
aria-haspopup="true"
aria-expanded={sortOpen}
>
<ArrowUpDown className="w-4 h-4" />
Sortuj: {SORT_OPTIONS.find((s) => s.id === sortKey)?.label}
<ChevronDown className="w-4 h-4" />
<ChevronDown className={`w-4 h-4 transition-transform ${sortOpen ? 'rotate-180' : ''}`} />
</Button>
{sortOpen && (
<>
<div className="fixed inset-0 z-40" onClick={() => setSortOpen(false)} />
<div className="absolute right-0 top-full z-50 mt-2 w-44 rounded-xl border border-line bg-card p-1 shadow-lg">
<div className="absolute right-0 top-full z-50 mt-2 min-w-full rounded-xl border border-line bg-card p-1.5 shadow-lg">
<p className="px-2.5 pb-1 pt-1.5 text-[0.7rem] font-bold uppercase tracking-[0.08em] text-dim">
Sortuj podopiecznych
</p>
{SORT_OPTIONS.map((s) => (
<button
key={s.id}
@@ -143,11 +147,12 @@ export default function Trainees() {
setSortKey(s.id);
setSortOpen(false);
}}
className={`w-full cursor-pointer rounded-lg px-2.5 py-1.5 text-left text-[0.85rem] font-semibold ${
sortKey === s.id ? 'bg-accent/15 text-accent-text' : 'text-ink hover:bg-line/30'
className={`flex w-full cursor-pointer items-center justify-between gap-3 rounded-lg px-2.5 py-2 text-left text-[0.9rem] font-semibold transition-colors ${
sortKey === s.id ? 'bg-accent/12 text-accent-text' : 'text-ink hover:bg-line/30'
}`}
>
{s.label}
{sortKey === s.id && <Check className="w-4 h-4" />}
</button>
))}
</div>