-
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: add greetings for articles page
- Loading branch information
Showing
10 changed files
with
78 additions
and
4 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
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
## Article page greeting |
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 { ArticlePageGreeting } from './ui/ArticlePageGreeting/ArticlePageGreeting'; |
18 changes: 18 additions & 0 deletions
18
src/features/articlePageGreeting/ui/ArticlePageGreeting/ArticlePageGreeting.stories.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 type { ComponentMeta, ComponentStory } from '@storybook/react'; | ||
|
||
import { ArticlePageGreeting } from './ArticlePageGreeting'; | ||
|
||
export default { | ||
title: 'features/ArticlePageGreeting', | ||
component: ArticlePageGreeting, | ||
argTypes: { | ||
backgroundColor: { control: 'color' }, | ||
}, | ||
} as ComponentMeta<typeof ArticlePageGreeting>; | ||
|
||
const Template: ComponentStory<typeof ArticlePageGreeting> = (args) => ( | ||
<ArticlePageGreeting {...args} /> | ||
); | ||
|
||
export const Normal = Template.bind({}); | ||
Normal.args = {}; |
45 changes: 45 additions & 0 deletions
45
src/features/articlePageGreeting/ui/ArticlePageGreeting/ArticlePageGreeting.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,45 @@ | ||
import { memo, useEffect, useState } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { isMobile } from 'react-device-detect'; | ||
|
||
import { Modal } from '@/shared/ui/Modal'; | ||
import { Text } from '@/shared/ui/Text'; | ||
import { saveJsonSettings, useJsonSettings } from '@/entities/User'; | ||
import { useAppDispatch } from '@/shared/lib/hooks/useAppDispatch/useAppDispatch'; | ||
import { Drawer } from '@/shared/ui/Drawer'; | ||
|
||
export const ArticlePageGreeting = memo(() => { | ||
const { t } = useTranslation('articles'); | ||
|
||
const [isOpen, setIsOpen] = useState(false); | ||
const { isArticlesPageWasOpened } = useJsonSettings(); | ||
const dispatch = useAppDispatch(); | ||
|
||
useEffect(() => { | ||
if (!isArticlesPageWasOpened) { | ||
setIsOpen(true); | ||
dispatch(saveJsonSettings({ isArticlesPageWasOpened: true })); | ||
} | ||
}, [dispatch, isArticlesPageWasOpened]); | ||
|
||
const onClose = () => setIsOpen(false); | ||
|
||
const text = ( | ||
<Text | ||
title={t('Добро пожаловать на страницу статей')} | ||
text={t('Здесь Вы можете искать и просматривать статьи на различные темы')} | ||
/> | ||
); | ||
|
||
if (isMobile) { | ||
return <Drawer>{text}</Drawer>; | ||
} | ||
|
||
return ( | ||
<Modal lazy isOpen={isOpen} onClose={onClose}> | ||
{text} | ||
</Modal> | ||
); | ||
}); | ||
|
||
ArticlePageGreeting.displayName = 'ArticlePageGreeting'; |
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