-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: redesign article details, add counts translations
- Loading branch information
Showing
9 changed files
with
135 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
src/pages/ArticlesDetailsPage/ui/AdditionalInfoContainer/AdditionalInfoContainer.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.card { | ||
width: 264px; | ||
} |
35 changes: 35 additions & 0 deletions
35
src/pages/ArticlesDetailsPage/ui/AdditionalInfoContainer/AdditionalInfoContainer.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { memo, useCallback } from 'react'; | ||
import { useSelector } from 'react-redux'; | ||
import { useNavigate } from 'react-router-dom'; | ||
import { Card } from '@/shared/ui/redesigned/Card'; | ||
import { ArticleAdditionalInfo } from '@/widgets/ArticleAdditionalInfo'; | ||
import cls from './AdditionalInfoContainer.module.scss'; | ||
import { getRouteArticleEdit } from '@/shared/const/router'; | ||
import { getArticlesDetailsData } from '@/entities/Article'; | ||
|
||
export const AdditionalInfoContainer = memo(() => { | ||
const article = useSelector(getArticlesDetailsData); | ||
|
||
const navigate = useNavigate(); | ||
|
||
const onEditArticle = useCallback(() => { | ||
if (article) { | ||
navigate(getRouteArticleEdit(article.id)); | ||
} | ||
}, [article, navigate]); | ||
|
||
if (!article) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<Card padding="24" border="round" className={cls.card}> | ||
<ArticleAdditionalInfo | ||
onEdit={onEditArticle} | ||
author={article.user} | ||
createdAt={article.createdAt} | ||
views={article.views} | ||
/> | ||
</Card> | ||
); | ||
}); |
44 changes: 16 additions & 28 deletions
44
src/pages/ArticlesDetailsPage/ui/ArticlesDetailsPage/ArticlesDetailsPage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/pages/ArticlesDetailsPage/ui/DetailsContainer/DetailsContainer.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { memo } from 'react'; | ||
import { useParams } from 'react-router-dom'; | ||
import { ArticleDetails } from '@/entities/Article'; | ||
import { Card } from '@/shared/ui/redesigned/Card'; | ||
|
||
interface DetailsContainerProps { | ||
className?: string; | ||
} | ||
|
||
export const DetailsContainer = memo((props: DetailsContainerProps) => { | ||
const { className } = props; | ||
|
||
const { id } = useParams<{ id: string }>(); | ||
|
||
if (!id) { | ||
return null; | ||
} | ||
return ( | ||
<Card max padding="24" className={className}> | ||
<ArticleDetails id={id} /> | ||
</Card> | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { ArticleAdditionalInfo } from './ui/ArticleAdditionalInfo/ArticleAdditionalInfo'; |
35 changes: 35 additions & 0 deletions
35
src/widgets/ArticleAdditionalInfo/ui/ArticleAdditionalInfo/ArticleAdditionalInfo.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { memo } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { classNames } from '@/shared/lib/classNames/classNames'; | ||
import { User } from '@/entities/User'; | ||
import { HStack, VStack } from '@/shared/ui/redesigned/Stack'; | ||
import { Avatar } from '@/shared/ui/redesigned/Avatar'; | ||
import { Text } from '@/shared/ui/redesigned/Text'; | ||
import { Button } from '@/shared/ui/redesigned/Button'; | ||
|
||
interface ArticleAdditionalInfoProps { | ||
className?: string; | ||
author: User; | ||
createdAt: string; | ||
views: number; | ||
onEdit: () => void; | ||
} | ||
|
||
export const ArticleAdditionalInfo = memo( | ||
(props: ArticleAdditionalInfoProps) => { | ||
const { className, author, createdAt, views, onEdit } = props; | ||
const { t } = useTranslation(); | ||
|
||
return ( | ||
<VStack gap="32" className={classNames('', {}, [className])}> | ||
<HStack gap="8"> | ||
<Avatar src={author.avatar} size={32} /> | ||
<Text text={author.username} bold /> | ||
<Text text={createdAt} /> | ||
</HStack> | ||
<Button onClick={onEdit}>{t('Edit')}</Button> | ||
<Text text={t('{{count}} views', { count: views })} /> | ||
</VStack> | ||
); | ||
}, | ||
); |