|
4 | 4 |
|
5 | 5 | import { share } from 'rxjs/operators' |
6 | 6 | import { onMount } from 'svelte' |
| 7 | +import { object_without_properties } from 'svelte/internal'; |
7 | 8 |
|
8 | 9 | const INFURA_ID = 'e0b15c21b7d54cd4814586334af72618' |
9 | 10 | const injected = injectedModule() |
|
72 | 73 | document.querySelector('#image_drop_area').style.backgroundImage = '' |
73 | 74 | uploaded_image = undefined |
74 | 75 | webURL = '' |
| 76 | + resetTheme() |
| 77 | + const onboardCloseBtnVisible = |
| 78 | + document?.querySelector('body > onboard-v2')?.shadowRoot?.querySelector('.close-button') |
| 79 | + if (onboardCloseBtnVisible) onboardCloseBtnVisible?.click() |
75 | 80 | } |
76 | 81 |
|
77 | 82 | const handleConnectWalletBtn = () => { |
78 | 83 | !!$wallets$ && $wallets$.length |
79 | | - ? onboard.disconnectWallet({label: $wallets$[0].label}) |
| 84 | + ? onboard.disconnectWallet({ label: $wallets$[0].label }) |
80 | 85 | : onboard.connectWallet() |
81 | 86 | } |
82 | 87 |
|
83 | | - const defaultStyling = { |
| 88 | + const baseStyles = { |
84 | 89 | '--background-color': '#ffffff', |
85 | 90 | '--text-color': '#1a1d26', |
86 | 91 | '--border-color': '#ebebed', |
|
90 | 95 | '--secondary-text-color': '#707481' |
91 | 96 | } |
92 | 97 |
|
| 98 | + let defaultStyling = {...baseStyles} |
| 99 | +
|
93 | 100 | const baseStyling = `--onboard-connect-sidebar-background: var(--accent-background); |
94 | 101 | --onboard-close-button-background: var(--accent-background); |
95 | 102 | --onboard-connect-sidebar-color: var(--text-color); |
|
119 | 126 |
|
120 | 127 | let copyableStyles = `:root {\n ${styleToString(defaultStyling)}${baseStyling}\n}` |
121 | 128 |
|
122 | | - const updateThemes = (e, targetStyle) => { |
| 129 | + const updateTheme = (e, targetStyle) => { |
123 | 130 | document.documentElement.style.setProperty(targetStyle, e.target.value) |
124 | 131 |
|
125 | 132 | copyableStyles = `:root {\n ${styleToString(defaultStyling)}${baseStyling}\n}` |
126 | 133 | } |
127 | 134 |
|
| 135 | + const resetTheme = () => { |
| 136 | + defaultStyling = {...baseStyles} |
| 137 | + Object.keys(defaultStyling).forEach(style => { |
| 138 | + document.documentElement.style.setProperty(style, defaultStyling[style]) |
| 139 | + }) |
| 140 | + } |
| 141 | +
|
128 | 142 | let checked = false |
129 | 143 |
|
130 | 144 | const handleBackdrop = () => { |
|
184 | 198 | type="color" |
185 | 199 | name="Theme" |
186 | 200 | bind:value={defaultStyling[target]} |
187 | | - on:input={(e) => updateThemes(e, target)} |
| 201 | + on:input={(e) => updateTheme(e, target)} |
188 | 202 | /> |
189 | 203 | </div> |
190 | 204 | <span class="text" id="current-theme">{target} : {defaultStyling[target]}</span> |
|
206 | 220 | </div> |
207 | 221 | <div class="image-drop-container"> |
208 | 222 | <div id="image_drop_area"> |
209 | | - <div class="drop-area-controls"> |
| 223 | + <form class="drop-area-controls" on:submit|preventDefault={addURLToIFrame}> |
210 | 224 | <div> |
211 | 225 | Enter your website url or drag and drop a screenshot to preview web3-onboard on your site |
212 | 226 | </div> |
|
228 | 242 | >{!!$wallets$ && $wallets$.length ? 'Disconnect Wallet' : 'Connect Wallet'}</button |
229 | 243 | > |
230 | 244 | </div> |
231 | | - </div> |
| 245 | + </form> |
232 | 246 | <iframe |
233 | 247 | id="iframe_underlay" |
234 | 248 | title="iframe area for testing W3O with your app" |
|
0 commit comments