mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-16 12:39:39 +02:00
Projects included: - maerchenzauber (NestJS backend + Expo mobile + SvelteKit web + Astro landing) - manacore (Expo mobile + SvelteKit web + Astro landing) - manadeck (NestJS backend + Expo mobile + SvelteKit web) - memoro (Expo mobile + SvelteKit web + Astro landing) This commit preserves the current state before monorepo restructuring. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
42 lines
No EOL
1.2 KiB
TypeScript
42 lines
No EOL
1.2 KiB
TypeScript
import { useState, useEffect } from 'react';
|
|
import { Dimensions, Platform } from 'react-native';
|
|
|
|
const BREAKPOINTS = {
|
|
mobile: 640,
|
|
tablet: 768,
|
|
desktop: 1024,
|
|
wide: 1440,
|
|
} as const;
|
|
|
|
export function useResponsive() {
|
|
const [dimensions, setDimensions] = useState(() => {
|
|
const { width, height } = Dimensions.get('window');
|
|
return { width, height };
|
|
});
|
|
|
|
useEffect(() => {
|
|
if (Platform.OS !== 'web') return;
|
|
|
|
const updateDimensions = () => {
|
|
const { width, height } = Dimensions.get('window');
|
|
setDimensions({ width, height });
|
|
};
|
|
|
|
const subscription = Dimensions.addEventListener('change', updateDimensions);
|
|
return () => subscription?.remove();
|
|
}, []);
|
|
|
|
const { width } = dimensions;
|
|
|
|
return {
|
|
width,
|
|
height: dimensions.height,
|
|
isMobile: width < BREAKPOINTS.tablet,
|
|
isTablet: width >= BREAKPOINTS.tablet && width < BREAKPOINTS.desktop,
|
|
isDesktop: width >= BREAKPOINTS.desktop,
|
|
isWide: width >= BREAKPOINTS.wide,
|
|
breakpoint: width < BREAKPOINTS.tablet ? 'mobile' :
|
|
width < BREAKPOINTS.desktop ? 'tablet' :
|
|
width < BREAKPOINTS.wide ? 'desktop' : 'wide'
|
|
};
|
|
} |