Skip to content

Commit

Permalink
fix: Better experience for switching network type
Browse files Browse the repository at this point in the history
  • Loading branch information
yanguoyu committed Nov 10, 2023
1 parent d127ac3 commit a000497
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 29 deletions.
27 changes: 12 additions & 15 deletions packages/neuron-ui/src/components/NetworkSetting/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,15 @@ const NetworkSetting = ({ chain = chainState, settings: { networks = [] } }: Sta
itemClassName={styles.radioItem}
options={showNetworks.map(network => ({
value: network.id,
label:
currentId === network.id && network.type === NetworkType.Light ? (
<div className={styles.networkLabel}>
<p>{`${network.name} (${network.remote})`}</p>
label: (
<div className={styles.networkLabel}>
<p>{`${network.name} (${network.remote})`}</p>
<div className={styles.tag}>{t(getNetworkLabelI18nkey(network.chain))}</div>
</div>
),
suffix: (
<div className={styles.suffix}>
{currentId === network.id && network.type === NetworkType.Light ? (
<Tooltip
tip={
<div className={styles.tooltip}>
Expand All @@ -113,21 +118,13 @@ const NetworkSetting = ({ chain = chainState, settings: { networks = [] } }: Sta
}
placement="top"
showTriangle
className={styles.switch}
>
<button type="button" className={styles.tag} onClick={onSwitchNetworkType}>
{t(getNetworkLabelI18nkey(network.chain))}
<button type="button" onClick={onSwitchNetworkType}>
<Switch />
</button>
</Tooltip>
</div>
) : (
<div className={styles.networkLabel}>
<p>{`${network.name} (${network.remote})`}</p>
<div className={styles.tag}>{t(getNetworkLabelI18nkey(network.chain))}</div>
</div>
),
suffix: (
<div className={styles.suffix}>
) : null}
{network.readonly ? null : (
<button type="button" aria-label={t('common.edit')} onClick={onHandleNetwork}>
<EditNetwork data-action="edit" data-id={network.id} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,11 @@
border-radius: 40px;
display: flex;
align-items: center;
cursor: default;

& > svg {
margin-left: 4px;
}
}
button.tag {
cursor: pointer;
&:hover {
color: var(--primary-color);
border-color: var(--primary-color);

& > svg {
path {
fill: var(--primary-color);
}
}
}
}
.tooltip {
background-color: transparent;
color: var(--main-text-color);
Expand All @@ -67,5 +53,13 @@
button {
@include icon-hover-button;
visibility: hidden;

& > svg {
width: 16px;
height: 16px;
}
}
.switch {
margin-right: 32px;
}
}

0 comments on commit a000497

Please sign in to comment.