import type { ReactNode } from 'react';
import { useEffect, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { Link } from 'react-router-dom';
import { ArrowLeft, ChevronLeft, ChevronRight, MessageSquare, X } from 'lucide-react';
import { buttonVariants } from './button';
import { H2, H3, Muted } from './typography';
import { cn } from '../../lib/utils';
/* Page header: opcjonalny element przed tytułem (np. awatar), tytuł + badge,
akcje zawsze w tej samej linii po prawej (nie stackują się na mobile). */
export function PageHeader({
title,
leading,
badge,
actions,
}: {
title: string;
/** Element przed tytułem (np. awatar). */
leading?: ReactNode;
badge?: ReactNode;
actions?: ReactNode;
}) {
return (
{leading}
{/* `
` należy do topbaru (tytuł strony) — nagłówek treści to `
` */}
{title}
{badge}
{actions &&
{actions}
}
);
}
/* Back button — ghost, small; `to` renders a Link, `onClick` a plain button */
export function BackButton({
to,
onClick,
children,
className = '',
}: {
to?: string;
onClick?: () => void;
children?: ReactNode;
className?: string;
}) {
const { t } = useTranslation();
// na telefonie „Wstecz” siedzi w topmenu („<”) — tu tylko md+
const cls = cn(buttonVariants({ variant: 'ghost', size: 'sm' }), 'max-md:hidden', className);
if (to) {
return (
{children ?? t('back')}
);
}
return (
);
}
/* Section header: H2 + muted description + optional actions (right) */
export function SectionHeader({
title,
description,
actions,
className = '',
}: {
title: ReactNode;
description?: ReactNode;
actions?: ReactNode;
className?: string;
}) {
return (
{title}
{description && {description}}
{actions &&
{actions}
}
);
}
/* Stat tile: bez boxa — mini etykieta (uppercase) + duża wartość */
export function StatTile({
label,
value,
valueClassName = 'truncate',
className = '',
}: {
label: ReactNode;
value: ReactNode;
/** Styl wartości (domyślnie `truncate`; np. `break-words` dla długich tekstów). */
valueClassName?: string;
className?: string;
}) {
return (
{label}
{value}
);
}
/* 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 (
{title}
{meta && {meta}}
{actions &&
{actions}
}
{children}
);
}
/* Callout komentarza serii (SessionSet.note): akcentowa ramka + normalna czcionka —
trener od razu widzi, że seria ma komentarz (ten sam styl w historii i u trenera). */
export function NoteCallout({
label,
text,
className = '',
}: {
label: string;
text: string;
className?: string;
}) {
return (