Skip to content

Commit

Permalink
Merge pull request #243 from hasan-deriv/hasan/landscape-mode-in-useD…
Browse files Browse the repository at this point in the history
…evice

landscape mode to useDevice hook
  • Loading branch information
shayan-deriv authored Aug 29, 2024
2 parents fbf33b9 + b47da93 commit 7962d82
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/components/PageLayout/__test__/PageLayout.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ describe("PageLayout Component", () => {
isDesktop: false,
isTablet: false,
isTabletPortrait: false,
isMobileOrTabletLandscape: false
}));
const sidebar = <div>Sidebar</div>;
render(<PageLayout sidebar={sidebar} />);
Expand Down
5 changes: 5 additions & 0 deletions src/hooks/useDevice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ export const useDevice = () => {
const isTabletPortrait = useMediaQuery(
`(min-width: 601px) and (max-width: 1279px) and (orientation: portrait)`,
);
const isMobileOrTabletLandscape = useMediaQuery(
`(max-width: 1279px) and (orientation: landscape)`,
);
return {
/** returns Larger screen tablets [min-width: 1280px] */
isDesktop,
Expand All @@ -19,5 +22,7 @@ export const useDevice = () => {
isTablet,
/** returns tablet screen with portrait orientation [min-width: 601px and max-width: 1279px and orientation: portrait] */
isTabletPortrait,
/** returns mobile or medium screens in landscape orientation [max-width: 1279px and orientation: landscape] */
isMobileOrTabletLandscape
};
};
7 changes: 7 additions & 0 deletions src/styles/abstracts/_devices.scss
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@
}
}

@mixin mobile-or-tablet-landscape {
@media only screen and (max-width: #{$desktop-width - 1}) and (orientation: landscape) {
@content;
}
}


@mixin touch-device {
// add css interaction media query to detect touch devices
// refer to: https://caniuse.com/#feat=css-media-interaction
Expand Down

0 comments on commit 7962d82

Please sign in to comment.