feat: replace category grid with select dropdown in units converter
- Consolidate category selection into the main converter card - Use a space-saving Select component for category switching - Add category color indicator to the select dropdown
This commit is contained in:
@@ -5,6 +5,7 @@ import { Copy, Star, Check, ArrowLeftRight, BarChart3 } from 'lucide-react';
|
||||
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/Card';
|
||||
import { Input } from '@/components/ui/Input';
|
||||
import { Button } from '@/components/ui/Button';
|
||||
import { Select } from '@/components/ui/Select';
|
||||
import SearchUnits from './SearchUnits';
|
||||
import VisualComparison from './VisualComparison';
|
||||
import CommandPalette from '@/components/units/ui/CommandPalette';
|
||||
@@ -122,42 +123,28 @@ export default function MainConverter() {
|
||||
<SearchUnits onSelectUnit={handleSearchSelect} />
|
||||
</div>
|
||||
|
||||
{/* Category Selection */}
|
||||
{/* Main Converter Card */}
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle>Select Category</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="grid grid-cols-2 md:grid-cols-4 lg:grid-cols-6 gap-2">
|
||||
{measures.map((measure) => (
|
||||
<Button
|
||||
key={measure}
|
||||
variant={selectedMeasure === measure ? 'default' : 'outline'}
|
||||
size="sm"
|
||||
onClick={() => setSelectedMeasure(measure)}
|
||||
className="justify-start"
|
||||
<div className="flex items-center justify-between">
|
||||
<CardTitle>Convert {formatMeasureName(selectedMeasure)}</CardTitle>
|
||||
<div className="w-48">
|
||||
<Select
|
||||
value={selectedMeasure}
|
||||
onChange={(e) => setSelectedMeasure(e.target.value as Measure)}
|
||||
className="h-9 text-xs"
|
||||
style={{
|
||||
backgroundColor:
|
||||
selectedMeasure === measure
|
||||
? getCategoryColorHex(measure)
|
||||
: undefined,
|
||||
borderColor: selectedMeasure !== measure
|
||||
? getCategoryColorHex(measure)
|
||||
: undefined,
|
||||
color: selectedMeasure === measure ? 'white' : undefined,
|
||||
borderLeft: `4px solid ${getCategoryColorHex(selectedMeasure)}`,
|
||||
}}
|
||||
>
|
||||
{formatMeasureName(measure)}
|
||||
</Button>
|
||||
))}
|
||||
{measures.map((measure) => (
|
||||
<option key={measure} value={measure}>
|
||||
{formatMeasureName(measure)}
|
||||
</option>
|
||||
))}
|
||||
</Select>
|
||||
</div>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* Input Section */}
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle>Convert {formatMeasureName(selectedMeasure)}</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-4">
|
||||
<div className="flex gap-2 items-end">
|
||||
|
||||
Reference in New Issue
Block a user