@titan-design/react-ui 0.10.0 → 0.11.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.
- package/dist/index.d.mts +399 -4
- package/dist/index.d.ts +399 -4
- package/dist/index.js +2295 -895
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2279 -905
- package/dist/index.mjs.map +1 -1
- package/dist/{pages-DyEx-lBf.d.ts → pages-B1hqnGIC.d.ts} +149 -15
- package/dist/{pages-D7hOD4Vj.d.mts → pages-CvsFqNtx.d.mts} +149 -15
- package/dist/pages.d.mts +1 -1
- package/dist/pages.d.ts +1 -1
- package/dist/pages.js +1974 -1740
- package/dist/pages.js.map +1 -1
- package/dist/pages.mjs +1975 -1741
- package/dist/pages.mjs.map +1 -1
- package/package.json +8 -3
- package/src/components/custom/Fatigue/DualGhostSpark.stories.tsx +258 -0
- package/src/components/custom/Fatigue/DualGhostSpark.test.tsx +138 -0
- package/src/components/custom/Fatigue/DualGhostSpark.tsx +208 -0
- package/src/components/custom/Fatigue/FatigueLights.stories.tsx +74 -0
- package/src/components/custom/Fatigue/FatigueLights.test.tsx +33 -0
- package/src/components/custom/Fatigue/FatigueLights.tsx +83 -0
- package/src/components/custom/Fatigue/GhostBand.test.tsx +235 -0
- package/src/components/custom/Fatigue/GhostBand.tsx +246 -0
- package/src/components/custom/Fatigue/GhostBloom.tsx +132 -0
- package/src/components/custom/Fatigue/GhostSpark.stories.tsx +175 -0
- package/src/components/custom/Fatigue/GhostSpark.test.tsx +45 -0
- package/src/components/custom/Fatigue/GhostSpark.tsx +126 -0
- package/src/components/custom/Fatigue/LiveFatigueCard.stories.tsx +126 -0
- package/src/components/custom/Fatigue/LiveFatigueCard.test.tsx +28 -0
- package/src/components/custom/Fatigue/LiveFatigueCard.tsx +86 -0
- package/src/components/custom/Fatigue/LiveFatiguePanel.stories.tsx +95 -0
- package/src/components/custom/Fatigue/LiveFatiguePanel.tsx +151 -0
- package/src/components/custom/Fatigue/README.md +93 -0
- package/src/components/custom/Fatigue/RomProgressionChart.stories.tsx +94 -0
- package/src/components/custom/Fatigue/RomProgressionChart.test.tsx +31 -0
- package/src/components/custom/Fatigue/RomProgressionChart.tsx +132 -0
- package/src/components/custom/Fatigue/SilverRedPalette.stories.tsx +226 -0
- package/src/components/custom/Fatigue/VelocityHero.stories.tsx +70 -0
- package/src/components/custom/Fatigue/VelocityHero.test.tsx +26 -0
- package/src/components/custom/Fatigue/VelocityHero.tsx +46 -0
- package/src/components/custom/Fatigue/VerdictHero.stories.tsx +59 -0
- package/src/components/custom/Fatigue/VerdictHero.test.tsx +49 -0
- package/src/components/custom/Fatigue/VerdictHero.tsx +79 -0
- package/src/components/custom/Fatigue/fatigue-mock.test.ts +59 -0
- package/src/components/custom/Fatigue/fatigue-mock.ts +268 -0
- package/src/components/custom/Fatigue/fatigue-model.ts +129 -0
- package/src/components/custom/Fatigue/fatigue-tokens.test.ts +70 -0
- package/src/components/custom/Fatigue/fatigue-tokens.ts +180 -0
- package/src/components/custom/Fatigue/index.ts +41 -0
- package/src/components/custom/Fatigue/tempo-pacing.test.ts +176 -0
- package/src/components/custom/Fatigue/tempo-pacing.ts +112 -0
- package/src/components/custom/Workout/DualVelocityStrip.test.tsx +685 -0
- package/src/components/custom/Workout/ExerciseCard.test.tsx +4 -4
- package/src/components/custom/Workout/ExerciseCard.tsx +3 -1
- package/src/components/custom/Workout/ExerciseDetailPage.tsx +7 -1
- package/src/components/custom/Workout/README.md +62 -16
- package/src/components/custom/Workout/SegmentedBar.stories.tsx +3 -3
- package/src/components/custom/Workout/SessionRail.test.tsx +43 -0
- package/src/components/custom/Workout/SessionRail.tsx +50 -13
- package/src/components/custom/Workout/SetRow.test.tsx +6 -6
- package/src/components/custom/Workout/SetRow.tsx +9 -2
- package/src/components/custom/Workout/VelocityStrip.compact.stories.tsx +191 -0
- package/src/components/custom/Workout/VelocityStrip.dual.stories.tsx +186 -0
- package/src/components/custom/Workout/VelocityStrip.expanded.stories.tsx +296 -0
- package/src/components/custom/Workout/VelocityStrip.hero.stories.tsx +259 -0
- package/src/components/custom/Workout/VelocityStrip.stories.tsx +217 -250
- package/src/components/custom/Workout/VelocityStrip.test.tsx +196 -79
- package/src/components/custom/Workout/VelocityStrip.tsx +953 -609
- package/src/components/custom/Workout/index.ts +3 -0
- package/src/components/custom/Workout/velocity-story-kit.tsx +438 -0
- package/src/components/custom/charts/SetBarChart.test.tsx +275 -0
- package/src/components/custom/charts/SetBarChart.tsx +651 -0
- package/src/components/custom/charts/live-rep-growth.ts +91 -0
- package/src/components/custom/index.ts +1 -0
- package/src/test/raw-color-patterns.test.ts +71 -0
- package/src/theme/ColorPalettes.stories.tsx +871 -0
- package/src/theme/ColorPrimitives.stories.tsx +300 -0
- package/src/theme/bar-paper.ts +59 -0
- package/src/theme/color-stories.coverage.test.ts +130 -0
- package/src/theme/color-story-kit.tsx +170 -0
- package/src/components/custom/Workout/VelocityStrip.modalities.stories.tsx +0 -254
- package/src/components/custom/Workout/VelocityStrip.responsive.stories.tsx +0 -145
- package/src/theme/ColorSystem.stories.tsx +0 -508
- package/src/theme/Colors.stories.tsx +0 -323
|
@@ -49,7 +49,7 @@ describe('ExerciseCard', () => {
|
|
|
49
49
|
expect(screen.getByTestId('pr-badge-star')).toBeInTheDocument()
|
|
50
50
|
})
|
|
51
51
|
|
|
52
|
-
it('renders
|
|
52
|
+
it('renders compact velocity strips for logged sets', () => {
|
|
53
53
|
render(
|
|
54
54
|
<ExerciseCard
|
|
55
55
|
{...baseCollapsedProps}
|
|
@@ -158,10 +158,10 @@ describe('ExerciseCard', () => {
|
|
|
158
158
|
expect(within(rows[2]).getByText('3')).toHaveStyle({ color: T_MUTED })
|
|
159
159
|
})
|
|
160
160
|
|
|
161
|
-
it('uses the
|
|
161
|
+
it('uses the velocity-height spotlight for the live set and the flat compact strip elsewhere', () => {
|
|
162
162
|
render(<ExerciseCard {...expandedProps} />)
|
|
163
|
-
expect(screen.getAllByTestId('velocity-strip-
|
|
164
|
-
expect(screen.getAllByTestId('velocity-strip-
|
|
163
|
+
expect(screen.getAllByTestId('velocity-strip-spotlight')).toHaveLength(1)
|
|
164
|
+
expect(screen.getAllByTestId('velocity-strip-compact')).toHaveLength(2)
|
|
165
165
|
})
|
|
166
166
|
|
|
167
167
|
it('renders the TempoDisplay in the header when tempo provided', () => {
|
|
@@ -386,7 +386,13 @@ function VbtBreakdown({
|
|
|
386
386
|
{set.label}
|
|
387
387
|
</Text>
|
|
388
388
|
<View className="flex-1" style={{ height: 8, justifyContent: 'center' }}>
|
|
389
|
-
<VelocityStrip
|
|
389
|
+
<VelocityStrip
|
|
390
|
+
velocities={set.velocities}
|
|
391
|
+
zones={zones}
|
|
392
|
+
variant="compact"
|
|
393
|
+
height={8}
|
|
394
|
+
hideBaseline
|
|
395
|
+
/>
|
|
390
396
|
</View>
|
|
391
397
|
<Text
|
|
392
398
|
className="text-text-tertiary"
|
|
@@ -13,8 +13,8 @@ DeviationBar · IntensityBar · WorkoutPill · MuscleGroupChip · Sparkline ·
|
|
|
13
13
|
SupersetWrapper · InputBar · MetricCell · SetsRepsLoad · ExerciseIndicator · SetBar
|
|
14
14
|
|
|
15
15
|
**Molecules** — compose atoms, own a little local state:
|
|
16
|
-
VelocityStrip · SetRow · TempoDisplay · RestTimer · MesoProgressBar ·
|
|
17
|
-
WorkoutCard · SetStrip · ExerciseHeading · ExerciseCardHeading
|
|
16
|
+
VelocityStrip · DualVelocityStrip · SetRow · TempoDisplay · RestTimer · MesoProgressBar ·
|
|
17
|
+
WeekRow · WorkoutCard · SetStrip · ExerciseHeading · ExerciseCardHeading
|
|
18
18
|
|
|
19
19
|
**Organisms** — full features, often with their own data contract:
|
|
20
20
|
ExerciseCard · SessionRail · MesoCard · MesoStatusCard · PrHistoryModal ·
|
|
@@ -66,11 +66,12 @@ type props without pulling the dependency.
|
|
|
66
66
|
needs the same yellow/green/red "time-to-target" tone (a coach card, a rep-tempo
|
|
67
67
|
summary). It is pure logic, trivially portable.
|
|
68
68
|
3. **`LiveTempoRow` → a `TempoLiveRow` molecule** — only if a consumer wants the running
|
|
69
|
-
row
|
|
69
|
+
row _without_ the chip chrome (label/background/padding). Until then the chrome and the
|
|
70
70
|
row belong together as one component with a `live` prop, not two.
|
|
71
71
|
|
|
72
72
|
Not worth splitting today (speculative extraction the workflow warns against); this note
|
|
73
73
|
is the trigger list for when it stops being speculative.
|
|
74
|
+
|
|
74
75
|
- **S3 session-rail family** — `SessionRail` (organism) composes the standalone
|
|
75
76
|
`ExerciseCardHeading` molecule per exercise, which composes an `ExerciseHeading`
|
|
76
77
|
info block + a `SetStrip`:
|
|
@@ -96,7 +97,7 @@ type props without pulling the dependency.
|
|
|
96
97
|
vs. variable-todo cyan), `drop` (one set, sub-loads split by 2px notches), `myo`
|
|
97
98
|
(done rest-pause — activation + clusters split by 3px cluster gaps), and
|
|
98
99
|
`myo-upcoming` (planned myo, length unknown — grey activation + a fading, right-open
|
|
99
|
-
cyan "clusters-to-failure" trail). The chunk-size
|
|
100
|
+
cyan "clusters-to-failure" trail). The chunk-size _pattern_ carries set-type identity:
|
|
100
101
|
**butted reps (0) < notch (2px) < cluster gap (3px) < set gap (5px)**. `cyan-900`
|
|
101
102
|
(`SET_STRIP_VARIABLE_COLOR`) is the shared "variable / unknown / opportunity" pin.
|
|
102
103
|
`SegmentedBar` carries these via additive `leadingGap` (per-segment left margin) and
|
|
@@ -113,6 +114,14 @@ type props without pulling the dependency.
|
|
|
113
114
|
**Composes** link down the tree — matching the S1/S2 shell families. (The component
|
|
114
115
|
files stay flat on disk in `custom/Workout/`; only the story `title`s build the tree.)
|
|
115
116
|
|
|
117
|
+
- **Dual at the RAIL level — rejected, removed** — `DualSessionRail` (two
|
|
118
|
+
`SessionRail` columns side by side) was explored and rejected: bilateral
|
|
119
|
+
asymmetry is a property of how a SET was performed, not of the session's
|
|
120
|
+
structure, so the rail stays single and consistent and the dual distinction is
|
|
121
|
+
surfaced per-set/per-rep instead (`DualVelocityStrip`). Deleted 2026-07-26 —
|
|
122
|
+
see `packages/ui/REJECTED.md` for the full reasoning. Do not reintroduce a
|
|
123
|
+
rail-level split without reading it first.
|
|
124
|
+
|
|
116
125
|
- **VelocityStrip set-type modes (`set` prop)** — beyond the flat `velocities`
|
|
117
126
|
array (unchanged, still the source of truth for `SetRow` / `ExerciseCard`), the
|
|
118
127
|
strip accepts an optional structured `VelocitySet` descriptor and renders the
|
|
@@ -133,7 +142,7 @@ type props without pulling the dependency.
|
|
|
133
142
|
active-set spotlight (velocity-height done reps + short grey stubs) and renders
|
|
134
143
|
the advanced types as a short mini-style encoding. Every modality is documented
|
|
135
144
|
with a copy-paste `set` config in **`Workout/DataViz/VelocityStrip/Set
|
|
136
|
-
|
|
145
|
+
Modalities`** (each card carries a `Collapse` accordion; promoted from the
|
|
137
146
|
now-deleted `S3SetModalities` Lab specimen).
|
|
138
147
|
- **VelocityStrip `hero` variant** — the across-the-room, single-set **wall**
|
|
139
148
|
treatment (the north-star live page's velocity hero). Tall bars (default 220px
|
|
@@ -147,12 +156,49 @@ type props without pulling the dependency.
|
|
|
147
156
|
left-packed) with a caller-set fixed height; the eyebrow/section title is
|
|
148
157
|
organism chrome, not part of the primitive. **Live-update model:** the plan's
|
|
149
158
|
slots are pre-allocated (`max(done, target)` columns), so a landing rep converts
|
|
150
|
-
placeholder→bar in the
|
|
159
|
+
placeholder→bar in the _same_ slot with a pop — no reflow within the plan; pair
|
|
151
160
|
with `scale="fixed"` so heights never rescale either. The one reflow case is
|
|
152
161
|
set-expansion **beyond** `targetReps` (AMRAP overflow adds a column and flex-
|
|
153
162
|
narrows the rest — currently snaps; smooth overflow reflow is a deferred
|
|
154
163
|
follow-up). Documented by the `HeroPlayground` / `Hero*` stories on the wall
|
|
155
164
|
background.
|
|
165
|
+
- **DualVelocityStrip** (molecule) — the two-device (LEFT + RIGHT voltra) **diverging**
|
|
166
|
+
wall/rail chart. `composes ↓` the `VelocityStrip` machinery in the same file
|
|
167
|
+
(`buildSlots`/`VelocitySlot` slot model, the `makeBarColorFor` zone scale, the hero
|
|
168
|
+
geometry constants, the shared `useLiveRepPop` entrance, and the extracted
|
|
169
|
+
`DashedReferenceLine`) rather than restating it. `used-by ↑` the north-star dual-voltra
|
|
170
|
+
live page (organism chrome). ONE diverging chart shares a horizontal centre axis: LEFT
|
|
171
|
+
reps grow **up**, RIGHT reps grow **down**, one mirrored pair per rep index, so the L/R
|
|
172
|
+
asymmetry reads pre-attentively as the silhouette. **Side is POSITION only, never hue** —
|
|
173
|
+
both wings colour reps by velocity zone through the same resolver as the single strip.
|
|
174
|
+
Each side takes a `DualVelocityStream` (`velocities` OR a structured `set` — the same
|
|
175
|
+
shapes `VelocityStrip` accepts — plus an optional `label`). The **vertical edge label is
|
|
176
|
+
data**: each side renders its `DualVelocityStream.label` (a slot name, e.g. "Left Arm"),
|
|
177
|
+
NOT a hardcoded LEFT/RIGHT — a side with no `label` (or an empty one) renders no tag, and
|
|
178
|
+
when neither side carries one the gutter is omitted entirely. The label keeps the prior
|
|
179
|
+
vertical (rotated) orientation so it never overlaps the bars. Two scales: `hero` (tall
|
|
180
|
+
wings, per-rep m/s velocity labels, a dashed running-best reference line per side) and
|
|
181
|
+
`rail` (compact — no velocity labels / reference lines, slot names in a narrow gutter).
|
|
182
|
+
**Rep-index alignment is the invariant:** column *i* is rep *i* on
|
|
183
|
+
both sides, so the set-type slot *kinds* carry through (rep / todo / variable / continue,
|
|
184
|
+
coloured as in the single strip) but the wide-notch chunk **gaps** (drop / myo / cluster
|
|
185
|
+
boundaries) are intentionally NOT rendered — per-side horizontal gaps would break the
|
|
186
|
+
mirrored L↔R column alignment. Single-voltra sets keep using `VelocityStrip`
|
|
187
|
+
`variant="hero"`. Documented by the `Playground` / `Hero*` / `Rail` stories on the wall
|
|
188
|
+
background (`Workout/DataViz/DualVelocityStrip`).
|
|
189
|
+
|
|
190
|
+
**Reuse audit — `DashedReferenceLine` (in-file today, top-level follow-up).** The dashed
|
|
191
|
+
running-best line was hand-rolled three times inside `VelocityStrip.tsx` (the single
|
|
192
|
+
`hero`, plus the dual's L and R wings); it is now one in-file `DashedReferenceLine`
|
|
193
|
+
(`anchor: 'top' | 'bottom'`, pixel `offset`, `testID`) those three sites share. A FOURTH
|
|
194
|
+
consumer exists across files — `Sparkline`'s `referenceLines` prop renders the same dashed
|
|
195
|
+
overlay (with an added opacity, an optional label, and a data-domain→Y projection), and two
|
|
196
|
+
Lab specimens duplicate it again. Promoting `DashedReferenceLine` to a **top-level
|
|
197
|
+
`ReferenceLine` overlay primitive** and migrating `Sparkline` (keeping its label/opacity
|
|
198
|
+
options as props) is the ≥2-consumer extraction the DoD favours — deliberately deferred to
|
|
199
|
+
a follow-up so the hero PR stays focused (the cross-file migration touches `Sparkline`'s
|
|
200
|
+
test surface and the Lab specimens, which are out of this branch's scope). Proposed API:
|
|
201
|
+
`<ReferenceLine anchor offset color dashed opacity? label? testID />`.
|
|
156
202
|
- **RestTimer `ring` variant** — the across-the-room **wall** rest treatment (the
|
|
157
203
|
north-star rest page). Built as a **three-tier decomposition** (not a one-off):
|
|
158
204
|
`CircularProgress` (atom, gained a **`children`** center slot + a **`fill`**
|
|
@@ -174,7 +220,7 @@ type props without pulling the dependency.
|
|
|
174
220
|
dashboard scale, added as the idiomatic titan `size` union (a JS number-map per
|
|
175
221
|
component; **`default` values are byte-identical** to before, so existing consumers are
|
|
176
222
|
untouched). **ZoneTrack** (the shared gauge primitive) gained `size` that scales track,
|
|
177
|
-
needle, tick lines and tick labels together; its
|
|
223
|
+
needle, tick lines and tick labels together; its _other_ consumers (TrainingLoadGauge,
|
|
178
224
|
RpeCalibration) default to `default` and are unaffected. **FatigueMeter** passes `size`
|
|
179
225
|
through and lets `trackHeight` flow from it. `Wall*` / `WallDensity` stories on the wall
|
|
180
226
|
background. (**TempoBar** was retired here — the standalone active-tempo bar is superseded
|
|
@@ -187,17 +233,17 @@ type props without pulling the dependency.
|
|
|
187
233
|
per exercise, six distinct kinds over four tier colors (bound to titan status
|
|
188
234
|
tokens, read as literal hex via `getSemanticColors('dark')`, not `resolveColor`,
|
|
189
235
|
so tests can assert them). Glyph = the specific signal; color = the severity tier. Chips are
|
|
190
|
-
outlined (border + glyph, no fill) so they never collide with the
|
|
236
|
+
outlined (border + glyph, no fill) so they never collide with the _filled_
|
|
191
237
|
velocity strip, and static (no pulse — they are chrome). Precedence, high → low:
|
|
192
238
|
|
|
193
|
-
| #
|
|
194
|
-
|
|
195
|
-
| 1
|
|
196
|
-
| 2
|
|
197
|
-
| 3
|
|
198
|
-
| 4
|
|
199
|
-
| 5
|
|
200
|
-
| 6
|
|
239
|
+
| # | kind | tier | glyph (mirrors lucide) |
|
|
240
|
+
| --- | --------------- | -------------------------- | ---------------------- |
|
|
241
|
+
| 1 | `imbalance` | danger (`status-error`) | `Scale` |
|
|
242
|
+
| 2 | `overshoot` | danger (`status-error`) | `AlertTriangle` |
|
|
243
|
+
| 3 | `velocity-loss` | warning (`status-warning`) | `TrendingDown` |
|
|
244
|
+
| 4 | `missed-reps` | warning (`status-warning`) | `CircleSlash` |
|
|
245
|
+
| 5 | `pr` | success (`status-success`) | `Award` |
|
|
246
|
+
| 6 | `info` | info (`status-info`) | `Info` |
|
|
201
247
|
|
|
202
248
|
`resolveIndicator(candidates)` collapses the active signals to the single
|
|
203
249
|
highest-precedence kind to show (`undefined` when none). Alerts outrank `pr`. The
|
|
@@ -56,7 +56,7 @@ export const Weighted: Story = {
|
|
|
56
56
|
args: {
|
|
57
57
|
height: 12,
|
|
58
58
|
gap: 4,
|
|
59
|
-
radius:
|
|
59
|
+
radius: 2,
|
|
60
60
|
segments: [
|
|
61
61
|
{ color: '#2ED573', weight: 3 },
|
|
62
62
|
{ color: '#F9B415', weight: 2 },
|
|
@@ -72,7 +72,7 @@ export const PartialFills: Story = {
|
|
|
72
72
|
args: {
|
|
73
73
|
height: 12,
|
|
74
74
|
gap: 4,
|
|
75
|
-
radius:
|
|
75
|
+
radius: 2,
|
|
76
76
|
segments: [
|
|
77
77
|
{ color: '#2ED573', fill: 1 },
|
|
78
78
|
{ color: '#F9B415', fill: 0.6 },
|
|
@@ -89,7 +89,7 @@ export const PartialFills: Story = {
|
|
|
89
89
|
export const WithMarker: Story = {
|
|
90
90
|
args: {
|
|
91
91
|
height: 10,
|
|
92
|
-
radius:
|
|
92
|
+
radius: 2,
|
|
93
93
|
segments: [{ color: '#01B5D1', fill: 0.7 }],
|
|
94
94
|
marker: { position: 0.5, color: '#FFFFFF' },
|
|
95
95
|
},
|
|
@@ -76,6 +76,49 @@ describe('SessionRail', () => {
|
|
|
76
76
|
expect(onExercisePress).toHaveBeenCalledWith(exercises[1], 1)
|
|
77
77
|
})
|
|
78
78
|
|
|
79
|
+
describe('expandedIndex', () => {
|
|
80
|
+
const withSets: SessionRailExercise[] = exercises.map((ex, i) =>
|
|
81
|
+
i === 1
|
|
82
|
+
? {
|
|
83
|
+
...ex,
|
|
84
|
+
sets: [
|
|
85
|
+
{
|
|
86
|
+
state: 'done' as const,
|
|
87
|
+
setNumber: 1,
|
|
88
|
+
unit: 'lbs' as const,
|
|
89
|
+
reps: 10,
|
|
90
|
+
weight: 90,
|
|
91
|
+
velocities: [0.72, 0.66],
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
}
|
|
95
|
+
: ex
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
it('renders the named exercise expanded in place, leaving the others collapsed', () => {
|
|
99
|
+
render(<SessionRail {...baseProps} exercises={withSets} expandedIndex={1} />)
|
|
100
|
+
// The expanded row reveals the set table; the collapsed ones do not.
|
|
101
|
+
expect(screen.getByText('SET')).toBeInTheDocument()
|
|
102
|
+
expect(screen.getByText('RPE')).toBeInTheDocument()
|
|
103
|
+
// Every exercise still has a row.
|
|
104
|
+
expect(screen.getByText('Seated Cable Row')).toBeInTheDocument()
|
|
105
|
+
expect(screen.getByText('Cable Chest Press')).toBeInTheDocument()
|
|
106
|
+
expect(screen.getByText('Face Pull')).toBeInTheDocument()
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
it('stays collapsed when the named exercise has no sets', () => {
|
|
110
|
+
// Guards the real case: an exercise whose sets have not loaded yet must not
|
|
111
|
+
// expand into an empty table.
|
|
112
|
+
render(<SessionRail {...baseProps} expandedIndex={1} />)
|
|
113
|
+
expect(screen.queryByText('SET')).not.toBeInTheDocument()
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
it('leaves every row collapsed when expandedIndex is omitted', () => {
|
|
117
|
+
render(<SessionRail {...baseProps} exercises={withSets} />)
|
|
118
|
+
expect(screen.queryByText('SET')).not.toBeInTheDocument()
|
|
119
|
+
})
|
|
120
|
+
})
|
|
121
|
+
|
|
79
122
|
describe('accessibility', () => {
|
|
80
123
|
it('has no accessibility violations', async () => {
|
|
81
124
|
const { container } = render(<SessionRail {...baseProps} />)
|
|
@@ -4,6 +4,8 @@ import { primitiveColors } from '../../../theme/tokens/primitives'
|
|
|
4
4
|
import { neumorphicShadows } from '../../../theme/shadows'
|
|
5
5
|
import { Surface } from '../../ui/surface'
|
|
6
6
|
import { ExerciseCardHeading } from './ExerciseCardHeading'
|
|
7
|
+
import { ExerciseCard } from './ExerciseCard'
|
|
8
|
+
import type { SetRowProps } from './SetRow'
|
|
7
9
|
import { SessionHeader } from './SessionHeader'
|
|
8
10
|
import type { MetricTileData } from './MetricTiles'
|
|
9
11
|
import type { SetStripSet } from './SetStrip'
|
|
@@ -38,6 +40,12 @@ export interface SessionRailExercise {
|
|
|
38
40
|
setStates: SetStripSet[]
|
|
39
41
|
/** Dim the row as a not-yet-reached exercise. */
|
|
40
42
|
upcoming?: boolean
|
|
43
|
+
/**
|
|
44
|
+
* Per-set rows for the expanded body. Only read when this row is the one named
|
|
45
|
+
* by `expandedIndex` — a rail row without them can never expand, which is the
|
|
46
|
+
* correct behaviour for an exercise whose sets aren't loaded.
|
|
47
|
+
*/
|
|
48
|
+
sets?: SetRowProps[]
|
|
41
49
|
}
|
|
42
50
|
|
|
43
51
|
export interface SessionRailProps extends ViewProps {
|
|
@@ -60,6 +68,16 @@ export interface SessionRailProps extends ViewProps {
|
|
|
60
68
|
stripHeight?: number
|
|
61
69
|
/** Rail width in px. Default 246. */
|
|
62
70
|
width?: number
|
|
71
|
+
/**
|
|
72
|
+
* Index of the exercise to render EXPANDED in place — its set table opens
|
|
73
|
+
* inside the rail rather than in a separate pane. The row still draws the same
|
|
74
|
+
* `ExerciseCardHeading` (an `ExerciseCard` composes one), so an expanded row
|
|
75
|
+
* differs from a collapsed one only by the revealed body.
|
|
76
|
+
*
|
|
77
|
+
* Ignored when the named exercise has no `sets`. Omit for an all-collapsed
|
|
78
|
+
* rail, which is the prior behaviour.
|
|
79
|
+
*/
|
|
80
|
+
expandedIndex?: number
|
|
63
81
|
onExercisePress?: (exercise: SessionRailExercise, index: number) => void
|
|
64
82
|
className?: string
|
|
65
83
|
}
|
|
@@ -81,6 +99,7 @@ export function SessionRail({
|
|
|
81
99
|
next,
|
|
82
100
|
stripHeight = 8,
|
|
83
101
|
width = DEFAULT_WIDTH,
|
|
102
|
+
expandedIndex,
|
|
84
103
|
onExercisePress,
|
|
85
104
|
className,
|
|
86
105
|
style,
|
|
@@ -118,19 +137,37 @@ export function SessionRail({
|
|
|
118
137
|
borderBottomColor: DIVIDER,
|
|
119
138
|
}}
|
|
120
139
|
>
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
140
|
+
{i === expandedIndex && ex.sets ? (
|
|
141
|
+
<ExerciseCard
|
|
142
|
+
name={ex.name}
|
|
143
|
+
expanded
|
|
144
|
+
summary={{
|
|
145
|
+
sets: ex.summary.sets,
|
|
146
|
+
reps: ex.summary.reps,
|
|
147
|
+
// ExerciseCard's summary takes a numeric load; a string load is
|
|
148
|
+
// an unset/discovery weight, which has no expanded form yet.
|
|
149
|
+
weight: typeof ex.summary.weight === 'number' ? ex.summary.weight : 0,
|
|
150
|
+
unit: ex.summary.unit,
|
|
151
|
+
}}
|
|
152
|
+
tempo={ex.tempo}
|
|
153
|
+
sets={ex.sets}
|
|
154
|
+
onExpandedChange={() => onExercisePress?.(ex, i)}
|
|
155
|
+
/>
|
|
156
|
+
) : (
|
|
157
|
+
<ExerciseCardHeading
|
|
158
|
+
name={ex.name}
|
|
159
|
+
sets={ex.summary.sets}
|
|
160
|
+
reps={ex.summary.reps}
|
|
161
|
+
load={ex.summary.weight}
|
|
162
|
+
unit={ex.summary.unit}
|
|
163
|
+
tempo={ex.tempo}
|
|
164
|
+
indicator={ex.indicator}
|
|
165
|
+
setStates={ex.setStates}
|
|
166
|
+
stripHeight={stripHeight}
|
|
167
|
+
dimmed={ex.upcoming}
|
|
168
|
+
onPress={() => onExercisePress?.(ex, i)}
|
|
169
|
+
/>
|
|
170
|
+
)}
|
|
134
171
|
</View>
|
|
135
172
|
))}
|
|
136
173
|
</Surface>
|
|
@@ -55,9 +55,9 @@ describe('SetRow', () => {
|
|
|
55
55
|
expect(screen.getByText('8')).toHaveStyle({ color: T_MUTED })
|
|
56
56
|
})
|
|
57
57
|
|
|
58
|
-
it('renders
|
|
58
|
+
it('renders the flat compact strip (done reps, no todo stubs)', () => {
|
|
59
59
|
render(<SetRow {...doneRow} />)
|
|
60
|
-
expect(screen.getByTestId('velocity-strip-
|
|
60
|
+
expect(screen.getByTestId('velocity-strip-compact')).toBeInTheDocument()
|
|
61
61
|
expect(screen.getAllByTestId(/^velocity-bar-\d+$/)).toHaveLength(3)
|
|
62
62
|
expect(screen.queryByTestId('velocity-slot-todo')).not.toBeInTheDocument()
|
|
63
63
|
})
|
|
@@ -76,9 +76,9 @@ describe('SetRow', () => {
|
|
|
76
76
|
expect(screen.getByText('2')).toHaveStyle({ color: T_ACTIVE })
|
|
77
77
|
})
|
|
78
78
|
|
|
79
|
-
it('renders the
|
|
79
|
+
it('renders the velocity-height spotlight strip', () => {
|
|
80
80
|
render(<SetRow {...liveRow} />)
|
|
81
|
-
expect(screen.getByTestId('velocity-strip-
|
|
81
|
+
expect(screen.getByTestId('velocity-strip-spotlight')).toBeInTheDocument()
|
|
82
82
|
// 2 performed reps + grey stubs to the target (10).
|
|
83
83
|
expect(screen.getAllByTestId(/^velocity-bar-\d+$/)).toHaveLength(2)
|
|
84
84
|
expect(screen.getAllByTestId('velocity-slot-todo')).toHaveLength(8)
|
|
@@ -93,10 +93,10 @@ describe('SetRow', () => {
|
|
|
93
93
|
expect(screen.getByTestId('set-row-rpe')).toHaveTextContent('—')
|
|
94
94
|
})
|
|
95
95
|
|
|
96
|
-
it('is muted and renders an all-grey
|
|
96
|
+
it('is muted and renders an all-grey compact stub strip', () => {
|
|
97
97
|
render(<SetRow {...todoRow} />)
|
|
98
98
|
expect(screen.getByText('3')).toHaveStyle({ color: T_MUTED })
|
|
99
|
-
expect(screen.getByTestId('velocity-strip-
|
|
99
|
+
expect(screen.getByTestId('velocity-strip-compact')).toBeInTheDocument()
|
|
100
100
|
expect(screen.getAllByTestId('velocity-slot-todo')).toHaveLength(10)
|
|
101
101
|
expect(screen.queryByTestId(/^velocity-bar-\d+$/)).not.toBeInTheDocument()
|
|
102
102
|
})
|
|
@@ -120,7 +120,7 @@ function Cell({
|
|
|
120
120
|
)
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
/** The per-row velocity strip:
|
|
123
|
+
/** The per-row velocity strip: the velocity-height `expanded` spotlight for the live set, the flat `compact` strip otherwise. */
|
|
124
124
|
function RowStrip({ set }: { set: SetRowProps }) {
|
|
125
125
|
const zones = set.velocityZones
|
|
126
126
|
if (set.state === 'live') {
|
|
@@ -133,15 +133,22 @@ function RowStrip({ set }: { set: SetRowProps }) {
|
|
|
133
133
|
showInfo={false}
|
|
134
134
|
height={24}
|
|
135
135
|
scale="fixed"
|
|
136
|
+
// Grow the newest rep from the baseline as it lands (the live-set spotlight).
|
|
137
|
+
liveRepIndex={set.velocities.length - 1}
|
|
136
138
|
set={{ type: 'straight', velocities: set.velocities, planned: set.target.reps }}
|
|
137
139
|
zones={zones}
|
|
138
140
|
/>
|
|
139
141
|
)
|
|
140
142
|
}
|
|
141
143
|
const velocities = set.state === 'done' ? set.velocities : []
|
|
144
|
+
// Resting (done / todo) → the flat `compact` strip at the 8px SegmentedBar flat-bar language (the
|
|
145
|
+
// static compact bar fills its plot), so the resting per-rep strip matches the set-level segmented
|
|
146
|
+
// bars used elsewhere; the live spotlight above stays taller (24px).
|
|
142
147
|
return (
|
|
143
148
|
<VelocityStrip
|
|
144
|
-
variant="
|
|
149
|
+
variant="compact"
|
|
150
|
+
height={8}
|
|
151
|
+
hideBaseline
|
|
145
152
|
set={{ type: 'straight', velocities, planned: plannedReps(set) }}
|
|
146
153
|
zones={zones}
|
|
147
154
|
/>
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite'
|
|
2
|
+
import { VelocityStrip } from './VelocityStrip'
|
|
3
|
+
import {
|
|
4
|
+
Sheet,
|
|
5
|
+
Note,
|
|
6
|
+
ScenarioPair,
|
|
7
|
+
SetTypeBoard,
|
|
8
|
+
RepTypeBoard,
|
|
9
|
+
REP_SET,
|
|
10
|
+
REP_SET_LAGGING,
|
|
11
|
+
FATIGUE_SET,
|
|
12
|
+
FATIGUE_SET_LAGGING,
|
|
13
|
+
} from './velocity-story-kit'
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* `compact` — the flat resting strip. SetBarChart in flat mode: uniform short
|
|
17
|
+
* bars, no labels, no axis. The glance used in the SetRow table and on cards,
|
|
18
|
+
* where the bar is colour-encoded rather than height-encoded.
|
|
19
|
+
*
|
|
20
|
+
* The compact dual FOLDS into one footprint rather than stacking to 2x: each
|
|
21
|
+
* rep column splits at the centre into an L top pill and an R bottom pill.
|
|
22
|
+
* Because resting bars carry their meaning in colour, the pair costs the same
|
|
23
|
+
* vertical space as a single — 2x is only forced for the value-height expanded.
|
|
24
|
+
*/
|
|
25
|
+
const meta: Meta<typeof VelocityStrip> = {
|
|
26
|
+
title: 'Workout/DataViz/VelocityStrip/Compact',
|
|
27
|
+
component: VelocityStrip,
|
|
28
|
+
tags: ['autodocs'],
|
|
29
|
+
}
|
|
30
|
+
export default meta
|
|
31
|
+
type Story = StoryObj<typeof VelocityStrip>
|
|
32
|
+
|
|
33
|
+
export const Default: Story = {
|
|
34
|
+
name: 'Default',
|
|
35
|
+
render: () => (
|
|
36
|
+
<Sheet>
|
|
37
|
+
<Note>
|
|
38
|
+
The representative set at rest. Single fills its plot; the dual folds the same reps into
|
|
39
|
+
rounded L/R pills sharing that footprint.
|
|
40
|
+
</Note>
|
|
41
|
+
<ScenarioPair
|
|
42
|
+
view="compact"
|
|
43
|
+
title="Default"
|
|
44
|
+
single={REP_SET}
|
|
45
|
+
left={REP_SET}
|
|
46
|
+
right={REP_SET_LAGGING}
|
|
47
|
+
/>
|
|
48
|
+
</Sheet>
|
|
49
|
+
),
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export const SetTypes: Story = {
|
|
53
|
+
name: 'Set Types',
|
|
54
|
+
render: () => (
|
|
55
|
+
<Sheet>
|
|
56
|
+
<Note>
|
|
57
|
+
The full set-type vocabulary at resting scale. The chunk-notch still separates drop
|
|
58
|
+
sub-loads even when every bar is the same height.
|
|
59
|
+
</Note>
|
|
60
|
+
<SetTypeBoard view="compact" />
|
|
61
|
+
</Sheet>
|
|
62
|
+
),
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export const FatigueDecline: Story = {
|
|
66
|
+
name: 'Fatigue Decline',
|
|
67
|
+
render: () => (
|
|
68
|
+
<Sheet>
|
|
69
|
+
<Note>
|
|
70
|
+
Loss colouring is the default: each bar is coloured by its drop from the set's own
|
|
71
|
+
best, so a fatiguing set reads green-to-red regardless of absolute speed. At compact scale
|
|
72
|
+
this colour IS the signal — there is no height to read.
|
|
73
|
+
</Note>
|
|
74
|
+
<ScenarioPair
|
|
75
|
+
view="compact"
|
|
76
|
+
title="Fatigue decline"
|
|
77
|
+
single={FATIGUE_SET}
|
|
78
|
+
left={FATIGUE_SET}
|
|
79
|
+
right={FATIGUE_SET_LAGGING}
|
|
80
|
+
barColor="loss"
|
|
81
|
+
/>
|
|
82
|
+
</Sheet>
|
|
83
|
+
),
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export const EmptyColdBoot: Story = {
|
|
87
|
+
name: 'Empty / Cold Boot',
|
|
88
|
+
render: () => (
|
|
89
|
+
<Sheet>
|
|
90
|
+
<Note>
|
|
91
|
+
Before the first rep lands. A planned set draws its upcoming reps, so the strip holds both
|
|
92
|
+
its footprint AND its column count — nothing reflows when rep one arrives.
|
|
93
|
+
</Note>
|
|
94
|
+
<ScenarioPair
|
|
95
|
+
view="compact"
|
|
96
|
+
title="Cold boot · 6 planned, none logged"
|
|
97
|
+
singleSet={{ type: 'straight', velocities: [], planned: 6 }}
|
|
98
|
+
leftSet={{ type: 'straight', velocities: [], planned: 6 }}
|
|
99
|
+
rightSet={{ type: 'straight', velocities: [], planned: 6 }}
|
|
100
|
+
/>
|
|
101
|
+
<ScenarioPair
|
|
102
|
+
view="compact"
|
|
103
|
+
title="Truly empty · no plan to draw"
|
|
104
|
+
note="No planned count either — the only case where there is nothing to hold."
|
|
105
|
+
single={[]}
|
|
106
|
+
left={[]}
|
|
107
|
+
right={[]}
|
|
108
|
+
/>
|
|
109
|
+
</Sheet>
|
|
110
|
+
),
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export const DualLaggingSide: Story = {
|
|
114
|
+
name: 'Dual · Lagging Side',
|
|
115
|
+
render: () => (
|
|
116
|
+
<Sheet>
|
|
117
|
+
<Note>
|
|
118
|
+
Index-locked: the right slot has logged fewer reps, so its trailing columns render as faint
|
|
119
|
+
empties directly under the left's. Columns never shift — the next rep a lagging side
|
|
120
|
+
performs lands in its own column.
|
|
121
|
+
</Note>
|
|
122
|
+
<ScenarioPair
|
|
123
|
+
view="compact"
|
|
124
|
+
title="Equal counts · the common case"
|
|
125
|
+
note="Both slots logged the same reps. This is what most of a session looks like."
|
|
126
|
+
single={REP_SET}
|
|
127
|
+
left={REP_SET}
|
|
128
|
+
right={[0.93, 0.88, 0.84, 0.78, 0.7]}
|
|
129
|
+
/>
|
|
130
|
+
<ScenarioPair
|
|
131
|
+
view="compact"
|
|
132
|
+
title="Missed rep · lower slot"
|
|
133
|
+
note="Rep 3 missing from the LOWER slot — its column holds as a faint empty."
|
|
134
|
+
single={REP_SET}
|
|
135
|
+
left={REP_SET}
|
|
136
|
+
right={[0.93, 0.88, 0.78, 0.7]}
|
|
137
|
+
/>
|
|
138
|
+
<ScenarioPair
|
|
139
|
+
view="compact"
|
|
140
|
+
title="Missed rep · upper slot"
|
|
141
|
+
note="The mirror: the UPPER slot is short a rep."
|
|
142
|
+
single={REP_SET}
|
|
143
|
+
left={[0.95, 0.9, 0.8, 0.72]}
|
|
144
|
+
right={[0.93, 0.88, 0.84, 0.78, 0.7]}
|
|
145
|
+
/>
|
|
146
|
+
<ScenarioPair
|
|
147
|
+
view="compact"
|
|
148
|
+
title="One slot well behind"
|
|
149
|
+
single={REP_SET}
|
|
150
|
+
left={REP_SET}
|
|
151
|
+
right={REP_SET_LAGGING.slice(0, 2)}
|
|
152
|
+
/>
|
|
153
|
+
</Sheet>
|
|
154
|
+
),
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export const Responsive: Story = {
|
|
158
|
+
name: 'Responsive',
|
|
159
|
+
render: () => (
|
|
160
|
+
<Sheet width={520}>
|
|
161
|
+
<Note>
|
|
162
|
+
Compact degrades by WIDTH, not height — the bar layout is shared geometry, so bars and gaps
|
|
163
|
+
scale together and the chunk-notch stays proportional.
|
|
164
|
+
</Note>
|
|
165
|
+
{[440, 300, 180, 110].map((w) => (
|
|
166
|
+
<ScenarioPair
|
|
167
|
+
key={w}
|
|
168
|
+
view="compact"
|
|
169
|
+
title={`${w}px`}
|
|
170
|
+
width={w}
|
|
171
|
+
single={REP_SET}
|
|
172
|
+
left={REP_SET}
|
|
173
|
+
right={REP_SET_LAGGING}
|
|
174
|
+
/>
|
|
175
|
+
))}
|
|
176
|
+
</Sheet>
|
|
177
|
+
),
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export const RepTypes: Story = {
|
|
181
|
+
name: 'Rep Types',
|
|
182
|
+
render: () => (
|
|
183
|
+
<Sheet>
|
|
184
|
+
<Note>
|
|
185
|
+
Every state a rep column can be in at resting scale. Colour is the only channel compact has,
|
|
186
|
+
so a state that needs height to read must find another way here.
|
|
187
|
+
</Note>
|
|
188
|
+
<RepTypeBoard view="compact" />
|
|
189
|
+
</Sheet>
|
|
190
|
+
),
|
|
191
|
+
}
|