feat(createResponsiveManager): rewrote ifs to switch case

This commit is contained in:
Ilia Mashkov
2026-02-27 18:35:40 +03:00
parent 3a813b019b
commit 80feda41a3

View File

@@ -146,12 +146,20 @@ export function createResponsiveManager(customBreakpoints?: Partial<Breakpoints>
*/
const currentBreakpoint = $derived<keyof Breakpoints | 'xs'>(
(() => {
if (isMobile) return 'mobile';
if (isTabletPortrait) return 'tabletPortrait';
if (isTablet) return 'tablet';
if (isDesktop) return 'desktop';
if (isDesktopLarge) return 'desktopLarge';
return 'xs'; // Fallback for very small screens
switch (true) {
case isMobile:
return 'mobile';
case isTabletPortrait:
return 'tabletPortrait';
case isTablet:
return 'tablet';
case isDesktop:
return 'desktop';
case isDesktopLarge:
return 'desktopLarge';
default:
return 'xs'; // Fallback for very small screens
}
})(),
);