Skip to content

feat: update import SRP UI #31098

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 19, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions app/_locales/de/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions app/_locales/el/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions app/_locales/en/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions app/_locales/en_GB/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions app/_locales/es/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions app/_locales/fr/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions app/_locales/hi/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions app/_locales/id/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions app/_locales/ja/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions app/_locales/ko/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions app/_locales/pt/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions app/_locales/ru/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions app/_locales/tl/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions app/_locales/tr/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions app/_locales/vi/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions app/_locales/zh_CN/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

72 changes: 40 additions & 32 deletions ui/components/app/srp-input/srp-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,38 +127,46 @@ export default function SrpInput({ onChange, srpText }) {

return (
<div className="import-srp__container">
<label className="import-srp__srp-label">
<Text align={TextAlign.Left} variant={TextVariant.headingSm} as="h4">
{srpText}
</Text>
</label>
<BannerAlert
className="import-srp__paste-tip"
severity={Severity.Info}
description={t('srpPasteTip')}
descriptionProps={{ className: 'import-srp__banner-alert-text' }}
/>
<Dropdown
className="import-srp__number-of-words-dropdown"
onChange={(newSelectedOption) => {
const newNumberOfWords = parseInt(newSelectedOption, 10);
if (Number.isNaN(newNumberOfWords)) {
throw new Error('Unable to parse option as integer');
}

let newDraftSrp = draftSrp.slice(0, newNumberOfWords);
if (newDraftSrp.length < newNumberOfWords) {
newDraftSrp = newDraftSrp.concat(
new Array(newNumberOfWords - newDraftSrp.length).fill(''),
);
}
setNumberOfWords(newNumberOfWords);
setShowSrp(new Array(newNumberOfWords).fill(false));
onSrpChange(newDraftSrp);
}}
options={numberOfWordsOptions}
selectedOption={`${numberOfWords}`}
/>
<div className="import-srp__dropdown-container">
<label className="import-srp__srp-label">
{srpText && (
<Text
align={TextAlign.Left}
variant={TextVariant.headingSm}
as="h4"
>
{srpText}
</Text>
)}
</label>
<BannerAlert
className="import-srp__paste-tip"
severity={Severity.Info}
description={t('srpPasteTip')}
descriptionProps={{ className: 'import-srp__banner-alert-text' }}
/>
<Dropdown
className="import-srp__number-of-words-dropdown"
onChange={(newSelectedOption) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we move this out of an inline function into a useCallback usage?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great suggestion! I'll do it now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

const newNumberOfWords = parseInt(newSelectedOption, 10);
if (Number.isNaN(newNumberOfWords)) {
throw new Error('Unable to parse option as integer');
}

let newDraftSrp = draftSrp.slice(0, newNumberOfWords);
if (newDraftSrp.length < newNumberOfWords) {
newDraftSrp = newDraftSrp.concat(
new Array(newNumberOfWords - newDraftSrp.length).fill(''),
);
}
setNumberOfWords(newNumberOfWords);
setShowSrp(new Array(newNumberOfWords).fill(false));
onSrpChange(newDraftSrp);
}}
options={numberOfWordsOptions}
selectedOption={`${numberOfWords}`}
/>
</div>
<div className="import-srp__srp">
{[...Array(numberOfWords).keys()].map((index) => {
const id = `import-srp__srp-word-${index}`;
Expand Down
23 changes: 16 additions & 7 deletions ui/components/app/srp-input/srp-input.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,19 @@
&__container {
display: grid;
grid-template-areas:
'title dropdown'
'paste-tip paste-tip'
'input input'
'error error'
'too-many-words-error too-many-words-error';
'title'
'paste-tip'
'input'
'error'
'too-many-words-error'
}

&__dropdown-container {
display: flex;
flex-direction: column-reverse;
align-items: center;
justify-content: center;
margin-bottom: 8px;
}

@include design-system.screen-md-max {
Expand All @@ -30,10 +38,11 @@

&__number-of-words-dropdown {
grid-area: dropdown;
width: 100%;
}

&__paste-tip {
margin: 24px 0;
margin: 24px 0 12px 0;
grid-area: paste-tip;
width: auto;
margin-left: auto;
Expand All @@ -48,7 +57,7 @@

@include design-system.screen-md-max {
&__srp {
grid-template-columns: 1fr;
grid-template-columns: 1fr 1fr 1fr;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ export const ImportSrp = ({
flexDirection={FlexDirection.Row}
>
<Label
className="import-srp__srp-label"
className="import-srp__multi-srp-label"
variant={TextVariant.bodyMdMedium}
marginRight={4}
>
Expand Down
2 changes: 1 addition & 1 deletion ui/components/multichain/multi-srp/import-srp/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
grid-area: input;
}

&__srp-label {
&__multi-srp-label {
min-width: 16px;
max-width: 16px;
flex-shrink: 0;
Expand Down
7 changes: 2 additions & 5 deletions ui/pages/onboarding-flow/import-srp/import-srp.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default function ImportSRP({ submitSecretRecoveryPhrase }) {
</Typography>
</div>
<div className="import-srp__description">
<Typography variant={TypographyVariant.H4}>
<Typography align={TEXT_ALIGN.LEFT} variant={TypographyVariant.H4}>
{t('accessYourWalletWithSRPDescription', [
<a
key="learnMore"
Expand All @@ -69,10 +69,7 @@ export default function ImportSRP({ submitSecretRecoveryPhrase }) {
</div>
<div className="import-srp__actions">
<Box textAlign={TEXT_ALIGN.LEFT}>
<SrpInput
onChange={setSecretRecoveryPhrase}
srpText={t('typeYourSRP')}
/>
<SrpInput onChange={setSecretRecoveryPhrase} />
<Button
className="import-srp__confirm-button"
type="primary"
Expand Down
2 changes: 1 addition & 1 deletion ui/pages/onboarding-flow/import-srp/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
flex-direction: column;
justify-content: center;
text-align: center;
margin-bottom: 40px;
margin-bottom: 30px;

a {
color: var(--color-primary-default);
Expand Down
Loading