Skip to content

Commit

Permalink
feat: redesign modals, login and profile btn, add btn colors variants
Browse files Browse the repository at this point in the history
  • Loading branch information
TomatoVan committed Apr 26, 2024
1 parent c56a8c0 commit 431ccef
Show file tree
Hide file tree
Showing 16 changed files with 101 additions and 95 deletions.
56 changes: 28 additions & 28 deletions extractedTranslations/en/profile.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
{
"": "",
"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": "",
"Попробуйте обновить страницу": "",
"Произошла ошибка при загрузке профиля": ""
"": "",
"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": "",
"Попробуйте обновить страницу": "",
"Произошла ошибка при загрузке профиля": ""
}
4 changes: 2 additions & 2 deletions json-server/db.json
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,7 @@
},
"avatar": "https://mobimg.b-cdn.net/v3/fetch/22/2207633df03a819cd72889249c8361a8.jpeg?w=1470&r=0.5625",
"jsonSettings": {
"theme": "app_dark_theme",
"theme": "app_light_theme",
"isFirstVisit": true,
"settingsPageHasBeenOpen": false,
"isArticlesPageWasOpened": true
Expand Down Expand Up @@ -817,7 +817,7 @@
"profile": [
{
"id": "1",
"first": "timurasdasd",
"first": "leotestt",
"lastname": "ulbi",
"age": 465,
"currency": "RUB",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export const ArticleListItem = memo((props: ArticleListItemProps) => {
cls[view],
])}
>
<Card className={cls.card} border="round" padding="0">
<Card className={cls.card} border="partial" padding="0">
<AppImage
alt={article.title}
src={article.img}
Expand Down
2 changes: 1 addition & 1 deletion src/entities/Comment/ui/CommentCard/CommentCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const CommentCard = memo(
}

return (
<Card padding="24" max>
<Card border="partial" padding="24" max>
<VStack
data-testid="CommentCard.Content"
max
Expand Down
3 changes: 2 additions & 1 deletion src/entities/Profile/ui/ProfileCard/ProfileCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const ProfileCard = (props: ProfileCardProps) => {

if (isLoading) {
return (
<Card padding="24" max>
<Card border="partial" padding="24" max>
<VStack gap="32">
<HStack max justify="center">
<Skeleton border="100%" width={128} height={128} />
Expand Down Expand Up @@ -89,6 +89,7 @@ export const ProfileCard = (props: ProfileCardProps) => {

return (
<Card
border="partial"
padding="24"
max
className={classNames(cls.ProfileCardRedesigned, {}, [className])}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const ArticleViewSelector = memo((props: ArticleViewSelectorProps) => {
className={classNames(cls.ArticleViewSelectorRedesigned, {}, [
className,
])}
border="round"
border="partial"
>
<HStack gap="8">
{viewTypes.map((viewType) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const AddCommentForm = memo((props: AddCommentFormProps) => {

return (
<DynamicModuleLoader reducers={reducers}>
<Card padding="24" border="round" max>
<Card padding="24" border="partial" max>
<HStack
data-testid="AddCommentForm"
justify="between"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export const EditableProfileCard = memo((props: EditableProfileCardProps) => {

return (
<DynamicModuleLoader reducers={reducers}>
<VStack max gap="8" className={classNames('', {}, [className])}>
<VStack max gap="16" className={classNames('', {}, [className])}>
<EditableProfileCardHeader />
{validateErrors?.length &&
validateErrors.map((err) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ import { useTranslation } from 'react-i18next';
import { memo, useCallback } from 'react';
import { useSelector } from 'react-redux';
import { HStack } from '@/shared/ui/redesigned/Stack';
import { Button, ButtonTheme } from '@/shared/ui/deprecated/Button';
import { Text } from '@/shared/ui/deprecated/Text';
import { Button } from '@/shared/ui/redesigned/Button';
import { Text } from '@/shared/ui/redesigned/Text';
import { classNames } from '@/shared/lib/classNames/classNames';
import { useAppDispatch } from '@/shared/lib/hook/useAppDispatch/useAppDispatch';
import { getUserAuthData } from '../../../../entities/User';
import { profileActions } from '../../model/slice/profileSlice';
import { getProfileData } from '../../model/selectors/getProfileData/getProfileData';
import { getProfileReadonly } from '../../model/selectors/getProfileReadonly/getProfileReadonly';
import { updateProfileData } from '../../model/services/updateProfileData/updateProfileData';
import { Card } from '@/shared/ui/redesigned/Card';

interface EditableProfileCardHeaderProps {
className?: string;
Expand Down Expand Up @@ -40,43 +41,44 @@ export const EditableProfileCardHeader = memo(
}, [dispatch]);

return (
<HStack
max
justify="between"
className={classNames('', {}, [className])}
>
<Text title={t('Profile')} />
{canEdit && (
<>
{readonly ? (
<Button
theme={ButtonTheme.OUTLINE}
onClick={onEdit}
data-testid="EditableProfileCardHeader.EditButton"
>
{t('Edit')}
</Button>
) : (
<HStack gap="8">
<Card border="partial" padding="24" max>
<HStack
max
justify="between"
className={classNames('', {}, [className])}
>
<Text title={t('Profile')} />
{canEdit && (
<>
{readonly ? (
<Button
theme={ButtonTheme.OUTLINE_RED}
onClick={onCancelEdit}
data-testid="EditableProfileCardHeader.CancelButton"
onClick={onEdit}
data-testid="EditableProfileCardHeader.EditButton"
>
{t('Cancel')}
{t('Edit')}
</Button>
<Button
theme={ButtonTheme.OUTLINE}
onClick={onSave}
data-testid="EditableProfileCardHeader.SaveButton"
>
{t('Save')}
</Button>
</HStack>
)}
</>
)}
</HStack>
) : (
<HStack gap="8">
<Button
color="error"
onClick={onCancelEdit}
data-testid="EditableProfileCardHeader.CancelButton"
>
{t('Cancel')}
</Button>
<Button
color="success"
onClick={onSave}
data-testid="EditableProfileCardHeader.SaveButton"
>
{t('Save')}
</Button>
</HStack>
)}
</>
)}
</HStack>
</Card>
);
},
);
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const AdditionalInfoContainer = memo(() => {
}

return (
<Card padding="24" border="round" className={cls.card}>
<Card padding="24" border="partial" className={cls.card}>
<ArticleAdditionalInfo
onEdit={onEditArticle}
author={article.user}
Expand Down
14 changes: 12 additions & 2 deletions src/shared/ui/redesigned/Button/Button.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,23 @@

.outline {
background: none;
border: 2px solid var(--icon-redesigned);
border-radius: 34px;

&:hover {
border: 2px solid var(--accent-redesigned);
}

&.normal {
border: 2px solid var(--icon-redesigned);
}

&.error {
border: 2px solid var(--cancel-redesigned);
}

&.success {
border: 2px solid var(--save-redesigned);
}
}

.square {
Expand Down Expand Up @@ -86,7 +97,6 @@

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

.fullWidth {
Expand Down
6 changes: 5 additions & 1 deletion src/shared/ui/redesigned/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { classNames, Mods } from '@/shared/lib/classNames/classNames';
import cls from './Button.module.scss';

export type ButtonVariant = 'clear' | 'outline' | 'filled';
export type ButtonColor = 'normal' | 'success' | 'error';

export type ButtonSize = 'm' | 'l' | 'xl';

Expand All @@ -16,6 +17,7 @@ interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
fullWidth?: boolean;
addonLeft?: ReactNode;
addonRight?: ReactNode;
color?: ButtonColor;
}

export const Button = memo((props: ButtonProps) => {
Expand All @@ -29,6 +31,8 @@ export const Button = memo((props: ButtonProps) => {
fullWidth,
addonLeft,
addonRight,
color = 'normal',

...otherProps
} = props;

Expand All @@ -41,7 +45,7 @@ export const Button = memo((props: ButtonProps) => {
[cls.withAddon]: Boolean(addonLeft) || Boolean(addonRight),
};

const additional = [className, cls[variant], cls[size]];
const additional = [className, cls[variant], cls[size], cls[color]];

return (
<button
Expand Down
4 changes: 4 additions & 0 deletions src/shared/ui/redesigned/Card/Card.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
border-radius: 12px;
}

.partial {
border-radius: 20px;
}

.round {
border-radius: 40px;
}
Expand Down
2 changes: 1 addition & 1 deletion src/shared/ui/redesigned/Card/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import cls from './Card.module.scss';

export type CardVariant = 'normal' | 'outlined' | 'light';
export type CardPadding = '0' | '8' | '16' | '24';
export type CardBorder = 'normal' | 'round';
export type CardBorder = 'normal' | 'partial' | 'round';

interface CardProps extends HTMLAttributes<HTMLDivElement> {
className?: string;
Expand Down
9 changes: 0 additions & 9 deletions src/widgets/Navbar/ui/Navbar.module.scss
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
.Navbar {
width: 100%;
height: var(--navbar-height);
background: var(--inverted-bg-color);
display: flex;
align-items: center;
padding: 20px;
}

.NavbarRedesigned {
padding: 16px;
}

Expand Down
12 changes: 3 additions & 9 deletions src/widgets/Navbar/ui/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { memo, useCallback, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useSelector } from 'react-redux';
import { HStack } from '@/shared/ui/redesigned/Stack';
import { Button, ButtonTheme } from '@/shared/ui/deprecated/Button';
import { Button } from '@/shared/ui/redesigned/Button';
import { classNames } from '@/shared/lib/classNames/classNames';
import { LoginModal } from '@/features/AuthByUsername';
import { NotificationButton } from '@/features/notificationButton';
Expand All @@ -29,9 +29,7 @@ export const Navbar = memo(({ className }: NavbarProps) => {

if (authData) {
return (
<header
className={classNames(cls.NavbarRedesigned, {}, [className])}
>
<header className={classNames(cls.Navbar, {}, [className])}>
<HStack gap="16" className={cls.actions}>
<NotificationButton />
<AvatarDropDown />
Expand All @@ -42,11 +40,7 @@ export const Navbar = memo(({ className }: NavbarProps) => {

return (
<header className={classNames(cls.Navbar, {}, [className])}>
<Button
theme={ButtonTheme.CLEAR_INVERTED}
className={cls.links}
onClick={onShowModal}
>
<Button variant="clear" className={cls.links} onClick={onShowModal}>
{t('login')}
</Button>
{isAuthModal && (
Expand Down

0 comments on commit 431ccef

Please sign in to comment.