-
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.
- Loading branch information
Showing
35 changed files
with
459 additions
and
135 deletions.
There are no files selected for viewing
Binary file added
BIN
+21 KB
.loki/reference/chrome_iphone7_entities_Article_ArticleDetailsDeprecated_Error.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+32.8 KB
.../reference/chrome_iphone7_entities_Article_ArticleDetailsDeprecated_Loading.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.18 MB
...i/reference/chrome_iphone7_entities_Article_ArticleDetailsDeprecated_Normal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+23.7 KB
.loki/reference/chrome_iphone7_entities_Article_ArticleDetailsRedesigned_Error.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+43.3 KB
.../reference/chrome_iphone7_entities_Article_ArticleDetailsRedesigned_Loading.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.19 MB
...i/reference/chrome_iphone7_entities_Article_ArticleDetailsRedesigned_Normal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+12.8 KB
.loki/reference/chrome_laptop_entities_Article_ArticleDetailsDeprecated_Error.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+37.2 KB
...i/reference/chrome_laptop_entities_Article_ArticleDetailsDeprecated_Loading.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+419 KB
.loki/reference/chrome_laptop_entities_Article_ArticleDetailsDeprecated_Normal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+14.3 KB
.loki/reference/chrome_laptop_entities_Article_ArticleDetailsRedesigned_Error.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+34.3 KB
...i/reference/chrome_laptop_entities_Article_ArticleDetailsRedesigned_Loading.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+427 KB
.loki/reference/chrome_laptop_entities_Article_ArticleDetailsRedesigned_Normal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,3 +19,12 @@ select { | |
a { | ||
text-decoration: none; | ||
} | ||
|
||
h1, | ||
h2, | ||
h3, | ||
h4, | ||
h5, | ||
h6 { | ||
font-weight: normal; | ||
} |
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
118 changes: 9 additions & 109 deletions
118
src/entities/Article/ui/ArticleDetails/ArticleDetails.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
File renamed without changes.
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
124 changes: 124 additions & 0 deletions
124
src/entities/Article/ui/ArticleDetails/ArticleDetailsDeprecated/ArticleDetailsDeprecated.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,124 @@ | ||
import { memo, useCallback, useEffect } from 'react'; | ||
import { useSelector } from 'react-redux'; | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
import { classNames } from '@/shared/lib/classNames'; | ||
import { | ||
DynamicModuleLoader, | ||
ReducersList, | ||
} from '@/shared/lib/components/DynamicModuleLoader/DynamicModuleLoader'; | ||
import { useAppDispatch } from '@/shared/lib/hooks/useAppDispatch/useAppDispatch'; | ||
import { Text, TextAlign, TextSize } from '@/shared/ui/deprecated/Text'; | ||
import { Skeleton } from '@/shared/ui/deprecated/Skeleton'; | ||
import { Avatar } from '@/shared/ui/deprecated/Avatar'; | ||
import { Icon } from '@/shared/ui/deprecated/Icon'; | ||
import EyeIcon from '@/shared/assets/icons/eye-20-20.svg'; | ||
import CalendarIcon from '@/shared/assets/icons/date-20-20.svg'; | ||
import { HStack, VStack } from '@/shared/ui/redesigned/Stack'; | ||
|
||
import { ArticleBlockType } from '../../../model/consts/consts'; | ||
import { ArticleImageBlockComponent } from '../../ArticleImageBlockComponent/ArticleImageBlockComponent'; | ||
import { ArticleCodeBlockComponent } from '../../ArticleCodeBlockComponent/ArticleCodeBlockComponent'; | ||
import { ArticleTextBlockComponent } from '../../ArticleTextBlockComponent/ArticleTextBlockComponent'; | ||
import { ArticleBlock } from '../../../model/types/article'; | ||
import { fetchArticleById } from '../../../model/services/fetchArticleById/fetchArticleById'; | ||
import { | ||
getArticleDetails, | ||
getArticleDetailsError, | ||
getArticleDetailsIsLoading, | ||
} from '../../../model/selectors/getArticleDetails/getArticleDetails'; | ||
import cls from './ArticleDetailsDeprecated.module.scss'; | ||
import { articleDetailsReducer } from '../../../model/slice/articleDetailsSlice'; | ||
|
||
interface ArticleDetailsProps { | ||
className?: string; | ||
id: string; | ||
} | ||
|
||
const reducers: ReducersList = { | ||
articleDetails: articleDetailsReducer, | ||
}; | ||
|
||
export const ArticleDetailsDeprecated = memo((props: ArticleDetailsProps) => { | ||
const { className, id } = props; | ||
|
||
const { t } = useTranslation('articles'); | ||
const dispatch = useAppDispatch(); | ||
const article = useSelector(getArticleDetails); | ||
const isLoading = useSelector(getArticleDetailsIsLoading); | ||
const error = useSelector(getArticleDetailsError); | ||
|
||
const renderBlock = useCallback((block: ArticleBlock) => { | ||
switch (block.type) { | ||
case ArticleBlockType.TEXT: | ||
return <ArticleTextBlockComponent key={block.id} block={block} className={cls.block} />; | ||
case ArticleBlockType.CODE: | ||
return <ArticleCodeBlockComponent key={block.id} block={block} className={cls.block} />; | ||
case ArticleBlockType.IMAGE: | ||
return <ArticleImageBlockComponent key={block.id} block={block} className={cls.block} />; | ||
default: | ||
return null; | ||
} | ||
}, []); | ||
|
||
useEffect(() => { | ||
if (__PROJECT__ !== 'storybook') { | ||
dispatch(fetchArticleById(id)); | ||
} | ||
}, [dispatch, id]); | ||
|
||
let content; | ||
|
||
if (isLoading) { | ||
content = ( | ||
<> | ||
<Skeleton className={cls.avatar} width={200} height={200} borderRadius="50%" /> | ||
<Skeleton className={cls.title} width={300} height={32} /> | ||
<Skeleton className={cls.skeleton} width={600} height={24} /> | ||
<Skeleton className={cls.skeleton} width="100%" height={200} /> | ||
<Skeleton className={cls.skeleton} width="100%" height={200} /> | ||
</> | ||
); | ||
} else if (error) { | ||
content = <Text title={t('Произошла ошибка при загрузке статьи')} align={TextAlign.CENTER} />; | ||
} else { | ||
content = ( | ||
<> | ||
<HStack max className={cls.avatarWrapper}> | ||
<Avatar size={200} src={article?.img} className={cls.avatar} /> | ||
</HStack> | ||
|
||
<VStack gap="4" max data-testid="ArticleDetails.title"> | ||
<Text | ||
className={cls.title} | ||
title={article?.title} | ||
text={article?.subtitle} | ||
size={TextSize.L} | ||
/> | ||
|
||
<HStack gap="8" className={cls.articleInfo}> | ||
<Icon className={cls.icon} Svg={EyeIcon} /> | ||
<Text text={String(article?.views)} /> | ||
</HStack> | ||
|
||
<HStack gap="8" className={cls.articleInfo}> | ||
<Icon className={cls.icon} Svg={CalendarIcon} /> | ||
<Text text={article?.createdAt} /> | ||
</HStack> | ||
</VStack> | ||
|
||
{article?.blocks.map(renderBlock)} | ||
</> | ||
); | ||
} | ||
|
||
return ( | ||
<DynamicModuleLoader reducers={reducers} removeAfterUnmount> | ||
<VStack gap="16" max className={classNames(cls.articleDetails, {}, [className])}> | ||
{content} | ||
</VStack> | ||
</DynamicModuleLoader> | ||
); | ||
}); | ||
|
||
ArticleDetailsDeprecated.displayName = 'ArticleDetailsDeprecated'; |
13 changes: 13 additions & 0 deletions
13
...s/Article/ui/ArticleDetails/ArticleDetailsRedesigned/ArticleDetailsRedesigned.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,13 @@ | ||
.articleDetails { | ||
min-height: 100%; | ||
} | ||
|
||
.avatar { | ||
margin: 0 auto; | ||
} | ||
|
||
.img { | ||
max-height: 420px; | ||
max-width: 100%; | ||
margin: 0 auto; | ||
} |
Oops, something went wrong.