fix: Mobile media query not working correctly
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import styled from "styled-components";
|
import styled from "styled-components";
|
||||||
|
import useMediaQuery from "~/hooks/useMediaQuery";
|
||||||
import useMobile from "~/hooks/useMobile";
|
import useMobile from "~/hooks/useMobile";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
@@ -15,7 +16,13 @@ const MobileWrapper = styled.div`
|
|||||||
|
|
||||||
const MobileScrollWrapper = ({ children }: Props) => {
|
const MobileScrollWrapper = ({ children }: Props) => {
|
||||||
const isMobile = useMobile();
|
const isMobile = useMobile();
|
||||||
return isMobile ? <MobileWrapper>{children}</MobileWrapper> : <>{children}</>;
|
const isPrinting = useMediaQuery("print");
|
||||||
|
|
||||||
|
return isMobile && !isPrinting ? (
|
||||||
|
<MobileWrapper>{children}</MobileWrapper>
|
||||||
|
) : (
|
||||||
|
<>{children}</>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default MobileScrollWrapper;
|
export default MobileScrollWrapper;
|
||||||
|
|||||||
@@ -2,7 +2,5 @@ import { breakpoints } from "@shared/styles";
|
|||||||
import useMediaQuery from "~/hooks/useMediaQuery";
|
import useMediaQuery from "~/hooks/useMediaQuery";
|
||||||
|
|
||||||
export default function useMobile(): boolean {
|
export default function useMobile(): boolean {
|
||||||
return useMediaQuery(
|
return useMediaQuery(`(max-width: ${breakpoints.tablet - 1}px)`);
|
||||||
`(max-width: ${breakpoints.tablet - 1}px) and (not print)`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user