-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #419 from Studio-Yandex-Practicum/enhancement-411-…
…create-ShopNewsPage #411-enhancement-create-ShopNewsPage
- Loading branch information
Showing
8 changed files
with
138 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.container { | ||
display: flex; | ||
flex-direction: column; | ||
width: 100% | ||
} | ||
|
||
.title { | ||
margin-bottom: 10px; | ||
} |
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 WrapperForMainContent from '@/components/WrapperForMainContent/WrapperForMainContent' | ||
import Breadcrumbs from '@/shared/ui/Breadcrumbs/Breadcrumbs' | ||
import Heading, { HeadingType } from '@/shared/ui/Heading/Heading' | ||
import ShopNewsWidget from '@/widgets/NewsBlock/ui/ShopNewsWidget/ShopNewsWidget' | ||
|
||
import styles from './ShopNewsPage.module.scss' | ||
|
||
const links = [ | ||
{ heading: 'Главная', href: '/' }, | ||
{ heading: 'Новости', href: '' } | ||
] | ||
|
||
const ShopNewsPage = () => { | ||
return ( | ||
<WrapperForMainContent> | ||
<section className={styles.container}> | ||
<Heading type={HeadingType.MAIN} className={styles.title}> | ||
Новости | ||
</Heading> | ||
<Breadcrumbs links={links} /> | ||
<ShopNewsWidget /> | ||
</section> | ||
</WrapperForMainContent> | ||
) | ||
} | ||
|
||
export default ShopNewsPage |
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/widgets/NewsBlock/ui/ShopNewsWidget/ShopNewsWidget.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,23 @@ | ||
@use '@/shared/styles/utils/mixins' as media; | ||
|
||
.storybook { | ||
width: 1080px; | ||
} | ||
|
||
.container { | ||
display: flex; | ||
margin-top: 40px; | ||
} | ||
|
||
.list { | ||
display: flex; | ||
flex-wrap: wrap; | ||
column-gap: 20px; | ||
row-gap: 30px; | ||
} | ||
|
||
.item { | ||
@include media.respond-to('middle') { | ||
width: 100% | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/widgets/NewsBlock/ui/ShopNewsWidget/ShopNewsWidget.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,27 @@ | ||
import type { Meta, StoryObj } from '@storybook/react' | ||
import { FC } from 'react' | ||
|
||
import ShopNewsWidget from './ShopNewsWidget' | ||
import styles from './ShopNewsWidget.module.scss' | ||
|
||
const StorybookWrapper: FC = () => { | ||
return ( | ||
<div className={styles.storybook}> | ||
<ShopNewsWidget /> | ||
</div> | ||
) | ||
} | ||
|
||
const meta = { | ||
title: 'widgets/ShopNewsWidget', | ||
component: StorybookWrapper, | ||
parameters: { | ||
layout: 'centered' | ||
}, | ||
tags: ['autodocs'] | ||
} satisfies Meta<typeof StorybookWrapper> | ||
|
||
export default meta | ||
type Story = StoryObj<typeof meta> | ||
|
||
export const Default: Story = {} |
42 changes: 42 additions & 0 deletions
42
src/widgets/NewsBlock/ui/ShopNewsWidget/ShopNewsWidget.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,42 @@ | ||
import { FC, useEffect } from 'react' | ||
|
||
import NewsCard from '@/entities/NewsCard' | ||
import { useAppDispatch } from '@/shared/libs/hooks/store' | ||
|
||
import useNewsArray from '../../model/hooks/useNewsArray' | ||
import { getShopNews } from '../../model/services/getShopNews' | ||
|
||
import styles from './ShopNewsWidget.module.scss' | ||
|
||
/** | ||
* Компонент ShopNewsWidget - это блок группы новостей. Отрисовывается на главной странице ShopNewsPage | ||
*/ | ||
|
||
const ShopNewsWidget: FC = () => { | ||
const dispatch = useAppDispatch() | ||
const { allNewsArray } = useNewsArray() | ||
|
||
useEffect(() => { | ||
dispatch(getShopNews()) | ||
}, []) | ||
|
||
return ( | ||
<section className={styles.container}> | ||
<ul className={styles.list}> | ||
{allNewsArray.map(item => ( | ||
<li key={item.id} className={styles.item}> | ||
<NewsCard | ||
id={item.id} | ||
image={item.image} | ||
date={item.pub_date} | ||
title={item.title} | ||
link={item.slug} | ||
/> | ||
</li> | ||
))} | ||
</ul> | ||
</section> | ||
) | ||
} | ||
|
||
export default ShopNewsWidget |