diff --git a/app/globals.css b/app/globals.css index c79ae63..5c1cc7b 100644 --- a/app/globals.css +++ b/app/globals.css @@ -1,6 +1,8 @@ @import "tailwindcss"; -@source "../components/**/*.{js,ts,jsx,tsx}"; +@source "../components/converter/*.{js,ts,jsx,tsx}"; +@source "../components/providers/*.{js,ts,jsx,tsx}"; +@source "../components/ui/*.{js,ts,jsx,tsx}"; @source "*.{js,ts,jsx,tsx}"; @custom-variant dark (&:is(.dark *)); diff --git a/components/converter/MainConverter.tsx b/components/converter/MainConverter.tsx index 7415f79..ce5abd9 100644 --- a/components/converter/MainConverter.tsx +++ b/components/converter/MainConverter.tsx @@ -16,6 +16,7 @@ import { convertUnit, formatMeasureName, getCategoryColor, + getCategoryColorHex, type Measure, type ConversionResult, } from '@/lib/units'; @@ -253,7 +254,7 @@ export default function MainConverter() { {showVisualComparison ? ( ) : (
diff --git a/components/converter/VisualComparison.tsx b/components/converter/VisualComparison.tsx index af2b9a9..97a9b3d 100644 --- a/components/converter/VisualComparison.tsx +++ b/components/converter/VisualComparison.tsx @@ -81,16 +81,27 @@ export default function VisualComparison({
{/* Progress bar */} -
+
+ {/* Colored fill */}
- - {item.percentage >= 15 && `${Math.round(item.percentage)}%`} + /> + {/* Percentage label overlay */} +
+ + {Math.round(item.percentage)}% + + 30 ? 'white' : 'var(--foreground)', + }} + > + {item.percentage > 30 && formatNumber(item.value)}
diff --git a/lib/units.ts b/lib/units.ts index 217c292..d3e74e3 100644 --- a/lib/units.ts +++ b/lib/units.ts @@ -116,7 +116,7 @@ export function convertToAll( } /** - * Get category color for a measure + * Get category color for a measure (Tailwind class name) */ export function getCategoryColor(measure: Measure): string { const colorMap: Record = { @@ -148,6 +148,39 @@ export function getCategoryColor(measure: Measure): string { return colorMap[measure]; } +/** + * Get category color hex value for a measure + */ +export function getCategoryColorHex(measure: Measure): string { + const colorMap: Record = { + angle: '#0EA5E9', + apparentPower: '#8B5CF6', + area: '#F59E0B', + current: '#F59E0B', + digital: '#06B6D4', + each: '#64748B', + energy: '#EAB308', + frequency: '#A855F7', + illuminance: '#84CC16', + length: '#3B82F6', + mass: '#10B981', + pace: '#14B8A6', + partsPer: '#EC4899', + power: '#F43F5E', + pressure: '#6366F1', + reactiveEnergy: '#D946EF', + reactivePower: '#E879F9', + speed: '#10B981', + temperature: '#EF4444', + time: '#7C3AED', + voltage: '#FB923C', + volume: '#8B5CF6', + volumeFlowRate: '#22D3EE', + }; + + return colorMap[measure]; +} + /** * Format measure name for display */