-
Notifications
You must be signed in to change notification settings - Fork 18
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
Showing
5 changed files
with
73 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import Swal from 'sweetalert2' | ||
import './styles.css' | ||
|
||
Swal.fire({ | ||
title: 'Modal with iframe', | ||
html: '<iframe frameborder="0" src="https://www.youtube.com/embed/6JxAis_v2mw"></iframe>', | ||
showCloseButton: true, | ||
showConfirmButton: false, | ||
customClass: { | ||
popup: 'swal-with-iframe', | ||
}, | ||
width: 1000, | ||
}) |
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,15 @@ | ||
.swal-with-iframe { | ||
padding-bottom: 0; | ||
} | ||
|
||
.swal-with-iframe .swal2-html-container { | ||
padding-right: 0; | ||
padding-bottom: 0; | ||
padding-left: 0; | ||
} | ||
|
||
.swal-with-iframe iframe { | ||
aspect-ratio: 16 / 9; | ||
width: 100%; | ||
float: left; | ||
} |
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,8 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<load ="partials/head.html" title="Modal with iframe inside" /> | ||
<body> | ||
<div id="root"></div> | ||
<script type="module" src="./modal-with-iframe.tsx"></script> | ||
</body> | ||
</html> |
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,34 @@ | ||
import ReactDOM from 'react-dom/client' | ||
import { Nav } from '../src/components' | ||
import { Sandpack } from './components/Sandpack' | ||
|
||
const styles = (await import(`./modal-with-iframe-styles.css?raw`)).default | ||
const src = (await import('./modal-with-iframe-src?raw')).default | ||
|
||
function Recipe() { | ||
return ( | ||
<> | ||
<Nav recipeGallery /> | ||
<h1>Modal with <strong>iframe</strong> inside</h1> | ||
|
||
<p> | ||
The important detail here is to keep the aspect ratio of the iframe. This is done by using CSS property <strong>aspect-ratio: 16 / 9;</strong> | ||
</p> | ||
|
||
<p> | ||
The rest of CSS styles are to remove the default paddings and make iframe take all the space available. | ||
</p> | ||
|
||
<Sandpack | ||
files={{ | ||
'/App.ts': src, | ||
'/styles.css': styles, | ||
}} | ||
editorHeight={350} | ||
previewHeight={600} | ||
/> | ||
</> | ||
) | ||
} | ||
|
||
ReactDOM.createRoot(document.getElementById('root')!).render(<Recipe />) |