App: widocznosc komentarzy serii dla trenera - callouty w tabeli serii, ikona przy numerze, licznik komentarzy w wierszu cwiczenia i callout w oknie serii; komentarze spoza progu zwijania (i18n, unit + e2e)

This commit is contained in:
tisachi
2026-11-05 19:31:20 +01:00
parent 600c3f8c68
commit ecbf7f46d7
11 changed files with 168 additions and 41 deletions

View File

@@ -4,6 +4,7 @@ import { MessageSquare } from 'lucide-react';
import type { ExerciseReport, ExerciseReportSet } from '../api/types';
import { fmtLoadKg } from '../lib/format';
import DifficultyDots from './DifficultyDots';
import { NoteCallout } from './ui';
/** Powyżej tylu serii mobilne karty zwijają się za „Pokaż więcej”. */
const COLLAPSED_LIMIT = 3;
@@ -33,6 +34,24 @@ export default function ExerciseReportTable({ exercise, isMobile }: ExerciseRepo
const notes = exercise.sets.filter((s) => s.note);
/* Sekcja calloutów komentarzy: etykieta sekcji + callout na serie. */
const notesSection = (list: ExerciseReportSet[]) => (
<div className="mt-2">
<div className="mb-1 text-[11px] font-bold uppercase tracking-[0.1em] text-dim">
{t('history.setNotes')}
</div>
<div className="space-y-1">
{list.map((set) => (
<NoteCallout
key={set.index}
label={t('plans:exec.setN', { n: set.index })}
text={set.note ?? ''}
/>
))}
</div>
</div>
);
const table = (
<div className="overflow-x-auto">
<table className="w-full border-collapse text-[0.8125rem]">
@@ -52,7 +71,15 @@ export default function ExerciseReportTable({ exercise, isMobile }: ExerciseRepo
{exercise.sets.map((set) => (
<tr key={set.index} className="border-t border-line tabular-nums">
<td className="sticky left-0 z-10 bg-card py-1.5 pr-3 font-semibold text-dim">
<span title={set.note ? set.note : undefined}>{set.index}</span>
<span className="inline-flex items-center gap-1" title={set.note || undefined}>
{set.index}
{set.note && (
<MessageSquare
className="h-3 w-3 shrink-0 text-accent-text"
aria-hidden="true"
/>
)}
</span>
</td>
<td className="py-1.5 pr-3">{set.planned?.reps ?? '—'}</td>
<td className="py-1.5 pr-3">
@@ -75,20 +102,14 @@ export default function ExerciseReportTable({ exercise, isMobile }: ExerciseRepo
))}
</tbody>
</table>
{notes.length > 0 && (
<div className="mt-1.5 space-y-0.5 text-[0.75rem] text-dim">
{notes.map((set) => (
<div key={set.index}>
<MessageSquare className="mr-1 inline h-3 w-3 align-[-2px]" />S{set.index}: {set.note}
</div>
))}
</div>
)}
{notes.length > 0 && notesSection(notes)}
</div>
);
const collapsed = exercise.sets.length > COLLAPSED_LIMIT && !expanded;
const visibleSets = collapsed ? exercise.sets.slice(0, COLLAPSED_LIMIT) : exercise.sets;
// komentarze serii spoza zwiniętego progu — nie mogą znikać z widoku trenera
const hiddenNotes = collapsed ? exercise.sets.slice(COLLAPSED_LIMIT).filter((s) => s.note) : [];
const cards = (
<div>
@@ -121,14 +142,16 @@ export default function ExerciseReportTable({ exercise, isMobile }: ExerciseRepo
{planCell(set, t('common:bodyweight'))}
</div>
{set.note && (
<div className="mt-0.5 pl-10 text-[0.75rem] text-dim">
<MessageSquare className="mr-1 inline h-3 w-3 align-[-2px]" />
{set.note}
</div>
<NoteCallout
className="mt-1 ml-10"
label={t('plans:exec.setN', { n: set.index })}
text={set.note}
/>
)}
</div>
))}
</div>
{hiddenNotes.length > 0 && notesSection(hiddenNotes)}
{exercise.sets.length > COLLAPSED_LIMIT && (
<div className="mt-1.5">
{collapsed ? (

View File

@@ -1,6 +1,6 @@
import { useState } from 'react';
import { useTranslation } from 'react-i18next';
import { ChevronDown, ChevronRight, ChevronUp } from 'lucide-react';
import { ChevronDown, ChevronRight, ChevronUp, MessageSquare } from 'lucide-react';
import type { HistoryExercise, HistorySession } from '../api/types';
import { fmtDate, fmtDuration, fmtVolume } from '../lib/format';
import { localizedName } from '../lib/localizedName';
@@ -165,6 +165,8 @@ export default function HistoryTable({
: sum,
0,
);
// komentarze serii: wskaznik, by trener nie musial otwierac dialogu
const exNotes = ex.sets.filter((set) => set.note).length;
return (
<button
key={ex.id}
@@ -201,6 +203,16 @@ export default function HistoryTable({
{exVolume > 0 && (
<span className="tabular-nums">{fmtVolume(exVolume)}</span>
)}
{exNotes > 0 && (
<Badge
color="green"
title={t('history.setNotesBadge', { count: exNotes })}
aria-label={t('history.setNotesBadge', { count: exNotes })}
>
<MessageSquare className="h-3 w-3" aria-hidden="true" />
{exNotes}
</Badge>
)}
<span className="sm:hidden">{muscleName(ex.muscle)}</span>
</div>
</button>

View File

@@ -55,13 +55,17 @@ export function Badge({
color,
className,
children,
title,
'aria-label': ariaLabel,
}: {
color?: BadgeColor;
className?: string;
children: ReactNode;
title?: string;
'aria-label'?: string;
}) {
return (
<UIBadge color={color} className={className}>
<UIBadge color={color} className={className} title={title} aria-label={ariaLabel}>
{children}
</UIBadge>
);

View File

@@ -2,7 +2,7 @@ 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, X } from 'lucide-react';
import { ArrowLeft, ChevronLeft, ChevronRight, MessageSquare, X } from 'lucide-react';
import { buttonVariants } from './button';
import { H2, H3, Muted } from './typography';
import { cn } from '../../lib/utils';
@@ -143,6 +143,33 @@ export function ListRow({
);
}
/* 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 (
<div
data-slot="note-callout"
className={cn(
'flex items-start gap-2 rounded-[10px] border border-accent/40 bg-accent/10 px-2.5 py-2 text-[0.8125rem] text-ink',
className,
)}
>
<MessageSquare className="mt-0.5 h-3.5 w-3.5 shrink-0 text-accent-text" aria-hidden="true" />
<span className="min-w-0">
<strong className="font-semibold">{label}</strong> {text}
</span>
</div>
);
}
/* Meta item: small icon + muted text */
export function MetaItem({
icon: Icon,