Refaktoryzacja struktury i podział modułów (app/admin/api), konsolidacja testów w test/, komunikator (lista kontaktów, załącznik bez treści), profil podopiecznego (menu kontekstowe, nagłówek, zapamiętywanie zakładki), Tabs: strzałki poza scrollem + scroll-snap do całych zakładek, podniesione limity rate-limit

This commit is contained in:
tisachi
2026-09-04 23:19:28 +02:00
parent 1c8594ad96
commit e0f70ffa58
144 changed files with 5283 additions and 4788 deletions

View File

@@ -5,12 +5,9 @@ import type {
SelectHTMLAttributes,
TextareaHTMLAttributes,
} from 'react';
import { Link } from 'react-router-dom';
import { ArrowLeft, Moon, Sun, X } from 'lucide-react';
import { cva } from 'class-variance-authority';
import { useTheme } from '../store/theme';
import { cn } from '../lib/utils';
import { Button as UIButton, buttonVariants } from './ui/button';
import { Button as UIButton } from './ui/button';
import { Card as UICard } from './ui/card';
import { Badge as UIBadge } from './ui/badge';
import { Input as UIInput } from './ui/input';
@@ -20,14 +17,11 @@ import { Field as UIField } from './ui/field';
import { Skeleton as UISkeleton } from './ui/skeleton';
import { Progress as UIProgress } from './ui/progress';
import { ErrorText as UIErrorText, SuccessText as UISuccessText } from './ui/alert';
import {
Dialog,
DialogClose,
DialogContent,
DialogDescription,
DialogHeader,
DialogTitle,
} from './ui/dialog';
export * from './ui/typography';
export * from './ui/content';
export * from './ui/dialogs';
export * from './ui/theme-toggle';
/* Button */
export type ButtonVariant = 'primary' | 'secondary' | 'danger' | 'ghost';
@@ -127,172 +121,7 @@ export function Field({
);
}
/* Headings */
export function H1({ className = '', children }: { className?: string; children: ReactNode }) {
return <h1 className={`text-[1.45rem] sm:text-[1.6rem] font-bold tracking-[-0.02em] mb-4 ${className}`.trim()}>{children}</h1>;
}
export function H2({ className = '', children }: { className?: string; children: ReactNode }) {
return <h2 className={`text-[1.15rem] sm:text-[1.25rem] font-bold tracking-[-0.01em] mb-3 ${className}`.trim()}>{children}</h2>;
}
export function H3({ className = '', children }: { className?: string; children: ReactNode }) {
return <h3 className={`text-[1.05rem] font-semibold mb-2 ${className}`.trim()}>{children}</h3>;
}
/* Page header: title + optional badge, actions on the right (stacks on mobile) */
export function PageHeader({
title,
badge,
actions,
}: {
title: string;
badge?: ReactNode;
actions?: ReactNode;
}) {
return (
<div className="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3 mb-5">
<div className="flex items-center gap-3 flex-wrap">
<H1 className="mb-0">{title}</H1>
{badge}
</div>
{actions}
</div>
);
}
/* Back button — ghost, small; `to` renders a Link, `onClick` a plain button */
export function BackButton({
to,
onClick,
children = 'Wstecz',
className = '',
}: {
to?: string;
onClick?: () => void;
children?: ReactNode;
className?: string;
}) {
const cls = cn(buttonVariants({ variant: 'ghost', size: 'sm' }), className);
if (to) {
return (
<Link to={to} className={cls}>
<ArrowLeft className="w-4 h-4" />
{children}
</Link>
);
}
return (
<button type="button" onClick={onClick} className={cls}>
<ArrowLeft className="w-4 h-4" />
{children}
</button>
);
}
/* Section header: H2 + muted description + optional actions (right) */
export function SectionHeader({
title,
description,
actions,
className = '',
}: {
title: ReactNode;
description?: ReactNode;
actions?: ReactNode;
className?: string;
}) {
return (
<div className={`flex flex-wrap items-start justify-between gap-3 mb-3 ${className}`.trim()}>
<div className="min-w-0">
<H2 className="mb-0.5">{title}</H2>
{description && <Muted className="text-[0.875rem]">{description}</Muted>}
</div>
{actions && <div className="flex items-center gap-2 shrink-0">{actions}</div>}
</div>
);
}
/* Meta item: small icon + muted text */
export function MetaItem({
icon: Icon,
children,
className = '',
}: {
icon: React.ComponentType<{ className?: string }>;
children: ReactNode;
className?: string;
}) {
return (
<span className={`inline-flex items-center gap-1.5 text-dim text-[0.875rem] ${className}`.trim()}>
<Icon className="w-4 h-4 shrink-0" />
<span className="min-w-0 truncate">{children}</span>
</span>
);
}
/* List row: płaski wiersz (tytuł + meta lewo, akcje prawo); w listach w karcie
rodzic używa `divide-y divide-line` (dłuższe) albo `space-y-1` (krótkie). */
export function ListRow({
title,
meta,
actions,
children,
className = '',
}: {
title: ReactNode;
meta?: ReactNode;
actions?: ReactNode;
children?: ReactNode;
className?: string;
}) {
return (
<div
data-slot="list-row"
className={`flex flex-wrap items-center justify-between gap-3 px-2 py-3 rounded-lg transition-colors hover:bg-line/20 ${className}`.trim()}
>
<div className="min-w-0 flex-1">
<div className="text-[0.95rem] font-semibold min-w-0 truncate">{title}</div>
{meta && <Muted className="text-[0.875rem]">{meta}</Muted>}
</div>
{actions && <div className="flex items-center gap-2 shrink-0">{actions}</div>}
{children}
</div>
);
}
/* Chip: small pill (+ optional remove button) */
export function Chip({
children,
onRemove,
removeLabel = 'Usuń',
className = '',
}: {
children: ReactNode;
onRemove?: () => void;
removeLabel?: string;
className?: string;
}) {
return (
<span
data-slot="chip"
className={`inline-flex items-center gap-1.5 bg-card border border-line rounded-full px-3 py-1 text-[0.8125rem] font-semibold text-dim ${className}`.trim()}
>
{children}
{onRemove && (
<button type="button" onClick={onRemove} aria-label={removeLabel} className="text-dim hover:text-danger cursor-pointer">
<X className="w-3.5 h-3.5" />
</button>
)}
</span>
);
}
/* Text helpers */
export function Muted({ className = '', children }: { className?: string; children: ReactNode }) {
return <span className={`text-dim ${className}`.trim()}>{children}</span>;
}
export function ErrorText({ children }: { children: ReactNode }) {
return <UIErrorText>{children}</UIErrorText>;
}
@@ -301,152 +130,12 @@ export function SuccessText({ children }: { children: ReactNode }) {
return <UISuccessText>{children}</UISuccessText>;
}
export function Loading({ children = 'Ładowanie…' }: { children?: ReactNode }) {
return <div className="text-dim">{children}</div>;
}
/* Skeleton */
export function Skeleton({ className = '' }: { className?: string }) {
return <UISkeleton className={className} />;
}
/* Empty state */
export function EmptyState({
icon: Icon,
title,
description,
action,
}: {
icon: React.ComponentType<{ className?: string }>;
title: string;
description?: string;
action?: ReactNode;
}) {
return (
<div className="flex flex-col items-center justify-center text-center py-10 px-4">
<div className="w-14 h-14 rounded-full bg-accent/10 border border-accent/25 text-accent-text flex items-center justify-center mb-4">
<Icon className="w-7 h-7" />
</div>
<H3 className="mb-1">{title}</H3>
{description && <p className="text-dim text-[0.9rem] max-w-sm">{description}</p>}
{action && <div className="mt-4">{action}</div>}
</div>
);
}
/* Progress bar */
export function ProgressBar({ percent, className = '' }: { percent: number; className?: string }) {
return <UIProgress percent={percent} className={className} />;
}
/* Tabs */
export function Tabs({
tabs,
active,
onChange,
}: {
tabs: { id: string; label: string }[];
active: string;
onChange: (id: string) => void;
}) {
return (
<div className="flex gap-1 p-1 bg-input rounded-[10px] border border-line overflow-x-auto">
{tabs.map((t) => (
<button
key={t.id}
type="button"
onClick={() => onChange(t.id)}
className={`px-3.5 py-2 rounded-lg text-[0.9rem] font-semibold whitespace-nowrap cursor-pointer transition-all duration-150 ${
active === t.id ? 'bg-card text-ink border border-line shadow-card' : 'border border-transparent text-dim hover:text-ink'
}`}
>
{t.label}
</button>
))}
</div>
);
}
/* Modal — Radix Dialog: focus trap, Esc, scroll-lock, aria; bottom-sheet na mobile */
export function Modal({
open,
onClose,
title,
children,
}: {
open: boolean;
onClose: () => void;
title: string;
children: ReactNode;
}) {
return (
<Dialog open={open} onOpenChange={(o) => !o && onClose()}>
<DialogContent>
<DialogHeader>
<DialogTitle asChild>
<h3 className="text-[1.05rem] font-semibold">{title}</h3>
</DialogTitle>
<DialogClose asChild>
<button aria-label="Zamknij" className="p-1.5 -m-1.5 text-dim hover:text-ink cursor-pointer">
<X className="w-5 h-5" />
</button>
</DialogClose>
</DialogHeader>
<DialogDescription asChild>
<span className="sr-only" />
</DialogDescription>
{children}
</DialogContent>
</Dialog>
);
}
/* Confirm dialog */
export function ConfirmDialog({
open,
onClose,
onConfirm,
title,
description,
confirmLabel = 'Potwierdź',
danger,
busy,
}: {
open: boolean;
onClose: () => void;
onConfirm: () => void;
title: string;
description: string;
confirmLabel?: string;
danger?: boolean;
busy?: boolean;
}) {
return (
<Modal open={open} onClose={onClose} title={title}>
<p className="text-dim text-[0.95rem]">{description}</p>
<div className="flex flex-col-reverse sm:flex-row sm:items-center sm:justify-end gap-3 mt-5">
<Button variant="secondary" onClick={onClose} className="w-full sm:w-auto">
Anuluj
</Button>
<Button variant={danger ? 'danger' : 'primary'} onClick={onConfirm} disabled={busy} className="w-full sm:w-auto">
{confirmLabel}
</Button>
</div>
</Modal>
);
}
/* Theme toggle */
export function ThemeToggle({ className = '' }: { className?: string }) {
const { theme, toggle } = useTheme();
return (
<button
onClick={toggle}
aria-label="Przełącz motyw"
title="Przełącz motyw"
className={`p-2.5 rounded-full bg-card border border-line text-dim shadow-card hover:text-ink hover:border-accent/45 cursor-pointer transition-all duration-150 ${className}`.trim()}
>
{theme === 'dark' ? <Sun className="w-5 h-5" /> : <Moon className="w-5 h-5" />}
</button>
);
}

View File

@@ -0,0 +1,206 @@
import type { ReactNode } from 'react';
import { Link } from 'react-router-dom';
import { ArrowLeft, X } from 'lucide-react';
import { buttonVariants } from './button';
import { H1, H2, H3, Muted } from './typography';
import { cn } from '../../lib/utils';
/* Page header: title + optional badge, actions on the right (stacks on mobile) */
export function PageHeader({
title,
badge,
actions,
}: {
title: string;
badge?: ReactNode;
actions?: ReactNode;
}) {
return (
<div className="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3 mb-5">
<div className="flex items-center gap-3 flex-wrap">
<H1 className="mb-0">{title}</H1>
{badge}
</div>
{actions}
</div>
);
}
/* Back button — ghost, small; `to` renders a Link, `onClick` a plain button */
export function BackButton({
to,
onClick,
children = 'Wstecz',
className = '',
}: {
to?: string;
onClick?: () => void;
children?: ReactNode;
className?: string;
}) {
const cls = cn(buttonVariants({ variant: 'ghost', size: 'sm' }), className);
if (to) {
return (
<Link to={to} className={cls}>
<ArrowLeft className="w-4 h-4" />
{children}
</Link>
);
}
return (
<button type="button" onClick={onClick} className={cls}>
<ArrowLeft className="w-4 h-4" />
{children}
</button>
);
}
/* Section header: H2 + muted description + optional actions (right) */
export function SectionHeader({
title,
description,
actions,
className = '',
}: {
title: ReactNode;
description?: ReactNode;
actions?: ReactNode;
className?: string;
}) {
return (
<div className={`flex flex-wrap items-start justify-between gap-3 mb-3 ${className}`.trim()}>
<div className="min-w-0">
<H2 className="mb-0.5">{title}</H2>
{description && <Muted className="text-[0.875rem]">{description}</Muted>}
</div>
{actions && <div className="flex items-center gap-2 shrink-0">{actions}</div>}
</div>
);
}
/* Meta item: small icon + muted text */
export function MetaItem({
icon: Icon,
children,
className = '',
}: {
icon: React.ComponentType<{ className?: string }>;
children: ReactNode;
className?: string;
}) {
return (
<span className={`inline-flex items-center gap-1.5 text-dim text-[0.875rem] ${className}`.trim()}>
<Icon className="w-4 h-4 shrink-0" />
<span className="min-w-0 truncate">{children}</span>
</span>
);
}
/* List row: płaski wiersz (tytuł + meta lewo, akcje prawo); w listach w karcie
rodzic używa `divide-y divide-line` (dłuższe) albo `space-y-1` (krótkie). */
export function ListRow({
title,
meta,
actions,
children,
className = '',
}: {
title: ReactNode;
meta?: ReactNode;
actions?: ReactNode;
children?: ReactNode;
className?: string;
}) {
return (
<div
data-slot="list-row"
className={`flex flex-wrap items-center justify-between gap-3 px-2 py-3 rounded-lg transition-colors hover:bg-line/20 ${className}`.trim()}
>
<div className="min-w-0 flex-1">
<div className="text-[0.95rem] font-semibold min-w-0 truncate">{title}</div>
{meta && <Muted className="text-[0.875rem]">{meta}</Muted>}
</div>
{actions && <div className="flex items-center gap-2 shrink-0">{actions}</div>}
{children}
</div>
);
}
/* Chip: small pill (+ optional remove button) */
export function Chip({
children,
onRemove,
removeLabel = 'Usuń',
className = '',
}: {
children: ReactNode;
onRemove?: () => void;
removeLabel?: string;
className?: string;
}) {
return (
<span
data-slot="chip"
className={`inline-flex items-center gap-1.5 bg-card border border-line rounded-full px-3 py-1 text-[0.8125rem] font-semibold text-dim ${className}`.trim()}
>
{children}
{onRemove && (
<button type="button" onClick={onRemove} aria-label={removeLabel} className="text-dim hover:text-danger cursor-pointer">
<X className="w-3.5 h-3.5" />
</button>
)}
</span>
);
}
/* Empty state */
export function EmptyState({
icon: Icon,
title,
description,
action,
}: {
icon: React.ComponentType<{ className?: string }>;
title: string;
description?: string;
action?: ReactNode;
}) {
return (
<div className="flex flex-col items-center justify-center text-center py-10 px-4">
<div className="w-14 h-14 rounded-full bg-accent/10 border border-accent/25 text-accent-text flex items-center justify-center mb-4">
<Icon className="w-7 h-7" />
</div>
<H3 className="mb-1">{title}</H3>
{description && <p className="text-dim text-[0.9rem] max-w-sm">{description}</p>}
{action && <div className="mt-4">{action}</div>}
</div>
);
}
/* Tabs */
export function Tabs({
tabs,
active,
onChange,
}: {
tabs: { id: string; label: string }[];
active: string;
onChange: (id: string) => void;
}) {
return (
<div className="flex gap-1 p-1 bg-input rounded-[10px] border border-line overflow-x-auto">
{tabs.map((t) => (
<button
key={t.id}
type="button"
onClick={() => onChange(t.id)}
className={`px-3.5 py-2 rounded-lg text-[0.9rem] font-semibold whitespace-nowrap cursor-pointer transition-all duration-150 ${
active === t.id ? 'bg-card text-ink border border-line shadow-card' : 'border border-transparent text-dim hover:text-ink'
}`}
>
{t.label}
</button>
))}
</div>
);
}

View File

@@ -0,0 +1,80 @@
import type { ReactNode } from 'react';
import { X } from 'lucide-react';
import { Button } from './button';
import {
Dialog,
DialogClose,
DialogContent,
DialogDescription,
DialogHeader,
DialogTitle,
} from './dialog';
/* Modal — Radix Dialog: focus trap, Esc, scroll-lock, aria; bottom-sheet na mobile */
export function Modal({
open,
onClose,
title,
children,
}: {
open: boolean;
onClose: () => void;
title: string;
children: ReactNode;
}) {
return (
<Dialog open={open} onOpenChange={(o) => !o && onClose()}>
<DialogContent>
<DialogHeader>
<DialogTitle asChild>
<h3 className="text-[1.05rem] font-semibold">{title}</h3>
</DialogTitle>
<DialogClose asChild>
<button aria-label="Zamknij" className="p-1.5 -m-1.5 text-dim hover:text-ink cursor-pointer">
<X className="w-5 h-5" />
</button>
</DialogClose>
</DialogHeader>
<DialogDescription asChild>
<span className="sr-only" />
</DialogDescription>
{children}
</DialogContent>
</Dialog>
);
}
/* Confirm dialog */
export function ConfirmDialog({
open,
onClose,
onConfirm,
title,
description,
confirmLabel = 'Potwierdź',
danger,
busy,
}: {
open: boolean;
onClose: () => void;
onConfirm: () => void;
title: string;
description: string;
confirmLabel?: string;
danger?: boolean;
busy?: boolean;
}) {
return (
<Modal open={open} onClose={onClose} title={title}>
<p className="text-dim text-[0.95rem]">{description}</p>
<div className="flex flex-col-reverse sm:flex-row sm:items-center sm:justify-end gap-3 mt-5">
<Button variant="secondary" onClick={onClose} className="w-full sm:w-auto">
Anuluj
</Button>
<Button variant={danger ? 'danger' : 'primary'} onClick={onConfirm} disabled={busy} className="w-full sm:w-auto">
{confirmLabel}
</Button>
</div>
</Modal>
);
}

View File

@@ -0,0 +1,16 @@
import { Moon, Sun } from 'lucide-react';
import { useTheme } from '../../store/theme';
export function ThemeToggle({ className = '' }: { className?: string }) {
const { theme, toggle } = useTheme();
return (
<button
onClick={toggle}
aria-label="Przełącz motyw"
title="Przełącz motyw"
className={`p-2.5 rounded-full bg-card border border-line text-dim shadow-card hover:text-ink hover:border-accent/45 cursor-pointer transition-all duration-150 ${className}`.trim()}
>
{theme === 'dark' ? <Sun className="w-5 h-5" /> : <Moon className="w-5 h-5" />}
</button>
);
}

View File

@@ -0,0 +1,21 @@
import type { ReactNode } from 'react';
export function H1({ className = '', children }: { className?: string; children: ReactNode }) {
return <h1 className={`text-[1.45rem] sm:text-[1.6rem] font-bold tracking-[-0.02em] mb-4 ${className}`.trim()}>{children}</h1>;
}
export function H2({ className = '', children }: { className?: string; children: ReactNode }) {
return <h2 className={`text-[1.15rem] sm:text-[1.25rem] font-bold tracking-[-0.01em] mb-3 ${className}`.trim()}>{children}</h2>;
}
export function H3({ className = '', children }: { className?: string; children: ReactNode }) {
return <h3 className={`text-[1.05rem] font-semibold mb-2 ${className}`.trim()}>{children}</h3>;
}
export function Muted({ className = '', children }: { className?: string; children: ReactNode }) {
return <span className={`text-dim ${className}`.trim()}>{children}</span>;
}
export function Loading({ children = 'Ładowanie…' }: { children?: ReactNode }) {
return <div className="text-dim">{children}</div>;
}