Skip to content
This repository has been archived by the owner on Apr 14, 2024. It is now read-only.

Commit

Permalink
fix: исправление для мобильных устройств высоты
Browse files Browse the repository at this point in the history
  • Loading branch information
ko22009 committed Nov 10, 2023
1 parent 4160728 commit 7bf3180
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
11 changes: 9 additions & 2 deletions src/app/providers/layout/Layout.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Box, ChakraProvider, Container, Flex, Stack } from '@chakra-ui/react';
import { useRef } from 'react';
import { useEffect, useRef } from 'react';
import { ScrollRestoration, useLocation } from 'react-router-dom';

import { MenuBase, MenuDesktop } from '~/widgets/menu';

import { desktopTheme, mobileTheme } from '~/shared/config';
import { LayoutContext } from '~/shared/contexts';
import { useIsMobile } from '~/shared/hooks';
import { useIsMobile, useWindowSizes } from '~/shared/hooks';
import { PATHS } from '~/shared/lib/router';

import { AuthProvider } from './AuthProvider';
Expand All @@ -15,12 +15,19 @@ import { Routes } from './Routes';
export const Layout = () => {
const isMobile = useIsMobile();
const location = useLocation();
const sizes = useWindowSizes();
const footerRef = useRef<HTMLDivElement>(null);
const headerRef = useRef<HTMLDivElement>(null);

const isNotFoundPage = location.pathname === PATHS.notFound;
const isDialogPage = new RegExp(`${PATHS.chats}/\\d+`).test(location.pathname);

useEffect(() => {
if (!isMobile) return;
const vh = window.innerHeight * 0.01;
document.documentElement.style.setProperty('--vh', `${vh}px`);
}, [isMobile, sizes.height]);

return (
<>
<LayoutContext.Provider value={{ header: headerRef, footer: footerRef }}>
Expand Down
13 changes: 12 additions & 1 deletion src/shared/config/theme/mobileTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,15 @@ import { extendTheme } from '@chakra-ui/react';

import { basicTheme } from './theme';

export const mobileTheme = extendTheme(basicTheme);
export const mobileTheme = extendTheme(basicTheme, {
styles: {
global: {
html: {
minHeight: 'calc(100vh - 56px)',
'@supports (--css: variables)': {
minHeight: 'calc(var(--vh, 1vh) * 100)',
},
},
},
},
});
1 change: 1 addition & 0 deletions src/shared/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ export * from './useLayoutRefs';
export * from './useHorizontalScroll';
export * from './useApi';
export * from './useAuth';
export * from './useWindowSizes';

0 comments on commit 7bf3180

Please sign in to comment.