Files
GearBox/.planning/phases/07-weight-unit-selection/07-CONTEXT.md

64 lines
2.1 KiB
Markdown

# Phase 7: Weight Unit Selection - Context
**Gathered:** 2026-03-16
**Status:** Ready for planning
<domain>
## Phase Boundary
Users can select a preferred weight unit (g, oz, lb, kg) and all weight displays across the app reflect that choice. Weight input stays in grams. The setting persists across sessions.
</domain>
<decisions>
## Implementation Decisions
### Claude's Discretion
- Unit selector placement (TotalsBar, settings page, or elsewhere)
- Pounds display format (traditional "2 lb 3 oz" vs decimal "2.19 lb")
- Precision per unit (decimal places for oz, kg)
- Default unit (grams, matching current behavior)
- How formatWeight gets access to the setting (hook, context, parameter)
</decisions>
<code_context>
## Existing Code Insights
### Reusable Assets
- `formatWeight()` in `src/client/lib/formatters.ts`: Currently `Math.round(grams) + "g"` — single conversion point for all weight display
- `useSetting(key)` hook in `src/client/hooks/useSettings.ts`: Fetches from `/api/settings/:key`, caches with React Query
- `useUpdateSetting()` mutation: PUT to `/api/settings/:key`, invalidates query cache
- Settings API already exists with get/put endpoints
### Established Patterns
- Settings stored as key/value strings in SQLite `settings` table
- React Query for server state, Zustand for UI-only state
- Pill badges for weight/price display on ItemCard and CandidateCard (blue-50/blue-400 for weight)
### Integration Points
- `formatWeight()` call sites (~8 components): TotalsBar, ItemCard, CandidateCard, CategoryHeader, SetupCard, ItemPicker, collection route, setup detail route
- `formatPrice()` is in the same file — similar pattern, not affected by this phase
- TotalsBar already imports `useTotals()` and `formatWeight` — natural place for a unit toggle
</code_context>
<specifics>
## Specific Ideas
No specific requirements — user gave full discretion. Standard gear app patterns apply (LighterPack-style toggle).
</specifics>
<deferred>
## Deferred Ideas
None — discussion stayed within phase scope
</deferred>
---
*Phase: 07-weight-unit-selection*
*Context gathered: 2026-03-16*