Skip to content

Commit 7469911

Browse files
committed
feat(neuron-ui): update loading style of submit button for importing/creating wallets
1 parent 8508965 commit 7469911

2 files changed

Lines changed: 19 additions & 9 deletions

File tree

packages/neuron-ui/src/components/ImportKeystore/index.tsx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useState, useCallback, useMemo, useEffect } from 'react'
22
import { RouteComponentProps } from 'react-router-dom'
3-
import { Stack, DefaultButton, PrimaryButton, TextField } from 'office-ui-fabric-react'
3+
import { Stack, DefaultButton, PrimaryButton, TextField, Spinner } from 'office-ui-fabric-react'
44
import { useTranslation } from 'react-i18next'
55
import { showOpenDialog } from 'services/remote'
66
import { importWalletWithKeystore } from 'states/stateProvider/actionCreators'
@@ -124,12 +124,15 @@ const ImportKeystore = (props: React.PropsWithoutRef<StateWithDispatch & RouteCo
124124
</Stack>
125125
<Stack horizontal horizontalAlign="end" tokens={{ childrenGap: 15 }}>
126126
<DefaultButton onClick={goBack}>{t('import-keystore.button.back')}</DefaultButton>
127-
<PrimaryButton
128-
disabled={loading || !(fields.name && fields.path && fields.password && !isNameUsed)}
129-
onClick={onSubmit}
130-
>
131-
{t('import-keystore.button.submit')}
132-
</PrimaryButton>
127+
{loading ? (
128+
<PrimaryButton disabled>
129+
<Spinner />
130+
</PrimaryButton>
131+
) : (
132+
<PrimaryButton disabled={!(fields.name && fields.path && fields.password && !isNameUsed)} onClick={onSubmit}>
133+
{t('import-keystore.button.submit')}
134+
</PrimaryButton>
135+
)}
133136
</Stack>
134137
</Stack>
135138
)

packages/neuron-ui/src/components/WalletWizard/index.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
DefaultButton,
1111
TextField,
1212
FontSizes,
13+
Spinner,
1314
} from 'office-ui-fabric-react'
1415

1516
import withWizard, { WizardElementProps, WithWizardState } from 'components/withWizard'
@@ -283,7 +284,7 @@ const Submission = ({
283284
const isNameUnused = useMemo(() => name && !wallets.find(w => w.name === name), [name, wallets])
284285
const isPwdComplex = useMemo(() => verifyPasswordComplexity(password) === true, [password])
285286
const isPwdSame = useMemo(() => password && password === confirmPassword, [password, confirmPassword])
286-
const disableNext = loading || !(isNameUnused && isPwdComplex && isPwdSame)
287+
const disableNext = !(isNameUnused && isPwdComplex && isPwdSame)
287288

288289
return (
289290
<Stack verticalFill verticalAlign="center" horizontalAlign="stretch" tokens={{ childrenGap: 15 }}>
@@ -320,7 +321,13 @@ const Submission = ({
320321

321322
<Stack horizontal horizontalAlign="end" tokens={{ childrenGap: 10 }}>
322323
<DefaultButton onClick={history.goBack} text={t('wizard.back')} />
323-
<PrimaryButton type="submit" onClick={onNext} disabled={disableNext} text={t('wizard.next')} />
324+
{loading ? (
325+
<PrimaryButton disabled>
326+
<Spinner />
327+
</PrimaryButton>
328+
) : (
329+
<PrimaryButton type="submit" onClick={onNext} disabled={disableNext} text={t('wizard.next')} />
330+
)}
324331
</Stack>
325332
</Stack>
326333
)

0 commit comments

Comments
 (0)