1974801d5993231424fc1743d4cc2888c0d0f2db
Fixed issue where bars would snap back to original position on drag release. Problem: - On mouseup/touchend, we cleared draggedPercentage immediately - Conversions hadn't updated yet (async state updates) - Bar switched from draggedPercentage to old item.percentage - Bar visually "snapped back" to original position Solution: Delay clearing drag state until conversions update - On drag end: only clear draggingUnit, keep draggedPercentage - Added useEffect that watches conversions + draggingUnit - When !draggingUnit && draggedPercentage !== null → drag just ended - This means conversions have updated, safe to clear visual state - Now clears draggedPercentage and baseConversionsRef Flow: 1. User releases mouse/touch 2. handleMouseUp/handleTouchEnd: calls onValueChange(..., false) 3. Sets draggingUnit = null (stops active drag) 4. Keeps draggedPercentage (maintains visual position) 5. MainConverter updates inputValue and selectedUnit 6. Conversions recalculate 7. useEffect detects: !draggingUnit && draggedPercentage 8. Clears draggedPercentage → bar smoothly transitions to calculated position Result: Bar stays at dragged position and smoothly settles to final value! 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
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
Languages
TypeScript
90.3%
CSS
8.2%
Dockerfile
1.4%