-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add option to render iframe inline via containerId
- Loading branch information
Showing
9 changed files
with
89 additions
and
78 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
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 |
---|---|---|
@@ -1,15 +1,15 @@ | ||
import { generateURL } from 'Utils/generate-url'; | ||
import { TransakConfig } from 'Types/sdk-config.types'; | ||
|
||
export function renderIframe(container: HTMLElement, config: TransakConfig) { | ||
const url = generateURL(config); | ||
export function createIframe(config: TransakConfig) { | ||
const src = generateURL(config); | ||
const iframe = document.createElement('iframe'); | ||
|
||
Object.assign(iframe, { | ||
id: 'transakIframe', | ||
allow: 'camera;microphone;payment', | ||
src: url, | ||
src, | ||
}); | ||
|
||
return container.appendChild(iframe); | ||
return iframe; | ||
} |
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,31 @@ | ||
import { closeIcon } from 'Assets/svg/close-icon'; | ||
import { createIframe } from 'Utils/create-iframe'; | ||
import { renderInModalStyles } from 'Utils/render-in-modal.styles'; | ||
import { TransakConfig } from 'Types/sdk-config.types'; | ||
|
||
export function renderInModal(config: TransakConfig, closeRequest: () => void) { | ||
const styleElement = renderInModalStyles(config); | ||
const rootElement = document.createElement('div'); | ||
const modal = document.createElement('div'); | ||
const iframeElement = createIframe(config); | ||
|
||
Object.assign(modal, { | ||
id: 'transakModal', | ||
innerHTML: closeIcon, | ||
}); | ||
|
||
modal.appendChild(iframeElement); | ||
|
||
Object.assign(rootElement, { | ||
id: 'transakRoot', | ||
onclick: () => closeRequest(), | ||
}); | ||
|
||
rootElement.appendChild(modal); | ||
|
||
document.getElementsByTagName('body')[0].appendChild(rootElement); | ||
|
||
document.getElementById('transakCloseIcon')?.addEventListener('click', () => closeRequest()); | ||
|
||
return { styleElement, rootElement, iframeElement }; | ||
} |
This file was deleted.
Oops, something went wrong.
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