feat: ensure all category components use consistent hex colors

Update all category-related UI components to use getCategoryColorHex() function
instead of CSS variables for consistent color application across the app.

Changes:
- MainConverter: category buttons now use hex colors for background/border
- MainConverter: quick result display uses hex color for text and border
- MainConverter: result cards use hex color for left border
- CommandPalette: measure commands use hex colors for color indicators
- SearchUnits: category color dots use hex colors

This ensures all category colors are consistently applied using the same
hex color values defined in the OKLCH color palette.

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-08 10:36:26 +01:00
parent 1943974908
commit eb556ddfce
3 changed files with 15 additions and 7 deletions

View File

@@ -153,8 +153,12 @@ export default function MainConverter() {
style={{ style={{
backgroundColor: backgroundColor:
selectedMeasure === measure selectedMeasure === measure
? `var(--color-${getCategoryColor(measure)})` ? getCategoryColorHex(measure)
: undefined, : undefined,
borderColor: selectedMeasure !== measure
? getCategoryColorHex(measure)
: undefined,
color: selectedMeasure === measure ? 'white' : undefined,
}} }}
> >
{formatMeasureName(measure)} {formatMeasureName(measure)}
@@ -224,10 +228,12 @@ export default function MainConverter() {
{/* Quick result */} {/* Quick result */}
{parseNumberInput(inputValue) !== null && ( {parseNumberInput(inputValue) !== null && (
<div className="p-4 rounded-lg bg-accent/50 border-l-4" style={{ <div className="p-4 rounded-lg bg-accent/50 border-l-4" style={{
borderLeftColor: `var(--color-${getCategoryColor(selectedMeasure)})`, borderLeftColor: getCategoryColorHex(selectedMeasure),
}}> }}>
<div className="text-sm text-muted-foreground">Result</div> <div className="text-sm text-muted-foreground">Result</div>
<div className="text-3xl font-bold mt-1"> <div className="text-3xl font-bold mt-1" style={{
color: getCategoryColorHex(selectedMeasure),
}}>
{formatNumber(convertUnit(parseNumberInput(inputValue)!, selectedUnit, targetUnit))} {targetUnit} {formatNumber(convertUnit(parseNumberInput(inputValue)!, selectedUnit, targetUnit))} {targetUnit}
</div> </div>
</div> </div>
@@ -268,7 +274,7 @@ export default function MainConverter() {
className="group relative p-4 rounded-lg border bg-card hover:bg-accent/50 transition-colors" className="group relative p-4 rounded-lg border bg-card hover:bg-accent/50 transition-colors"
style={{ style={{
borderLeftWidth: '4px', borderLeftWidth: '4px',
borderLeftColor: `var(--color-${getCategoryColor(selectedMeasure)})`, borderLeftColor: getCategoryColorHex(selectedMeasure),
}} }}
> >
{/* Favorite & Copy buttons */} {/* Favorite & Copy buttons */}

View File

@@ -11,6 +11,7 @@ import {
getUnitInfo, getUnitInfo,
formatMeasureName, formatMeasureName,
getCategoryColor, getCategoryColor,
getCategoryColorHex,
type Measure, type Measure,
type UnitInfo, type UnitInfo,
} from '@/lib/units'; } from '@/lib/units';
@@ -182,7 +183,7 @@ export default function SearchUnits({ onSelectUnit }: SearchUnitsProps) {
<div <div
className="w-3 h-3 rounded-full flex-shrink-0" className="w-3 h-3 rounded-full flex-shrink-0"
style={{ style={{
backgroundColor: `var(--color-${getCategoryColor(result.measure)})`, backgroundColor: getCategoryColorHex(result.measure),
}} }}
/> />
</button> </button>

View File

@@ -7,6 +7,7 @@ import {
getAllMeasures, getAllMeasures,
formatMeasureName, formatMeasureName,
getCategoryColor, getCategoryColor,
getCategoryColorHex,
type Measure, type Measure,
} from '@/lib/units'; } from '@/lib/units';
import { getHistory, getFavorites } from '@/lib/storage'; import { getHistory, getFavorites } from '@/lib/storage';
@@ -60,7 +61,7 @@ export default function CommandPalette({
icon: Hash, icon: Hash,
action: () => onSelectMeasure(measure), action: () => onSelectMeasure(measure),
keywords: ['convert', measure, formatMeasureName(measure).toLowerCase()], keywords: ['convert', measure, formatMeasureName(measure).toLowerCase()],
color: getCategoryColor(measure), color: getCategoryColorHex(measure),
})); }));
const allCommands = [...commands, ...measureCommands]; const allCommands = [...commands, ...measureCommands];
@@ -187,7 +188,7 @@ export default function CommandPalette({
<div <div
className="w-5 h-5 rounded flex-shrink-0" className="w-5 h-5 rounded flex-shrink-0"
style={{ style={{
backgroundColor: `var(--color-${command.color})`, backgroundColor: command.color,
}} }}
/> />
) : ( ) : (