From 2c542264a90b1270588d03076ef3288673acf866 Mon Sep 17 00:00:00 2001 From: Alexander Morugin Date: Fri, 24 May 2024 16:39:13 +0300 Subject: [PATCH] fix-Advantages enhancement_350_adaptive_main_page --- .../ui/AdvantageCard.stories.tsx | 36 +++++++++++++++++++ .../AdvantageCard/ui/AdvantageCard.tsx | 6 ++-- .../ui/advantageCard.module.scss | 26 ++++++++++++-- src/mockData/advantagesData.ts | 19 ++++++---- src/widgets/Advantages/ui/Advantages.tsx | 2 +- .../Advantages/ui/advantages.module.scss | 10 +++--- 6 files changed, 83 insertions(+), 16 deletions(-) create mode 100644 src/entities/AdvantageCard/ui/AdvantageCard.stories.tsx diff --git a/src/entities/AdvantageCard/ui/AdvantageCard.stories.tsx b/src/entities/AdvantageCard/ui/AdvantageCard.stories.tsx new file mode 100644 index 00000000..2b797d89 --- /dev/null +++ b/src/entities/AdvantageCard/ui/AdvantageCard.stories.tsx @@ -0,0 +1,36 @@ +import type { Meta, StoryObj } from '@storybook/react' + +import { advantagesData } from '@/mockData/advantagesData' + +import AdvantageCard from './AdvantageCard' + +const meta = { + title: 'entities/AdvantageCard', + component: AdvantageCard, + parameters: { + layout: 'centered' + }, + tags: ['autodocs'] +} satisfies Meta + +export default meta +type Story = StoryObj + +export const Default: Story = () => { + const image = advantagesData[0].image + const alt = advantagesData[0].alt + const name = advantagesData[0].name + + return ( +
+ +
+ ) +} + +Default.args = { + image: advantagesData[0].image, + alt: advantagesData[0].alt, + name: advantagesData[0].name, + route: '#' +} diff --git a/src/entities/AdvantageCard/ui/AdvantageCard.tsx b/src/entities/AdvantageCard/ui/AdvantageCard.tsx index 829a770b..c1c5249b 100644 --- a/src/entities/AdvantageCard/ui/AdvantageCard.tsx +++ b/src/entities/AdvantageCard/ui/AdvantageCard.tsx @@ -8,6 +8,7 @@ export type TAdvantageCardProps = { image: string alt: string name: string + route: string } /** @@ -15,11 +16,12 @@ export type TAdvantageCardProps = { * @param {string} image - картинка для преимущества * @param {string} alt - описание картинки * @param {string} name - название преимущества + * @param {string} route - ссылка для перехода */ -const AdvantageCard: FC = ({ image, alt, name }) => { +const AdvantageCard: FC = ({ image, alt, name, route }) => { return ( - + {alt} {name} diff --git a/src/entities/AdvantageCard/ui/advantageCard.module.scss b/src/entities/AdvantageCard/ui/advantageCard.module.scss index fb02ab26..e8b97dde 100644 --- a/src/entities/AdvantageCard/ui/advantageCard.module.scss +++ b/src/entities/AdvantageCard/ui/advantageCard.module.scss @@ -16,10 +16,32 @@ line-height: 20px; color: var.$body-color; padding: 13px 18px; - transition: 0.25s; - border: 1px solid red; + transition: 0.3s ease-in-out; + + &:hover { + box-shadow: 0 0 5px var.$body-color-light-grey; + } + + &:active { + box-shadow: 0 0 5px var.$body-color-light-grey; + } + + @include media.respond-to('large') { + gap: 24px; + max-width: 100%; + } + + @include media.respond-to('middle') { + justify-content: flex-start; + padding-left: 30px; + padding-right: 30px; + } } .image { width: 36px; + + @include media.respond-to('large') { + width: 44px; + } } diff --git a/src/mockData/advantagesData.ts b/src/mockData/advantagesData.ts index 87c7f973..49812d49 100644 --- a/src/mockData/advantagesData.ts +++ b/src/mockData/advantagesData.ts @@ -4,36 +4,43 @@ import img3 from '@/assets/images/advantages/img3.png' import img4 from '@/assets/images/advantages/img4.png' import img5 from '@/assets/images/advantages/img5.png' import img6 from '@/assets/images/advantages/img6.png' +import { Routes } from '@/shared/config/routerConfig/routes' export const advantagesData = [ { image: img1, name: 'Бесплатная доставка', - alt: 'изображение' + alt: 'изображение', + route: Routes.DELIVERY }, { image: img2, alt: 'изображение', - name: 'Бонусы за покупку' + name: 'Бонусы за покупку', + route: Routes.ADD_RETURN }, { image: img3, alt: 'изображение', - name: 'Гарантированный возврат и обмен' + name: 'Гарантированный возврат и обмен', + route: Routes.BLOG }, { image: img4, alt: 'изображение', - name: 'Сертификаты на все товары' + name: 'Сертификаты на все товары', + route: Routes.BRANDS }, { image: img5, alt: 'изображение', - name: 'Сертификаты на все товары' + name: 'Сертификаты на все товары', + route: Routes.HOME }, { image: img6, alt: 'изображение', - name: 'Гарантийное обслуживание' + name: 'Гарантийное обслуживание', + route: Routes.HOME } ] diff --git a/src/widgets/Advantages/ui/Advantages.tsx b/src/widgets/Advantages/ui/Advantages.tsx index 695d02a9..648eb60e 100644 --- a/src/widgets/Advantages/ui/Advantages.tsx +++ b/src/widgets/Advantages/ui/Advantages.tsx @@ -16,7 +16,7 @@ const Advantages: FC = () => {
    {advantagesData.map((item, index) => (
  • - +
  • ))}
diff --git a/src/widgets/Advantages/ui/advantages.module.scss b/src/widgets/Advantages/ui/advantages.module.scss index 879f731b..265b6297 100644 --- a/src/widgets/Advantages/ui/advantages.module.scss +++ b/src/widgets/Advantages/ui/advantages.module.scss @@ -3,8 +3,6 @@ .advantages { display: flex; width: 100%; - - // user-select: none; } .cards { @@ -13,13 +11,15 @@ gap: 10px; width: 100%; - @include media.respond-to('large') { display: grid; grid-template-columns: repeat(3, 1fr); - justify-items: center; gap: 20px; width: 100%; - border: 1px solid red; + } + + @include media.respond-to('middle') { + display: flex; + flex-direction: column; } }