Skip to content

Commit

Permalink
Merge pull request #662 from near/account-export-ui-improvements
Browse files Browse the repository at this point in the history
style: UI/UX improvements and cosmatic changes on account-export
  • Loading branch information
kujtimprenkuSQA authored Jan 27, 2023
2 parents 94773c6 + f60d5bc commit c047895
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 16 deletions.
42 changes: 40 additions & 2 deletions packages/account-export/src/lib/components/AccountSelect.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import type { ReactElement } from "react";
import React, { Fragment } from "react";
import { translate } from "@near-wallet-selector/core";
import { ModalHeader } from "./ModalHeader";
import type { ExportAccountData } from "./ExportAccount";
import { ACCESS_KEY_TYPES } from "./ExportAccount";

interface AccountSelectProps {
onCloseModal: () => void;
Expand All @@ -14,9 +16,42 @@ interface AccountSelectProps {
isLoading: boolean;
}

interface WarningLabelProp {
hasBalance: boolean;
type: string;
}

const LOADING_ICON_DATA_URL =
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAAZCAYAAADE6YVjAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAR3SURBVHgBpVZ9aJVVGH+e55z33bi7zY9hMz+yMAeNoEIq6A9ZRKQWEsQNFIIpsf5Y9E+GsD9iBEEDMUkDa6ShRKKZYIWiRkaKaUGUGCKOTGMF84PNO99773vOefq9720yK5ZzD/dwPt/nd37P17lEk5Qnuz9roUkKT7T5bNe+QjTNLCHv24h1Xgh+OmtwQYPH2jUXwlnW9NRooqePfLS6MmmQ59cdeEGJlkJZA5MGVecoAwghBYZTVY9ftuaDSy8x8w9fbFl95JZAXuw9dmelkvRAyXxS7wMFryG4bIyWZiqzPgMhaFfGfn3NY3AZG9sPf/Dy8HidZvxkZc/h1pqnPlKey6yspMqUd9jVAEYY6RCGDQTwjGDwGTgAlbwRijV1C9vanz577tT+6r+YrOz5rlXFrQ/qZ+FbDxCfXS5oOgxln4v473f3rbgwdn7FK5/MCaH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iI6YfUpcAAAAASUVORK5CYII=";

const getWarningLabel = ({
hasBalance,
type,
}: WarningLabelProp): ReactElement | null => {
if (type === ACCESS_KEY_TYPES.UNKNOWN) {
return (
<span className="error">
{translate("modal.exportAccounts.selectAccounts.error")}
</span>
);
}
if (type === ACCESS_KEY_TYPES.LEDGER) {
return (
<span className="warning">
{translate("modal.exportAccounts.selectAccounts.warningLedger")}
</span>
);
}
if (!hasBalance) {
return (
<span className="warning">
{translate("modal.exportAccounts.selectAccounts.noBalance")}
</span>
);
}
return null;
};

export const AccountSelect: React.FC<AccountSelectProps> = ({
onCloseModal,
onBack,
Expand Down Expand Up @@ -95,7 +130,7 @@ export const AccountSelect: React.FC<AccountSelectProps> = ({
{translate("modal.exportAccounts.selectAccounts.unavailable")}
</span>
<div className="account-selection">
{disabledAccounts.map(({ accountId }) => (
{disabledAccounts.map(({ accountId, type, hasBalance }) => (
<div className="account-selection-row" key={accountId}>
<div className="checkbox">
<input
Expand All @@ -109,7 +144,10 @@ export const AccountSelect: React.FC<AccountSelectProps> = ({
value={accountId}
disabled
/>
<label htmlFor={accountId}> {accountId}</label>
<label htmlFor={accountId}>
<span>{accountId}</span>
{getWarningLabel({ hasBalance, type })}
</label>
</div>
</div>
))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const EXPORT_ACCOUNT_STEPS = {
COMPLETE: "COMPLETE",
};

const ACCESS_KEY_TYPES = {
export const ACCESS_KEY_TYPES = {
LEDGER: "Ledger",
FULL_ACCESS_KEY: "Full Access Key",
MULTI_SIG: "Multi-Sig",
Expand Down
41 changes: 30 additions & 11 deletions packages/account-export/src/lib/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@

.nws-modal-wrapper .nws-modal .nws-modal-body button.middleButton:disabled,
.nws-modal-wrapper .nws-modal .nws-modal-body button.middleButton[disabled]{
border-color: var(--secondary-button-border-color);
background-color: var(--secondary-button-bg-color);
cursor: not-allowed;
background-color: var(--wallet-selector-home-button-bg, var(--home-button-bg));
color: #606060;
border: none;
}


Expand All @@ -46,15 +47,14 @@
}

.checkbox {
width: 100%;
position: relative;
display: block;
}

.checkbox label {
position: relative;
display: block;
padding-left: 50px;
padding-left: 40px;
margin-bottom: 0;
cursor: pointer;
color: var(--wallet-selector-heading-color, var(--heading-color));
Expand Down Expand Up @@ -111,6 +111,18 @@
.checkbox input[type="checkbox"]:disabled + label {
color: var(--wallet-selector-text-color, var(--text-color));
cursor: not-allowed;
display: flex;
flex-direction: column;
}

.checkbox input[type="checkbox"]:disabled + label > span.error {
color: var(--wallet-selector-error, var(--error));
font-size: 10px;
}

.checkbox input[type="checkbox"]:disabled + label > span.warning {
color: #E9B870;
font-size: 10px;
}

.checkbox input[type="checkbox"]:disabled + label::before {
Expand Down Expand Up @@ -156,6 +168,7 @@

.account-export {
height: 100%;
margin-top: 15px !important;
}

.account-export .content {
Expand Down Expand Up @@ -185,7 +198,7 @@
width: 100%;
max-height: 200px;
overflow-y: auto;
margin-top: 20px;
margin: 20px 0;
}

.account-export .account-select-all {
Expand All @@ -208,15 +221,20 @@
flex-direction: row;
align-items: center;
width: 100%;
padding: 0 12px;
margin-bottom: 24px;
padding: 15px 12px;
border-bottom: 1px solid #313030;
}

.account-export .account-selection .account-selection-row label {
display: flex;
flex-direction: column;
}

.account-export .passphrase-title {
font-size: 14px;
font-size: 15px;
text-align: center;
font-weight: 400;
color: #c1c1c1;
font-weight: 500;
color: var(--wallet-selector-text-color, var(--text-color));
margin: 40px 0 30px;
}

Expand All @@ -236,8 +254,9 @@
}

.account-export .passphrase-label {
font-size: 10px;
font-size: 12px;
cursor: copy;
color: var(--wallet-selector-text-color, var(--text-color));
}

.account-export .complete-desc {
Expand Down
7 changes: 5 additions & 2 deletions packages/core/src/lib/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,15 @@
"button": "Get Passphrase",
"deselectAll": "Deselect All",
"selectAll": "Select All",
"unavailable": "Transfer Unavailable"
"unavailable": "Transfer Unavailable",
"error": "Account does not exist",
"warningLedger": "Ledger support required",
"noBalance": "Account not funded"
},
"getPassphrase": {
"title": "Copy Temporary Password",
"desc": "You’ll need to enter this password when you begin exporting your accounts to a different wallet.",
"button": "Transfer Accounts",
"button": "Continue",
"label": "Click to Copy",
"checkLabel": "I copied or wrote down the password"
},
Expand Down

0 comments on commit c047895

Please sign in to comment.