Skip to content
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

TW-1205: Accounts dropdown UI/UX improvements #1034

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
11 changes: 8 additions & 3 deletions public/_locales/de/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"message": "Kryptowährungs-Wallet für Tezos-Blockchain als Web-Erweiterung für Ihren Browser."
},
"createAccount": {
"message": "Konto erstellen oder wiederherstellen"
"message": "Konto erstellen"
},
"importAccount": {
"message": "Konto importieren"
Expand Down Expand Up @@ -1455,8 +1455,13 @@
"searchAssets": {
"message": "Vermögenswerte suchen..."
},
"searchByName": {
"message": "Nach Name suchen..."
"searchAccount": {
"message": "Suchen$hotkey$",
"placeholders": {
"hotkey": {
"content": "$1"
}
}
},
"deployNew": {
"message": "Neu bereitstellen"
Expand Down
11 changes: 8 additions & 3 deletions public/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"message": "🔐💰Cryptocurrency wallet for Tezos blockchain as Web Extension for your Browser."
},
"createAccount": {
"message": "Create or Restore account"
"message": "Create account"
},
"importAccount": {
"message": "Import account"
Expand Down Expand Up @@ -1744,8 +1744,13 @@
"searchAssets": {
"message": "Search assets..."
},
"searchByName": {
"message": "Search by name..."
"searchAccount": {
"message": "Search$hotkey$",
"placeholders": {
"hotkey": {
"content": "$1"
}
}
},
"deployNew": {
"message": "Deploy new"
Expand Down
2 changes: 1 addition & 1 deletion public/_locales/en_GB/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"message": "🔐💰Cryptocurrency wallet for Tezos blockchain as Web Extension for your Browser."
},
"createAccount": {
"message": "Create or Restore account"
"message": "Create account"
},
"totalEquityValue": {
"message": "Total Equity Value"
Expand Down
2 changes: 1 addition & 1 deletion public/_locales/fr/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"message": "Importer un compte"
},
"createAccount": {
"message": "Créer ou restaurer un compte"
"message": "Créer un compte"
},
"faucetFileTitle": {
"message": "Fichier Faucet"
Expand Down
2 changes: 1 addition & 1 deletion public/_locales/ja/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"message": "アカウントをインポート"
},
"createAccount": {
"message": "アカウントを作成または復元する"
"message": "アカウントを作成"
keshan3262 marked this conversation as resolved.
Show resolved Hide resolved
},
"faucetFileTitle": {
"message": "フォーセットファイル"
Expand Down
2 changes: 1 addition & 1 deletion public/_locales/ko/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"message": "계정 불러오기"
},
"createAccount": {
"message": "계정 생성 또는 복원"
"message": "계정 만들기"
},
"faucetFileTitle": {
"message": "수도꼭지 파일"
Expand Down
11 changes: 8 additions & 3 deletions public/_locales/pt/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"message": "Carteira de criptomoedas para blocos em cadeia Tezos como extensão da Web para o seu Browser."
},
"createAccount": {
"message": "Criar ou restaurar conta"
"message": "Criar conta"
},
"importAccount": {
"message": "Importar conta"
Expand Down Expand Up @@ -1455,8 +1455,13 @@
"searchAssets": {
"message": "Procurar ativos..."
},
"searchByName": {
"message": "Procurar por nome..."
"searchAccount": {
"message": "Procurar$hotkey$",
"placeholders": {
"hotkey": {
"content": "$1"
}
}
},
"deployNew": {
"message": "Implantar novo"
Expand Down
11 changes: 8 additions & 3 deletions public/_locales/tr/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"message": "Tarayıcınızda Web Uzantısı olarak Tezos blokzinciri için kripto para cüzdanı."
},
"createAccount": {
"message": "Hesap Oluştur veya Geri Yükle"
"message": "Bir hesap oluşturun"
},
"importAccount": {
"message": "Hesabı içe aktar"
Expand Down Expand Up @@ -1455,8 +1455,13 @@
"searchAssets": {
"message": "Varlıkları ara..."
},
"searchByName": {
"message": "Ada göre ara..."
"searchAccount": {
"message": "Aramak$hotkey$",
"placeholders": {
"hotkey": {
"content": "$1"
}
}
},
"deployNew": {
"message": "Yeni dağıt"
Expand Down
2 changes: 1 addition & 1 deletion public/_locales/uk/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"message": "🔐💰Криптовалютний гаманець для блокчейну Тезос як Розширення для твого браузеру"
},
"createAccount": {
"message": "Створити або відновити аккаунт"
"message": "Створити аккаунт"
},
"importAccount": {
"message": "Імпортувати аккаунт"
Expand Down
2 changes: 1 addition & 1 deletion public/_locales/zh_CN/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"message": "导入账户"
},
"createAccount": {
"message": "创建或恢复帐户"
"message": "创建一个帐户"
},
"faucetFileTitle": {
"message": "Faucet文件"
Expand Down
2 changes: 1 addition & 1 deletion public/_locales/zh_TW/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"message": "匯入帳戶"
},
"createAccount": {
"message": "創建或恢復帳戶"
"message": "建立一個帳戶"
},
"faucetFileTitle": {
"message": "水龍頭檔案"
Expand Down
2 changes: 1 addition & 1 deletion src/app/atoms/AccountTypeBadge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const AccountTypeBadge = memo<AccountTypeBadgeProps>(({ account, darkTheme = fal
return title ? (
<span
className={clsx(
'rounded border border-opacity-25 px-1 py-px ml-2 leading-tight text-opacity-50',
'rounded border border-opacity-25 px-1 py-px ml-2 leading-tight font-medium text-opacity-50',
darkTheme ? 'border-white text-white' : 'border-black text-black'
)}
style={{ fontSize: '0.6rem' }}
Expand Down
18 changes: 18 additions & 0 deletions src/app/hooks/use-current-os.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { useEffect, useState } from 'react';

import browser from 'webextension-polyfill';

export const useCurrentOs = () => {
const [currentOs, setCurrentOs] = useState('');

const getCurrentOs = async () => {
const { os } = await browser.runtime.getPlatformInfo();
setCurrentOs(os);
};

useEffect(() => {
getCurrentOs();
}, []);

return currentOs;
};
5 changes: 5 additions & 0 deletions src/app/icons/sad-search.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const AccountItem: React.FC<AccountItemProps> = ({ account, selected, gas
'text-white text-shadow-black overflow-hidden',
'transition ease-in-out duration-200',
selected && 'shadow',
selected ? 'bg-gray-700 bg-opacity-40' : 'hover:bg-white hover:bg-opacity-5',
selected ? 'bg-gray-700 bg-opacity-40' : 'hover:bg-gray-700 hover:bg-opacity-20',
!selected && 'opacity-65 hover:opacity-100'
),
[selected]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@ export const ActionButton: React.FC<ActionButtonProps> = ({ Icon, linkTo, onClic
className: classNames(
'block w-full flex items-center px-2 whitespace-nowrap overflow-hidden',
'rounded text-white text-shadow-black text-sm',
'hover:bg-white hover:bg-opacity-10',
'hover:bg-gray-700 hover:bg-opacity-30',
'transition ease-in-out duration-200'
),
style: {
paddingTop: '0.375rem',
paddingBottom: '0.375rem'
paddingTop: '0.5rem',
paddingBottom: '0.5rem'
},
onClick,
children: (
<>
<div className="flex items-center w-8">
<Icon className="w-auto h-6 stroke-current" />
<div className="flex items-center w-6">
<Icon className="w-auto h-4 stroke-current" />
</div>

<T id={i18nKey} />
Expand Down
68 changes: 33 additions & 35 deletions src/app/layouts/PageLayout/Header/AccountDropdown/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ import classNames from 'clsx';
import { Button } from 'app/atoms/Button';
import DropdownWrapper from 'app/atoms/DropdownWrapper';
import { openInFullPage, useAppEnv } from 'app/env';
import { useCurrentOs } from 'app/hooks/use-current-os';
import { ReactComponent as AddIcon } from 'app/icons/add.svg';
import { ReactComponent as DAppsIcon } from 'app/icons/apps-alt.svg';
import { ReactComponent as DownloadIcon } from 'app/icons/download.svg';
import { ReactComponent as LinkIcon } from 'app/icons/link.svg';
import { ReactComponent as LockIcon } from 'app/icons/lock.svg';
import { ReactComponent as MaximiseIcon } from 'app/icons/maximise.svg';
import { ReactComponent as SadSearchIcon } from 'app/icons/sad-search.svg';
import { ReactComponent as SettingsIcon } from 'app/icons/settings.svg';
import SearchField from 'app/templates/SearchField';
import { T, t } from 'lib/i18n';
Expand All @@ -22,6 +24,8 @@ import { AccountItem } from './AccountItem';
import { ActionButtonProps, ActionButton } from './ActionButton';
import { AccountDropdownSelectors } from './selectors';

const COLOR_GRAY_600 = '#718096';

type AccountDropdownProps = PopperRenderProps;

interface TDropdownAction extends ActionButtonProps {
Expand All @@ -35,12 +39,11 @@ const AccountDropdown: FC<AccountDropdownProps> = ({ opened, setOpened }) => {
const account = useAccount();
const setAccountPkh = useSetAccountPkh();
const { assetName: gasTokenName } = useGasToken();
const os = useCurrentOs();
lendihop marked this conversation as resolved.
Show resolved Hide resolved

const [searchValue, setSearchValue] = useState('');
const [attractSelectedAccount, setAttractSelectedAccount] = useState(true);

const isShowSearch = useMemo(() => allAccounts.length > 5, [allAccounts.length]);

const filteredAccounts = useMemo(() => {
if (searchValue.length === 0) {
return allAccounts;
Expand Down Expand Up @@ -134,9 +137,11 @@ const AccountDropdown: FC<AccountDropdownProps> = ({ opened, setOpened }) => {
[appEnv.fullPage, closeDropdown, handleMaximiseViewClick]
);

const searchHotkey = useMemo(() => ` (${os === 'mac' ? '⌘' : 'Ctrl + '}K)`, [os]);

useEffect(() => {
if (searchValue) setAttractSelectedAccount(false);
else if (opened === false) setAttractSelectedAccount(true);
else if (!opened) setAttractSelectedAccount(true);
}, [opened, searchValue]);

return (
Expand All @@ -158,11 +163,11 @@ const AccountDropdown: FC<AccountDropdownProps> = ({ opened, setOpened }) => {

<Button
className={classNames(
'px-2 py-1',
'px-2 py-0.5',
'rounded-md',
'border border-gray-700',
'border border-gray-200',
'flex items-center',
'text-white text-shadow-black',
'text-gray-200',
'text-sm',
'transition duration-300 ease-in-out',
'opacity-20',
Expand All @@ -177,39 +182,32 @@ const AccountDropdown: FC<AccountDropdownProps> = ({ opened, setOpened }) => {
</div>

<div className="my-2">
{isShowSearch && (
<SearchField
value={searchValue}
className={classNames(
'py-2 pl-8 pr-4',
'bg-transparent',
'border border-white border-opacity-10',
'focus:outline-none',
'transition ease-in-out duration-200',
'rounded-md rounded-b-none',
'text-white text-sm leading-tight'
)}
placeholder={t('searchByName')}
searchIconClassName="h-5 w-auto"
searchIconWrapperClassName="px-2 text-white opacity-75"
cleanButtonStyle={{ backgroundColor: 'transparent' }}
cleanButtonIconStyle={{ stroke: 'white' }}
onValueChange={setSearchValue}
/>
)}

<div
<SearchField
value={searchValue}
className={classNames(
'overflow-y-auto rounded border border-gray-700 shadow-inner',
isShowSearch && 'border-t-0 rounded-t-none'
'py-2 pl-8 pr-4',
'bg-transparent',
'border border-gray-200 border-opacity-20',
'focus:outline-none',
'transition ease-in-out duration-200',
'rounded-md rounded-b-none',
'text-gray-500 placeholder-gray-600 text-sm leading-tight'
)}
style={{ maxHeight: isShowSearch ? '12rem' : '14.25rem' }}
>
placeholder={t('searchAccount', [searchHotkey])}
searchIconClassName="h-5 w-auto"
searchIconWrapperClassName="px-2"
cleanButtonStyle={{ backgroundColor: 'transparent', borderColor: COLOR_GRAY_600 }}
cleanButtonIconStyle={{ stroke: COLOR_GRAY_600 }}
searchIconStyle={{ stroke: COLOR_GRAY_600 }}
onValueChange={setSearchValue}
lendihop marked this conversation as resolved.
Show resolved Hide resolved
/>

<div className="overflow-y-auto rounded border border-gray-200 border-opacity-20 shadow-inner border-t-0 rounded-t-none h-48">
<div className="flex flex-col">
{filteredAccounts.length === 0 ? (
<p className="text-center text-white text-sm p-10">
<T id="noResults" />
</p>
<div className="h-48 flex justify-center items-center">
<SadSearchIcon />
</div>
) : (
filteredAccounts.map(acc => (
<AccountItem
Expand Down
7 changes: 6 additions & 1 deletion src/app/templates/SearchField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ export interface SearchFieldProps extends InputHTMLAttributes<HTMLInputElement>,
containerClassName?: string;
searchIconClassName?: string;
searchIconWrapperClassName?: string;
cleanButtonClassName?: string;
searchIconStyle?: React.CSSProperties;
cleanButtonStyle?: React.CSSProperties;
cleanButtonIconStyle?: React.CSSProperties;
value: string;
Expand All @@ -25,6 +27,8 @@ const SearchField: FC<SearchFieldProps> = ({
onValueChange,
searchIconClassName,
searchIconWrapperClassName,
cleanButtonClassName,
searchIconStyle,
cleanButtonStyle,
cleanButtonIconStyle,
testID,
Expand Down Expand Up @@ -61,12 +65,13 @@ const SearchField: FC<SearchFieldProps> = ({
searchIconWrapperClassName
)}
>
<SearchIcon className={classNames('stroke-current', searchIconClassName)} />
<SearchIcon style={searchIconStyle} className={classNames('stroke-current', searchIconClassName)} />
</div>

{Boolean(value) && (
<CleanButton
bottomOffset={bottomOffset}
className={cleanButtonClassName}
style={cleanButtonStyle}
iconStyle={cleanButtonIconStyle}
onClick={handleClean}
Expand Down
2 changes: 1 addition & 1 deletion tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ module.exports = {
inset: {
'2px': '2px',
'1/2': '50%',
18: '4.5rem',
18: '4.5rem'
},
space: (theme, { negative }) => ({
...theme('spacing'),
Expand Down
Loading