Skip to content

Commit

Permalink
fix: fix UI issues (#1037)
Browse files Browse the repository at this point in the history
* fix UI issues

* remove unused import

---------

Co-authored-by: Vynnyk Dmytro <[email protected]>
  • Loading branch information
ost-ptk and Comp0te authored Aug 18, 2024
1 parent 84b6721 commit b055bfe
Show file tree
Hide file tree
Showing 11 changed files with 68 additions and 52 deletions.
1 change: 0 additions & 1 deletion src/apps/onboarding/pages/unlock-wallet/content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ export function UnlockWalletPageContent({
validationType={InputValidationType.Password}
type={passwordInputType}
placeholder={t('Password')}
oneColoredIcons
autoFocus
suffixIcon={
<PasswordVisibilityIcon
Expand Down
5 changes: 4 additions & 1 deletion src/libs/layout/unlock-vault/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,10 @@ export const UnlockVaultPage = ({ popupLayout }: UnlockVaultPageProps) => {

const footer = (
<FooterButtonsContainer>
<Button type="submit" disabled={isLoading}>
<Button
type="submit"
style={{ pointerEvents: isLoading ? 'none' : 'auto' }}
>
{isLoading ? (
<AlignedFlexRow gap={SpacingSize.Small}>
<Player
Expand Down
22 changes: 1 addition & 21 deletions src/libs/ui/components/input/input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,7 @@ import { BaseProps } from '@libs/ui/types';
type Ref = HTMLInputElement;

const InputContainer = styled('div')<InputProps>(
({
theme,
oneColoredIcons,
disabled,
error,
monotype,
readOnly,
secondaryBackground
}) => ({
({ theme, disabled, monotype, readOnly, secondaryBackground }) => ({
display: 'flex',
flexDirection: 'row',
justifyContent: 'space-between',
Expand All @@ -34,14 +26,6 @@ const InputContainer = styled('div')<InputProps>(
lineHeight: '2.4rem',
height: '4rem',

path: {
fill: oneColoredIcons
? theme.color.contentDisabled
: error
? theme.color.fillCritical
: ''
},

...((disabled || readOnly) && {
color: theme.color.contentSecondary
})
Expand Down Expand Up @@ -132,8 +116,6 @@ export interface InputProps extends BaseProps {
rightLabel?: string | null;
prefixIcon?: ReactNode | null;
suffixIcon?: ReactNode | null;
// TODO: make a better name 🙈
oneColoredIcons?: boolean;
suffixText?: string | null | ReactNode;

type?: HTMLInputTypeAttribute;
Expand Down Expand Up @@ -163,7 +145,6 @@ export const Input = forwardRef<Ref, InputProps>(function Input(
error,
validationType,
validationText,
oneColoredIcons,
onFocus,
dataTestId,
readOnly,
Expand Down Expand Up @@ -207,7 +188,6 @@ export const Input = forwardRef<Ref, InputProps>(function Input(
monotype={monotype}
error={error}
height={height}
oneColoredIcons={oneColoredIcons}
secondaryBackground={secondaryBackground}
>
{prefixIcon && <PrefixContainer>{prefixIcon}</PrefixContainer>}
Expand Down
2 changes: 0 additions & 2 deletions src/libs/ui/components/password-inputs/password-inputs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ export const PasswordInputs = ({
validationType={InputValidationType.Password}
type={passwordInputType}
placeholder={t('Password')}
oneColoredIcons
suffixIcon={
<PasswordVisibilityIcon
passwordInputType={passwordInputType}
Expand All @@ -79,7 +78,6 @@ export const PasswordInputs = ({
<Input
type={confirmPasswordInputType}
placeholder={t('Confirm password')}
oneColoredIcons
suffixIcon={
<PasswordVisibilityIcon
passwordInputType={confirmPasswordInputType}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export function PasswordVisibilityIcon({
? 'assets/icons/hide.svg'
: 'assets/icons/show.svg'
}
color="contentDisabled"
size={20}
/>
);
Expand Down
4 changes: 2 additions & 2 deletions src/libs/ui/components/recipient-plate/recipient-plate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const RecipientPlate = ({
gap={SpacingSize.Medium}
onClick={handleClick}
>
<Avatar publicKey={publicKey} size={24} />
<Avatar publicKey={publicKey} size={24} borderRadius={2} />
<LeftAlignedFlexColumn>
<Hash
value={publicKey}
Expand All @@ -78,7 +78,7 @@ export const RecipientPlate = ({

return (
<Container gap={SpacingSize.Medium} onClick={handleClick}>
<Avatar publicKey={publicKey} size={24} />
<Avatar publicKey={publicKey} size={24} borderRadius={2} />
<LeftAlignedFlexColumn>
<Hash
value={publicKey}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
import React, { useEffect, useState } from 'react';
import { useSelector } from 'react-redux';
import styled from 'styled-components';

import { selectAllContacts } from '@background/redux/contacts/selectors';
import { ContactWithId } from '@background/redux/contacts/types';
import { selectVaultActiveAccount } from '@background/redux/vault/selectors';

import { SpacingSize, TileContainer } from '@libs/layout';
import { SpacingSize } from '@libs/layout';
import { List, RecipientPlate, Tile, Typography } from '@libs/ui/components';

interface ContactsListProps {
handleSelectRecipient: (publicKey: string, name: string) => void;
}

const Container = styled.div`
padding: 16px;
`;

export const ContactsList = ({ handleSelectRecipient }: ContactsListProps) => {
const [contactsWithId, setContactsWithId] = useState<ContactWithId[]>([]);

Expand All @@ -32,11 +37,11 @@ export const ContactsList = ({ handleSelectRecipient }: ContactsListProps) => {
if (contactsWithId.length === 0) {
return (
<Tile>
<TileContainer top={SpacingSize.None}>
<Container>
<Typography type="body" color="contentPrimary" textAlign="center">
No contacts found
</Typography>
</TileContainer>
</Container>
</Tile>
);
}
Expand Down
13 changes: 9 additions & 4 deletions src/libs/ui/components/recipient-tabs/components/recent-list.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import React, { useEffect, useState } from 'react';
import { useSelector } from 'react-redux';
import styled from 'styled-components';

import { selectAllContacts } from '@background/redux/contacts/selectors';
import { selectRecentRecipientPublicKeys } from '@background/redux/recent-recipient-public-keys/selectors';
import { selectVaultActiveAccount } from '@background/redux/vault/selectors';

import { SpacingSize, TileContainer } from '@libs/layout';
import { SpacingSize } from '@libs/layout';
import { List, RecipientPlate, Tile, Typography } from '@libs/ui/components';

interface MyAccountsListProps {
Expand All @@ -18,6 +19,10 @@ interface RecentListState {
name: string;
}

const Container = styled.div`
padding: 16px;
`;

export const RecentList = ({ handleSelectRecipient }: MyAccountsListProps) => {
const [accountsWithIds, setAccountsWithIds] = useState<RecentListState[]>([]);

Expand Down Expand Up @@ -54,11 +59,11 @@ export const RecentList = ({ handleSelectRecipient }: MyAccountsListProps) => {
if (!accountsWithIds.length) {
return (
<Tile>
<TileContainer top={SpacingSize.None}>
<Container>
<Typography type="body" color="contentPrimary" textAlign="center">
No recent recipients were found.
No recent recipients found
</Typography>
</TileContainer>
</Container>
</Tile>
);
}
Expand Down
51 changes: 36 additions & 15 deletions src/libs/ui/components/recipient-tabs/recipient-tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ export const RecipientTabs = ({

const { t } = useTranslation();

const { register, trigger, control, formState, setValue } = recipientForm;
const { register, trigger, control, formState, setValue, clearErrors } =
recipientForm;
const { errors } = formState;
const { onChange } = register('recipientPublicKey');

Expand Down Expand Up @@ -94,7 +95,29 @@ export const RecipientTabs = ({
>
<Input
monotype
prefixIcon={<SvgIcon src="assets/icons/search.svg" size={24} />}
prefixIcon={
<SvgIcon
src="assets/icons/search.svg"
size={24}
color="contentDisabled"
/>
}
suffixIcon={
inputValue && (
<SvgIcon
src="assets/icons/cross.svg"
size={16}
onClick={() => {
setValue('recipientPublicKey', '');
if (setRecipientPublicKey) {
setRecipientPublicKey('');
}
setRecipientName('');
trigger('recipientPublicKey');
}}
/>
)
}
placeholder={t('Public key')}
{...register('recipientPublicKey')}
onChange={e => {
Expand All @@ -107,19 +130,17 @@ export const RecipientTabs = ({
error={!!errors?.recipientPublicKey}
validationText={errors?.recipientPublicKey?.message}
/>
<VerticalSpaceContainer top={SpacingSize.Tiny}>
<Tabs>
<Tab tabName={RecipientTabName.Recent}>
<RecentList handleSelectRecipient={handleSelectRecipient} />
</Tab>
<Tab tabName={RecipientTabName.MyAccounts}>
<MyAccountsList handleSelectRecipient={handleSelectRecipient} />
</Tab>
<Tab tabName={RecipientTabName.Contacts}>
<ContactsList handleSelectRecipient={handleSelectRecipient} />
</Tab>
</Tabs>
</VerticalSpaceContainer>
<Tabs onClick={inputValue ? undefined : clearErrors}>
<Tab tabName={RecipientTabName.Recent}>
<RecentList handleSelectRecipient={handleSelectRecipient} />
</Tab>
<Tab tabName={RecipientTabName.MyAccounts}>
<MyAccountsList handleSelectRecipient={handleSelectRecipient} />
</Tab>
<Tab tabName={RecipientTabName.Contacts}>
<ContactsList handleSelectRecipient={handleSelectRecipient} />
</Tab>
</Tabs>
</VerticalSpaceContainer>
);
};
6 changes: 5 additions & 1 deletion src/libs/ui/components/tabs/tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,10 @@ interface TabProps {
interface TabsProps {
children: React.ReactElement<TabProps>[];
preferActiveTabId?: number;
onClick?: () => void;
}

export function Tabs({ children, preferActiveTabId }: TabsProps) {
export function Tabs({ children, preferActiveTabId, onClick }: TabsProps) {
// set preferActiveTabId as the default value if it is provided. We do not need to track props change, so we can set it directly in useState
const [activeTabId, setActiveTabId] = useState(preferActiveTabId || 0);

Expand All @@ -77,6 +78,9 @@ export function Tabs({ children, preferActiveTabId }: TabsProps) {
<TabContainer
onClick={() => {
setActiveTabId(index);
if (onClick) {
onClick();
}
}}
key={tabName}
>
Expand Down
4 changes: 2 additions & 2 deletions src/libs/ui/forms/transfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ export const useTransferRecipientForm = () => {
});

const recipientFormOptions: UseFormProps<TransferRecipientFormValues> = {
reValidateMode: 'onBlur',
mode: 'onBlur',
reValidateMode: 'onChange',
mode: 'onChange',
resolver: yupResolver(recipientFormSchema),
delayError: 500
};
Expand Down

0 comments on commit b055bfe

Please sign in to comment.