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'>( const currentBreakpoint = $derived<keyof Breakpoints | 'xs'>(
(() => { (() => {
if (isMobile) return 'mobile'; switch (true) {
if (isTabletPortrait) return 'tabletPortrait'; case isMobile:
if (isTablet) return 'tablet'; return 'mobile';
if (isDesktop) return 'desktop'; case isTabletPortrait:
if (isDesktopLarge) return 'desktopLarge'; return 'tabletPortrait';
return 'xs'; // Fallback for very small screens case isTablet:
return 'tablet';
case isDesktop:
return 'desktop';
case isDesktopLarge:
return 'desktopLarge';
default:
return 'xs'; // Fallback for very small screens
}
})(), })(),
); );