@titan-design/react-ui 0.2.7 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/dist/bodymap-BhG55xHM.d.mts +318 -0
  2. package/dist/bodymap-BhG55xHM.d.ts +318 -0
  3. package/dist/bodymap.d.mts +3 -0
  4. package/dist/bodymap.d.ts +3 -0
  5. package/dist/bodymap.js +2670 -0
  6. package/dist/bodymap.js.map +1 -0
  7. package/dist/bodymap.mjs +1101 -0
  8. package/dist/bodymap.mjs.map +1 -0
  9. package/dist/{chunk-5SSKGS6E.mjs → chunk-7XPB4NAO.mjs} +124 -4
  10. package/dist/chunk-7XPB4NAO.mjs.map +1 -0
  11. package/dist/{chunk-3VLOBS6O.mjs → chunk-P7TSQUN6.mjs} +3 -3
  12. package/dist/{chunk-3VLOBS6O.mjs.map → chunk-P7TSQUN6.mjs.map} +1 -1
  13. package/dist/chunk-TOD2WQBG.mjs +1048 -0
  14. package/dist/chunk-TOD2WQBG.mjs.map +1 -0
  15. package/dist/index.d.mts +375 -249
  16. package/dist/index.d.ts +375 -249
  17. package/dist/index.js +1259 -918
  18. package/dist/index.js.map +1 -1
  19. package/dist/index.mjs +1314 -2107
  20. package/dist/index.mjs.map +1 -1
  21. package/dist/theme/index.d.mts +260 -0
  22. package/dist/theme/index.d.ts +260 -0
  23. package/dist/theme/index.js +122 -2
  24. package/dist/theme/index.js.map +1 -1
  25. package/dist/theme/index.mjs +2 -2
  26. package/dist/theme/tokens-css.d.mts +5 -3
  27. package/dist/theme/tokens-css.d.ts +5 -3
  28. package/dist/theme/tokens-css.js +318 -9
  29. package/dist/theme/tokens-css.js.map +1 -1
  30. package/dist/theme/tokens-css.mjs +1 -1
  31. package/dist/theme/tokens-css.mjs.map +1 -1
  32. package/package.json +10 -1
  33. package/src/bodymap.ts +37 -0
  34. package/src/components/custom/Table/Table.test.tsx +27 -0
  35. package/src/components/custom/Table/Table.tsx +33 -17
  36. package/src/components/custom/Workout/ActiveWorkoutPage.stories.tsx +118 -0
  37. package/src/components/custom/Workout/ActiveWorkoutPage.test.tsx +171 -0
  38. package/src/components/custom/Workout/ActiveWorkoutPage.tsx +447 -0
  39. package/src/components/custom/Workout/BodyMap.tsx +5 -6
  40. package/src/components/custom/Workout/BodyMapDetailPanel.tsx +7 -8
  41. package/src/components/custom/Workout/CapacityBandChart.tsx +1 -1
  42. package/src/components/custom/Workout/ExerciseCard.test.tsx +24 -0
  43. package/src/components/custom/Workout/ExerciseCard.tsx +28 -15
  44. package/src/components/custom/Workout/ExerciseDetailPage.stories.tsx +225 -0
  45. package/src/components/custom/Workout/ExerciseDetailPage.test.tsx +128 -0
  46. package/src/components/custom/Workout/ExerciseDetailPage.tsx +630 -0
  47. package/src/components/custom/Workout/InputBar.tsx +6 -7
  48. package/src/components/custom/Workout/MesoCard.tsx +4 -2
  49. package/src/components/custom/Workout/MesoProgressBar.test.tsx +12 -0
  50. package/src/components/custom/Workout/MesoProgressBar.tsx +5 -1
  51. package/src/components/custom/Workout/MesoStatusCard.tsx +5 -5
  52. package/src/components/custom/Workout/PlaceholderStrip.tsx +2 -3
  53. package/src/components/custom/Workout/PrHistoryModal.tsx +5 -5
  54. package/src/components/custom/Workout/ProgramPlanningPage.stories.tsx +257 -0
  55. package/src/components/custom/Workout/ProgramPlanningPage.test.tsx +142 -0
  56. package/src/components/custom/Workout/ProgramPlanningPage.tsx +422 -0
  57. package/src/components/custom/Workout/ReadinessCheck.tsx +7 -8
  58. package/src/components/custom/Workout/RestTimer.test.tsx +10 -0
  59. package/src/components/custom/Workout/RestTimer.tsx +11 -9
  60. package/src/components/custom/Workout/SetRow.tsx +13 -19
  61. package/src/components/custom/Workout/StatusDot.tsx +1 -0
  62. package/src/components/custom/Workout/StrengthTrendChart.tsx +5 -5
  63. package/src/components/custom/Workout/TempoDisplay.tsx +3 -1
  64. package/src/components/custom/Workout/TrainingStatusPage.stories.tsx +212 -0
  65. package/src/components/custom/Workout/TrainingStatusPage.test.tsx +131 -0
  66. package/src/components/custom/Workout/TrainingStatusPage.tsx +321 -0
  67. package/src/components/custom/Workout/VelocityStrip.test.tsx +10 -0
  68. package/src/components/custom/Workout/VelocityStrip.tsx +16 -15
  69. package/src/components/custom/Workout/WeekRow.tsx +1 -1
  70. package/src/components/custom/Workout/WorkoutCard.tsx +5 -3
  71. package/src/components/custom/Workout/index.ts +71 -32
  72. package/src/theme/config.completeness.test.ts +77 -0
  73. package/src/theme/config.ts +151 -0
  74. package/src/theme/manifest/design-freeze.test.ts +155 -0
  75. package/src/theme/manifest/extract-css-properties.fixture.html +29 -0
  76. package/src/theme/manifest/extract-css-properties.test.ts +112 -0
  77. package/src/theme/tokens-css.ts +5 -3
  78. package/src/theme/workout-tokens.ts +12 -14
  79. package/src/utils/index.ts +10 -0
  80. package/src/utils/workout-format.test.ts +81 -0
  81. package/src/utils/workout-format.ts +83 -0
  82. package/dist/chunk-5SSKGS6E.mjs.map +0 -1
@@ -0,0 +1,171 @@
1
+ import { describe, it, expect } from 'vitest'
2
+ import { render, screen, fireEvent } from '@testing-library/react'
3
+ import {
4
+ ActiveWorkoutPage,
5
+ countCompletedSets,
6
+ deriveWorkoutProgress,
7
+ findActiveExercise,
8
+ statusToCardState,
9
+ groupExercises,
10
+ type ActiveWorkoutExercise,
11
+ type ActiveWorkoutPageProps,
12
+ } from './ActiveWorkoutPage'
13
+
14
+ const exercises: ActiveWorkoutExercise[] = [
15
+ {
16
+ id: 'warmup',
17
+ name: 'Band Pull-Apart',
18
+ status: 'completed',
19
+ unit: 'lbs',
20
+ totalPlannedSets: 2,
21
+ summary: { sets: 2, reps: 15, weight: 0, unit: 'lbs' },
22
+ setVelocities: [[0.9], [0.88]],
23
+ },
24
+ {
25
+ id: 'bench',
26
+ name: 'Barbell Bench Press',
27
+ status: 'active',
28
+ unit: 'lbs',
29
+ totalPlannedSets: 4,
30
+ setVelocities: [[0.72], [0.68]],
31
+ sets: [
32
+ { mode: 'completed', setNumber: 1, reps: 8, weight: 195, rpe: 8, unit: 'lbs' },
33
+ { mode: 'active', setNumber: 3, reps: null, weight: null, unit: 'lbs', isNextSet: true },
34
+ ],
35
+ },
36
+ {
37
+ id: 'incline',
38
+ name: 'Incline DB Press',
39
+ status: 'upcoming',
40
+ unit: 'lbs',
41
+ totalPlannedSets: 3,
42
+ prescription: '3 × 10',
43
+ supersetId: 'ss1',
44
+ },
45
+ {
46
+ id: 'lateral',
47
+ name: 'Cable Lateral Raise',
48
+ status: 'upcoming',
49
+ unit: 'lbs',
50
+ totalPlannedSets: 3,
51
+ prescription: '3 × 15',
52
+ supersetId: 'ss1',
53
+ },
54
+ ]
55
+
56
+ const baseProps: ActiveWorkoutPageProps = {
57
+ title: 'Push Day A',
58
+ subtitle: 'Week 6 of 8',
59
+ exercises,
60
+ supersets: [{ id: 'ss1', label: 'SS1', color: '#22D3EE' }],
61
+ input: { reps: '8', weight: '195' },
62
+ rest: { totalSeconds: 120, elapsedMs: 30_000, nextSetInfo: 'Set 3' },
63
+ }
64
+
65
+ describe('countCompletedSets', () => {
66
+ it('uses logged velocities when present', () => {
67
+ expect(countCompletedSets(exercises[1])).toBe(2)
68
+ })
69
+
70
+ it('falls back to the full plan for a completed exercise without velocities', () => {
71
+ expect(countCompletedSets({ ...exercises[0], setVelocities: undefined })).toBe(2)
72
+ })
73
+
74
+ it('counts zero for an upcoming exercise', () => {
75
+ expect(countCompletedSets(exercises[2])).toBe(0)
76
+ })
77
+ })
78
+
79
+ describe('deriveWorkoutProgress', () => {
80
+ it('rolls up completed exercises, sets, and the fraction', () => {
81
+ const progress = deriveWorkoutProgress(exercises)
82
+ expect(progress.completedExercises).toBe(1)
83
+ expect(progress.totalExercises).toBe(4)
84
+ expect(progress.completedSets).toBe(4)
85
+ expect(progress.totalSets).toBe(12)
86
+ expect(progress.fraction).toBeCloseTo(1 / 3)
87
+ })
88
+
89
+ it('is zeroed for an empty workout', () => {
90
+ expect(deriveWorkoutProgress([])).toEqual({
91
+ completedExercises: 0,
92
+ totalExercises: 0,
93
+ completedSets: 0,
94
+ totalSets: 0,
95
+ fraction: 0,
96
+ })
97
+ })
98
+ })
99
+
100
+ describe('findActiveExercise', () => {
101
+ it('returns the active exercise', () => {
102
+ expect(findActiveExercise(exercises)?.id).toBe('bench')
103
+ })
104
+
105
+ it('returns null when none are active', () => {
106
+ expect(findActiveExercise([exercises[0]])).toBeNull()
107
+ })
108
+ })
109
+
110
+ describe('statusToCardState', () => {
111
+ it('keeps upcoming exercises upcoming regardless of focus', () => {
112
+ expect(statusToCardState('upcoming', true)).toBe('upcoming')
113
+ expect(statusToCardState('upcoming', false)).toBe('upcoming')
114
+ })
115
+
116
+ it('expands only the focused active/completed exercise', () => {
117
+ expect(statusToCardState('active', true)).toBe('expanded')
118
+ expect(statusToCardState('active', false)).toBe('collapsed')
119
+ expect(statusToCardState('completed', true)).toBe('expanded')
120
+ })
121
+ })
122
+
123
+ describe('groupExercises', () => {
124
+ it('folds consecutive same-superset exercises into one group', () => {
125
+ const groups = groupExercises(exercises, baseProps.supersets ?? [])
126
+ expect(groups).toHaveLength(3)
127
+ expect(groups[0]).toEqual({ type: 'single', exercise: exercises[0] })
128
+ expect(groups[2].type).toBe('superset')
129
+ if (groups[2].type === 'superset') {
130
+ expect(groups[2].exercises).toHaveLength(2)
131
+ expect(groups[2].superset.label).toBe('SS1')
132
+ }
133
+ })
134
+ })
135
+
136
+ describe('ActiveWorkoutPage', () => {
137
+ it('renders the header, progress, and the focused active exercise expanded', () => {
138
+ render(<ActiveWorkoutPage {...baseProps} />)
139
+ expect(screen.getByTestId('active-workout-page')).toBeInTheDocument()
140
+ expect(screen.getByTestId('active-workout-page-title')).toHaveTextContent('Push Day A')
141
+ expect(screen.getByTestId('active-workout-page-progress-count')).toHaveTextContent('1/4')
142
+ expect(screen.getByTestId('exercise-card-sets')).toBeInTheDocument()
143
+ expect(screen.getByTestId('superset-wrapper')).toBeInTheDocument()
144
+ })
145
+
146
+ it('shows the input bar and hides it once a set is recorded (starts rest)', () => {
147
+ render(<ActiveWorkoutPage {...baseProps} />)
148
+ expect(screen.getByTestId('input-bar')).toBeInTheDocument()
149
+ expect(screen.getByTestId('input-bar-set-info')).toHaveTextContent('Set 3/4')
150
+
151
+ fireEvent.click(screen.getByTestId('input-bar-record'))
152
+ expect(screen.queryByTestId('input-bar')).not.toBeInTheDocument()
153
+ expect(screen.getByTestId('rest-timer')).toBeInTheDocument()
154
+ })
155
+
156
+ it('zoom-toggles focus: collapsing the active card hides its sets', () => {
157
+ render(<ActiveWorkoutPage {...baseProps} />)
158
+ expect(screen.getByTestId('exercise-card-sets')).toBeInTheDocument()
159
+
160
+ fireEvent.click(screen.getAllByTestId('exercise-card-header')[0])
161
+ expect(screen.queryByTestId('exercise-card-sets')).not.toBeInTheDocument()
162
+ })
163
+
164
+ it('skipping rest restores the input bar', () => {
165
+ render(<ActiveWorkoutPage {...baseProps} initialResting />)
166
+ expect(screen.getByTestId('rest-timer')).toBeInTheDocument()
167
+
168
+ fireEvent.click(screen.getByTestId('rest-timer-skip'))
169
+ expect(screen.getByTestId('input-bar')).toBeInTheDocument()
170
+ })
171
+ })
@@ -0,0 +1,447 @@
1
+ // Font mapping: font-heading=Space Grotesk, font-body=Nunito Sans (UI), font-sans=Inter (body)
2
+ import { useMemo, useState } from 'react'
3
+ import { View, Text, type ViewProps } from 'react-native'
4
+ import { ExerciseCard, type ExerciseCardProps, type ExerciseCardState } from './ExerciseCard'
5
+ import { InputBar } from './InputBar'
6
+ import { RestTimer } from './RestTimer'
7
+ import { SupersetWrapper } from './SupersetWrapper'
8
+ import { type SetRowProps } from './SetRow'
9
+
10
+ const SURFACE_ELEVATED = 'var(--color-surface-elevated)'
11
+ const BORDER_DEFAULT = 'var(--color-border-default)'
12
+ const BRAND_PRIMARY = '#FF7900'
13
+ const TEXT_PRIMARY = 'var(--color-text-primary)'
14
+ const TEXT_SECONDARY = 'var(--color-text-secondary)'
15
+ const TEXT_TERTIARY = 'var(--color-text-tertiary)'
16
+ const PAGE_BG = 'var(--color-background-base)'
17
+
18
+ /** Where an exercise sits in the during-workout flow. */
19
+ export type ActiveExerciseStatus = 'completed' | 'active' | 'upcoming'
20
+
21
+ /**
22
+ * One exercise in the running workout. Projected onto an `ExerciseCard`, whose
23
+ * visual state is driven by `status` and the page's zoom focus: completed and
24
+ * active exercises collapse/expand, upcoming ones stay dimmed.
25
+ */
26
+ export interface ActiveWorkoutExercise {
27
+ /** Stable id for zoom-focus selection. */
28
+ id: string
29
+ /** Exercise name, e.g. "Barbell Bench Press". */
30
+ name: string
31
+ /** Position in the workout flow. */
32
+ status: ActiveExerciseStatus
33
+ /** Unit used for this exercise's loads. */
34
+ unit: 'lbs' | 'kg'
35
+ /** Total sets prescribed for this exercise. */
36
+ totalPlannedSets: number
37
+ /** Collapsed summary (sets × reps @ weight) for a completed exercise. */
38
+ summary?: ExerciseCardProps['summary']
39
+ /** Estimated one-rep max badge. */
40
+ e1rm?: ExerciseCardProps['e1rm']
41
+ /** Flags a personal-record exercise. */
42
+ isPR?: boolean
43
+ /** Prescribed tempo, revealed when expanded. */
44
+ tempo?: ExerciseCardProps['tempo']
45
+ /** Per-rep velocities for each logged set (drives collapsed strips + set count). */
46
+ setVelocities?: number[][]
47
+ /** Per-set breakdown revealed when expanded. */
48
+ sets?: SetRowProps[]
49
+ /** One-line prescription for an upcoming exercise. */
50
+ prescription?: string
51
+ /** Previous-best hint for an upcoming exercise. */
52
+ previousBest?: string
53
+ /** Groups consecutive exercises under a shared `SupersetWrapper`. */
54
+ supersetId?: string
55
+ }
56
+
57
+ /** A superset grouping consecutive exercises that share its id. */
58
+ export interface ActiveWorkoutSuperset {
59
+ /** Matches `ActiveWorkoutExercise.supersetId`. */
60
+ id: string
61
+ /** Corner badge label, e.g. "SS1". */
62
+ label: string
63
+ /** Accent color for the wrapper rail + label. */
64
+ color?: string
65
+ }
66
+
67
+ /** Live-set inputs shown in the bottom `InputBar`. */
68
+ export interface ActiveWorkoutInput {
69
+ /** Current reps field value. */
70
+ reps: string
71
+ /** Current weight field value. */
72
+ weight: string
73
+ }
74
+
75
+ /** Rest-timer inputs shown in the bottom `RestTimer`. */
76
+ export interface ActiveWorkoutRest {
77
+ /** Prescribed rest length, seconds. */
78
+ totalSeconds: number
79
+ /** Elapsed rest, milliseconds. */
80
+ elapsedMs: number
81
+ /** Next-set hint, e.g. "Set 3 · 8 × 195 lbs". */
82
+ nextSetInfo?: string
83
+ }
84
+
85
+ /** Derived, page-level roll-up of workout progress. */
86
+ export interface WorkoutProgress {
87
+ /** Number of exercises marked completed. */
88
+ completedExercises: number
89
+ /** Total exercises in the workout. */
90
+ totalExercises: number
91
+ /** Sets logged so far across all exercises. */
92
+ completedSets: number
93
+ /** Total sets prescribed across all exercises. */
94
+ totalSets: number
95
+ /** Fraction of prescribed sets logged, 0-1. */
96
+ fraction: number
97
+ }
98
+
99
+ /** An ordered render group: a lone exercise or a superset of exercises. */
100
+ export type WorkoutGroup =
101
+ | { type: 'single'; exercise: ActiveWorkoutExercise }
102
+ | { type: 'superset'; superset: ActiveWorkoutSuperset; exercises: ActiveWorkoutExercise[] }
103
+
104
+ export interface ActiveWorkoutPageProps extends ViewProps {
105
+ /** Workout name shown in the header. */
106
+ title?: string
107
+ /** Context line under the title, e.g. "Push Day A · Week 6". */
108
+ subtitle?: string
109
+ /** Exercises in flow order. */
110
+ exercises: ActiveWorkoutExercise[]
111
+ /** Superset groupings referenced by `exercise.supersetId`. */
112
+ supersets?: ActiveWorkoutSuperset[]
113
+ /** Seed reps/weight for the live `InputBar`. */
114
+ input?: ActiveWorkoutInput
115
+ /** Rest-timer state; when resting, the timer replaces the input bar. */
116
+ rest?: ActiveWorkoutRest
117
+ /** Start the page in the resting state (timer showing). */
118
+ initialResting?: boolean
119
+ className?: string
120
+ }
121
+
122
+ /** Count the sets logged for an exercise (pure). */
123
+ export function countCompletedSets(exercise: ActiveWorkoutExercise): number {
124
+ if (exercise.setVelocities != null) return exercise.setVelocities.length
125
+ if (exercise.status === 'completed') return exercise.totalPlannedSets
126
+ return 0
127
+ }
128
+
129
+ /** Roll up the exercises into the header progress readout (pure, testable). */
130
+ export function deriveWorkoutProgress(exercises: ActiveWorkoutExercise[]): WorkoutProgress {
131
+ let completedExercises = 0
132
+ let completedSets = 0
133
+ let totalSets = 0
134
+ for (const exercise of exercises) {
135
+ if (exercise.status === 'completed') completedExercises += 1
136
+ completedSets += countCompletedSets(exercise)
137
+ totalSets += exercise.totalPlannedSets
138
+ }
139
+ return {
140
+ completedExercises,
141
+ totalExercises: exercises.length,
142
+ completedSets,
143
+ totalSets,
144
+ fraction: totalSets === 0 ? 0 : completedSets / totalSets,
145
+ }
146
+ }
147
+
148
+ /** The active exercise anchors the bottom bar; find it, or null (pure). */
149
+ export function findActiveExercise(
150
+ exercises: ActiveWorkoutExercise[]
151
+ ): ActiveWorkoutExercise | null {
152
+ return exercises.find((exercise) => exercise.status === 'active') ?? null
153
+ }
154
+
155
+ /** Map an exercise's status + focus onto an `ExerciseCard` visual state (pure). */
156
+ export function statusToCardState(
157
+ status: ActiveExerciseStatus,
158
+ focused: boolean
159
+ ): ExerciseCardState {
160
+ if (status === 'upcoming') return 'upcoming'
161
+ return focused ? 'expanded' : 'collapsed'
162
+ }
163
+
164
+ /** Project an exercise onto ExerciseCard props, wiring zoom focus (pure). */
165
+ export function toActiveCardProps(
166
+ exercise: ActiveWorkoutExercise,
167
+ focused: boolean,
168
+ onToggle: () => void,
169
+ supersetPosition: ExerciseCardProps['supersetPosition'] = null,
170
+ supersetColor?: string
171
+ ): ExerciseCardProps {
172
+ const state = statusToCardState(exercise.status, focused)
173
+ return {
174
+ name: exercise.name,
175
+ state,
176
+ onToggle,
177
+ summary: exercise.summary,
178
+ e1rm: exercise.e1rm,
179
+ isPR: exercise.isPR,
180
+ tempo: exercise.tempo,
181
+ setVelocities: exercise.setVelocities,
182
+ totalPlannedSets: exercise.totalPlannedSets,
183
+ sets: state === 'expanded' ? exercise.sets : undefined,
184
+ prescription: exercise.prescription,
185
+ previousBest: exercise.previousBest,
186
+ supersetPosition,
187
+ supersetColor,
188
+ }
189
+ }
190
+
191
+ /** Fold consecutive same-superset exercises into render groups (pure). */
192
+ export function groupExercises(
193
+ exercises: ActiveWorkoutExercise[],
194
+ supersets: ActiveWorkoutSuperset[]
195
+ ): WorkoutGroup[] {
196
+ const byId = new Map(supersets.map((superset) => [superset.id, superset]))
197
+ const groups: WorkoutGroup[] = []
198
+ for (const exercise of exercises) {
199
+ const superset = exercise.supersetId != null ? byId.get(exercise.supersetId) : undefined
200
+ const last = groups[groups.length - 1]
201
+ if (superset != null && last?.type === 'superset' && last.superset.id === superset.id) {
202
+ last.exercises.push(exercise)
203
+ } else if (superset != null) {
204
+ groups.push({ type: 'superset', superset, exercises: [exercise] })
205
+ } else {
206
+ groups.push({ type: 'single', exercise })
207
+ }
208
+ }
209
+ return groups
210
+ }
211
+
212
+ /** Position of an exercise within its superset, for corner-radius stitching. */
213
+ function supersetPositionAt(index: number, length: number): ExerciseCardProps['supersetPosition'] {
214
+ if (length === 1) return null
215
+ if (index === 0) return 'first'
216
+ if (index === length - 1) return 'last'
217
+ return 'middle'
218
+ }
219
+
220
+ function WorkoutHeader({
221
+ title,
222
+ subtitle,
223
+ progress,
224
+ }: {
225
+ title: string
226
+ subtitle?: string
227
+ progress: WorkoutProgress
228
+ }) {
229
+ return (
230
+ <View style={{ gap: 10 }} testID="active-workout-page-header">
231
+ <View className="flex-row items-start justify-between" style={{ gap: 8 }}>
232
+ <View style={{ flexShrink: 1 }}>
233
+ <Text
234
+ accessibilityRole="header"
235
+ style={{
236
+ fontSize: 20,
237
+ fontFamily: '"Space Grotesk", sans-serif',
238
+ fontWeight: '700',
239
+ color: TEXT_PRIMARY,
240
+ }}
241
+ testID="active-workout-page-title"
242
+ >
243
+ {title}
244
+ </Text>
245
+ {subtitle != null && (
246
+ <Text
247
+ style={{
248
+ marginTop: 2,
249
+ fontSize: 12,
250
+ fontFamily: 'Inter, sans-serif',
251
+ color: TEXT_SECONDARY,
252
+ }}
253
+ testID="active-workout-page-subtitle"
254
+ >
255
+ {subtitle}
256
+ </Text>
257
+ )}
258
+ </View>
259
+ <View style={{ alignItems: 'flex-end' }} testID="active-workout-page-progress-count">
260
+ <Text
261
+ style={{
262
+ fontSize: 15,
263
+ fontFamily: '"Space Grotesk", sans-serif',
264
+ fontWeight: '700',
265
+ color: BRAND_PRIMARY,
266
+ fontVariant: ['tabular-nums'],
267
+ }}
268
+ >
269
+ {`${progress.completedExercises}/${progress.totalExercises}`}
270
+ </Text>
271
+ <Text
272
+ style={{
273
+ fontSize: 10,
274
+ fontFamily: 'Inter, sans-serif',
275
+ fontWeight: '600',
276
+ letterSpacing: 0.4,
277
+ textTransform: 'uppercase',
278
+ color: TEXT_TERTIARY,
279
+ }}
280
+ >
281
+ {`${progress.completedSets}/${progress.totalSets} sets`}
282
+ </Text>
283
+ </View>
284
+ </View>
285
+ <View
286
+ style={{ height: 4, backgroundColor: BORDER_DEFAULT, borderRadius: 2 }}
287
+ testID="active-workout-page-progress-track"
288
+ >
289
+ <View
290
+ style={{
291
+ height: '100%',
292
+ width: `${Math.round(progress.fraction * 100)}%`,
293
+ backgroundColor: BRAND_PRIMARY,
294
+ borderRadius: 2,
295
+ }}
296
+ testID="active-workout-page-progress-fill"
297
+ />
298
+ </View>
299
+ </View>
300
+ )
301
+ }
302
+
303
+ interface ExerciseListProps {
304
+ groups: WorkoutGroup[]
305
+ focusedId: string | null
306
+ onToggle: (id: string) => void
307
+ }
308
+
309
+ function ExerciseList({ groups, focusedId, onToggle }: ExerciseListProps) {
310
+ return (
311
+ <View style={{ gap: 10 }} testID="active-workout-page-exercises">
312
+ {groups.map((group) => {
313
+ if (group.type === 'single') {
314
+ return (
315
+ <View
316
+ key={group.exercise.id}
317
+ style={{
318
+ backgroundColor: SURFACE_ELEVATED,
319
+ borderWidth: 1,
320
+ borderColor: BORDER_DEFAULT,
321
+ borderRadius: 12,
322
+ }}
323
+ >
324
+ <ExerciseCard
325
+ {...toActiveCardProps(group.exercise, group.exercise.id === focusedId, () =>
326
+ onToggle(group.exercise.id)
327
+ )}
328
+ />
329
+ </View>
330
+ )
331
+ }
332
+ return (
333
+ <SupersetWrapper
334
+ key={group.superset.id}
335
+ label={group.superset.label}
336
+ color={group.superset.color}
337
+ >
338
+ {group.exercises.map((exercise, index) => (
339
+ <ExerciseCard
340
+ key={exercise.id}
341
+ {...toActiveCardProps(
342
+ exercise,
343
+ exercise.id === focusedId,
344
+ () => onToggle(exercise.id),
345
+ supersetPositionAt(index, group.exercises.length),
346
+ group.superset.color
347
+ )}
348
+ />
349
+ ))}
350
+ </SupersetWrapper>
351
+ )
352
+ })}
353
+ </View>
354
+ )
355
+ }
356
+
357
+ /**
358
+ * ActiveWorkoutPage — the during-workout screen, built as a zoom hierarchy over
359
+ * `ExerciseCard`s. A header progress bar rolls up completed sets; the flow list
360
+ * dims upcoming exercises, collapses finished ones to their velocity strips, and
361
+ * expands exactly one focused exercise to its `SetRow` breakdown. Consecutive
362
+ * superset exercises stitch together inside a `SupersetWrapper`. A pinned bottom
363
+ * bar toggles between the live `InputBar` (log the next set) and the `RestTimer`.
364
+ * Focus and rest are page-level state; children keep their own styles.
365
+ *
366
+ * @example
367
+ * <ActiveWorkoutPage title="Push Day A" exercises={exercises} />
368
+ */
369
+ export function ActiveWorkoutPage({
370
+ title = 'Active Workout',
371
+ subtitle,
372
+ exercises,
373
+ supersets = [],
374
+ input,
375
+ rest,
376
+ initialResting = false,
377
+ className,
378
+ ...props
379
+ }: ActiveWorkoutPageProps) {
380
+ const active = findActiveExercise(exercises)
381
+ const [focusedId, setFocusedId] = useState<string | null>(active?.id ?? null)
382
+ const [resting, setResting] = useState(initialResting)
383
+ const [reps, setReps] = useState(input?.reps ?? '')
384
+ const [weight, setWeight] = useState(input?.weight ?? '')
385
+
386
+ const progress = useMemo(() => deriveWorkoutProgress(exercises), [exercises])
387
+ const groups = useMemo(() => groupExercises(exercises, supersets), [exercises, supersets])
388
+
389
+ const toggleFocus = (id: string) => setFocusedId((current) => (current === id ? null : id))
390
+
391
+ const nextSetNumber = active != null ? countCompletedSets(active) + 1 : 1
392
+ const canRecord = reps.trim() !== '' && weight.trim() !== ''
393
+ const showRest = resting && rest != null
394
+ const showInput = !showRest && active != null
395
+
396
+ return (
397
+ <View
398
+ className={className}
399
+ style={{ position: 'relative', width: 390, backgroundColor: PAGE_BG }}
400
+ accessibilityRole={'main' as ViewProps['accessibilityRole']}
401
+ aria-label={title}
402
+ testID="active-workout-page"
403
+ {...props}
404
+ >
405
+ <View style={{ padding: 16, gap: 14 }} testID="active-workout-page-content">
406
+ <WorkoutHeader title={title} subtitle={subtitle} progress={progress} />
407
+ <ExerciseList groups={groups} focusedId={focusedId} onToggle={toggleFocus} />
408
+ </View>
409
+
410
+ {(showRest || showInput) && (
411
+ <View
412
+ style={{ borderTopWidth: 1, borderTopColor: BORDER_DEFAULT }}
413
+ testID="active-workout-page-bottom-bar"
414
+ >
415
+ {showRest && rest != null ? (
416
+ <RestTimer
417
+ totalSeconds={rest.totalSeconds}
418
+ elapsedMs={rest.elapsedMs}
419
+ nextSetInfo={rest.nextSetInfo}
420
+ onSkip={() => setResting(false)}
421
+ onAddTime={() => undefined}
422
+ visible
423
+ />
424
+ ) : (
425
+ active != null && (
426
+ <InputBar
427
+ exerciseName={active.name}
428
+ setNumber={nextSetNumber}
429
+ totalSets={active.totalPlannedSets}
430
+ reps={reps}
431
+ weight={weight}
432
+ unit={active.unit}
433
+ onRepsChange={setReps}
434
+ onWeightChange={setWeight}
435
+ onRecord={() => {
436
+ if (rest != null) setResting(true)
437
+ }}
438
+ canRecord={canRecord}
439
+ visible
440
+ />
441
+ )
442
+ )}
443
+ </View>
444
+ )}
445
+ </View>
446
+ )
447
+ }
@@ -3,7 +3,6 @@ import { useEffect, useMemo, useState } from 'react'
3
3
  import { View, Text, Pressable, Animated, Easing, type ViewProps } from 'react-native'
4
4
  import BodyHighlighter, { type ExtendedBodyPart, type Slug } from 'react-native-body-highlighter'
5
5
  import { cn } from '../../../utils/cn'
6
- import { WORKOUT_TOKENS } from '../../../theme/workout-tokens'
7
6
  import {
8
7
  MuscleGroup,
9
8
  SimpleMuscleGroup,
@@ -28,8 +27,8 @@ const Body = ((BodyHighlighter as unknown as { default?: typeof BodyHighlighter
28
27
  const OUTLINE_FILL = 'rgba(255,255,255,0.08)'
29
28
  const OUTLINE_BORDER = 'rgba(255,255,255,0.12)'
30
29
  const BODY_SCALE = 0.8 // 200x400 intrinsic -> ~160x320 px
31
- const TEXT_PRIMARY = '#F3F4F6'
32
- const TEXT_SECONDARY = '#9CA3AF'
30
+ const TEXT_PRIMARY = 'var(--color-text-primary)'
31
+ const TEXT_SECONDARY = 'var(--color-text-secondary)'
33
32
 
34
33
  export interface BodyMapData {
35
34
  muscleGroup: MuscleGroup
@@ -277,7 +276,7 @@ function ViewToggle({ view, onViewChange }: ViewToggleProps) {
277
276
  borderRadius: 9999,
278
277
  backgroundColor: active ? 'rgba(255,121,0,0.16)' : 'transparent',
279
278
  borderWidth: 1,
280
- borderColor: active ? '#FF7900' : WORKOUT_TOKENS.border.strong,
279
+ borderColor: active ? '#FF7900' : 'var(--color-border-strong)',
281
280
  }}
282
281
  testID={`body-map-toggle-${side}`}
283
282
  >
@@ -322,8 +321,8 @@ function MuscleButton({ entry, highlighted, onMusclePress }: MuscleButtonProps)
322
321
  paddingVertical: 3,
323
322
  borderRadius: 9999,
324
323
  borderWidth: 1,
325
- borderColor: highlighted ? '#FF7900' : WORKOUT_TOKENS.border.default,
326
- backgroundColor: WORKOUT_TOKENS.surface.raised,
324
+ borderColor: highlighted ? '#FF7900' : 'var(--color-border-default)',
325
+ backgroundColor: 'var(--color-surface-raised)',
327
326
  }}
328
327
  testID={`body-map-muscle-${entry.key}`}
329
328
  >
@@ -11,7 +11,6 @@ import {
11
11
  type ViewStyle,
12
12
  } from 'react-native'
13
13
  import { Badge, type BadgeColor } from '../../ui/badge'
14
- import { WORKOUT_TOKENS } from '../../../theme/workout-tokens'
15
14
  import { Sparkline } from './Sparkline'
16
15
  import {
17
16
  MuscleGroup,
@@ -20,14 +19,14 @@ import {
20
19
  type VolumeStatus,
21
20
  } from './muscleTaxonomy'
22
21
 
23
- const SURFACE_ELEVATED = WORKOUT_TOKENS.surface.elevated
24
- const SURFACE_RAISED = WORKOUT_TOKENS.surface.raised
25
- const BORDER_STRONG = WORKOUT_TOKENS.border.strong
26
- const BORDER_DEFAULT = WORKOUT_TOKENS.border.default
22
+ const SURFACE_ELEVATED = 'var(--color-surface-elevated)'
23
+ const SURFACE_RAISED = 'var(--color-surface-raised)'
24
+ const BORDER_STRONG = 'var(--color-border-strong)'
25
+ const BORDER_DEFAULT = 'var(--color-border-default)'
27
26
  const BRAND_PRIMARY = '#FF7900'
28
- const TEXT_PRIMARY = '#F3F4F6'
29
- const TEXT_SECONDARY = '#9CA3AF'
30
- const TEXT_TERTIARY = '#6B7280'
27
+ const TEXT_PRIMARY = 'var(--color-text-primary)'
28
+ const TEXT_SECONDARY = 'var(--color-text-secondary)'
29
+ const TEXT_TERTIARY = 'var(--color-text-tertiary)'
31
30
 
32
31
  /** Volume track gradient: status-info (blue) -> result-improve (teal) -> status-error (red). */
33
32
  const VOLUME_GRADIENT = 'linear-gradient(90deg, #2196F3 0%, #14B8A6 50%, #D14343 100%)'
@@ -8,7 +8,7 @@ const STATUS_INFO = '#2196F3'
8
8
  /** Dot outline: near-white ring so load dots read on the band fill and any
9
9
  * surface (matches the MesoStatusCard gauge-marker convention). */
10
10
  const DOT_BORDER = '#F3F4F6'
11
- const TEXT_TERTIARY = '#6B7280'
11
+ const TEXT_TERTIARY = 'var(--color-text-tertiary)'
12
12
  const BAND_FILL = 'rgba(20,184,166,0.1)'
13
13
  const BAND_EDGE = 'rgba(20,184,166,0.45)'
14
14
  const PROJECTION_FILL = 'rgba(20,184,166,0.05)'