Skip to content

Fix splits page: km/mi toggle conversion and button hover styles#28

Draft
Copilot wants to merge 5 commits intomainfrom
copilot/explore-user-value-for-runners
Draft

Fix splits page: km/mi toggle conversion and button hover styles#28
Copilot wants to merge 5 commits intomainfrom
copilot/explore-user-value-for-runners

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 3, 2026

The splits page had two issues: the km/mi toggle only swapped the label without converting the distance value (e.g. selecting Half Marathon then toggling to miles kept 21.0975 as miles instead of converting to 13.1), and the shadcn <Button> component's built-in hover styles conflicted with custom Tailwind classes.

Distance conversion

  • Added convertDistance() to split-calculator utils with smart snapping to common race distances (5K, 10K, half, full)
  • handleUnitToggle now converts the distance value when switching units, matching /calculator behavior
const handleUnitToggle = (unit: DistanceUnit) => {
  if (unit === inputs.units) return;
  if (inputs.distance && !isNaN(parseFloat(inputs.distance))) {
    const converted = convertDistance(parseFloat(inputs.distance), inputs.units, unit);
    setInputs((prev) => ({ ...prev, units: unit, distance: converted.toString() }));
  } else {
    setInputs((prev) => ({ ...prev, units: unit }));
  }
  setResults(null);
};

Button hover styles

  • Replaced shadcn <Button> with native <button> elements using explicit Tailwind hover classes, consistent with /calculator
  • Replaced plain km/mi button pair with the calculator's animated sliding toggle

Tests

  • 4 new convertDistance test cases covering round-trip snapping and non-common distances

Fixed km/mi toggle with distance conversion


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@netlify
Copy link
Copy Markdown

netlify bot commented Mar 3, 2026

Deploy Preview for trainpace ready!

Name Link
🔨 Latest commit a663bfd
🔍 Latest deploy log https://app.netlify.com/projects/trainpace/deploys/69a7dfc813572e000853987b
😎 Deploy Preview https://deploy-preview-28--trainpace.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 80
Accessibility: 89
Best Practices: 100
SEO: 100
PWA: 60
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 3, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
trainpace Ready Ready Preview, Comment Mar 4, 2026 7:31am

New feature for runners: enter a goal time and distance to get
per-km or per-mile split targets for race day.

- Even, negative, and positive split strategies
- Printable pace band for wrist
- Copy splits to clipboard
- Race day pacing tips section
- 18 unit tests for calculation logic
- Added to navigation, landing page, and comparison table

Co-authored-by: aleexwong <65264501+aleexwong@users.noreply.github.com>
Co-authored-by: aleexwong <65264501+aleexwong@users.noreply.github.com>
Copilot AI changed the title [WIP] Investigate value propositions for average runners feat: Add Race Split Calculator with pace band printing Mar 3, 2026
…istent hover styles

The shadcn Button component's built-in hover styles (hover:bg-primary/90,
hover:bg-accent) conflicted with custom Tailwind classes, causing bad
hover behavior. Replaced with native <button> elements using explicit
Tailwind hover classes, matching the /calculator page approach.

Co-authored-by: aleexwong <65264501+aleexwong@users.noreply.github.com>
Copilot AI changed the title feat: Add Race Split Calculator with pace band printing fix: replace shadcn Button with native buttons on splits page for consistent hover styles Mar 3, 2026
…toggle

The km/mi toggle only changed the unit label without converting the
distance value. Selecting "Half Marathon" (21.0975 km) and toggling to
miles would leave distance as 21.0975 treated as miles.

- Add convertDistance utility with smart snapping to common race distances
- Update handleUnitToggle to convert distance when switching units
- Replace plain buttons with animated sliding toggle (matches /calculator)
- Add 4 test cases for convertDistance function

Co-authored-by: aleexwong <65264501+aleexwong@users.noreply.github.com>
Copilot AI changed the title fix: replace shadcn Button with native buttons on splits page for consistent hover styles Fix splits page: km/mi toggle conversion and button hover styles Mar 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants