Files
eranos/src/hooks/useEnvelopeDimensions.ts
T
Chad Curtis 0c29506402 Fix all 50 ESLint warnings by extracting non-component exports and adding missing deps
- Extract utility functions from component files into dedicated modules
  to fix react-refresh/only-export-components warnings:
  - parseBadgeDefinition -> src/lib/parseBadgeDefinition.ts
  - parseProfileBadges -> src/lib/parseProfileBadges.ts
  - getColors, paletteToTheme -> src/lib/colorMomentUtils.ts
  - parseDimToAspectRatio, eventToMediaItem -> src/lib/mediaUtils.ts
  - isAudioUrl, isImageUrl, isVideoUrl -> src/lib/mediaTypeDetection.ts
  - buildKindOptions, parseSelectedKinds -> src/lib/feedFilterUtils.ts
  - useVideoThumbnail -> src/hooks/useVideoThumbnail.ts
  - useEnvelopeDimensions -> src/hooks/useEnvelopeDimensions.ts
  - usePortalContainer -> src/hooks/usePortalContainer.ts
  - useAudioPlayer -> src/contexts/audioPlayerContextDef.ts
  - SubHeaderBar context/hooks -> src/components/SubHeaderBarContext.ts
  - EmotionDev hooks -> src/blobbi/dev/useEmotionDev.ts
  - BlobbiActions context def -> BlobbiActionsContextDef.ts

- Remove export from internal-only functions (useEventComments,
  parseEmojiPack, useScrollCarets, formatEffectSummary, getSortedEffectEntries)

- Fix react-hooks/exhaustive-deps warnings by adding missing dependencies
  to useEffect/useCallback/useMemo hooks across 14 files

- Fix logical expression dependency warnings by wrapping conditional
  values (tasks, pubkeys, authorPubkeys) in useMemo

- Move module-level constants (CORE_TAB_IDS, CORE_TAB_LABELS,
  DEFAULT_TAB_LABELS) out of ProfilePage component body

- Reorder usePushNotifications hooks so syncPreferences is defined
  before enable to fix block-scoped variable error
2026-04-05 11:57:31 -05:00

31 lines
995 B
TypeScript

import { useState, useEffect } from 'react';
function calcDims(vw: number) {
const envW = Math.min(Math.round(vw * 0.85), 420);
const envH = Math.round(envW / 1.588);
const r = Math.round(envW * 0.041);
const s = envW / 54;
const flapY = Math.round(envH * 0.147);
const vY = Math.round(envH * 0.647);
const flapTriH = Math.round(vY * 1.08);
const letterW = Math.round(envW * 0.82);
const letterH = letterW / (5 / 4);
const strokeV = Math.round(s * 1.6 * 10) / 10;
const strokeCorner = Math.round(s * 1.4 * 10) / 10;
return { envW, envH, r, flapY, vY, flapTriH, letterW, letterH, strokeV, strokeCorner };
}
export function useEnvelopeDimensions() {
const [dims, setDims] = useState(() => calcDims(window.innerWidth));
useEffect(() => {
const onResize = () => setDims(calcDims(window.innerWidth));
window.addEventListener('resize', onResize);
return () => window.removeEventListener('resize', onResize);
}, []);
return dims;
}