|
18 | 18 | rpcUrl: `https://mainnet.infura.io/v3/${INFURA_ID}`
|
19 | 19 | },
|
20 | 20 | {
|
21 |
| - id: '0x3', |
22 |
| - token: 'tROP', |
23 |
| - label: 'Ethereum Ropsten Testnet', |
24 |
| - rpcUrl: `https://ropsten.infura.io/v3/${INFURA_ID}` |
| 21 | + id: '0x5', |
| 22 | + token: 'ETH', |
| 23 | + label: 'Ethereum Goerli Testnet', |
| 24 | + rpcUrl: `https://goerli.infura.io/v3/${INFURA_ID}` |
| 25 | + }, |
| 26 | + { |
| 27 | + id: '0x13881', |
| 28 | + token: 'MATIC', |
| 29 | + label: 'Polygon - Mumbai', |
| 30 | + rpcUrl: 'https://matic-mumbai.chainstacklabs.com ' |
| 31 | + }, |
| 32 | + { |
| 33 | + id: '0x38', |
| 34 | + token: 'BNB', |
| 35 | + label: 'Binance', |
| 36 | + rpcUrl: 'https://bsc-dataseed.binance.org/' |
| 37 | + }, |
| 38 | + { |
| 39 | + id: 137, |
| 40 | + token: 'MATIC', |
| 41 | + label: 'Polygon', |
| 42 | + rpcUrl: 'https://matic-mainnet.chainstacklabs.com' |
| 43 | + }, |
| 44 | + { |
| 45 | + id: 10, |
| 46 | + token: 'OETH', |
| 47 | + label: 'Optimism', |
| 48 | + rpcUrl: 'https://mainnet.optimism.io' |
| 49 | + }, |
| 50 | + { |
| 51 | + id: 42161, |
| 52 | + token: 'ARB-ETH', |
| 53 | + label: 'Arbitrum', |
| 54 | + rpcUrl: 'https://rpc.ankr.com/arbitrum' |
25 | 55 | }
|
26 | 56 | ],
|
27 | 57 | appMetadata: {
|
28 | 58 | name: 'Documentation',
|
29 |
| - icon: '<svg></svg>', |
30 | 59 | description: 'Example showcasing how to connect a wallet.',
|
31 | 60 | recommendedInjectedWallets: [
|
32 | 61 | { name: 'MetaMask', url: 'https://metamask.io' },
|
33 | 62 | { name: 'Coinbase', url: 'https://wallet.coinbase.com/' }
|
34 | 63 | ]
|
35 | 64 | },
|
36 | 65 | accountCenter: {
|
37 |
| - desktop: { enabled: false }, |
38 |
| - mobile: { enabled: false } |
39 |
| - } |
| 66 | + desktop: { enabled: true }, |
| 67 | + mobile: { enabled: true } |
| 68 | + }, |
| 69 | + theme: 'system' |
40 | 70 | })
|
41 | 71 |
|
| 72 | + const themes = ['system', 'default', 'light', 'dark', 'custom'] |
| 73 | + let selectedTheme = 'system' |
| 74 | +
|
42 | 75 | // Subscribe to wallet updates
|
43 | 76 | const wallets$ = onboard.state.select('wallets').pipe(share())
|
44 | 77 |
|
|
73 | 106 | uploaded_image = undefined
|
74 | 107 | webURL = ''
|
75 | 108 | resetTheme()
|
76 |
| - const onboardCloseBtnVisible = |
77 |
| - document?.querySelector('body > onboard-v2')?.shadowRoot?.querySelector('.close-button') |
| 109 | + const onboardCloseBtnVisible = document |
| 110 | + ?.querySelector('body > onboard-v2') |
| 111 | + ?.shadowRoot?.querySelector('.close-button') |
78 | 112 | if (onboardCloseBtnVisible) onboardCloseBtnVisible?.click()
|
79 | 113 | }
|
80 | 114 |
|
|
84 | 118 | : onboard.connectWallet()
|
85 | 119 | }
|
86 | 120 |
|
87 |
| - const baseStyles = { |
88 |
| - '--background-color': '#ffffff', |
89 |
| - '--text-color': '#1a1d26', |
90 |
| - '--border-color': '#ebebed', |
91 |
| - '--accent-background': '#ebebed', |
92 |
| - '--accent-color': '#929bed', |
93 |
| - '--accent-color-hover': '#eff1fc', |
94 |
| - '--secondary-text-color': '#707481' |
95 |
| - } |
96 |
| -
|
97 |
| - let defaultStyling = {...baseStyles} |
98 |
| -
|
99 |
| - const baseStyling = `--onboard-connect-sidebar-background: var(--accent-background); |
100 |
| - --onboard-close-button-background: var(--accent-background); |
101 |
| - --onboard-connect-sidebar-color: var(--text-color); |
102 |
| - --onboard-connect-sidebar-progress-background: var(--secondary-text-color); |
103 |
| - --onboard-connect-sidebar-progress-color: var(--accent-color); |
104 |
| - --onboard-connect-header-background: var(--background-color); |
105 |
| - --onboard-connect-header-color: var(--text-color); |
106 |
| - --onboard-main-scroll-container-background: var(--background-color); |
107 |
| - --onboard-link-color: var(--accent-color); |
108 |
| - --onboard-wallet-button-background: var(--background-color); |
109 |
| - --onboard-wallet-button-background-hover: var(--accent-color-hover); |
110 |
| - --onboard-wallet-button-border-color: var(--border-color); |
111 |
| - --onboard-wallet-app-icon-border-color: var(--border-color);` |
| 121 | + const themingObjects = { |
| 122 | + default: { |
| 123 | + '--w3o-background-color': 'unset', |
| 124 | + '--w3o-foreground-color': 'unset', |
| 125 | + '--w3o-text-color': 'unset', |
| 126 | + '--w3o-border-color': 'unset', |
| 127 | + '--w3o-action-color': 'unset', |
| 128 | + '--w3o-border-radius': 'unset' |
| 129 | + }, |
| 130 | + custom: { |
| 131 | + '--w3o-background-color': 'unset', |
| 132 | + '--w3o-foreground-color': 'unset', |
| 133 | + '--w3o-text-color': 'unset', |
| 134 | + '--w3o-border-color': 'unset', |
| 135 | + '--w3o-action-color': 'unset', |
| 136 | + '--w3o-border-radius': 'unset' |
| 137 | + }, |
| 138 | + light: { |
| 139 | + '--w3o-background-color': '#ffffff', |
| 140 | + '--w3o-foreground-color': '#EFF1FC', |
| 141 | + '--w3o-text-color': '#1a1d26', |
| 142 | + '--w3o-border-color': '#d0d4f7', |
| 143 | + '--w3o-action-color': '#6370E5', |
| 144 | + '--w3o-border-radius': '16px' |
| 145 | + }, |
| 146 | + dark: { |
| 147 | + '--w3o-background-color': '#1A1D26', |
| 148 | + '--w3o-foreground-color': '#242835', |
| 149 | + '--w3o-text-color': '#EFF1FC', |
| 150 | + '--w3o-border-color': '#33394B', |
| 151 | + '--w3o-action-color': '#929bed', |
| 152 | + '--w3o-border-radius': '16px' |
| 153 | + } |
| 154 | + } |
112 | 155 |
|
113 | 156 | const styleToString = (style) => {
|
114 |
| - return Object.keys(style).reduce((acc, key) => acc + key + ': ' + style[key] + '; \n ', '') |
| 157 | + return Object.keys(style).reduce((acc, key) => acc + `"${key}": "${style[key]}", \n`, '') |
115 | 158 | }
|
116 | 159 |
|
117 | 160 | async function copyStylingConfig() {
|
|
123 | 166 | }
|
124 | 167 | }
|
125 | 168 |
|
126 |
| - let copyableStyles = `:root {\n ${styleToString(defaultStyling)}${baseStyling}\n}` |
| 169 | + let copyableStyles = |
| 170 | + selectedTheme !== 'custom' ? '' : `{\n ${styleToString(themingObjects[selectedTheme])}}` |
| 171 | +
|
| 172 | + const updateTheme = () => { |
| 173 | + selectedTheme !== 'custom' |
| 174 | + ? onboard.state.actions.updateTheme(selectedTheme) |
| 175 | + : onboard.state.actions.updateTheme('default') |
| 176 | + copyableStyles = |
| 177 | + selectedTheme !== 'custom' ? '' : `{\n ${styleToString(themingObjects[selectedTheme])}}` |
| 178 | + } |
127 | 179 |
|
128 |
| - const updateTheme = (e, targetStyle) => { |
| 180 | + const updateThemeEl = (e, targetStyle) => { |
| 181 | + if (selectedTheme !== 'custom') return |
129 | 182 | document.documentElement.style.setProperty(targetStyle, e.target.value)
|
130 | 183 |
|
131 |
| - copyableStyles = `:root {\n ${styleToString(defaultStyling)}${baseStyling}\n}` |
| 184 | + copyableStyles = `{\n ${styleToString(themingObjects[selectedTheme])}}` |
132 | 185 | }
|
133 | 186 |
|
134 | 187 | const resetTheme = () => {
|
135 |
| - defaultStyling = {...baseStyles} |
136 |
| - Object.keys(defaultStyling).forEach(style => { |
137 |
| - document.documentElement.style.setProperty(style, defaultStyling[style]) |
| 188 | + selectedTheme = 'custom' |
| 189 | + Object.keys(themingObjects['custom']).forEach((style) => { |
| 190 | + document.documentElement.style.setProperty(style, themingObjects['custom'][style]) |
138 | 191 | })
|
139 | 192 | }
|
140 | 193 |
|
|
187 | 240 |
|
188 | 241 | <section>
|
189 | 242 | <div class="control-panel">
|
190 |
| - <label for="Theme">Click Color Circles to Set Theme: </label> |
191 |
| - <hr /> |
192 |
| - <div class="theming-container"> |
193 |
| - {#each Object.keys(defaultStyling) as target} |
194 |
| - <div class="theming-inputs-wrapper"> |
195 |
| - <div class="theming-inputs"> |
196 |
| - <input |
197 |
| - type="color" |
198 |
| - name="Theme" |
199 |
| - bind:value={defaultStyling[target]} |
200 |
| - on:input={(e) => updateTheme(e, target)} |
201 |
| - /> |
202 |
| - </div> |
203 |
| - <span class="text" id="current-theme">{target} : {defaultStyling[target]}</span> |
204 |
| - </div> |
| 243 | + <label>Select a theme:</label> |
| 244 | + <select bind:value={selectedTheme} on:change={() => updateTheme()}> |
| 245 | + {#each themes as theme} |
| 246 | + <option value={theme}> |
| 247 | + {theme} |
| 248 | + </option> |
205 | 249 | {/each}
|
206 |
| - </div> |
207 |
| - <div class="copy-styles-container"> |
208 |
| - <textarea readonly bind:value={copyableStyles} rows="10" class="copy-styles-textarea" /> |
209 |
| - <button on:click={async () => await copyStylingConfig()}> Copy Styling Config </button> |
210 |
| - </div> |
211 |
| - <hr /> |
| 250 | + </select> |
| 251 | + {#if selectedTheme === 'custom'} |
| 252 | + <label for="Theme" |
| 253 | + >Click Color Circles to Customize Theme, Copy Config and Paste as `theme` property value in |
| 254 | + Onboard config: |
| 255 | + </label> |
| 256 | + <hr /> |
| 257 | + <div class="theming-container"> |
| 258 | + {#each Object.keys(themingObjects[selectedTheme]) as target} |
| 259 | + {#if !target.includes('border-radius')} |
| 260 | + <div class="theming-inputs-wrapper"> |
| 261 | + <div class="theming-inputs"> |
| 262 | + <input |
| 263 | + type="color" |
| 264 | + name="Theme" |
| 265 | + bind:value={themingObjects[selectedTheme][target]} |
| 266 | + on:input={(e) => updateThemeEl(e, target)} |
| 267 | + /> |
| 268 | + </div> |
| 269 | + <span class="text" id="current-theme" |
| 270 | + >{target} : {themingObjects[selectedTheme][target]}</span |
| 271 | + > |
| 272 | + </div> |
| 273 | + {:else} |
| 274 | + <div class="theming-inputs-wrapper"> |
| 275 | + <div class="theming-inputs-text"> |
| 276 | + <input |
| 277 | + class="br-text-input" |
| 278 | + type="text" |
| 279 | + bind:value={themingObjects[selectedTheme][target]} |
| 280 | + on:input={(e) => updateThemeEl(e, target)} |
| 281 | + /> |
| 282 | + </div> |
| 283 | + <span class="text" id="current-theme" |
| 284 | + >{target} : {themingObjects[selectedTheme][target]}</span |
| 285 | + > |
| 286 | + </div> |
| 287 | + {/if} |
| 288 | + {/each} |
| 289 | + </div> |
| 290 | + <div class="copy-styles-container"> |
| 291 | + <textarea readonly bind:value={copyableStyles} rows="8" class="copy-styles-textarea" /> |
| 292 | + <button on:click={async () => await copyStylingConfig()}> Copy Theming Config </button> |
| 293 | + </div> |
| 294 | + <hr /> |
| 295 | + {:else} |
| 296 | + <label for="Theme"> |
| 297 | + The system theme will align the theme with the users system preferences |
| 298 | + </label> |
| 299 | + <hr /> |
| 300 | + <div class="theming-container" /> |
| 301 | + {/if} |
| 302 | +
|
212 | 303 | <div class="backdrop-toggle">
|
213 | 304 | <label class="switch">
|
214 | 305 | <input type="checkbox" on:change={() => handleBackdrop()} bind:checked />
|
|
255 | 346 | </section>
|
256 | 347 |
|
257 | 348 | <style>
|
258 |
| - /* iframe { width: 100%; height: 62.5rem;} */ |
259 |
| - :root { |
260 |
| - --background-color: #ffffff; /* --white */ |
261 |
| - --text-color: #1a1d26; /* --gray-700 */ |
262 |
| - --border-color: #ebebed; /* --gray-100 taken from future mock */ |
263 |
| -
|
264 |
| - --accent-background: #ebebed; /* --gray-100 (currently gray-100 in connect modal) */ |
265 |
| - --accent-color: #929bed; /* --primary-400 */ |
266 |
| - --accent-color-hover: #eff1fc; /* --primary-200 */ |
267 |
| -
|
268 |
| - /* Account Center & Notify */ |
269 |
| - --secondary-text-color: #707481; /* --gray-400 (balance and token name) */ |
270 |
| - /* --secondary-accent-background: #242835; --gray-600 (Upper background in maximized) */ |
271 |
| -
|
272 |
| - /* --onboard-font-family-normal: System,monospace; */ |
273 |
| - --onboard-connect-sidebar-background: var(--accent-background); |
274 |
| - --onboard-close-button-background: var(--accent-background); |
275 |
| - --onboard-connect-sidebar-color: var(--text-color); |
276 |
| - --onboard-connect-sidebar-progress-background: var( |
277 |
| - --secondary-text-color |
278 |
| - ); /* defaults to gray-200 */ |
279 |
| - --onboard-connect-sidebar-progress-color: var(--accent-color); /* defaults to primary-600 */ |
280 |
| - --onboard-connect-header-background: var(--background-color); |
281 |
| - --onboard-connect-header-color: var(--text-color); |
282 |
| - --onboard-main-scroll-container-background: var(--background-color); |
283 |
| - --onboard-link-color: var(--accent-color); |
284 |
| - --onboard-wallet-button-background: var(--background-color); |
285 |
| - --onboard-wallet-button-background-hover: var(--accent-color-hover); |
286 |
| - --onboard-wallet-button-color-hover: var(--text-color); |
287 |
| - --onboard-wallet-button-color: var(--text-color); |
288 |
| - --onboard-wallet-button-border-color: var(--border-color); |
289 |
| - --onboard-wallet-app-icon-border-color: var(--border-color); |
290 |
| - } |
291 |
| -
|
292 | 349 | section {
|
293 | 350 | position: relative;
|
294 | 351 | height: 100%;
|
|
315 | 372 | }
|
316 | 373 |
|
317 | 374 | .control-panel {
|
318 |
| - z-index: 9999; |
319 |
| - left: auto; |
320 |
| - right: 0; |
| 375 | + z-index: 25; |
| 376 | + left: 0; |
| 377 | + right: auto; |
321 | 378 | bottom: 0;
|
322 | 379 | position: fixed;
|
323 | 380 | overflow: hidden;
|
|
368 | 425 | height: 2em;
|
369 | 426 | margin: 0.5em;
|
370 | 427 | }
|
| 428 | + .theming-inputs-text { |
| 429 | + display: inline-flex; |
| 430 | + align-items: center; |
| 431 | + justify-content: center; |
| 432 | + height: 2em; |
| 433 | + margin: 0.25em; |
| 434 | + } |
| 435 | + .br-text-input { |
| 436 | + width: 3rem; |
| 437 | + padding: 0.25rem; |
| 438 | + text-align: center; |
| 439 | + } |
371 | 440 | .iframe-input {
|
372 | 441 | flex: 1;
|
373 | 442 | padding: 1rem;
|
|
503 | 572 | transform: translateX(26px);
|
504 | 573 | }
|
505 | 574 |
|
| 575 | + select { |
| 576 | + width: 100%; |
| 577 | + padding: 1rem; |
| 578 | + } |
| 579 | +
|
506 | 580 | .backdrop-toggle {
|
507 | 581 | display: flex;
|
508 | 582 | align-items: center;
|
|
0 commit comments