Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat: optional full screen overlay w/ a fullscreen prop #610

Merged
merged 2 commits into from
Apr 21, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Components/Overlay/Documentation/Overlay.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ overlayStories.add(
)}
>
<OverlayContainer
fullScreen={boolean('fullScreen', false)}
maxWidth={400}
margin={
ComponentSize[
Expand Down Expand Up @@ -122,6 +123,7 @@ overlayStories.add(
<button onClick={logRef}>Log Ref</button>
</div>
<OverlayContainer
fullScreen={boolean('fullScreen', false)}
maxWidth={number('maxWidth', 800)}
ref={overlayContainerRef}
>
Expand Down
9 changes: 9 additions & 0 deletions src/Components/Overlay/Overlay.scss
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@
&__lg {
margin: $cf-page--gutter-lg;
}

&__full {
width: 100vw;
height: 100vh;
position: fixed;
top: 0;
left: 0;
margin: 0;
}
}

.cf-overlay--header {
Expand Down
8 changes: 6 additions & 2 deletions src/Components/Overlay/OverlayContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export interface OverlayContainerProps extends StandardFunctionProps {
maxWidth?: number
/** Margins on all sides of overlay */
margin?: ComponentSize
fullScreen?: boolean
}

export type OverlayContainerRef = HTMLDivElement
Expand All @@ -27,16 +28,19 @@ export const OverlayContainer = forwardRef<
children,
maxWidth = 800,
className,
fullScreen,
},
ref
) => {
const overlayContainerClass = classnames('cf-overlay--container', {
[`cf-overlay--container__${margin}`]: margin,
['cf-overlay--container__full']: fullScreen,
[`${className}`]: className,
})

const overlayContainerStyle = {maxWidth: `${maxWidth}px`, ...style}

const overlayContainerStyle = fullScreen
? {...style}
: {maxWidth: `${maxWidth}px`, ...style}
return (
<div
id={id}
Expand Down