Skip to content

Commit 86ff016

Browse files
ervwalterclaude
andcommitted
📱 feat: improve switch component layout for mobile devices
- Fix switch layout in advanced settings to prevent text wrapping issues - Add flex-shrink-0 to prevent switch compression on small screens - Improve switch thumb visibility with stronger shadow - Add pointer-events-none to thumb to fix iOS touch issues - Use focus-visible instead of focus for better keyboard navigation - Separate switch and label elements for better click targets 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent c98665e commit 86ff016

2 files changed

Lines changed: 9 additions & 7 deletions

File tree

‎apps/web/src/components/settings/AdvancedSection.tsx‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,15 @@ export function AdvancedSection({ control }: AdvancedSectionProps) {
6262
name="showCalories"
6363
control={control}
6464
render={({ field }) => (
65-
<label className="flex items-start space-x-3 cursor-pointer">
66-
<Switch checked={field.value ?? false} onCheckedChange={field.onChange} />
67-
<div>
65+
<div className="flex items-start space-x-3">
66+
<div className="flex-shrink-0">
67+
<Switch checked={field.value ?? false} onCheckedChange={field.onChange} />
68+
</div>
69+
<label htmlFor={field.name} className="cursor-pointer">
6870
<div className="text-sm font-medium text-gray-700">Show calorie calculations</div>
6971
<p className="text-sm text-gray-600 mt-1">Display estimated calorie surplus/deficit based on your weight changes</p>
70-
</div>
71-
</label>
72+
</label>
73+
</div>
7274
)}
7375
/>
7476
</div>

‎apps/web/src/components/ui/Switch.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ export const Switch = forwardRef<HTMLButtonElement, SwitchProps>(({ checked, onC
1616
onCheckedChange={onCheckedChange}
1717
name={name}
1818
disabled={disabled}
19-
className="relative inline-flex h-6 w-11 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-blue-600 data-[state=unchecked]:bg-gray-200"
19+
className="relative inline-flex h-6 w-11 flex-shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-blue-600 data-[state=unchecked]:bg-gray-200"
2020
>
21-
<SwitchPrimitive.Thumb className="inline-block h-5 w-5 transform rounded-full bg-white shadow-sm transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0.5" />
21+
<SwitchPrimitive.Thumb className="pointer-events-none inline-block h-5 w-5 transform rounded-full bg-white shadow-lg ring-0 transition duration-200 ease-in-out data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0" />
2222
</SwitchPrimitive.Root>
2323
);
2424
});

0 commit comments

Comments
 (0)