Sebastian Krüger 08026893d3 fix: keep source unit stable during drag - bars now update correctly
Critical fix: stopped switching selectedUnit during drag.

Problem:
- We were switching selectedUnit to the dragged unit
- This changed the conversion base
- All units maintained proportional relationships in log scale
- Bars didn't visually change size because ratios stayed the same
- On drag end, bars would snap back

Root cause: Switching source unit doesn't change bar proportions!
Example:
- Start: 1 meter → 3.28 feet (feet bar at 50% in log scale)
- Drag feet bar: switch to feet as source
- Now: 3.28 feet → 1 meter (meter bar at 50% in log scale)
- Proportions are IDENTICAL! No visual change!

Solution: Keep selectedUnit stable, only change inputValue
- Convert dragged value back to currently selected unit
- Update inputValue with converted amount
- selectedUnit stays unchanged
- All conversions scale proportionally from same base
- Bars resize because absolute values change!

How it works now:
- Dragging "feet" bar with "meters" selected
- Calculate new feet value from drag position
- Convert feet → meters: convertUnit(feetValue, 'ft', 'm')
- Update inputValue with meter equivalent
- All bars recalculate from meters (same base)
- Bars resize correctly because meter input changed!

Result: Bars now properly resize during drag AND stay at position on release!

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-08 10:59:57 +01:00

Unit Converter

A spectacular, innovative unit conversion application built with modern web technologies to provide the best user experience for converting between various measurement units.

Tech Stack

  • Next.js 16 - React framework with App Router and static export
  • TypeScript - Type-safe development
  • Tailwind CSS 4 - Modern utility-first CSS framework
  • convert-units - Comprehensive unit conversion library

Features

Supported Units

23 measurement categories with 187 individual units:

  • Angle, Apparent Power, Area, Current, Digital
  • Each, Energy, Frequency, Illuminance, Length
  • Mass, Pace, Parts Per, Power, Pressure
  • Reactive Energy, Reactive Power, Speed, Temperature
  • Time, Voltage, Volume, Volume Flow Rate

Innovative UX Features

  • Real-time bidirectional conversion
  • Smart context-aware interface with fuzzy search
  • Visual comparison with color-coded categories
  • Keyboard shortcuts for power users
  • Mobile-first responsive design
  • Conversion history with localStorage
  • Dark mode support

Getting Started

Prerequisites

  • Node.js 18+ or 20+
  • pnpm (recommended) or npm

Installation

# Install dependencies
pnpm install

# Run development server
pnpm dev

# Build for production
pnpm build

# Start production server
pnpm start

Open http://localhost:3000 to see the app.

Project Structure

units-ui/
├── app/                  # Next.js App Router
│   ├── layout.tsx       # Root layout
│   ├── page.tsx         # Home page
│   └── globals.css      # Global styles
├── components/          # React components (coming soon)
├── lib/                 # Utility functions (coming soon)
├── public/              # Static assets
└── IMPLEMENTATION_PLAN.md  # Detailed implementation plan

Development

See IMPLEMENTATION_PLAN.md for the complete development roadmap.

License

MIT


Built with Next.js 16, Tailwind CSS 4, and convert-units

Description
No description provided
Readme 148 KiB
Languages
TypeScript 90.3%
CSS 8.2%
Dockerfile 1.4%