Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | 1x 3x 3x | // src/components/UnitSystemToggle.tsx
import React from 'react';
interface UnitSystemToggleProps {
currentSystem: 'metric' | 'imperial';
onToggle: () => void;
}
export const UnitSystemToggle: React.FC<UnitSystemToggleProps> = ({ currentSystem, onToggle }) => {
const isImperial = currentSystem === 'imperial';
return (
<div className="flex items-center space-x-2">
<span
className={`text-sm font-medium ${isImperial ? 'text-gray-400 dark:text-gray-500' : 'text-gray-700 dark:text-gray-200'}`}
>
Metric
</span>
<label
htmlFor="unit-system-toggle"
className="relative inline-flex items-center cursor-pointer"
>
<input
type="checkbox"
id="unit-system-toggle"
className="sr-only peer"
checked={isImperial}
onChange={onToggle}
/>
<div className="w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-2 peer-focus:ring-brand-primary/50 dark:peer-focus:ring-brand-secondary rounded-full peer dark:bg-gray-700 peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-0.5] after:left-0.52px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all dark:border-gray-600 peer-checked:bg-brand-primary"></div>
</label>
<span
className={`text-sm font-medium ${isImperial ? 'text-gray-700 dark:text-gray-200' : 'text-gray-400 dark:text-gray-500'}`}
>
Imperial
</span>
</div>
);
};
|