Skip to content

Commit

Permalink
Merge pull request #3153 from yanguoyu/feat-add-prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
Keith-CY authored May 21, 2024
2 parents 2fcc43d + beeb8fa commit ea263b4
Show file tree
Hide file tree
Showing 11 changed files with 154 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ $action-button-width: 11.25rem;
gap: 16px;

.content {
width: 176px;
min-width: 176px;
padding: 16px;
background: var(--input-disabled-color);
border-radius: 8px;
Expand Down
44 changes: 41 additions & 3 deletions packages/neuron-ui/src/components/SyncStatus/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import React, { useCallback, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { SyncStatus as SyncStatusEnum, ConnectionStatus, clsx, localNumberFormatter, getSyncLeftTime } from 'utils'
import { Confirming, NewTab } from 'widgets/Icons/icon'
import { Confirming, NewTab, Question } from 'widgets/Icons/icon'
import { ReactComponent as UnexpandStatus } from 'widgets/Icons/UnexpandStatus.svg'
import { ReactComponent as StartBlock } from 'widgets/Icons/StartBlock.svg'
import Tooltip from 'widgets/Tooltip'
import { openExternal } from 'services/remote'
import styles from './syncStatus.module.scss'

const SyncDetail = ({
Expand Down Expand Up @@ -53,7 +54,17 @@ const SyncDetail = ({
</div>
) : null}
<div className={styles.item}>
<div className={styles.title}>{t('network-status.left-time')}</div>
<div className={styles.title}>
{t('network-status.left-time')}:
<Tooltip
tip={<div className={styles.leftTimeTip}>{t('network-status.left-time-tip')}</div>}
className={styles.question}
tipClassName={styles.questionTip}
placement="right-bottom"
>
<Question />
</Tooltip>
</div>
<div className={styles.number}>{getSyncLeftTime(estimate)}</div>
</div>
{isLightClient && (
Expand Down Expand Up @@ -114,7 +125,34 @@ const SyncStatus = ({
}

if (ConnectionStatus.Offline === connectionStatus) {
return <span className={styles.redDot}>{t('sync.sync-failed')}</span>
return (
<span className={styles.redDot}>
{t('sync.sync-failed')}
<Tooltip
tip={
<div className={styles.failedDetail}>
{t('sync.sync-failed-detail')}
&nbsp;&nbsp;
<button
type="button"
onClick={() => {
openExternal(`https://neuron.magickbase.com/posts/issues/2893`)
}}
className={styles.openHelper}
>
{t('sync.learn-more')}
</button>
</div>
}
trigger="click"
placement="left-bottom"
showTriangle
tipClassName={styles.helpTip}
>
<Question />
</Tooltip>
</span>
)
}

if (SyncStatusEnum.SyncNotStart === syncStatus) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,37 @@
.title {
font-size: 12px;
font-weight: 400;
display: flex;
align-items: center;

.question {
height: 14px;
flex: 1 1 auto;
svg {
margin-left: 4px;
cursor: pointer;
path {
stroke: var(--secondary-text-color);
}
&:hover {
path {
stroke: var(--primary-color);
}
}
}
}

.questionTip {
top: calc(100% + 28px);
right: -36px;
width: 200px;
left: inherit;
}

.leftTimeTip {
white-space: normal;
width: 200px;
}
}
.number {
color: var(--third-text-color);
Expand All @@ -110,8 +141,20 @@

.redDot {
position: relative;
color: '#FF1E1E';
color: var(--error-color);
padding-left: 14px;
display: flex;
align-items: center;

& > div {
height: 14px;
}

svg {
margin-left: 4px;
cursor: pointer;
}

&::before {
content: '';
height: 6px;
Expand All @@ -122,4 +165,27 @@
top: calc(50% - 3px);
background: var(--error-color);
}

.helpTip {
margin-top: 20px;
right: -10px !important;

& > div:nth-last-child(1) {
right: 12px;
}
}

.failedDetail {
white-space: normal;
min-width: 250px;
}
.openHelper {
font-weight: 500;
background: inherit;
color: var(--primary-color);
border: none;
padding: 0;
margin: 0;
cursor: pointer;
}
}
7 changes: 5 additions & 2 deletions packages/neuron-ui/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
"set-start-block-number": "Set start block number"
},
"migrating": "migrating...",
"left-time": "Left Time"
"left-time": "Time Remaining",
"left-time-tip": "The time remaining is an estimate and is related to the current network and other factors, and is for reference only."
},
"import-hardware": {
"title": {
Expand Down Expand Up @@ -688,7 +689,9 @@
"block-number": "block number",
"syncing-balance": "Balance is updating",
"slow": "Sync is slow",
"sync-failed": "Sync failed, please check network",
"sync-failed": "Synchronization failed",
"sync-failed-detail": "Synchronization failed due to network node or other problems.",
"learn-more": "Learn More",
"sync-not-start": "Sync not started yet, please try to restart Neuron Wallet",
"connecting": "Connecting"
},
Expand Down
7 changes: 5 additions & 2 deletions packages/neuron-ui/src/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"set-start-block-number": "Establecer el número de bloque inicial"
},
"migrating": "migrando...",
"left-time": "Tiempo restante"
"left-time": "Tiempo restante",
"left-time-tip": "El tiempo restante es una estimación y está relacionado con la red actual y otros factores, y es solo para referencia."
},
"import-hardware": {
"title": {
Expand Down Expand Up @@ -671,7 +672,9 @@
"block-number": "número de bloque",
"syncing-balance": "El saldo se está actualizando",
"slow": "La sincronización es lenta",
"sync-failed": "Error de sincronización, por favor compruebe la red",
"sync-failed": "sincronización fallida",
"sync-failed-detail": "Debido a nodos de red u otros problemas, la sincronización ha fallado.",
"learn-more": "Saber más",
"sync-not-start": "La sincronización no se ha iniciado todavía, por favor intente reiniciar Neuron Wallet",
"connecting": "Conectando"
},
Expand Down
7 changes: 5 additions & 2 deletions packages/neuron-ui/src/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
"set-start-block-number": "Définir le numéro de bloc de départ"
},
"migrating": "migration en cours...",
"left-time": "Temps restant"
"left-time": "Temps restant",
"left-time-tip": "Le temps restant est une estimation et est lié au réseau actuel et à d'autres facteurs, et est fourni à titre indicatif seulement."
},
"import-hardware": {
"title": {
Expand Down Expand Up @@ -678,7 +679,9 @@
"block-number": "numéro de bloc",
"syncing-balance": "La balance est en cours de mise à jour",
"slow": "La synchronisation est lente",
"sync-failed": "Échec de la synchronisation, veuillez vérifier le réseau",
"sync-failed": "échec de la synchronisation",
"sync-failed-detail": "En raison de nœuds réseau ou d'autres problèmes, la synchronisation a échoué.",
"learn-more": "En savoir plus",
"sync-not-start": "La synchronisation n'a pas encore commencé, veuillez essayer de redémarrer le Wallet Neuron",
"connecting": "Connexion en cours"
},
Expand Down
7 changes: 5 additions & 2 deletions packages/neuron-ui/src/locales/zh-tw.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
"set-start-block-number": "設置同步起始區塊"
},
"migrating": "正在數據遷移...",
"left-time": "剩余時間"
"left-time": "剩余時間",
"left-time-tip": "剩余時間僅為估計值,與當前網絡和其他因素有關,僅供參考。"
},
"import-hardware": {
"title": {
Expand Down Expand Up @@ -682,7 +683,9 @@
"block-number": "區塊高度",
"syncing-balance": "區塊同步中, 正在獲取最新余額",
"slow": "同步緩慢,請檢查網絡",
"sync-failed": "連接失敗, 請檢查網絡",
"sync-failed": "同步失敗",
"sync-failed-detail": "由於網絡節點或其他問題,同步失敗。",
"learn-more": "了解更多",
"sync-not-start": "同步尚未開始, 請嘗試重啟",
"connecting": "正在連接節點"
},
Expand Down
7 changes: 5 additions & 2 deletions packages/neuron-ui/src/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
"set-start-block-number": "设置同步起始区块"
},
"migrating": "正在数据迁移...",
"left-time": "剩余时间"
"left-time": "剩余时间",
"left-time-tip": "剩余时间仅为估计值,与当前网络和其他因素有关,仅供参考。"
},
"import-hardware": {
"title": {
Expand Down Expand Up @@ -681,7 +682,9 @@
"block-number": "区块高度",
"syncing-balance": "区块同步中, 正在获取最新余额",
"slow": "同步缓慢,请检查网络",
"sync-failed": "连接失败, 请检查网络",
"sync-failed": "同步失败",
"sync-failed-detail": "由于网络节点或其他问题,同步失败。",
"learn-more": "了解更多",
"sync-not-start": "同步尚未开始, 请尝试重启",
"connecting": "正在连接节点"
},
Expand Down
12 changes: 12 additions & 0 deletions packages/neuron-ui/src/widgets/Icons/Question.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions packages/neuron-ui/src/widgets/Icons/icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ import { ReactComponent as DeleteSvg } from './Delete.svg'
import { ReactComponent as ImportKeystoreSvg } from './SoftWalletImportKeystore.svg'
import { ReactComponent as ImportHardwareSvg } from './HardWalletImport.svg'
import { ReactComponent as DepositTimeSortSvg } from './DepositTimeSort.svg'
import { ReactComponent as QuestionSvg } from './Question.svg'

import styles from './icon.module.scss'

Expand Down Expand Up @@ -130,3 +131,4 @@ export const Delete = WrapSvg(DeleteSvg)
export const ImportKeystore = WrapSvg(ImportKeystoreSvg)
export const ImportHardware = WrapSvg(ImportHardwareSvg)
export const DepositTimeSort = WrapSvg(DepositTimeSortSvg)
export const Question = WrapSvg(QuestionSvg)
12 changes: 6 additions & 6 deletions packages/neuron-ui/src/widgets/Tooltip/tooltip.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -251,25 +251,25 @@ $placements: left, right, top, bottom, left-top, right-top, left-bottom, right-b
.tipWithNode {
position: relative;

.tip {
> .tip {
@include tip;
}

&[data-type='always-dark'] {
.tip {
> .tip {
background: #000000;
color: #ffffff;
}
}

&[data-trigger='click'] {
&[data-tip-show='true'] .tip {
&[data-tip-show='true'] > .tip {
display: block;
}
}

@each $placement in $placements {
@include tip-placement($placement, ' .tip');
@include tip-placement($placement, '> .tip');
}

&[data-trigger='hover'] {
Expand All @@ -286,14 +286,14 @@ $placements: left, right, top, bottom, left-top, right-top, left-bottom, right-b
&[data-has-trigger='true'] {
&[data-placement='bottom'] {
&:not([data-trigger-next-to-child='true']) {
& .tip {
& > .tip {
top: calc(100% + 20px);
}
}
}
&[data-placement='top'] {
&[data-trigger-next-to-child='true'] {
& .tip {
& > .tip {
margin-bottom: 2px;
}
}
Expand Down

1 comment on commit ea263b4

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Packaging for test is done in 9170888274

Please sign in to comment.