Add bar type selection to workouts - #14
Merged
Merged
Conversation
Movements can now have an optional barType (e.g. "barbell", "dumbbell") and barId (specific bar index). This flows through the full system: - Editor: select bar type or specific bar per movement via grouped dropdown - Viewer: set buttons include bar/barWeight in URL hash for the calculator - Export: barType is included in the packed format (backward-compatible) - Import: bar type mapping UI with auto-match to existing bar types Both fields are optional, so existing workouts are unaffected. https://claude.ai/code/session_01B33nPQF397D5gEJu9e2bJb
Replace `barType?: string` + `barId?: number` with a single
`bar?: { type: string } | { id: number }` field on Movement.
Export now takes a bars array and resolves `{ id }` to the bar's type
string, so the portable format always contains the bar type regardless
of how the user selected the bar. Added test coverage for id resolution
and unknown bar id fallback.
https://claude.ai/code/session_01B33nPQF397D5gEJu9e2bJb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds support for selecting and tracking bar types (barbell, dumbbell, etc.) in workout movements. Users can now specify which bar is used for each exercise, and this information is preserved during workout export/import and shared via URLs.
Key Changes
Movement bar selection: Added optional
barfield toMovementtype that can store either a bar type filter ({ type: string }) or a specific bar by ID ({ id: number })Workout export/import:
exportWorkout()now accepts abarsparameter and resolves bar selections to bar types in the exported dataWorkoutImportercomponent now handles bar type mapping with UI for linking imported bar types to local barsUI updates:
WorkoutEditornow displays a bar selection dropdown alongside the max selection, organized by bar type with options for specific bars or generic type selectionWorkoutViewerincludes bar information when building set hash links for external toolsShareDialogpasses bars to the export functionTest coverage: Added comprehensive test suite for bar type round-tripping with various scenarios (specific bar ID, generic type, mixed movements, unknown bars)
Implementation Details
resolveBarType()that handles both direct type specifications and ID-based lookups[name, maxName, sets], while those with bars use the 4-element format[name, maxName, sets, barType]bar:for ID,type:for type) to distinguish between selection modes in dropdown valueshttps://claude.ai/code/session_01B33nPQF397D5gEJu9e2bJb