Skip to content

armgit / lyftr

Public Imported from GitHub
0

Self-hosted fitness tracker. Log workouts, track nutrition, and monitor progress. Docker deployment, mobile-friendly.

UI polish: floating session pill, kebab menus, card layout improvements

Cawlummdb165c6ee017
diff --git a/web/e2e/programs.spec.ts b/web/e2e/programs.spec.ts
new file mode 100644
index 0000000..490aded
--- /dev/null
+++ b/web/e2e/programs.spec.ts
@@ -0,0 +1,129 @@
+import { test, expect } from '@playwright/test'
+
+const API = 'http://localhost:3000/api/v1'
+const E2E_PROGRAM_NAME = 'Test Program E2E'
+const SEED_PROGRAM_NAME = 'Seeded Test Program'
+
+let programId: number
+let authToken: string
+
+test.describe('Programs', () => {
+ test.beforeAll(async ({ request }) => {
+ const res = await request.post(`${API}/auth/login`, {
+ data: { email: '[email protected]', password: 'password123' }
+ })
+ const body = await res.json()
+ authToken = body.data.token
+
+ const p = await request.post(`${API}/programs`, {
+ headers: { Authorization: `Bearer ${authToken}` },
+ data: {
+ name: SEED_PROGRAM_NAME,
+ notes: 'Created by E2E seed',
+ exercises: []
+ }
+ })
+ const pb = await p.json()
+ programId = pb.data.id
+ })
+
+ test.afterAll(async ({ request }) => {
+ const headers = { Authorization: `Bearer ${authToken}` }
+
+ // Delete seeded program
+ if (programId) {
+ await request.delete(`${API}/programs/${programId}`, { headers })
+ }
+
+ // Delete any UI-created E2E programs
+ const list = await request.get(`${API}/programs`, { headers })
+ const lb = await list.json()
+ const toDelete = (lb.data ?? []).filter((p: any) => p.name === E2E_PROGRAM_NAME)
+ await Promise.all(toDelete.map((p: any) =>
+ request.delete(`${API}/programs/${p.id}`, { headers })
+ ))
+ })
+
+ test.beforeEach(async ({ page }) => {
+ await page.goto('/programs')
+ })
+
+ test('page loads and shows programs or empty state', async ({ page }) => {
+ await expect(page.getByRole('heading', { name: /programs/i })).toBeVisible()
+ const hasPrograms = await page.locator('.card').count() > 0
+ const hasEmpty = await page.getByText(/no programs|create your first/i).isVisible().catch(() => false)
+ expect(hasPrograms || hasEmpty).toBe(true)
+ })
+
+ test('create program via add page', async ({ page }) => {
+ await page.goto('/programs/new')
+ await expect(page.getByRole('heading', { name: /new program/i })).toBeVisible()
+
+ await page.getByPlaceholder(/push pull legs, upper lower/i).fill(E2E_PROGRAM_NAME)
+ await page.getByPlaceholder(/description or goals/i).fill('Test description')
+
+ // Add exercise
+ await page.getByRole('button', { name: /add exercise/i }).click()
+ await expect(page.getByPlaceholder(/search name/i)).toBeVisible()
+ await page.getByPlaceholder(/search name/i).fill('squat')
+ await page.getByText(/squat/i).first().click()
+
+ // Fill target sets
+ await page.locator('input[placeholder="10"]').first().fill('5')
+ await page.locator('input[placeholder="135"]').first().fill('225')
+
+ await page.getByRole('button', { name: /save program/i }).click()
+ await page.waitForURL('/programs')
+ await expect(page.getByText(E2E_PROGRAM_NAME).first()).toBeVisible()
+ })
+
+ test('program detail page loads with exercises', async ({ page }) => {
+ await page.goto(`/programs/${programId}`)
+ await expect(page.getByRole('heading')).toBeVisible()
+ })
+
+ test('start program creates workout session', async ({ page }) => {
+ const startButtons = page.getByRole('button', { name: /start workout/i })
+ if (await startButtons.count() === 0) {
+ test.skip()
+ return
+ }
+ await startButtons.first().click()
+ await expect(page).toHaveURL(/\/workout\/(active|start|add)|\/workouts/)
+ })
+
+ test('target weight unit shown correctly in program add form', async ({ page }) => {
+ await page.goto('/programs/new')
+ await page.getByRole('button', { name: /add exercise/i }).click()
+ await page.getByPlaceholder(/search name/i).fill('deadlift')
+ await page.getByText(/deadlift/i).first().click()
+
+ const weightSuffix = page.locator('text=/^(lb|kg)$/')
+ await expect(weightSuffix.first()).toBeVisible()
+ })
+
+ test('delete program shows confirm and cancels', async ({ page }) => {
+ // On mobile the delete button is behind a kebab (⋯) menu — open it first if present
+ const optionsBtn = page.getByRole('button', { name: /options/i }).first()
+ if (await optionsBtn.isVisible()) {
+ await optionsBtn.click()
+ await page.waitForTimeout(300)
+ await page.getByRole('button', { name: /delete program/i }).first().click()
+ } else {
+ const deleteButtons = page.getByRole('button', { name: /delete/i })
+ await expect(deleteButtons.first()).toBeVisible()
+ await deleteButtons.first().click()
+ }
+ await expect(page.getByText(/this cannot be undone/i)).toBeVisible({ timeout: 5000 })
+ await page.getByRole('button', { name: /cancel/i }).click()
+ await expect(page.getByText(/this cannot be undone/i)).not.toBeVisible()
+ })
+
+ test('edit program preserves existing data', async ({ page }) => {
+ await page.goto(`/programs/${programId}/edit`)
+ await expect(page.getByRole('heading', { name: /edit program/i })).toBeVisible()
+ const nameInput = page.locator('input[type="text"]').first()
+ const value = await nameInput.inputValue()
+ expect(value.length).toBeGreaterThan(0)
+ })
+})
diff --git a/web/e2e/workouts.spec.ts b/web/e2e/workouts.spec.ts
new file mode 100644
index 0000000..474e51b
--- /dev/null
+++ b/web/e2e/workouts.spec.ts
@@ -0,0 +1,128 @@
+import { test, expect } from '@playwright/test'
+
+const API = 'http://localhost:3000/api/v1'
+const E2E_WORKOUT_NAME = 'Test Workout E2E'
+const SEED_WORKOUT_NAME = 'Seeded Test Workout'
+
+let workoutId: number
+let authToken: string
+
+test.describe('Workouts', () => {
+ test.beforeAll(async ({ request }) => {
+ const res = await request.post(`${API}/auth/login`, {
+ data: { email: '[email protected]', password: 'password123' }
+ })
+ const body = await res.json()
+ authToken = body.data.token
+
+ const w = await request.post(`${API}/workouts`, {
+ headers: { Authorization: `Bearer ${authToken}` },
+ data: {
+ name: SEED_WORKOUT_NAME,
+ duration: 2700,
+ started_at: new Date().toISOString(),
+ exercises: []
+ }
+ })
+ const wb = await w.json()
+ workoutId = wb.data.id
+ })
+
+ test.afterAll(async ({ request }) => {
+ const headers = { Authorization: `Bearer ${authToken}` }
+
+ // Delete seeded workout
+ if (workoutId) {
+ await request.delete(`${API}/workouts/${workoutId}`, { headers })
+ }
+
+ // Delete any UI-created E2E workouts
+ const list = await request.get(`${API}/workouts?limit=100`, { headers })
+ const lb = await list.json()
+ const toDelete = (lb.data ?? []).filter((w: any) => w.name === E2E_WORKOUT_NAME)
+ await Promise.all(toDelete.map((w: any) =>
+ request.delete(`${API}/workouts/${w.id}`, { headers })
+ ))
+ })
+
+ test.beforeEach(async ({ page }) => {
+ await page.goto('/workouts')
+ })
+
+ test('page loads and shows workouts or empty state', async ({ page }) => {
+ await expect(page.getByRole('heading', { name: /workouts/i })).toBeVisible()
+ const hasWorkouts = await page.locator('.card').count() > 0
+ const hasEmpty = await page.getByText(/no workouts|start your first/i).isVisible().catch(() => false)
+ expect(hasWorkouts || hasEmpty).toBe(true)
+ })
+
+ test('create workout via add page', async ({ page }) => {
+ await page.goto('/workouts/new')
+ await expect(page.getByRole('heading', { name: /log workout/i })).toBeVisible()
+
+ await page.getByPlaceholder(/leg day|push day/i).fill(E2E_WORKOUT_NAME)
+ const durationInput = page.locator('input[type="number"]').first()
+ await durationInput.fill('45')
+
+ // Add exercise
+ await page.getByRole('button', { name: /add exercise/i }).click()
+ await expect(page.getByPlaceholder(/search name/i)).toBeVisible()
+ await page.getByPlaceholder(/search name/i).fill('bench press')
+ await page.getByText(/bench press/i).first().click()
+
+ // Fill in set
+ await page.locator('input[placeholder="10"]').first().fill('8')
+ await page.locator('input[placeholder="225"]').first().fill('135')
+
+ await page.getByRole('button', { name: /save workout/i }).click()
+ await page.waitForURL('/workouts')
+ await expect(page.getByText(E2E_WORKOUT_NAME).first()).toBeVisible()
+ })
+
+ test('workout list shows volume in correct unit', async ({ page }) => {
+ const volumeText = page.locator('text=/\\d+ (lb|kg)/')
+ if (await volumeText.count() > 0) {
+ await expect(volumeText.first()).toBeVisible()
+ }
+ })
+
+ test('delete workout shows confirm dialog', async ({ page }) => {
+ // On mobile the delete button is behind a kebab (⋯) menu — open it first if present
+ const optionsBtn = page.getByRole('button', { name: /options/i }).first()
+ if (await optionsBtn.isVisible()) {
+ await optionsBtn.click()
+ await page.waitForTimeout(300)
+ await page.getByRole('button', { name: /delete workout/i }).first().click()
+ } else {
+ const deleteButtons = page.getByRole('button', { name: /delete/i })
+ await expect(deleteButtons.first()).toBeVisible()
+ await deleteButtons.first().click()
+ }
+ await expect(page.getByText(/this cannot be undone/i)).toBeVisible({ timeout: 5000 })
+ await page.getByRole('button', { name: /cancel/i }).click()
+ await expect(page.getByText(/this cannot be undone/i)).not.toBeVisible()
+ })
+
+ test('workout detail page loads', async ({ page }) => {
+ await page.goto(`/workouts/${workoutId}`)
+ await expect(page.getByRole('heading')).toBeVisible()
+ await expect(page.locator('.card').first()).toBeVisible()
+ })
+
+ test('weight unit displays consistently', async ({ page }) => {
+ await page.goto('/settings')
+ const kgButton = page.getByRole('button', { name: 'kg' })
+ await kgButton.click()
+ await page.waitForTimeout(500)
+
+ await page.goto('/workouts')
+ const volumeElements = page.locator('text=/\\d+ kg/')
+ const count = await volumeElements.count()
+ if (count > 0) {
+ await expect(volumeElements.first()).toBeVisible()
+ }
+
+ await page.goto('/settings')
+ await page.getByRole('button', { name: 'lbs' }).click()
+ })
+})
diff --git a/web/src/components/Layout.tsx b/web/src/components/Layout.tsx
index 39280d2..b5ce006 100644
--- a/web/src/components/Layout.tsx
+++ b/web/src/components/Layout.tsx
@@ -47,24 +47,21 @@ function ActiveSessionBar() {
const totalSets = session.exercises.reduce((s, ex) => s + ex.sets.length, 0)
return (
- <button
- onClick={() => navigate('/workout/active')}
- className="w-full flex items-center justify-between px-4 py-2.5 bg-brand-500 hover:bg-brand-600 transition-colors"
- >
- <div className="flex items-center gap-3">
- <div className="w-7 h-7 rounded-lg bg-white/15 flex items-center justify-center flex-shrink-0">
- <Timer className="w-3.5 h-3.5 text-white" />
+ <div className="absolute bottom-full left-0 right-0 flex justify-center pb-3 pointer-events-none">
+ <button
+ onClick={() => navigate('/workout/active')}
+ className="pointer-events-auto flex items-center gap-2.5 px-4 py-2.5 bg-brand-500 hover:bg-brand-600 active:scale-95 shadow-lg shadow-brand-500/40 rounded-full transition-all"
+ >
+ <div className="w-6 h-6 rounded-full bg-white/20 flex items-center justify-center flex-shrink-0">
+ <Timer className="w-3 h-3 text-white" />
</div>
<div className="text-left">
- <p className="text-xs font-bold text-white leading-tight truncate max-w-[160px]">{session.name}</p>
- <p className="text-xs text-white/70">{completedSets}/{totalSets} sets · {formatElapsed(elapsed)}</p>
+ <p className="text-xs font-bold text-white leading-tight truncate max-w-[140px]">{session.name}</p>
+ <p className="text-[11px] text-white/70 leading-tight">{completedSets}/{totalSets} sets · {formatElapsed(elapsed)}</p>
</div>
- </div>
- <div className="flex items-center gap-1.5">
- <span className="text-xs font-semibold text-white">Resume</span>
- <ChevronRight className="w-4 h-4 text-white/80" />
- </div>
- </button>
+ <ChevronRight className="w-4 h-4 text-white/80 flex-shrink-0" />
+ </button>
+ </div>
)
}
@@ -168,8 +165,8 @@ export default function Layout() {
<Outlet />
</main>
- {/* Active session bar sits above bottom nav */}
- <div className="sticky bottom-0 z-50">
+ {/* Active session pill floats above bottom nav */}
+ <div className="sticky bottom-0 z-50 relative">
<ActiveSessionBar />
<nav className="border-t border-surface-border bg-surface-base/95 backdrop-blur-sm">
<div className="max-w-6xl mx-auto flex">
diff --git a/web/src/pages/AddWorkout.tsx b/web/src/pages/AddWorkout.tsx
index fe1585e..509aee7 100644
--- a/web/src/pages/AddWorkout.tsx
+++ b/web/src/pages/AddWorkout.tsx
@@ -1,7 +1,8 @@
import { useState } from 'react'
import { useNavigate } from 'react-router-dom'
-import { Plus, ArrowLeft, Trash2, AlertCircle, Dumbbell, Clock, FileText, Zap, Target, Gauge, BookOpen } from 'lucide-react'
+import { Plus, ArrowLeft, Trash2, AlertCircle, Dumbbell, Clock, FileText, Zap, Target, Gauge, BookOpen, CalendarDays } from 'lucide-react'
import { workoutAPI } from '../services/api'
+import { useSettingsStore, weightShort } from '../stores/settings'
import ExercisePicker from '../components/ExercisePicker'
import ProgramPicker from '../components/ProgramPicker'
import * as types from '../types'
@@ -10,17 +11,20 @@ interface WorkoutFormData {
name: string
notes: string
duration: number
+ date: string
exercises: { exercise_id: number; notes: string; sets: { set_number: number; reps: number; weight: number }[] }[]
}
export default function AddWorkout() {
const navigate = useNavigate()
+ const { settings } = useSettingsStore()
+ const wUnit = weightShort(settings.weight_unit)
const [showPicker, setShowPicker] = useState(false)
const [showProgramPicker, setShowProgramPicker] = useState(false)
const [loading, setLoading] = useState(false)
const [error, setError] = useState('')
const [pickerExercises, setPickerExercises] = useState<Record<number, types.Exercise>>({})
- const [formData, setFormData] = useState<WorkoutFormData>({ name: '', notes: '', duration: 0, exercises: [] })
+ const [formData, setFormData] = useState<WorkoutFormData>({ name: '', notes: '', duration: 0, date: new Date().toISOString().slice(0, 10), exercises: [] })
const loadFromProgram = (program: types.Program) => {
const newMap: Record<number, types.Exercise> = { ...pickerExercises }
@@ -73,7 +77,7 @@ export default function AddWorkout() {
if (formData.exercises.length === 0) { setError('Add at least one exercise'); return }
setLoading(true)
try {
- await workoutAPI.create({ ...formData, started_at: new Date().toISOString() })
+ await workoutAPI.create({ ...formData, duration: formData.duration * 60, started_at: new Date(formData.date).toISOString() })
navigate('/workouts')
} catch (err: any) {
setError(err.response?.data?.error || 'Failed to create workout')
@@ -115,6 +119,14 @@ export default function AddWorkout() {
<input type="text" value={formData.name} onChange={e => setFormData(prev => ({ ...prev, name: e.target.value }))} placeholder="e.g., Leg Day, Push Day" className="input mt-1" />
</div>
+ <div>
+ <div className="flex items-center gap-2 mb-2">
+ <CalendarDays className="w-4 h-4 text-brand-500" />
+ <label className="label">Date</label>
+ </div>
+ <input type="date" value={formData.date} onChange={e => setFormData(prev => ({ ...prev, date: e.target.value }))} className="input" max={new Date().toISOString().slice(0, 10)} />
+ </div>
+
<div>
<div className="flex items-center gap-2 mb-2">
<Clock className="w-4 h-4 text-brand-500" />
@@ -140,7 +152,7 @@ export default function AddWorkout() {
<div className="grid grid-cols-3 gap-2 p-3 bg-brand-500/10 border border-brand-500/20 rounded-lg">
<div className="text-center"><div className="text-sm font-bold text-brand-500">{formData.exercises.length}</div><div className="text-xs text-tx-muted">Exercises</div></div>
<div className="text-center"><div className="text-sm font-bold text-brand-500">{totalSets}</div><div className="text-xs text-tx-muted">Sets</div></div>
- <div className="text-center"><div className="text-sm font-bold text-brand-500">{Math.round(totalWeight)}</div><div className="text-xs text-tx-muted">Total lbs</div></div>
+ <div className="text-center"><div className="text-sm font-bold text-brand-500">{Math.round(totalWeight)}</div><div className="text-xs text-tx-muted">Total {wUnit}</div></div>
</div>
)}
@@ -210,7 +222,7 @@ export default function AddWorkout() {
<label className="text-xs text-tx-muted font-medium uppercase tracking-wider block mb-1">Weight</label>
<div className="relative">
<input type="number" inputMode="decimal" value={set.weight || ''} onChange={e => updateSet(exIdx, setIdx, 'weight', e.target.value)} placeholder="225" className="input text-sm w-full pr-7" min="0" step="0.5" />
- <span className="absolute right-2 top-1/2 -translate-y-1/2 text-xs text-tx-muted font-medium pointer-events-none">lbs</span>
+ <span className="absolute right-2 top-1/2 -translate-y-1/2 text-xs text-tx-muted font-medium pointer-events-none">{wUnit}</span>
</div>
</div>
<button type="button" onClick={() => removeSet(exIdx, setIdx)} className="p-2 hover:bg-error-500/20 rounded transition-colors flex-shrink-0">
diff --git a/web/src/pages/Dashboard.tsx b/web/src/pages/Dashboard.tsx
index fb6e1b6..929fa54 100644
--- a/web/src/pages/Dashboard.tsx
+++ b/web/src/pages/Dashboard.tsx
@@ -12,6 +12,7 @@ import Loading from '../components/Loading'
import { workoutAPI, foodAPI, weightAPI, userAPI } from '../services/api'
import { useWorkoutSession } from '../stores/workoutSession'
import { useAuthStore } from '../stores/auth'
+import { useSettingsStore, weightShort } from '../stores/settings'
import { useNavigate, Link } from 'react-router-dom'
import * as types from '../types'
import { muscleColor } from '../utils/exerciseUtils'
@@ -124,13 +125,15 @@ export default function Dashboard() {
const navigate = useNavigate()
const { session } = useWorkoutSession()
const { user } = useAuthStore()
+ const { settings: storedSettings } = useSettingsStore()
const [workouts, setWorkouts] = useState<types.Workout[]>([])
const [food, setFood] = useState<types.DailyStats>(DEFAULT_FOOD)
const [weightLogs, setWeightLogs] = useState<types.WeightLog[]>([])
- const [settings, setSettings] = useState<types.UserSettings>(DEFAULT_SETTINGS)
+ const [settings, setSettings] = useState<types.UserSettings>(storedSettings)
const [loading, setLoading] = useState(true)
const [error, setError] = useState<string | null>(null)
+ const wUnit = weightShort(settings.weight_unit)
useEffect(() => {
Promise.all([
@@ -247,7 +250,7 @@ export default function Dashboard() {
<p className="text-[11px] text-tx-muted uppercase tracking-wider font-medium">
{format(TODAY, 'EEEE, MMMM d')}
</p>
- <h1 className="font-display font-bold text-2xl text-tx-primary mt-0.5 truncate">
+ <h1 className="font-display font-bold text-2xl text-tx-primary mt-0.5">
{greeting()}, {username}
</h1>
</div>
@@ -348,7 +351,7 @@ export default function Dashboard() {
<YAxis hide />
<Tooltip
contentStyle={TOOLTIP_STYLE}
- formatter={(v: number) => [`${v.toLocaleString()} lbs`, 'Volume']}
+ formatter={(v: number) => [`${v.toLocaleString()} ${wUnit}`, 'Volume']}
labelFormatter={(label: string) => chartData.find(d => d.date === label)?.name || label}
cursor={{ fill: 'rgba(99,102,241,0.08)', radius: 4 }}
/>
@@ -362,21 +365,21 @@ export default function Dashboard() {
</div>
{/* Current week day dots */}
- <div className="flex items-center justify-between mt-3 px-1">
+ <div className="flex items-center justify-between mt-4 px-1">
{weekDays.map((day, i) => {
const hasWorkout = workouts.some(w => isSameDay(new Date(w.started_at), day))
const isToday = isSameDay(day, TODAY)
const isFuture = day > TODAY
return (
- <div key={i} className="flex flex-col items-center gap-1">
- <span className={`text-[9px] font-medium ${isToday ? 'text-brand-400' : 'text-tx-muted'}`}>
+ <div key={i} className="flex flex-col items-center gap-1.5">
+ <span className={`text-[10px] font-semibold ${isToday ? 'text-brand-400' : 'text-tx-muted'}`}>
{format(day, 'EEEEE')}
</span>
- <div className={`w-2 h-2 rounded-full transition-colors ${
- hasWorkout ? 'bg-brand-500' :
- isToday ? 'bg-brand-500/30 ring-1 ring-brand-500/50' :
- isFuture ? 'bg-surface-border/30' :
- 'bg-surface-border'
+ <div className={`w-3 h-3 rounded-full transition-all ${
+ hasWorkout ? 'bg-brand-500 shadow-sm shadow-brand-500/50' :
+ isToday ? 'bg-transparent ring-2 ring-brand-500/60' :
+ isFuture ? 'bg-surface-border/20' :
+ 'bg-surface-border/60'
}`} />
</div>
)
@@ -410,7 +413,7 @@ export default function Dashboard() {
{/* Row 0: spacer + month labels */}
<div />
{heatmapWeeks.map((_, i) => (
- <div key={i} className="text-[9px] text-tx-muted font-medium truncate leading-none pb-0.5">
+ <div key={i} className="text-[9px] text-tx-muted font-medium overflow-visible whitespace-nowrap leading-none pb-0.5">
{monthLabels[i] ?? ''}
</div>
))}
@@ -473,7 +476,7 @@ export default function Dashboard() {
{format(new Date(lastWorkout.started_at), 'MMM d')}
{mins > 0 && ` · ${mins} min`}
{totalSets > 0 && ` · ${totalSets} sets`}
- {totalVolume > 0 && ` · ${totalVolume.toLocaleString()} lbs`}
+ {totalVolume > 0 && ` · ${totalVolume.toLocaleString()} ${wUnit}`}
</p>
</div>
<Link to="/workouts" className="flex items-center gap-0.5 text-xs text-brand-400 hover:text-brand-300 flex-shrink-0 transition-colors">
@@ -510,7 +513,7 @@ export default function Dashboard() {
</div>
{best && (
<span className="text-xs text-tx-muted tabular-nums flex-shrink-0">
- {sets.length}×{best.weight > 0 ? ` ${best.weight}lb` : ' BW'}
+ {sets.length}×{best.weight > 0 ? ` ${best.weight}${wUnit}` : ' BW'}
</span>
)}
</div>
@@ -585,8 +588,7 @@ export default function Dashboard() {
</div>
{/* ── Muscle group balance ────────────────────── */}
- {muscleData.length > 0 && (
- <div className="card p-4">
+ <div className="card p-4">
<div className="flex items-center justify-between mb-1">
<div className="flex items-center gap-2">
<Dumbbell className="w-4 h-4 text-brand-500" />
@@ -595,12 +597,20 @@ export default function Dashboard() {
<span className="text-xs text-tx-muted">{workouts.length} workouts</span>
</div>
- {topMuscle && (
+ {topMuscle ? (
<p className="text-xs text-tx-muted mb-3 italic">
{muscleRoast(topMuscle)}
</p>
+ ) : (
+ <p className="text-xs text-tx-muted mb-3">Log workouts to see which muscles you train most.</p>
)}
+ {muscleData.length === 0 ? (
+ <div className="flex flex-col items-center justify-center py-6 gap-2">
+ <Dumbbell className="w-6 h-6 text-tx-muted opacity-30" />
+ <p className="text-xs text-tx-muted">No workout data yet</p>
+ </div>
+ ) : (
<div className="flex flex-col sm:flex-row items-center gap-4">
{/* Donut */}
<div className="flex-shrink-0 flex items-center justify-center">
@@ -659,8 +669,8 @@ export default function Dashboard() {
})}
</div>
</div>
- </div>
- )}
+ )}
+ </div>
{/* ── Weight sparkline ───────────────────────── */}
{weightLogs.length >= 2 && (
@@ -671,12 +681,12 @@ export default function Dashboard() {
<h2 className="section-title">Weight</h2>
</div>
<div className="text-right">
- <p className="text-sm font-bold text-tx-primary">{weightLogs[0].weight} lbs</p>
+ <p className="text-sm font-bold text-tx-primary">{weightLogs[0].weight} {wUnit}</p>
{(() => {
const delta = weightLogs[0].weight - weightLogs[weightLogs.length - 1].weight
return (
<p className={`text-xs ${delta <= 0 ? 'text-brand-400' : 'text-tx-muted'}`}>
- {delta <= 0 ? '↓' : '↑'}{Math.abs(delta).toFixed(1)} lbs
+ {delta <= 0 ? '↓' : '↑'}{Math.abs(delta).toFixed(1)} {wUnit}
</p>
)
})()}
@@ -688,7 +698,7 @@ export default function Dashboard() {
<Line dataKey="weight" dot={false} stroke="#6366f1" strokeWidth={2} type="monotone" />
<Tooltip
contentStyle={TOOLTIP_STYLE}
- formatter={(v: number) => [`${v} lbs`, 'Weight']}
+ formatter={(v: number) => [`${v} ${wUnit}`, 'Weight']}
/>
</LineChart>
</ResponsiveContainer>
diff --git a/web/src/pages/EditWorkout.tsx b/web/src/pages/EditWorkout.tsx
index 50e0f2b..13d860e 100644
--- a/web/src/pages/EditWorkout.tsx
+++ b/web/src/pages/EditWorkout.tsx
@@ -2,6 +2,7 @@ import { useState, useEffect } from 'react'
import { useNavigate, useParams } from 'react-router-dom'
import { Plus, ArrowLeft, Trash2, AlertCircle, Dumbbell, Clock, FileText, Zap, Target, Gauge } from 'lucide-react'
import { workoutAPI } from '../services/api'
+import { useSettingsStore, weightShort } from '../stores/settings'
import ExercisePicker from '../components/ExercisePicker'
import * as types from '../types'
@@ -15,12 +16,15 @@ interface WorkoutFormData {
export default function EditWorkout() {
const { id } = useParams<{ id: string }>()
const navigate = useNavigate()
+ const { settings } = useSettingsStore()
+ const wUnit = weightShort(settings.weight_unit)
const [showPicker, setShowPicker] = useState(false)
const [loading, setLoading] = useState(false)
const [initialLoading, setInitialLoading] = useState(true)
const [error, setError] = useState('')
const [pickerExercises, setPickerExercises] = useState<Record<number, types.Exercise>>({})
const [formData, setFormData] = useState<WorkoutFormData>({ name: '', notes: '', duration: 0, exercises: [] })
+ const [originalStartedAt, setOriginalStartedAt] = useState('')
useEffect(() => {
const workoutId = Number(id)
@@ -30,10 +34,11 @@ export default function EditWorkout() {
const map: Record<number, types.Exercise> = {}
;(workout.exercises || []).forEach(ex => { map[ex.exercise_id] = ex.exercise })
setPickerExercises(map)
+ setOriginalStartedAt(workout.started_at || new Date().toISOString())
setFormData({
name: workout.name,
notes: workout.notes || '',
- duration: workout.duration,
+ duration: Math.round(workout.duration / 60),
exercises: (workout.exercises || []).map(ex => ({
exercise_id: ex.exercise_id,
notes: ex.notes || '',
@@ -84,7 +89,7 @@ export default function EditWorkout() {
if (formData.exercises.length === 0) { setError('Add at least one exercise'); return }
setLoading(true)
try {
- await workoutAPI.update(Number(id), { ...formData, started_at: new Date().toISOString() })
+ await workoutAPI.update(Number(id), { ...formData, duration: formData.duration * 60, started_at: originalStartedAt || new Date().toISOString() })
navigate('/workouts')
} catch (err: any) {
setError(err.response?.data?.error || 'Failed to update workout')
@@ -158,7 +163,7 @@ export default function EditWorkout() {
<div className="grid grid-cols-3 gap-2 p-3 bg-brand-500/10 border border-brand-500/20 rounded-lg">
<div className="text-center"><div className="text-sm font-bold text-brand-500">{formData.exercises.length}</div><div className="text-xs text-tx-muted">Exercises</div></div>
<div className="text-center"><div className="text-sm font-bold text-brand-500">{totalSets}</div><div className="text-xs text-tx-muted">Sets</div></div>
- <div className="text-center"><div className="text-sm font-bold text-brand-500">{Math.round(totalWeight)}</div><div className="text-xs text-tx-muted">Total lbs</div></div>
+ <div className="text-center"><div className="text-sm font-bold text-brand-500">{Math.round(totalWeight)}</div><div className="text-xs text-tx-muted">Total {wUnit}</div></div>
</div>
)}
@@ -220,7 +225,7 @@ export default function EditWorkout() {
<label className="text-xs text-tx-muted font-medium uppercase tracking-wider block mb-1">Weight</label>
<div className="relative">
<input type="number" inputMode="decimal" value={set.weight || ''} onChange={e => updateSet(exIdx, setIdx, 'weight', e.target.value)} placeholder="225" className="input text-sm w-full pr-7" min="0" step="0.5" />
- <span className="absolute right-2 top-1/2 -translate-y-1/2 text-xs text-tx-muted font-medium pointer-events-none">lbs</span>
+ <span className="absolute right-2 top-1/2 -translate-y-1/2 text-xs text-tx-muted font-medium pointer-events-none">{wUnit}</span>
</div>
</div>
<button type="button" onClick={() => removeSet(exIdx, setIdx)} className="p-2 hover:bg-error-500/20 rounded transition-colors flex-shrink-0">
diff --git a/web/src/pages/Programs.tsx b/web/src/pages/Programs.tsx
index 5e549b0..f16a785 100644
--- a/web/src/pages/Programs.tsx
+++ b/web/src/pages/Programs.tsx
@@ -1,6 +1,7 @@
-import { useState, useEffect } from 'react'
+import { useState, useEffect, useRef } from 'react'
+import { createPortal } from 'react-dom'
import { format } from 'date-fns'
-import { BookOpen, Plus, Dumbbell, Edit2, Trash2, AlertCircle, Search, Play, ChevronRight } from 'lucide-react'
+import { BookOpen, Plus, Dumbbell, Edit2, Trash2, AlertCircle, Search, Play, ChevronRight, MoreVertical } from 'lucide-react'
import { useNavigate } from 'react-router-dom'
import Loading from '../components/Loading'
import { programAPI } from '../services/api'
@@ -20,6 +21,19 @@ function ProgramCard({
}) {
const navigate = useNavigate()
const { session, startSession } = useWorkoutSession()
+ const [menuOpen, setMenuOpen] = useState(false)
+ const menuRef = useRef<HTMLDivElement>(null)
+ const portalRef = useRef<HTMLDivElement>(null)
+
+ useEffect(() => {
+ const handler = (e: MouseEvent) => {
+ const inMenu = menuRef.current?.contains(e.target as Node)
+ const inPortal = portalRef.current?.contains(e.target as Node)
+ if (!inMenu && !inPortal) setMenuOpen(false)
+ }
+ document.addEventListener('mousedown', handler)
+ return () => document.removeEventListener('mousedown', handler)
+ }, [])
const handleStart = (e: React.MouseEvent) => {
e.stopPropagation()
@@ -91,7 +105,7 @@ function ProgramCard({
const totalSets = program.exercises?.reduce((s, e) => s + (e.sets?.length || 0), 0) || 0
return (
- <div className="card overflow-hidden group active:scale-[0.99] transition-transform">
+ <div className="card group active:scale-[0.99] transition-transform">
<div className="flex items-center p-4 gap-3">
<button
className="flex-1 flex items-center gap-3 min-w-0 text-left"
@@ -111,30 +125,98 @@ function ProgramCard({
)}
<div className="min-w-0 flex-1">
<p className="text-sm font-semibold text-tx-primary truncate">{program.name}</p>
- <div className="flex items-center flex-wrap gap-x-2 gap-y-0.5 mt-0.5">
- <span className="text-xs text-tx-muted">{format(new Date(program.created_at), 'MMM d, yyyy')}</span>
+ <p className="text-xs text-tx-muted mt-0.5 whitespace-nowrap">{format(new Date(program.created_at), 'MMM d, yyyy')}</p>
+ <div className="flex items-center gap-x-2 mt-0.5 min-w-0 overflow-hidden">
+ <span className="text-xs text-tx-muted whitespace-nowrap">{program.exercises?.length || 0} exercises</span>
<span className="text-tx-muted/40 text-xs">·</span>
- <span className="text-xs text-tx-muted">{program.exercises?.length || 0} exercises</span>
- <span className="text-tx-muted/40 text-xs">·</span>
- <span className="text-xs text-tx-muted">{totalSets} sets</span>
+ <span className="text-xs text-tx-muted whitespace-nowrap">{totalSets} sets</span>
</div>
</div>
<ChevronRight className="w-4 h-4 text-tx-muted flex-shrink-0" />
</button>
- <div className="flex items-center gap-0.5 sm:opacity-0 sm:group-hover:opacity-100 transition-opacity">
- <button onClick={handleStart}
- className="p-2 hover:bg-brand-500/10 rounded-lg transition-colors" title="Start workout">
- <Play className="w-4 h-4 text-brand-500" />
- </button>
- <button onClick={e => { e.stopPropagation(); onEdit(program.id) }}
- className="p-2 hover:bg-surface-muted rounded-lg transition-colors">
- <Edit2 className="w-4 h-4 text-brand-500" />
- </button>
- <button onClick={e => { e.stopPropagation(); setConfirming(true) }}
- className="p-2 hover:bg-error-500/10 rounded-lg transition-colors">
- <Trash2 className="w-4 h-4 text-error-400" />
+ {/* Mobile: kebab | Desktop: hover icons */}
+ <div className="relative flex-shrink-0" ref={menuRef}>
+ {/* Mobile kebab trigger */}
+ <button
+ onClick={e => { e.stopPropagation(); setMenuOpen(o => !o) }}
+ className={`sm:hidden p-2 rounded-lg transition-colors ${menuOpen ? 'bg-surface-muted' : 'hover:bg-surface-muted'}`}
+ aria-label="Options"
+ >
+ <MoreVertical className="w-4 h-4 text-tx-muted" />
</button>
+
+ {/* Centered modal dropdown — portal to escape transform stacking context */}
+ {menuOpen && createPortal(
+ <>
+ <div
+ className="fixed inset-0 z-40 bg-black/40 backdrop-blur-[2px]"
+ onClick={e => { e.stopPropagation(); setMenuOpen(false) }}
+ />
+ <div ref={portalRef} className="fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-64 bg-surface-overlay border border-surface-border/60 rounded-2xl shadow-2xl z-50 overflow-hidden">
+ <div className="px-4 pt-4 pb-3">
+ <p className="text-[10px] font-semibold text-tx-muted uppercase tracking-wider text-center">Program</p>
+ <p className="text-sm font-semibold text-tx-primary text-center mt-0.5 truncate">{program.name}</p>
+ </div>
+ <div className="border-t border-surface-border/40 py-1.5">
+ <button
+ onClick={e => { e.stopPropagation(); setMenuOpen(false); handleStart(e) }}
+ className="w-full flex items-center gap-3 px-4 py-3 text-sm font-medium text-tx-primary hover:bg-surface-muted/60 active:bg-surface-muted transition-colors"
+ >
+ <div className="w-8 h-8 rounded-xl bg-brand-500/10 flex items-center justify-center flex-shrink-0">
+ <Play className="w-4 h-4 text-brand-500" />
+ </div>
+ Start Workout
+ </button>
+ <div className="mx-4 border-t border-surface-border/30" />
+ <button
+ onClick={e => { e.stopPropagation(); setMenuOpen(false); onEdit(program.id) }}
+ className="w-full flex items-center gap-3 px-4 py-3 text-sm font-medium text-tx-primary hover:bg-surface-muted/60 active:bg-surface-muted transition-colors"
+ >
+ <div className="w-8 h-8 rounded-xl bg-brand-500/10 flex items-center justify-center flex-shrink-0">
+ <Edit2 className="w-4 h-4 text-brand-500" />
+ </div>
+ Edit Program
+ </button>
+ <div className="mx-4 border-t border-surface-border/30" />
+ <button
+ onClick={e => { e.stopPropagation(); setMenuOpen(false); setConfirming(true) }}
+ className="w-full flex items-center gap-3 px-4 py-3 text-sm font-medium text-error-400 hover:bg-error-500/10 active:bg-error-500/15 transition-colors"
+ >
+ <div className="w-8 h-8 rounded-xl bg-error-500/10 flex items-center justify-center flex-shrink-0">
+ <Trash2 className="w-4 h-4 text-error-400" />
+ </div>
+ Delete Program
+ </button>
+ </div>
+ <div className="border-t border-surface-border/40 p-3">
+ <button
+ onClick={e => { e.stopPropagation(); setMenuOpen(false) }}
+ className="w-full py-2.5 text-sm font-semibold text-tx-muted bg-surface-muted/60 hover:bg-surface-muted rounded-xl transition-colors"
+ >
+ Cancel
+ </button>
+ </div>
+ </div>
+ </>,
+ document.body
+ )}
+
+ {/* Desktop hover icons */}
+ <div className="hidden sm:flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity">
+ <button onClick={handleStart}
+ className="p-2 hover:bg-brand-500/10 rounded-lg transition-colors" title="Start workout">
+ <Play className="w-4 h-4 text-brand-500" />
+ </button>
+ <button onClick={e => { e.stopPropagation(); onEdit(program.id) }}
+ className="p-2 hover:bg-surface-muted rounded-lg transition-colors">
+ <Edit2 className="w-4 h-4 text-brand-500" />
+ </button>
+ <button aria-label="Delete" onClick={e => { e.stopPropagation(); setConfirming(true) }}
+ className="p-2 hover:bg-error-500/10 rounded-lg transition-colors">
+ <Trash2 className="w-4 h-4 text-error-400" />
+ </button>
+ </div>
</div>
</div>
</div>
diff --git a/web/src/pages/Weight.tsx b/web/src/pages/Weight.tsx
index 8f26ae9..2ea3214 100644
--- a/web/src/pages/Weight.tsx
+++ b/web/src/pages/Weight.tsx
@@ -4,6 +4,7 @@ import { format, subDays } from 'date-fns'
import { HelpTip } from '../components/Tooltip'
import Loading from '../components/Loading'
import { weightAPI } from '../services/api'
+import { useSettingsStore, weightShort } from '../stores/settings'
import * as types from '../types'
const PERIODS = ['7d', '30d', '90d', 'All'] as const
@@ -15,6 +16,8 @@ const getPeriodDays = (p: Period) => {
}
export default function Weight() {
+ const { settings } = useSettingsStore()
+ const wUnit = weightShort(settings.weight_unit)
const [period, setPeriod] = useState<Period>('30d')
const [newWeight, setNewWeight] = useState('')
const [logs, setLogs] = useState<types.WeightLog[]>([])
@@ -97,32 +100,41 @@ export default function Weight() {
<p className="text-tx-muted text-sm mt-0.5">Track your body weight over time</p>
</div>
<span className="badge-brand">
- <Calendar className="w-3 h-3" /> lbs
+ <Calendar className="w-3 h-3" /> {wUnit}
</span>
</div>
{/* Current weight hero */}
<div className="card p-6 border-brand-500/20 bg-brand-500/5">
- <div className="flex items-start justify-between">
- <div>
- <p className="stat-label mb-2">Current Weight</p>
- <div className="flex items-end gap-2">
- <span className="stat-value text-5xl">{current.toFixed(1)}</span>
- <span className="text-tx-muted text-lg mb-1">lbs</span>
- </div>
- </div>
- <div className={`flex items-center gap-1.5 text-sm font-semibold px-3 py-1.5 rounded-lg ${
- change < 0
- ? 'bg-success-500/10 border border-success-500/20 text-success-400'
- : 'bg-error-500/10 border border-error-500/20 text-error-400'
- }`}>
- {change < 0 ? <TrendingDown className="w-4 h-4" /> : <TrendingUp className="w-4 h-4" />}
- {Math.abs(change).toFixed(1)} lbs
+ {logs.length === 0 ? (
+ <div className="text-center py-2">
+ <p className="stat-label mb-1">Current Weight</p>
+ <p className="text-tx-muted text-sm">No logs yet — log your first weight below</p>
</div>
- </div>
- <p className="text-xs text-tx-muted mt-3">
- {Math.abs(change).toFixed(1)} lbs {change < 0 ? 'lost' : 'gained'} over {period}
- </p>
+ ) : (
+ <>
+ <div className="flex items-start justify-between">
+ <div>
+ <p className="stat-label mb-2">Current Weight</p>
+ <div className="flex items-end gap-2">
+ <span className="stat-value text-5xl">{current.toFixed(1)}</span>
+ <span className="text-tx-muted text-lg mb-1">{wUnit}</span>
+ </div>
+ </div>
+ <div className={`flex items-center gap-1.5 text-sm font-semibold px-3 py-1.5 rounded-lg ${
+ change < 0
+ ? 'bg-success-500/10 border border-success-500/20 text-success-400'
+ : 'bg-error-500/10 border border-error-500/20 text-error-400'
+ }`}>
+ {change < 0 ? <TrendingDown className="w-4 h-4" /> : <TrendingUp className="w-4 h-4" />}
+ {Math.abs(change).toFixed(1)} {wUnit}
+ </div>
+ </div>
+ <p className="text-xs text-tx-muted mt-3">
+ {Math.abs(change).toFixed(1)} {wUnit} {change < 0 ? 'lost' : 'gained'} over {period}
+ </p>
+ </>
+ )}
</div>
{/* Stats row */}
@@ -138,7 +150,7 @@ export default function Weight() {
<HelpTip content={s.tip} />
</div>
<span className="stat-value text-xl">{s.value.toFixed(1)}</span>
- <span className="text-xs text-tx-muted ml-1">lbs</span>
+ <span className="text-xs text-tx-muted ml-1">{wUnit}</span>
</div>
))}
</div>
@@ -165,28 +177,34 @@ export default function Weight() {
</div>
{/* Mini chart */}
- <div className="flex items-end gap-1 h-24 mb-1">
- {filtered.slice().reverse().map((entry, i) => {
- const pct = max > min ? ((entry.weight - min) / (max - min)) * 100 : 50
- const height = 20 + pct * 0.8
- return (
- <div key={i} className="flex-1 flex flex-col items-center gap-1 group relative">
- <div
- className="w-full bg-brand-500/20 border border-brand-500/30 rounded-sm transition-all group-hover:bg-brand-500/40"
- style={{ height: `${height}%` }}
- />
- <div className="absolute -top-6 left-1/2 -translate-x-1/2 opacity-0 group-hover:opacity-100 transition-opacity bg-surface-overlay border border-surface-border rounded px-1.5 py-0.5 text-xs text-tx-primary whitespace-nowrap z-10">
- {entry.weight.toFixed(1)} lbs
- </div>
- </div>
- )
- })}
- </div>
- {filtered.length > 0 && (
- <div className="flex justify-between text-xs text-tx-muted mt-1">
- <span>{format(new Date(filtered[filtered.length - 1].logged_at), 'MMM d')}</span>
- <span>{format(new Date(filtered[0].logged_at), 'MMM d')}</span>
+ {filtered.length === 0 ? (
+ <div className="flex items-center justify-center h-24 text-tx-muted text-sm">
+ No data for this period
</div>
+ ) : (
+ <>
+ <div className="flex items-end gap-1 h-24 mb-1">
+ {filtered.slice().reverse().map((entry, i) => {
+ const pct = max > min ? ((entry.weight - min) / (max - min)) * 100 : 50
+ const height = 20 + pct * 0.8
+ return (
+ <div key={i} className="flex-1 flex flex-col items-center gap-1 group relative">
+ <div
+ className="w-full bg-brand-500/20 border border-brand-500/30 rounded-sm transition-all group-hover:bg-brand-500/40"
+ style={{ height: `${height}%` }}
+ />
+ <div className="absolute -top-6 left-1/2 -translate-x-1/2 opacity-0 group-hover:opacity-100 transition-opacity bg-surface-overlay border border-surface-border rounded px-1.5 py-0.5 text-xs text-tx-primary whitespace-nowrap z-10">
+ {entry.weight.toFixed(1)} {wUnit}
+ </div>
+ </div>
+ )
+ })}
+ </div>
+ <div className="flex justify-between text-xs text-tx-muted mt-1">
+ <span>{format(new Date(filtered[filtered.length - 1].logged_at), 'MMM d')}</span>
+ <span>{format(new Date(filtered[0].logged_at), 'MMM d')}</span>
+ </div>
+ </>
)}
</div>
@@ -203,7 +221,7 @@ export default function Weight() {
step="0.1"
className="input pr-10"
/>
- <span className="absolute right-3.5 top-1/2 -translate-y-1/2 text-xs text-tx-muted">lbs</span>
+ <span className="absolute right-3.5 top-1/2 -translate-y-1/2 text-xs text-tx-muted">{wUnit}</span>
</div>
<button
onClick={handleLog}
@@ -236,7 +254,7 @@ export default function Weight() {
{delta < 0 ? '↓' : '↑'}{Math.abs(delta).toFixed(1)}
</span>
)}
- <span className="text-sm font-semibold text-tx-primary">{entry.weight.toFixed(1)} lbs</span>
+ <span className="text-sm font-semibold text-tx-primary">{entry.weight.toFixed(1)} {wUnit}</span>
</div>
</div>
)
diff --git a/web/src/pages/Workouts.tsx b/web/src/pages/Workouts.tsx
index 9912b36..64c2239 100644
--- a/web/src/pages/Workouts.tsx
+++ b/web/src/pages/Workouts.tsx
@@ -1,16 +1,33 @@
-import { useState, useEffect } from 'react'
+import { useState, useEffect, useRef } from 'react'
+import { createPortal } from 'react-dom'
import { format } from 'date-fns'
-import { Dumbbell, Plus, Clock, Search, AlertCircle, Edit2, Trash2, TrendingUp, ChevronRight } from 'lucide-react'
+import { Dumbbell, Plus, Clock, Search, AlertCircle, Edit2, Trash2, TrendingUp, ChevronRight, MoreVertical } from 'lucide-react'
import { useNavigate } from 'react-router-dom'
import Loading from '../components/Loading'
import { workoutAPI } from '../services/api'
+import { useSettingsStore, weightShort } from '../stores/settings'
import * as types from '../types'
import { muscleColor } from '../utils/exerciseUtils'
function WorkoutCard({ workout, onEdit, onDelete }: { workout: types.Workout; onEdit: (id: number) => void; onDelete: (id: number) => void }) {
const navigate = useNavigate()
+ const { settings } = useSettingsStore()
+ const wUnit = weightShort(settings.weight_unit)
const [confirming, setConfirming] = useState(false)
const [deleting, setDeleting] = useState(false)
+ const [menuOpen, setMenuOpen] = useState(false)
+ const menuRef = useRef<HTMLDivElement>(null)
+ const portalRef = useRef<HTMLDivElement>(null)
+
+ useEffect(() => {
+ const handler = (e: MouseEvent) => {
+ const inMenu = menuRef.current?.contains(e.target as Node)
+ const inPortal = portalRef.current?.contains(e.target as Node)
+ if (!inMenu && !inPortal) setMenuOpen(false)
+ }
+ document.addEventListener('mousedown', handler)
+ return () => document.removeEventListener('mousedown', handler)
+ }, [])
const durationMin = Math.round(workout.duration / 60)
const totalVolume = Math.round(
workout.exercises?.reduce((total, e) =>
@@ -58,7 +75,7 @@ function WorkoutCard({ workout, onEdit, onDelete }: { workout: types.Workout; on
}
return (
- <div className="card overflow-hidden group active:scale-[0.99] transition-transform">
+ <div className="card group active:scale-[0.99] transition-transform">
<div className="flex items-center p-4 gap-3">
{/* Thumbnail — tappable, navigates to detail */}
<button
@@ -79,23 +96,20 @@ function WorkoutCard({ workout, onEdit, onDelete }: { workout: types.Workout; on
)}
<div className="min-w-0 flex-1">
<p className="text-sm font-semibold text-tx-primary truncate">{workout.name}</p>
- <div className="flex items-center flex-wrap gap-x-2 gap-y-0.5 mt-0.5">
- <span className="text-xs text-tx-muted">{format(new Date(workout.started_at), 'MMM d, yyyy')}</span>
+ <p className="text-xs text-tx-muted mt-0.5 whitespace-nowrap">{format(new Date(workout.started_at), 'MMM d, yyyy')}</p>
+ <div className="flex items-center gap-x-2 mt-0.5 min-w-0 overflow-hidden">
{durationMin > 0 && (
- <>
- <span className="text-tx-muted/40 text-xs">·</span>
- <span className="flex items-center gap-1 text-xs text-tx-muted">
- <Clock className="w-3 h-3" />{durationMin} min
- </span>
- </>
+ <span className="flex items-center gap-1 text-xs text-tx-muted whitespace-nowrap">
+ <Clock className="w-3 h-3 flex-shrink-0" />{durationMin} min
+ </span>
)}
- <span className="text-tx-muted/40 text-xs">·</span>
- <span className="text-xs text-tx-muted">{workout.exercises?.length || 0} exercises</span>
+ {durationMin > 0 && <span className="text-tx-muted/40 text-xs">·</span>}
+ <span className="text-xs text-tx-muted whitespace-nowrap">{workout.exercises?.length || 0} exercises</span>
{totalVolume > 0 && (
<>
<span className="text-tx-muted/40 text-xs">·</span>
- <span className="flex items-center gap-1 text-xs text-tx-muted">
- <TrendingUp className="w-3 h-3" />{totalVolume.toLocaleString()} lbs
+ <span className="flex items-center gap-1 text-xs text-tx-muted whitespace-nowrap">
+ <TrendingUp className="w-3 h-3 flex-shrink-0" />{totalVolume.toLocaleString()} {wUnit}
</span>
</>
)}
@@ -104,20 +118,79 @@ function WorkoutCard({ workout, onEdit, onDelete }: { workout: types.Workout; on
<ChevronRight className="w-4 h-4 text-tx-muted flex-shrink-0" />
</button>
- {/* Action buttons — always visible on mobile, hover on desktop */}
- <div className="flex items-center gap-0.5 sm:opacity-0 sm:group-hover:opacity-100 transition-opacity">
- <button
- onClick={e => { e.stopPropagation(); onEdit(workout.id) }}
- className="p-2 hover:bg-surface-muted rounded-lg transition-colors"
- >
- <Edit2 className="w-4 h-4 text-brand-500" />
- </button>
+ {/* Mobile: kebab menu | Desktop: hover icons */}
+ <div className="relative flex-shrink-0" ref={menuRef}>
+ {/* Mobile kebab trigger */}
<button
- onClick={e => { e.stopPropagation(); setConfirming(true) }}
- className="p-2 hover:bg-error-500/10 rounded-lg transition-colors"
+ onClick={e => { e.stopPropagation(); setMenuOpen(o => !o) }}
+ className={`sm:hidden p-2 rounded-lg transition-colors ${menuOpen ? 'bg-surface-muted' : 'hover:bg-surface-muted'}`}
+ aria-label="Options"
>
- <Trash2 className="w-4 h-4 text-error-400" />
+ <MoreVertical className="w-4 h-4 text-tx-muted" />
</button>
+
+ {/* Centered modal dropdown — portal to escape transform stacking context */}
+ {menuOpen && createPortal(
+ <>
+ <div
+ className="fixed inset-0 z-40 bg-black/40 backdrop-blur-[2px]"
+ onClick={e => { e.stopPropagation(); setMenuOpen(false) }}
+ />
+ <div ref={portalRef} className="fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-64 bg-surface-overlay border border-surface-border/60 rounded-2xl shadow-2xl z-50 overflow-hidden">
+ <div className="px-4 pt-4 pb-3">
+ <p className="text-[10px] font-semibold text-tx-muted uppercase tracking-wider text-center">Workout</p>
+ <p className="text-sm font-semibold text-tx-primary text-center mt-0.5 truncate">{workout.name}</p>
+ </div>
+ <div className="border-t border-surface-border/40 py-1.5">
+ <button
+ onClick={e => { e.stopPropagation(); setMenuOpen(false); onEdit(workout.id) }}
+ className="w-full flex items-center gap-3 px-4 py-3 text-sm font-medium text-tx-primary hover:bg-surface-muted/60 active:bg-surface-muted transition-colors"
+ >
+ <div className="w-8 h-8 rounded-xl bg-brand-500/10 flex items-center justify-center flex-shrink-0">
+ <Edit2 className="w-4 h-4 text-brand-500" />
+ </div>
+ Edit Workout
+ </button>
+ <div className="mx-4 border-t border-surface-border/30" />
+ <button
+ onClick={e => { e.stopPropagation(); setMenuOpen(false); setConfirming(true) }}
+ className="w-full flex items-center gap-3 px-4 py-3 text-sm font-medium text-error-400 hover:bg-error-500/10 active:bg-error-500/15 transition-colors"
+ >
+ <div className="w-8 h-8 rounded-xl bg-error-500/10 flex items-center justify-center flex-shrink-0">
+ <Trash2 className="w-4 h-4 text-error-400" />
+ </div>
+ Delete Workout
+ </button>
+ </div>
+ <div className="border-t border-surface-border/40 p-3">
+ <button
+ onClick={e => { e.stopPropagation(); setMenuOpen(false) }}
+ className="w-full py-2.5 text-sm font-semibold text-tx-muted bg-surface-muted/60 hover:bg-surface-muted rounded-xl transition-colors"
+ >
+ Cancel
+ </button>
+ </div>
+ </div>
+ </>,
+ document.body
+ )}
+
+ {/* Desktop hover icons */}
+ <div className="hidden sm:flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity">
+ <button
+ onClick={e => { e.stopPropagation(); onEdit(workout.id) }}
+ className="p-2 hover:bg-surface-muted rounded-lg transition-colors"
+ >
+ <Edit2 className="w-4 h-4 text-brand-500" />
+ </button>
+ <button
+ aria-label="Delete"
+ onClick={e => { e.stopPropagation(); setConfirming(true) }}
+ className="p-2 hover:bg-error-500/10 rounded-lg transition-colors"
+ >
+ <Trash2 className="w-4 h-4 text-error-400" />
+ </button>
+ </div>
</div>
</div>
</div>
@@ -180,17 +253,17 @@ export default function Workouts() {
{/* Summary */}
<div className="grid grid-cols-3 gap-3">
{[
- { label: 'Total', value: workouts.length.toString(), unit: 'workouts', icon: Dumbbell },
- { label: 'This Month', value: workouts.filter(w => new Date(w.started_at).getMonth() === new Date().getMonth()).length.toString(), unit: 'sessions', icon: Clock },
- { label: 'Avg Duration', value: workouts.length > 0 ? Math.round(workouts.reduce((sum, w) => sum + w.duration, 0) / workouts.length / 60).toString() : '0', unit: 'min', icon: Clock },
+ { label: 'Total', value: workouts.length.toString(), unit: 'logged' },
+ { label: 'This Month', value: workouts.filter(w => new Date(w.started_at).getMonth() === new Date().getMonth()).length.toString(), unit: 'sessions' },
+ { label: 'Avg Time', value: workouts.length > 0 ? Math.round(workouts.reduce((sum, w) => sum + w.duration, 0) / workouts.length / 60).toString() : '0', unit: 'min' },
].map(s => (
<div key={s.label} className="card p-4">
<div className="flex items-center gap-1.5 mb-2">
- <span className="stat-label">{s.label}</span>
+ <span className="stat-label truncate">{s.label}</span>
</div>
- <div className="flex items-end gap-1.5">
+ <div className="flex items-end gap-1 min-w-0">
<span className="stat-value text-xl">{s.value}</span>
- <span className="text-xs text-tx-muted mb-0.5">{s.unit}</span>
+ <span className="text-xs text-tx-muted mb-0.5 truncate">{s.unit}</span>
</div>
</div>
))}