-
-
Notifications
You must be signed in to change notification settings - Fork 235
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
611d455
commit 180f4d9
Showing
7 changed files
with
545 additions
and
43 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
components/atoms/FullHeightContainer/full-height-container.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/** | ||
* A react component that will ensure that its min-height is the same as the screen height. | ||
* This is not possible with pure css because some mobile browsers don't account for the top and bottom bars | ||
* when calculating `vh`. | ||
* see https://dev.to/nirazanbasnet/dont-use-100vh-for-mobile-responsive-3o97 | ||
*/ | ||
|
||
import clsx from "clsx"; | ||
import React, { useEffect, useState } from "react"; | ||
import { useWindowSize } from "react-use"; | ||
|
||
interface Props extends React.HTMLAttributes<HTMLDivElement> { | ||
} | ||
|
||
export default function FullHeightContainer(props: Props) { | ||
const { children, className, ...rest } = props; | ||
const { height: innerHeight } = useWindowSize(); | ||
const [minHeight, setMinHeight] = useState<string>("100vh"); | ||
|
||
useEffect(() => { | ||
setMinHeight(`${innerHeight}px`); | ||
}, [innerHeight]); | ||
|
||
return ( | ||
<div | ||
className={clsx("grid min-h-screen max-h-screen", className)} | ||
style={{ minHeight: minHeight }} | ||
{...rest} | ||
> | ||
{children} | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.