Skip to content

Commit

Permalink
feat: redesign profile card (form), input
Browse files Browse the repository at this point in the history
  • Loading branch information
TomatoVan committed Apr 23, 2024
1 parent a8969f5 commit 808b8d4
Show file tree
Hide file tree
Showing 12 changed files with 191 additions and 121 deletions.
47 changes: 28 additions & 19 deletions extractedTranslations/en/profile.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,30 @@
{
"": "",
"Edit": "",
"Error": "",
"Error with getting profile data": "",
"Error with profile ": "",
"Incorrect age": "",
"Incorrect country": "",
"Incorrect user data": "",
"No data": "",
"Profile": "",
"Server error": "",
"Try to reload page": "",
"Your age": "",
"Your avatar": "",
"Your city": "",
"Your lastname": "",
"Your name": "",
"Your surname": "",
"Your username": ""
"": "",
"Age": "",
"Avatar": "",
"City": "",
"Edit": "",
"Error": "",
"Error with getting profile data": "",
"Error with profile ": "",
"Incorrect age": "",
"Incorrect country": "",
"Incorrect user data": "",
"Lastname": "",
"Name": "",
"No data": "",
"Profile": "",
"Server error": "",
"Try to reload page": "",
"Username": "",
"Username>": "",
"Your age": "",
"Your avatar": "",
"Your city": "",
"Your lastname": "",
"Your name": "",
"Your surname": "",
"Your username": "",
"Попробуйте обновить страницу": "",
"Произошла ошибка при загрузке профиля": ""
}
3 changes: 3 additions & 0 deletions extractedTranslations/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"Ascending": "",
"Back to list": "",
"Cancel": "",
"Choose ": "",
"Choose country": "",
"Choose currency": "",
"Comments": "",
Expand Down Expand Up @@ -93,7 +94,9 @@
"Отправить": "",
"Оценка статей скоро появится!": "",
"Поиск": "",
"Попробуйте обновить страницу": "",
"Произошла непредвиденная ошибка": "",
"Произошла ошибка при загрузке профиля": "",
"Сортировать ПО": "",
"Статьи не найдены": "",
"Экономика": "",
Expand Down
2 changes: 1 addition & 1 deletion src/entities/Country/ui/CountrySelect/CountrySelect.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useTranslation } from 'react-i18next';
import { memo, useCallback } from 'react';
import { ListBox } from '@/shared/ui/deprecated/Popups';
import { ListBox } from '@/shared/ui/redesigned/Popups';
import { Country } from '../../model/types/country';

interface CountrySelectProps {
Expand Down
2 changes: 1 addition & 1 deletion src/entities/Currency/ui/CurrencySelect/CurrencySelect.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useTranslation } from 'react-i18next';
import { memo, useCallback } from 'react';
import { ListBox } from '@/shared/ui/deprecated/Popups';
import { ListBox } from '@/shared/ui/redesigned/Popups';
import { Currency } from '../../model/types/currency';

interface CurrencySelectProps {
Expand Down
201 changes: 108 additions & 93 deletions src/entities/Profile/ui/ProfileCard/ProfileCard.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import { useTranslation } from 'react-i18next';
import { HStack, VStack } from '@/shared/ui/redesigned/Stack';
import { Avatar } from '@/shared/ui/deprecated/Avatar';
import { Text, TextAlign, TextTheme } from '@/shared/ui/deprecated/Text';
import { classNames, Mods } from '@/shared/lib/classNames/classNames';

import { classNames } from '@/shared/lib/classNames/classNames';
import { Country, CountrySelect } from '../../../Country';
import { Currency, CurrencySelect } from '../../../Currency';
import { Profile } from '../../model/types/profile';
import cls from './ProfileCard.module.scss';
import { Loader } from '@/shared/ui/deprecated/Loader';
import { Input } from '@/shared/ui/deprecated/Input';
import { Input } from '@/shared/ui/redesigned/Input';
import { Card } from '@/shared/ui/redesigned/Card';
import { Avatar } from '@/shared/ui/redesigned/Avatar';
import { Text } from '@/shared/ui/redesigned/Text';
import { Skeleton } from '@/shared/ui/redesigned/Skeleton';

interface ProfileCardProps {
className?: string;
Expand Down Expand Up @@ -47,110 +49,123 @@ export const ProfileCard = (props: ProfileCardProps) => {

if (isLoading) {
return (
<HStack
justify="center"
max
className={classNames(cls.ProfileCard, {}, [
className,
cls.loading,
])}
>
<Loader />
</HStack>
<Card padding="24" max>
<VStack gap="32">
<HStack max justify="center">
<Skeleton border="100%" width={128} height={128} />
</HStack>
<HStack gap="32" max>
<VStack gap="16" max>
<Skeleton width="100%" height={38} />
<Skeleton width="100%" height={38} />
<Skeleton width="100%" height={38} />
<Skeleton width="100%" height={38} />
</VStack>

<VStack gap="16" max>
<Skeleton width="100%" height={38} />
<Skeleton width="100%" height={38} />
<Skeleton width="100%" height={38} />
<Skeleton width="100%" height={38} />
</VStack>
</HStack>
</VStack>
</Card>
);
}

if (error) {
return (
<HStack
justify="center"
max
className={classNames(cls.ProfileCard, {}, [
className,
cls.error,
])}
>
<HStack justify="center" max>
<Text
theme={TextTheme.ERROR}
variant="error"
title={t('Error with getting profile data')}
text={t('Try to reload page')}
align={TextAlign.CENTER}
align="center"
/>
</HStack>
);
}

const mods: Mods = {
[cls.editing]: !readonly,
};

return (
<VStack
<Card
padding="24"
max
gap="16"
className={classNames(cls.ProfileCard, mods, [className])}
className={classNames(cls.ProfileCardRedesigned, {}, [className])}
>
{data?.avatar && (
<HStack justify="center" className={cls.avatarWrapper}>
<Avatar src={data?.avatar} alt="avatar img" />
<VStack gap="32" align="center">
{data?.avatar && (
<HStack justify="center" className={cls.avatarWrapper}>
<Avatar
size={128}
src={data?.avatar}
alt="avatar img"
/>
</HStack>
)}
<HStack gap="24" max>
<VStack gap="16" max>
<Input
value={data?.first}
label={`${t('Name')}:`}
className={cls.input}
onChange={onChangeFirstName}
readonly={readonly}
data-testid="ProfileCard.firstname"
/>
<Input
value={data?.lastname}
label={`${t('Lastname')}:`}
className={cls.input}
onChange={onChangeLastName}
readonly={readonly}
data-testid="ProfileCard.lastname"
/>
<Input
value={data?.age}
label={`${t('Age')}:`}
className={cls.input}
onChange={onChangeAge}
readonly={readonly}
/>
<Input
value={data?.city}
label={`${t('City')}:`}
className={cls.input}
onChange={onChangeCity}
readonly={readonly}
/>
</VStack>
<VStack gap="16" max>
<Input
value={data?.avatar}
label={`${t('Avatar')}:`}
className={cls.input}
onChange={onChangeAvatar}
readonly={readonly}
/>
<Input
value={data?.username}
label={`${t('Username')}:`}
className={cls.input}
onChange={onChangeUsername}
readonly={readonly}
/>
<CurrencySelect
className={cls.input}
value={data?.currency}
onChange={onChangeCurrency}
readonly={readonly}
/>
<CountrySelect
className={cls.input}
value={data?.country}
onChange={onChangeCountry}
readonly={readonly}
/>
</VStack>
</HStack>
)}
<Input
value={data?.first}
placeholder={t('Your name')}
className={cls.input}
onChange={onChangeFirstName}
readonly={readonly}
data-testid="ProfileCard.firstname"
/>
<Input
value={data?.lastname}
placeholder={t('Your lastname')}
className={cls.input}
onChange={onChangeLastName}
readonly={readonly}
data-testid="ProfileCard.lastname"
/>
<Input
value={data?.age}
placeholder={t('Your age')}
className={cls.input}
onChange={onChangeAge}
readonly={readonly}
/>
<Input
value={data?.city}
placeholder={t('Your city')}
className={cls.input}
onChange={onChangeCity}
readonly={readonly}
/>
<Input
value={data?.avatar}
placeholder={t('Your avatar')}
className={cls.input}
onChange={onChangeAvatar}
readonly={readonly}
/>
<Input
value={data?.username}
placeholder={t('Your username')}
className={cls.input}
onChange={onChangeUsername}
readonly={readonly}
/>
<CurrencySelect
className={cls.input}
value={data?.currency}
onChange={onChangeCurrency}
readonly={readonly}
/>
<CountrySelect
className={cls.input}
value={data?.country}
onChange={onChangeCountry}
readonly={readonly}
/>
</VStack>
</VStack>
</Card>
);
};
3 changes: 2 additions & 1 deletion src/shared/ui/redesigned/Button/Button.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@
font: var(--font-xl-redesigned);
}

.disabled {
.isDisabled {
opacity: 0.5;
pointer-events: none;
}

.fullWidth {
Expand Down
12 changes: 12 additions & 0 deletions src/shared/ui/redesigned/Input/Input.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@
width: 100%;
}

.s {
height: 32px;
}

.m {
height: 38px;
}

.l {
height: 44px;
}

.addonLeft,
.addonRight {
display: flex;
Expand Down
Loading

0 comments on commit 808b8d4

Please sign in to comment.