Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Docs update: Add handling of url err for iframe #1509

Merged
merged 10 commits into from
Feb 6, 2023
30 changes: 22 additions & 8 deletions docs/src/lib/components/ThemeCustomizer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
let wallets$

const themes = ['system', 'default', 'light', 'dark', 'custom']
let selectedTheme = 'custom'
let selectedTheme = 'system'

let webURL = ''
let iframeUsed = false
Expand All @@ -30,13 +30,23 @@

const addURLToIFrame = () => {
if (!webURL || !isValidUrl(webURL)) {
alert('Invaled URL entered')
alert('Invalid URL entered')
return
}
iframeUsed = true
document.querySelector('#iframe_underlay').setAttribute('src', webURL)
hideDirections = true
onboard.connectWallet()

fetch(webURL)
.then(() => {
iframeUsed = true
document.querySelector('#iframe_underlay').setAttribute('src', webURL)
hideDirections = true
!onboard && getOnboard()
onboard.connectWallet()
})
.catch(() => {
alert(
'The website entered cannot be displayed within an iframe. Please try a different URL. See the browser console for more information.'
)
})
}

const resetPage = () => {
Expand All @@ -47,6 +57,10 @@
uploaded_image = undefined
webURL = ''
resetTheme()
closeOnboard()
}

const closeOnboard = () => {
const onboardCloseBtnVisible = document
?.querySelector('body > onboard-v2')
?.shadowRoot?.querySelector('.close-button')
Expand Down Expand Up @@ -266,9 +280,9 @@
placeholder="Enter your Website URL"
bind:value={webURL}
/>
<button on:click={addURLToIFrame}>Preview On Your Website</button>
<button type="submit">Preview On Your Website</button>
<button
on:click={resetPage}
on:click={() => resetPage()}
type="button"
disabled={iframeUsed || !!uploaded_image ? false : true}>Reset</button
>
Expand Down