Skip to content

Commit 9f069ad

Browse files
authored
[core] : Enhancement - Dropdown select icon opens options (#952)
* Add passing of icons into network select to allow for clickable icon to open select options * Add the Max and Min views to commit * Prettier-ify * Add padding when network is switching
1 parent b98c900 commit 9f069ad

File tree

5 files changed

+17
-23
lines changed

5 files changed

+17
-23
lines changed
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
1-
export default `
2-
<svg width="100%" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
3-
<path d="M16.59 8.59L12 13.17L7.41 8.59L6 10L12 16L18 10L16.59 8.59Z" fill="currentColor"/>
4-
</svg>
5-
`
1+
export default `<svg width="100%" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M16.59 8.59L12 13.17L7.41 8.59L6 10L12 16L18 10L16.59 8.59Z" fill="currentColor"/></svg>`

packages/core/src/icons/caret.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
1-
export default `
2-
<svg width="100%" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
3-
<path d="M7 10L12 15L17 10H7Z" fill="currentColor"/>
4-
</svg>
5-
`
1+
export default `<svg width="100%" height="24" viewBox="0 5 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M7 10L12 15L17 10H7Z" fill="currentColor"/></svg>`

packages/core/src/views/account-center/Maximized.svelte

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -319,10 +319,8 @@
319319
chains={appChains}
320320
color="#33394B"
321321
bold={true}
322+
selectIcon={caretLightIcon}
322323
/>
323-
<div class="caret flex items-center justify-center">
324-
{@html caretLightIcon}
325-
</div>
326324
</div>
327325
</div>
328326
</div>

packages/core/src/views/account-center/Minimized.svelte

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@
4040
? firstAccount.balance[firstAddressAsset]
4141
: null
4242
43-
$: primaryChain =
44-
primaryWallet && primaryWallet.chains[0]
43+
$: primaryChain = primaryWallet && primaryWallet.chains[0]
4544
4645
$: validAppChain = chains.find(({ id, namespace }) =>
4746
primaryChain
@@ -203,11 +202,7 @@
203202
: warningIcon}
204203
</div>
205204

206-
<NetworkSelector {chains} color="#33394B" />
207-
</div>
208-
209-
<div class="caret flex items-center">
210-
{@html caretIcon}
205+
<NetworkSelector {chains} color="#33394B" selectIcon={caretIcon} />
211206
</div>
212207
</div>
213208
</div>

packages/core/src/views/shared/NetworkSelector.svelte

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
import setChain from '../../chain'
66
import { wallets$ } from '../../streams'
77
import { distinctUntilChanged, debounceTime, skip } from 'rxjs/operators'
8+
import caretIcon from '../../icons/caret'
89
10+
export let selectIcon: string = caretIcon
911
export let color = '#33394B'
1012
export let chains: Chain[]
1113
export let bold = false
@@ -72,8 +74,13 @@
7274
font-size: var(--onboard-font-size-7, var(--font-size-7));
7375
line-height: var(--onboard-font-line-height-3, var(--font-line-height-3));
7476
max-width: 90px;
75-
width: 54px;
77+
min-width: 72px;
7678
transition: width 250ms ease-in-out;
79+
background-repeat: no-repeat, repeat;
80+
background-position: right 0px top 0px, 0 0;
81+
scrollbar-width: none;
82+
-ms-overflow-style: none;
83+
padding: 0 16px 0 0;
7784
}
7885
7986
select:focus {
@@ -88,14 +95,16 @@
8895

8996
{#if wallet}
9097
{#if $switching$}
91-
<span style={`color: ${color};`}>switching...</span>
98+
<span style={`color: ${color}; padding: 0 12px 0 8px;`}>switching...</span>
9299
{:else}
93100
<select
94101
class="flex justify-center items-center pointer"
95102
bind:this={selectElement}
96103
value={wallet.chains[0].id}
97104
on:change={handleSelect}
98-
style={`color: ${color}; ${bold ? 'font-weight: 700;' : ''}`}
105+
style={`color: ${color}; background-image: url('data:image/svg+xml;utf8,${selectIcon}'); ${
106+
bold ? 'font-weight: 700;' : ''
107+
}`}
99108
>
100109
{#if !connectedToValidAppChain(wallet.chains[0], chains)}
101110
<option value={wallet.chains[0].id}

0 commit comments

Comments
 (0)