-
Notifications
You must be signed in to change notification settings - Fork 80
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
2723858
commit 7c3ca82
Showing
6 changed files
with
92 additions
and
65 deletions.
There are no files selected for viewing
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
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
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
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,13 @@ | ||
.modal-iframe { | ||
position: fixed; | ||
top: 0; | ||
left: 0; | ||
width: 100%; | ||
height: 100%; | ||
z-index: $zindex-modal; | ||
|
||
iframe { | ||
width: inherit; | ||
height: inherit; | ||
} | ||
} |
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,44 @@ | ||
import { forwardRef, ForwardedRef, IframeHTMLAttributes } from 'react'; | ||
import classNames from 'classnames'; | ||
|
||
interface ModalIframeProps extends IframeHTMLAttributes<HTMLIFrameElement> { | ||
title: string; | ||
className?: string; | ||
} | ||
|
||
const SANDBOX_OPTIONS = [ | ||
'allow-forms', | ||
'allow-modals', | ||
'allow-popups', | ||
'allow-popups-to-escape-sandbox', | ||
'allow-presentation', | ||
'allow-same-origin', | ||
'allow-scripts', | ||
'allow-top-navigation-by-user-activation', | ||
].join(' '); | ||
|
||
export const IFRAME_FEATURE_POLICY = ( | ||
'microphone *; camera *; midi *; geolocation *; encrypted-media *, clipboard-write *' | ||
); | ||
|
||
const ModalIframe = forwardRef<HTMLIFrameElement, ModalIframeProps>( | ||
({ title, className, ...props }, ref: ForwardedRef<HTMLIFrameElement>) => ( | ||
<iframe | ||
title={title} | ||
className={classNames('modal-iframe', className)} | ||
allow={IFRAME_FEATURE_POLICY} | ||
referrerPolicy="origin" | ||
frameBorder="0" | ||
scrolling="no" | ||
ref={ref} | ||
sandbox={SANDBOX_OPTIONS} | ||
{...props} | ||
/> | ||
), | ||
); | ||
|
||
ModalIframe.defaultProps = { | ||
className: 'modal-iframe', | ||
}; | ||
|
||
export default ModalIframe; |
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