-
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.
Redesign article blocks, articles list
- Loading branch information
1 parent
99d8412
commit 6ab3a98
Showing
41 changed files
with
386 additions
and
164 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
2 changes: 1 addition & 1 deletion
2
src/entities/Article/ui/ArticleCodeBlockComponent/ArticleCodeBlockComponent.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
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 |
---|---|---|
|
@@ -12,7 +12,3 @@ | |
margin: 0 auto; | ||
} | ||
|
||
.article { | ||
// width: 100%; | ||
// height: 100%; | ||
} |
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
51 changes: 51 additions & 0 deletions
51
...es/Article/ui/ArticleDetails/ArticleDetailsDeprecated/ArticleDetailsDeprecatedContent.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,51 @@ | ||
import { FC } from 'react'; | ||
import { Avatar } from '@/shared/ui/deprecated/Avatar'; | ||
import { HStack, VStack } from '@/shared/ui/redesigned/Stack'; | ||
import { Text, TextSize } from '@/shared/ui/deprecated/Text'; | ||
import { Icon } from '@/shared/ui/deprecated/Icon'; | ||
import { CreatedAtIcon, ViewsIcon } from '@/shared/assets/deprecated-icons'; | ||
|
||
import { renderBlock } from '../renderBlock'; | ||
import { Article } from '../../../model/types/article'; | ||
|
||
interface ArticleDetailsDeprecatedContentProps { | ||
data?: Article | ||
} | ||
|
||
/** | ||
* @deprecated | ||
*/ | ||
export const ArticleDetailsDeprecatedContent: FC<ArticleDetailsDeprecatedContentProps> = (props) => { | ||
const { data } = props; | ||
|
||
return ( | ||
<article> | ||
<VStack justify="center" align="center" gap={12}> | ||
<Avatar | ||
width={200} | ||
height={200} | ||
src={data?.img} | ||
alt="Avatar" | ||
/> | ||
</VStack> | ||
<VStack gap={4} data-testid="ArticleDetailsInfo"> | ||
<Text | ||
title={data?.title} | ||
text={data?.subtitle} | ||
size={TextSize.L} | ||
/> | ||
<HStack gap={12}> | ||
<Icon SVG={<ViewsIcon />} /> | ||
<Text text={data?.views.toString()} /> | ||
</HStack> | ||
<HStack gap={12}> | ||
<Icon SVG={<CreatedAtIcon />} /> | ||
<Text text={new Date(data?.createdAt as number).toLocaleString()} /> | ||
</HStack> | ||
</VStack> | ||
<VStack gap={16} justify="center" align="center"> | ||
{data?.blocks.map(renderBlock)} | ||
</VStack> | ||
</article> | ||
); | ||
}; |
18 changes: 18 additions & 0 deletions
18
...ties/Article/ui/ArticleDetails/ArticleDetailsDeprecated/ArticleDetailsDeprecatedError.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,18 @@ | ||
import { FC } from 'react'; | ||
import { useAppTranslation } from '@/shared/lib/hooks/useAppTranslation'; | ||
import { Text, TextAlign, TextTheme } from '@/shared/ui/deprecated/Text'; | ||
|
||
/** | ||
* @deprecated | ||
*/ | ||
export const ArticleDetailsDeprecatedError: FC = () => { | ||
const { t } = useAppTranslation('articles'); | ||
|
||
return ( | ||
<Text | ||
align={TextAlign.CENTER} | ||
theme={TextTheme.ERROR} | ||
title={t('error-fetching-article')} | ||
/> | ||
); | ||
}; |
27 changes: 27 additions & 0 deletions
27
.../Article/ui/ArticleDetails/ArticleDetailsDeprecated/ArticleDetailsDeprecatedSkeletons.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,27 @@ | ||
import { FC } from 'react'; | ||
import { classNames } from '@/shared/lib/classNames/classNames'; | ||
import { Skeleton } from '@/shared/ui/deprecated/Skeleton'; | ||
|
||
import cls from '../ArticleDetails.module.scss'; | ||
|
||
interface ArticleDetailsRedesignedSkeletonsProps { | ||
isLoading: boolean; | ||
className?: string; | ||
} | ||
|
||
/** | ||
* @deprecated | ||
*/ | ||
export const ArticleDetailsDeprecatedSkeletons: FC<ArticleDetailsRedesignedSkeletonsProps> = ({ isLoading, className }) => { | ||
return ( | ||
<div className={classNames(cls.ArticleDetails, { [cls.loading]: isLoading }, [className])}> | ||
<Skeleton width={200} height={200} borderRadius="50%" className={cls.avatar} /> | ||
<Skeleton width={700} height={30} /> | ||
<Skeleton width={400} height={30} /> | ||
<Skeleton width={300} height={16} /> | ||
<Skeleton height={200} /> | ||
<Skeleton height={200} /> | ||
<Skeleton height={200} /> | ||
</div> | ||
); | ||
}; |
3 changes: 3 additions & 0 deletions
3
src/entities/Article/ui/ArticleDetails/ArticleDetailsDeprecated/index.ts
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 @@ | ||
export { ArticleDetailsDeprecatedContent } from './ArticleDetailsDeprecatedContent'; | ||
export { ArticleDetailsDeprecatedError } from './ArticleDetailsDeprecatedError'; | ||
export { ArticleDetailsDeprecatedSkeletons } from './ArticleDetailsDeprecatedSkeletons'; |
39 changes: 39 additions & 0 deletions
39
...es/Article/ui/ArticleDetails/ArticleDetailsRedesigned/ArticleDetailsRedesignedContent.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,39 @@ | ||
import { FC } from 'react'; | ||
import { VStack } from '@/shared/ui/redesigned/Stack'; | ||
import { Text } from '@/shared/ui/redesigned/Text'; | ||
import { AppImage } from '@/shared/ui/redesigned/AppImage'; | ||
import { Skeleton } from '@/shared/ui/redesigned/Skeleton'; | ||
|
||
import { renderBlock } from '../renderBlock'; | ||
import { Article } from '../../../model/types/article'; | ||
|
||
interface ArticleDetailsRedesignedContentProps { | ||
data?: Article | ||
} | ||
|
||
export const ArticleDetailsRedesignedContent: FC<ArticleDetailsRedesignedContentProps> = (props) => { | ||
const { data } = props; | ||
|
||
return ( | ||
<VStack component="article" gap={16}> | ||
<Text | ||
bold={{ title: true, text: false }} | ||
title={data?.title} | ||
text={data?.subtitle} | ||
size="l" | ||
/> | ||
<VStack justify="center" align="center"> | ||
<AppImage | ||
width={200} | ||
height={200} | ||
src={data?.img} | ||
alt="Avatar" | ||
fallback={<Skeleton width={200} height={200} borderRadius="50%" />} | ||
/> | ||
</VStack> | ||
<VStack gap={16} justify="center" align="center"> | ||
{data?.blocks.map(renderBlock)} | ||
</VStack> | ||
</VStack> | ||
); | ||
}; |
15 changes: 15 additions & 0 deletions
15
...ties/Article/ui/ArticleDetails/ArticleDetailsRedesigned/ArticleDetailsRedesignedError.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,15 @@ | ||
import { FC } from 'react'; | ||
import { useAppTranslation } from '@/shared/lib/hooks/useAppTranslation'; | ||
import { Text } from '@/shared/ui/redesigned/Text'; | ||
|
||
export const ArticleDetailsRedesignedError: FC = () => { | ||
const { t } = useAppTranslation('articles'); | ||
|
||
return ( | ||
<Text | ||
align="center" | ||
variant="error" | ||
title={t('error-fetching-article')} | ||
/> | ||
); | ||
}; |
24 changes: 24 additions & 0 deletions
24
.../Article/ui/ArticleDetails/ArticleDetailsRedesigned/ArticleDetailsRedesignedSkeletons.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,24 @@ | ||
import { FC } from 'react'; | ||
import { classNames } from '@/shared/lib/classNames/classNames'; | ||
import { Skeleton } from '@/shared/ui/redesigned/Skeleton'; | ||
|
||
import cls from '../ArticleDetails.module.scss'; | ||
|
||
interface ArticleDetailsRedesignedSkeletonsProps { | ||
isLoading: boolean; | ||
className?: string; | ||
} | ||
|
||
export const ArticleDetailsRedesignedSkeletons: FC<ArticleDetailsRedesignedSkeletonsProps> = ({ isLoading, className }) => { | ||
return ( | ||
<div className={classNames(cls.ArticleDetails, { [cls.loading]: isLoading }, [className])}> | ||
<Skeleton width={700} height={30} /> | ||
<Skeleton width={400} height={30} /> | ||
<Skeleton width={200} height={200} borderRadius="50%" className={cls.avatar} /> | ||
<Skeleton width={300} height={16} /> | ||
<Skeleton height={200} /> | ||
<Skeleton height={200} /> | ||
<Skeleton height={200} /> | ||
</div> | ||
); | ||
}; |
3 changes: 3 additions & 0 deletions
3
src/entities/Article/ui/ArticleDetails/ArticleDetailsRedesigned/index.ts
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 @@ | ||
export { ArticleDetailsRedesignedContent } from './ArticleDetailsRedesignedContent'; | ||
export { ArticleDetailsRedesignedError } from './ArticleDetailsRedesignedError'; | ||
export { ArticleDetailsRedesignedSkeletons } from './ArticleDetailsRedesignedSkeletons'; |
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,18 @@ | ||
import { ArticleBlockType } from '../../model/consts'; | ||
import { ArticleBlock } from '../../model/types/article'; | ||
import { ArticleCodeBlockComponent } from '../ArticleCodeBlockComponent'; | ||
import { ArticleImageBlockComponent } from '../ArticleImageBlockComponent'; | ||
import { ArticleTextBlockComponent } from '../ArticleTextBlockComponent'; | ||
|
||
export const renderBlock = (block: ArticleBlock) => { | ||
switch (block.type) { | ||
case ArticleBlockType.CODE: | ||
return <ArticleCodeBlockComponent key={block.id} block={block} />; | ||
case ArticleBlockType.IMAGE: | ||
return <ArticleImageBlockComponent key={block.id} block={block} />; | ||
case ArticleBlockType.TEXT: | ||
return <ArticleTextBlockComponent key={block.id} block={block} />; | ||
default: | ||
return null; | ||
} | ||
}; |
Oops, something went wrong.