-
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 #258 from Studio-Yandex-Practicum/development-257-…
…BannerBlock #257-development-BannerBlock-done
- Loading branch information
Showing
9 changed files
with
268 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
@use '@/app/styles/index' as color; | ||
@use '../../shared/styles/utils/mixins' as media; | ||
|
||
.storybook { | ||
width: 900px; | ||
height: 400px; | ||
} | ||
|
||
.slider { | ||
flex: 1 0 100%; | ||
position: relative; | ||
background-color: color.$theme-secondary-color; | ||
} | ||
|
||
.link { | ||
color: color.$black; | ||
position: absolute; | ||
width: 100%; | ||
height: 100%; | ||
|
||
.content { | ||
position: absolute; | ||
left: 12%; | ||
top: 100px; | ||
|
||
@include media.respond-to('middle') { | ||
left: 39%; | ||
top: 5%; | ||
} | ||
|
||
.title { | ||
margin-top: 5px; | ||
font-size: 30px; | ||
color: color.$black; | ||
line-height: 37.5px; | ||
} | ||
} | ||
} | ||
|
||
.button { | ||
border: 1px solid color.$body-color-light-grey; | ||
column-gap: 15px; | ||
background-color: inherit; | ||
color: color.$black; | ||
margin-top: 30px; | ||
|
||
path { | ||
fill: color.$black; | ||
} | ||
} |
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,46 @@ | ||
import type { Meta, StoryObj } from '@storybook/react' | ||
import { FC } from 'react' | ||
|
||
import img1 from '@/assets/images/banner/banner.png' | ||
|
||
import BannerCard, { TBannerCardProps } from './BannerCard' | ||
import styles from './BannerCard.module.scss' | ||
|
||
const StorybookWrapper: FC<TBannerCardProps> = ({ alt, title, subtitle, href, urlImg, urlImg_m }) => { | ||
return ( | ||
<div className={styles.storybook}> | ||
<BannerCard | ||
urlImg={urlImg} | ||
urlImg_m={urlImg_m} | ||
alt={alt} | ||
title={title} | ||
subtitle={subtitle} | ||
href={href} | ||
/> | ||
</div> | ||
) | ||
} | ||
|
||
const meta = { | ||
title: 'entities/BannerCard', | ||
component: StorybookWrapper, | ||
parameters: { | ||
layout: 'centered' | ||
}, | ||
|
||
tags: ['autodocs'] | ||
} satisfies Meta<typeof StorybookWrapper> | ||
|
||
export default meta | ||
type Story = StoryObj<typeof meta> | ||
|
||
export const Normal: Story = { | ||
args: { | ||
urlImg: img1, | ||
urlImg_m: img1, | ||
alt: 'Mobil', | ||
title: 'DJI OSMO', | ||
subtitle: 'Mobile 4', | ||
href: 'jelektronika/telefony-i-smart-chasy/umnye-chasy' | ||
} | ||
} |
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,55 @@ | ||
import { FC } from 'react' | ||
|
||
import ArrowRightNextPage from '@/assets/icons/ArrowRightNextPage.svg' | ||
import { media } from '@/shared/styles/utils/media' | ||
import { Button, ButtonSize, ButtonTheme } from '@/shared/ui/Button/Button' | ||
import Heading, { HeadingType } from '@/shared/ui/Heading/Heading' | ||
import Link from '@/shared/ui/Link/Link' | ||
import Img from '@/ui/img' | ||
|
||
import styles from './BannerCard.module.scss' | ||
|
||
export type TBannerCardProps = { | ||
urlImg: string | ||
urlImg_m: string | ||
alt: string | ||
title: string | ||
subtitle: string | ||
href: string | ||
} | ||
|
||
/** | ||
* Entity SliderCard | ||
* Карточка для SliderBlock на главной странице. | ||
* @param {string} urlImg - изображение | ||
* @param {string} urlImg_m - изображение | ||
* @param {string} alt - название картинки, если картинка не подгрузится | ||
* @param {string} title - название | ||
* @param {string} subtitle - название | ||
* @param {string} href - ссылка | ||
*/ | ||
|
||
const BannerCard: FC<TBannerCardProps> = ({ alt, title, subtitle, href, urlImg, urlImg_m }) => { | ||
return ( | ||
<div className={styles.slider}> | ||
<Link to={href} className={styles.link}> | ||
<div className={styles.content}> | ||
<Heading type={HeadingType.NORMAL} className={styles.title}> | ||
{title} | ||
</Heading> | ||
<Heading type={HeadingType.NORMAL} className={styles.title}> | ||
{subtitle} | ||
</Heading> | ||
|
||
<Button size={ButtonSize.S} theme={ButtonTheme.PRIMARY} className={styles.button}> | ||
Подробнее | ||
<ArrowRightNextPage className={styles.icon} /> | ||
</Button> | ||
</div> | ||
<Img srcSet={urlImg_m} media={media.middle} src={urlImg} alt={alt} /> | ||
</Link> | ||
</div> | ||
) | ||
} | ||
|
||
export default BannerCard |
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,31 @@ | ||
import img1 from '@/assets/images/banner/banner.png' | ||
|
||
export const bannerData = [ | ||
{ | ||
id: 100, | ||
urlImg: img1, | ||
urlImg_m: img1, | ||
alt: 'Mobil', | ||
title: 'DJI OSMO', | ||
subtitle: 'Mobile 4', | ||
href: 'jelektronika/telefony-i-smart-chasy/umnye-chasy' | ||
}, | ||
{ | ||
id: 101, | ||
urlImg: img1, | ||
urlImg_m: img1, | ||
alt: 'Mobil', | ||
title: 'DJI OSMO', | ||
subtitle: 'Mobile 4', | ||
href: 'jelektronika/telefony-i-smart-chasy/umnye-chasy' | ||
}, | ||
{ | ||
id: 102, | ||
urlImg: img1, | ||
urlImg_m: img1, | ||
alt: 'Mobil', | ||
title: 'DJI OSMO', | ||
subtitle: 'Mobile 4', | ||
href: 'jelektronika/telefony-i-smart-chasy/umnye-chasy' | ||
} | ||
] |
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,22 @@ | ||
@use '@/app/styles/index' as color; | ||
@use '../../../shared/styles/utils/mixins' as media; | ||
|
||
.storybook { | ||
width: 900px; | ||
height: 400px; | ||
} | ||
|
||
.container { | ||
display: flex; | ||
column-gap: 20px; | ||
width: 1420px; | ||
max-width: 100%; | ||
height: 370px; | ||
margin: 0 auto; | ||
padding: 0 10px; | ||
|
||
@include media.respond-to('middle') { | ||
width: 653px; | ||
height: 512px; | ||
} | ||
} |
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,28 @@ | ||
import type { Meta, StoryObj } from '@storybook/react' | ||
import { FC } from 'react' | ||
|
||
import BannerBlock from './BannerBlock' | ||
import styles from './BannerBlock.module.scss' | ||
|
||
const StorybookWrapper: FC = () => { | ||
return ( | ||
<div className={styles.storybook}> | ||
<BannerBlock /> | ||
</div> | ||
) | ||
} | ||
|
||
const meta = { | ||
title: 'widgets/BannerBlock', | ||
component: StorybookWrapper, | ||
parameters: { | ||
layout: 'centered' | ||
}, | ||
|
||
tags: ['autodocs'] | ||
} satisfies Meta<typeof StorybookWrapper> | ||
|
||
export default meta | ||
type Story = StoryObj<typeof meta> | ||
|
||
export const Normal: Story = {} |
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,34 @@ | ||
import BannerCard from '@/entities/BannerCard/BannerCard' | ||
import Slider from '@/features/Slider/ui/Slider/Slider' | ||
import { bannerData } from '@/mockData/bannerData' | ||
|
||
import styles from './BannerBlock.module.scss' | ||
|
||
/** | ||
* Component BannerBlock | ||
* Компонент для перелистывания главных картинок на главной странице. | ||
*/ | ||
|
||
const BannerBlock = () => { | ||
return ( | ||
<div className={styles.container}> | ||
<Slider> | ||
{bannerData.map(item => { | ||
return ( | ||
<BannerCard | ||
key={item.id} | ||
urlImg={item.urlImg} | ||
urlImg_m={item.urlImg_m} | ||
alt={item.alt} | ||
title={item.title} | ||
subtitle={item.subtitle} | ||
href={item.href} | ||
/> | ||
) | ||
})} | ||
</Slider> | ||
</div> | ||
) | ||
} | ||
|
||
export default BannerBlock |