Files
units-ui/IMPLEMENTATION_PLAN.md
Sebastian Krüger 5c0b8d668e docs: update implementation plan with all 23 unit categories
Update IMPLEMENTATION_PLAN.md to reflect accurate count from convert-units:
- Correct from estimated 13-27 categories to actual 23 categories
- Add complete list of all 23 measures with individual unit counts
- Total of 187 individual units across all categories
- Expand color palette from 8 to 23 distinct category colors
- Update visual comparison section with all 23 color assignments

New categories include:
- Angle, Apparent Power, Current, Illuminance, Pace
- Parts Per, Reactive Energy, Reactive Power, Voltage
- Volume Flow Rate (37 units - largest category)

Discovered through direct library inspection of convert-units package.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-08 09:16:13 +01:00

9.9 KiB

Unit Conversion App - Implementation Plan

Project Overview

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
  • TypeScript
  • Tailwind CSS 4
  • convert-units library
  • Static Site Generation

Innovative UX Features

1. Real-time Bidirectional Conversion

  • As you type in one field, all other compatible units update instantly
  • No "convert" button needed - everything is live
  • Smooth, debounced updates for performance

2. Smart Context-Aware Interface

  • Auto-detect measurement type from input
  • Suggest most relevant units based on context
  • Fuzzy search: type "kilo" → finds "kilogram", "kilometer"
  • Intelligent unit suggestions based on user's location/preferences

3. Visual Comparison

  • Show visual representations (bars, icons) to understand magnitude differences
  • Animated transitions between conversions
  • Color-coded categories (23 distinct colors):
    • Angle: Sky Blue
    • Apparent Power: Violet
    • Area: Orange
    • Current: Amber
    • Digital: Cyan
    • Each: Slate
    • Energy: Yellow
    • Frequency: Purple
    • Illuminance: Lime
    • Length: Blue
    • Mass: Green
    • Pace: Teal
    • Parts Per: Pink
    • Power: Rose
    • Pressure: Indigo
    • Reactive Energy: Fuchsia
    • Reactive Power: Magenta
    • Speed: Emerald
    • Temperature: Red
    • Time: Violet Blue
    • Voltage: Yellow Orange
    • Volume: Purple Blue
    • Volume Flow Rate: Aqua

4. Power User Features

  • Keyboard Shortcuts:
    • Tab - Cycle through units
    • / - Focus search
    • Esc - Clear inputs
    • Ctrl/Cmd + K - Command palette
    • Ctrl/Cmd + C - Copy result
  • Quick access to favorite/recent conversions
  • One-click copy results
  • Conversion history with undo/redo
  • URL-based sharing of conversions

5. Mobile-First Design

  • Large touch targets (min 44px)
  • Swipe gestures to switch between categories
  • Optimized for one-handed use
  • Bottom sheet UI for unit selection on mobile
  • Haptic feedback on interactions

Technical Architecture

Pages Structure

app/
├── page.tsx              # Home - Main conversion interface
├── layout.tsx            # Root layout with metadata
├── categories/
│   └── page.tsx          # Browse all unit categories
├── [category]/
│   └── page.tsx          # Category-specific converter
└── about/
    └── page.tsx          # About the app

Component Structure

components/
├── converter/
│   ├── MainConverter.tsx       # Main conversion interface
│   ├── UnitInput.tsx          # Individual unit input field
│   ├── UnitSelector.tsx       # Unit selection dropdown
│   ├── CategoryTabs.tsx       # Category navigation
│   └── VisualComparison.tsx   # Visual magnitude display
├── search/
│   ├── FuzzySearch.tsx        # Fuzzy search component
│   └── CommandPalette.tsx     # Keyboard command interface
├── history/
│   ├── ConversionHistory.tsx  # History sidebar
│   └── HistoryItem.tsx        # Individual history entry
└── ui/
    ├── Button.tsx
    ├── Input.tsx
    ├── Card.tsx
    └── Badge.tsx

State Management

// Global state structure
interface AppState {
  currentCategory: string | null;
  selectedUnits: {
    from: string;
    to: string[];
  };
  inputValue: number | null;
  history: ConversionRecord[];
  favorites: string[];
  preferences: UserPreferences;
}

Data Layer

// Unit metadata
interface UnitInfo {
  abbr: string;
  measure: string;
  system: 'metric' | 'imperial' | 'other';
  plural: string;
  singular: string;
  description?: string;
}

// Conversion record
interface ConversionRecord {
  id: string;
  timestamp: number;
  from: { value: number; unit: string };
  to: { value: number; unit: string };
  category: string;
}

Implementation Phases

Phase 1: Project Setup

  • Initialize git repository
  • Initialize Next.js 16 project with TypeScript
  • Configure Tailwind CSS 4
  • Install convert-units library
  • Set up project structure
  • Configure static export

Phase 2: Core Conversion Engine

  • Create convert-units wrapper/service
  • Implement real-time conversion logic
  • Build unit metadata system
  • Add input validation and error handling
  • Create conversion utilities

Phase 3: Main UI Components

  • Build MainConverter component
  • Create UnitInput with live updates
  • Implement UnitSelector dropdown
  • Add CategoryTabs navigation
  • Design responsive layout with Tailwind CSS 4

Phase 4: Enhanced UX Features

  • Implement fuzzy search for units
  • Add visual comparison bars
  • Create command palette
  • Build keyboard shortcuts system
  • Add smooth animations

Phase 5: User Preferences & History

  • Implement localStorage for history
  • Add favorites system
  • Create conversion history UI
  • Add undo/redo functionality
  • Build user preferences panel

Phase 6: Mobile Optimization

  • Optimize touch targets
  • Implement swipe gestures
  • Create bottom sheet UI
  • Add haptic feedback
  • Test on various devices

Phase 7: Accessibility & Polish

  • WCAG 2.1 AA compliance
  • Screen reader optimization
  • Keyboard navigation testing
  • Add dark mode support
  • Performance optimization

Phase 8: Static Generation & Deployment

  • Configure Next.js static export
  • Optimize bundle size
  • Add SEO metadata
  • Generate sitemap
  • Deploy to hosting platform

Design System

Color Palette (Category-based - 23 colors)

/* All 23 measurement categories */
--color-angle: #0EA5E9;           /* Sky Blue */
--color-apparent-power: #8B5CF6;  /* Violet */
--color-area: #F59E0B;            /* Orange */
--color-current: #F59E0B;         /* Amber */
--color-digital: #06B6D4;         /* Cyan */
--color-each: #64748B;            /* Slate */
--color-energy: #EAB308;          /* Yellow */
--color-frequency: #A855F7;       /* Purple */
--color-illuminance: #84CC16;     /* Lime */
--color-length: #3B82F6;          /* Blue */
--color-mass: #10B981;            /* Green */
--color-pace: #14B8A6;            /* Teal */
--color-parts-per: #EC4899;       /* Pink */
--color-power: #F43F5E;           /* Rose */
--color-pressure: #6366F1;        /* Indigo */
--color-reactive-energy: #D946EF; /* Fuchsia */
--color-reactive-power: #E879F9;  /* Magenta */
--color-speed: #10B981;           /* Emerald */
--color-temperature: #EF4444;     /* Red */
--color-time: #7C3AED;            /* Violet Blue */
--color-voltage: #FB923C;         /* Yellow Orange */
--color-volume: #8B5CF6;          /* Purple Blue */
--color-volume-flow-rate: #22D3EE;/* Aqua */

Typography

  • Headings: Inter (system font fallback)
  • Body: System UI stack
  • Mono: JetBrains Mono (for numbers)

Spacing Scale

  • Tailwind CSS 4 default scale
  • Custom breakpoints for mobile-first design

Supported Unit Categories

Based on convert-units library (23 total measures):

  1. Angle: rad, deg, grad, arcmin, arcsec (5 units)
  2. Apparent Power: VA, mVA, kVA, MVA, GVA (5 units)
  3. Area: mm2, cm2, m2, ha, km2, in2, yd2, ft2, ac, mi2 (10 units)
  4. Current: A, mA, kA (3 units)
  5. Digital: b, Kb, Mb, Gb, Tb, B, KB, MB, GB, TB (10 units)
  6. Each: ea (each), dz (dozen) (2 units)
  7. Energy: Wh, mWh, kWh, MWh, GWh, J, kJ (7 units)
  8. Frequency: mHz, Hz, kHz, MHz, GHz, THz, rpm, deg/s, rad/s (9 units)
  9. Illuminance: lx, ft-cd (2 units)
  10. Length: mm, cm, m, km, in, yd, ft-us, ft, mi (9 units)
  11. Mass: mcg, mg, g, kg, mt, oz, lb, t (8 units)
  12. Pace: min/km, s/m, min/mi, s/ft (4 units)
  13. Parts Per: ppm, ppb, ppt, ppq (4 units)
  14. Power: W, mW, kW, MW, GW (5 units)
  15. Pressure: Pa, kPa, MPa, hPa, bar, torr, psi, ksi (8 units)
  16. Reactive Energy: VARh, mVARh, kVARh, MVARh, GVARh (5 units)
  17. Reactive Power: VAR, mVAR, kVAR, MVAR, GVAR (5 units)
  18. Speed: m/s, km/h, m/h, knot, ft/s (5 units)
  19. Temperature: C, K, F, R (4 units)
  20. Time: ns, mu, ms, s, min, h, d, week, month, year (10 units)
  21. Voltage: V, mV, kV (3 units)
  22. Volume: mm3, cm3, ml, cl, dl, l, kl, m3, km3, krm, tsk, msk, kkp, glas, kanna, tsp, Tbs, in3, fl-oz, cup, pnt, qt, gal, ft3, yd3 (25 units)
  23. Volume Flow Rate: mm3/s, cm3/s, ml/s, cl/s, dl/s, l/s, l/min, l/h, kl/s, kl/min, kl/h, m3/s, m3/min, m3/h, km3/s, tsp/s, Tbs/s, in3/s, in3/min, in3/h, fl-oz/s, fl-oz/min, fl-oz/h, cup/s, pnt/s, pnt/min, pnt/h, qt/s, gal/s, gal/min, gal/h, ft3/s, ft3/min, ft3/h, yd3/s, yd3/min, yd3/h (37 units)

Total: 23 measurement categories with 187 individual units

Performance Targets

  • First Contentful Paint: < 1.0s
  • Time to Interactive: < 2.0s
  • Lighthouse Score: > 95
  • Bundle Size: < 100KB (gzipped)

Accessibility Requirements

  • WCAG 2.1 AA compliance
  • Keyboard navigation for all features
  • Screen reader support with ARIA labels
  • Focus indicators
  • Color contrast ratios ≥ 4.5:1
  • Reduced motion support

Browser Support

  • Chrome/Edge (last 2 versions)
  • Firefox (last 2 versions)
  • Safari (last 2 versions)
  • Mobile Safari iOS 14+
  • Chrome Android (last 2 versions)

Future Enhancements

  • Custom unit creation
  • Multi-unit conversions (e.g., feet + inches)
  • Currency conversion
  • Unit conversion formulas display
  • Share conversions as images
  • PWA support with offline capability
  • Multi-language support
  • Voice input for conversions
  • API for programmatic access

Development Guidelines

  1. Code Style: Follow Airbnb TypeScript style guide
  2. Commits: Conventional commits format
  3. Testing: Unit tests for conversion logic
  4. Documentation: JSDoc for all components
  5. Performance: Monitor bundle size and runtime performance

Project Start Date: 2025-11-08 Target Completion: TBD Version: 1.0.0