Skip to content

Commit

Permalink
feat: redesign rating card, comments, skeletons
Browse files Browse the repository at this point in the history
  • Loading branch information
TomatoVan committed Apr 25, 2024
1 parent 6c86a8c commit c56a8c0
Show file tree
Hide file tree
Showing 18 changed files with 101 additions and 105 deletions.
1 change: 1 addition & 0 deletions extractedTranslations/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"Choose ": "",
"Choose country": "",
"Choose currency": "",
"Close": "",
"Comments": "",
"Comments is loading": "",
"Create new article": "",
Expand Down
8 changes: 7 additions & 1 deletion json-server/db.json
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,12 @@
"userId": "1",
"text": "asfasf",
"id": "SygCNYE"
},
{
"articleId": "1",
"userId": "1",
"text": "some commentsome commentsome commentsome commentsome commentsome commentsome commentsome commentsome commentsome commentsome commentsome commentsome commentsome commentsome commentsome commentsome commentsome commentsome commentsome commentsome commentsome commentsome commentsome commentsome commentsome commentsome commentsome commentsome commentsome commentsome commentsome commentsome comment",
"id": "wIFyEdj"
}
],
"users": [
Expand All @@ -756,7 +762,7 @@
},
"avatar": "https://mobimg.b-cdn.net/v3/fetch/22/2207633df03a819cd72889249c8361a8.jpeg?w=1470&r=0.5625",
"jsonSettings": {
"theme": "app_light_theme",
"theme": "app_dark_theme",
"isFirstVisit": true,
"settingsPageHasBeenOpen": false,
"isArticlesPageWasOpened": true
Expand Down
4 changes: 2 additions & 2 deletions src/entities/Article/ui/ArticleDetails/ArticleDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const ArticleDetails = memo(({ className, id }: ArticleDetailsProps) => {
let content;
if (isLoading) {
content = (
<>
<VStack gap="16" max>
<Skeleton
className={cls.avatar}
width={200}
Expand All @@ -58,7 +58,7 @@ export const ArticleDetails = memo(({ className, id }: ArticleDetailsProps) => {
<Skeleton className={cls.skeleton} width={600} height={24} />
<Skeleton className={cls.skeleton} width="100%" height={200} />
<Skeleton className={cls.skeleton} width="100%" height={200} />
</>
</VStack>
);
} else if (error) {
content = (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
.CommentCard {
padding: 10px;
border: 1px solid var(--primary-color);
}

.header {
Expand Down
56 changes: 26 additions & 30 deletions src/entities/Comment/ui/CommentCard/CommentCard.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { useTranslation } from 'react-i18next';
import { memo } from 'react';
import { VStack } from '@/shared/ui/redesigned/Stack';
import { HStack, VStack } from '@/shared/ui/redesigned/Stack';
import { AppLink } from '@/shared/ui/deprecated/AppLink';
import { classNames } from '@/shared/lib/classNames/classNames';
import cls from './CommentCard.module.scss';
import { Comment } from '../../model/types/comment';
import { Avatar } from '@/shared/ui/deprecated/Avatar/Avatar';
import { Text } from '@/shared/ui/deprecated/Text/Text';
import { Skeleton } from '@/shared/ui/deprecated/Skeleton/Skeleton';
import { Avatar } from '@/shared/ui/redesigned/Avatar';
import { Text } from '@/shared/ui/redesigned/Text';
import { Skeleton } from '@/shared/ui/redesigned/Skeleton';
import { getRouteProfile } from '@/shared/const/router';
import { Card } from '@/shared/ui/redesigned/Card';

interface CommentCardProps {
className?: string;
Expand All @@ -18,8 +18,6 @@ interface CommentCardProps {

export const CommentCard = memo(
({ className, comment, isLoading }: CommentCardProps) => {
const { t } = useTranslation();

if (isLoading) {
return (
<VStack
Expand Down Expand Up @@ -49,30 +47,28 @@ export const CommentCard = memo(
}

return (
<VStack
data-testid="CommentCard.Content"
max
gap="8"
className={classNames(cls.CommentCard, {}, [className])}
>
<AppLink
to={getRouteProfile(comment.user.id)}
className={cls.header}
<Card padding="24" max>
<VStack
data-testid="CommentCard.Content"
max
gap="8"
className={classNames('', {}, [className])}
>
{comment.user.avatar && (
<Avatar
src={comment.user.avatar}
alt={comment.user.username}
size={30}
/>
)}
<Text
className={cls.username}
title={comment.user.username}
/>
</AppLink>
<Text className={cls.text} text={comment.text} />
</VStack>
<AppLink to={getRouteProfile(comment.user.id)}>
<HStack gap="16">
{comment.user.avatar && (
<Avatar
src={comment.user.avatar}
alt={comment.user.username}
size={30}
/>
)}
<Text text={comment.user.username} bold />
</HStack>
</AppLink>
<Text text={comment.text} />
</VStack>
</Card>
);
},
);
2 changes: 1 addition & 1 deletion src/entities/Comment/ui/CommentList/CommentList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useTranslation } from 'react-i18next';
import { memo } from 'react';
import { VStack } from '@/shared/ui/redesigned/Stack';
import { classNames } from '@/shared/lib/classNames/classNames';
import { Text } from '@/shared/ui/deprecated/Text/Text';
import { Text } from '@/shared/ui/redesigned/Text';
import { CommentCard } from '../CommentCard/CommentCard';
import { Comment } from '../../model/types/comment';

Expand Down
22 changes: 9 additions & 13 deletions src/entities/Rating/ui/RatingCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import { useTranslation } from 'react-i18next';
import { memo, useCallback, useState } from 'react';
import { BrowserView, MobileView } from 'react-device-detect';
import { HStack, VStack } from '@/shared/ui/redesigned/Stack';
import { Card } from '@/shared/ui/deprecated/Card';
import { Button, ButtonSize, ButtonTheme } from '@/shared/ui/deprecated/Button';
import { Text } from '@/shared/ui/deprecated/Text';
import { Card } from '@/shared/ui/redesigned/Card';
import { Button } from '@/shared/ui/redesigned/Button';
import { Text } from '@/shared/ui/redesigned/Text';
import { classNames } from '@/shared/lib/classNames/classNames';
import { Input } from '@/shared/ui/deprecated/Input';
import { StarRating } from '@/shared/ui/deprecated/StarRating';
import { Input } from '@/shared/ui/redesigned/Input';
import { Modal } from '@/shared/ui/redesigned/Modal';
import { Drawer } from '@/shared/ui/redesigned/Drawer';
import { StarRating } from '@/shared/ui/redesigned/StarRating';

interface RatingCardProps {
className?: string;
Expand Down Expand Up @@ -92,15 +92,15 @@ export const RatingCard = memo((props: RatingCardProps) => {
<Button
data-testid="RatingCard.Close"
onClick={cancelHandle}
theme={ButtonTheme.OUTLINE_RED}
variant="outline"
>
{t('Закрыть')}
{t('Close')}
</Button>
<Button
data-testid="RatingCard.Send"
onClick={acceptHandle}
>
{t('Отправить')}
{t('Send')}
</Button>
</HStack>
</VStack>
Expand All @@ -110,11 +110,7 @@ export const RatingCard = memo((props: RatingCardProps) => {
<Drawer isOpen={isModalOpen} lazy onClose={cancelHandle}>
<VStack gap="32">
{modalContent}
<Button
fullWidth
onClick={acceptHandle}
size={ButtonSize.L}
>
<Button fullWidth onClick={acceptHandle} size="l">
{t('Send')}
</Button>
</VStack>
Expand Down

This file was deleted.

49 changes: 26 additions & 23 deletions src/features/addCommentForm/ui/AddCommentForm/AddCommentForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ 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 { Button } from '@/shared/ui/redesigned/Button';
import { classNames } from '@/shared/lib/classNames/classNames';
import { useAppDispatch } from '@/shared/lib/hook/useAppDispatch/useAppDispatch';
import {
Expand All @@ -17,8 +17,8 @@ import {
getAddCommentFormError,
getAddCommentFormText,
} from '../../model/selectors/addCommentFormSelectors';
import cls from './AddCommentForm.module.scss';
import { Input } from '@/shared/ui/deprecated/Input';
import { Input } from '@/shared/ui/redesigned/Input';
import { Card } from '@/shared/ui/redesigned/Card';

export interface AddCommentFormProps {
className?: string;
Expand Down Expand Up @@ -51,27 +51,30 @@ const AddCommentForm = memo((props: AddCommentFormProps) => {

return (
<DynamicModuleLoader reducers={reducers}>
<HStack
data-testid="AddCommentForm"
justify="between"
max
className={classNames(cls.AddCommentForm, {}, [className])}
>
<Input
data-testid="AddCommentForm.Input"
value={text}
placeholder={t('Enter comment text')}
className={cls.input}
onChange={onCommentTextChange}
/>
<Button
data-testid="AddCommentForm.Button"
theme={ButtonTheme.OUTLINE}
onClick={onSendHandler}
<Card padding="24" border="round" max>
<HStack
data-testid="AddCommentForm"
justify="between"
max
gap="16"
align="center"
className={classNames('', {}, [className])}
>
{t('Send')}
</Button>
</HStack>
<Input
data-testid="AddCommentForm.Input"
value={text}
placeholder={t('Enter comment text')}
onChange={onCommentTextChange}
/>
<Button
data-testid="AddCommentForm.Button"
variant="outline"
onClick={onSendHandler}
>
{t('Send')}
</Button>
</HStack>
</Card>
</DynamicModuleLoader>
);
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useTranslation } from 'react-i18next';
import { memo, useCallback } from 'react';
import { useSelector } from 'react-redux';
import { Skeleton } from '@/shared/ui/deprecated/Skeleton';
import { Skeleton } from '@/shared/ui/redesigned/Skeleton';
import { RatingCard } from '@/entities/Rating';
import {
useGetArticleRating,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useTranslation } from 'react-i18next';
import { memo } from 'react';
import { VStack } from '@/shared/ui/redesigned/Stack';
import { Text, TextSize } from '@/shared/ui/deprecated/Text';
import { Text } from '@/shared/ui/redesigned/Text';
import { classNames } from '@/shared/lib/classNames/classNames';
import { ArticleList } from '../../../../entities/Article';
import { useArticleRecommendaionsList } from '../../api/ArticleRecommendationsApi';
Expand Down Expand Up @@ -31,7 +31,7 @@ export const ArticleRecommendationsList = memo(
max
className={classNames('', {}, [className])}
>
<Text size={TextSize.L} title={t('Recommend')} />
<Text size="l" title={t('Recommend')} />
<ArticleList articles={articles} target="_blank" />
</VStack>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useTranslation } from 'react-i18next';
import { memo, Suspense, useCallback } from 'react';
import { useSelector } from 'react-redux';
import { Text, TextSize } from '@/shared/ui/deprecated/Text';
import { Text } from '@/shared/ui/redesigned/Text';
import { classNames } from '@/shared/lib/classNames/classNames';
import { AddCommentForm } from '@/features/addCommentForm';
import { useAppDispatch } from '@/shared/lib/hook/useAppDispatch/useAppDispatch';
Expand Down Expand Up @@ -41,7 +41,7 @@ export const ArticleDetailsComments = memo(

return (
<VStack gap="16" max className={classNames('', {}, [className])}>
<Text size={TextSize.L} title={t('Comments')} />
<Text size="l" title={t('Comments')} />
<Suspense fallback={<Loader />}>
<AddCommentForm onSendComment={onSendComment} />
</Suspense>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
} from '@/shared/lib/components/DynamicModuleLoared/DynamicModuleLoared';
import { ArticleRecommendationsList } from '@/features/articleRecommendationsList';
import { ArticleDetailsComments } from '../../ui/ArticleDetailsComments/ArticleDetailsComments';

import { articleDetailsPageReducer } from '../../model/slices';
import { ArticleRating } from '@/features/articleRating';
import { Page } from '@/widgets/Page';
Expand Down
15 changes: 0 additions & 15 deletions src/shared/ui/deprecated/StarRating/StarRating.module.scss

This file was deleted.

21 changes: 21 additions & 0 deletions src/shared/ui/redesigned/StarRating/StarRating.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.StarRating {
.normal {
fill: none;
}

.hovered {
fill: var(--icon-redesigned);
}
}

.normal {
fill: none;
}

.starIcon {
cursor: pointer;
}

.selected {
cursor: auto;
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { memo, useState } from 'react';
import { classNames } from '@/shared/lib/classNames/classNames';
import cls from './StarRating.module.scss';
import { Icon } from '../Icon/Icon';
import StarIcon from '@/shared/assets/icons/star.svg';
import { Icon } from '../Icon';

interface StarRatingProps {
className?: string;
Expand Down Expand Up @@ -38,10 +38,7 @@ export const StarRating = memo((props: StarRatingProps) => {
setIsSelected(true);
}
};
/**
* Устарел, используем новые компоненты из папки redesigned
* @deprecated
*/

return (
<div className={classNames(cls.StarRating, {}, [className])}>
{stars.map((starNumber) => (
Expand All @@ -64,6 +61,7 @@ export const StarRating = memo((props: StarRatingProps) => {
onClick={() => onClick(starNumber)}
data-testid={`StarRating.${starNumber}`}
data-selected={currentStarsCount >= starNumber}
clickable={!isSelected}
/>
))}
</div>
Expand Down

0 comments on commit c56a8c0

Please sign in to comment.