-
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 #179 from Studio-Yandex-Practicum/enhancement-149-…
…change-BrandBlock-according-to-fsd #149 Переделка компонента Бренды по fsd
- Loading branch information
Showing
14 changed files
with
222 additions
and
121 deletions.
There are no files selected for viewing
Binary file not shown.
This file was deleted.
Oops, something went wrong.
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,57 @@ | ||
@use '../../shared/styles/utils/variables' as color; | ||
@use '../../shared/styles/utils/mixins' as media; | ||
|
||
.brand { | ||
width: 240px; | ||
height: 220px; | ||
padding: 0 10px; | ||
display: block; | ||
|
||
&:hover { | ||
cursor: pointer; | ||
} | ||
|
||
@include media.respond-to('large') { | ||
min-width: 230px; | ||
width: 100%; | ||
height: 230px; | ||
} | ||
|
||
@include media.respond-to('small') { | ||
min-width: 148px; | ||
width: 100%; | ||
height: 148px; | ||
} | ||
|
||
} | ||
|
||
.wrap { | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
width: 100%; | ||
height: 100%; | ||
border: 1px solid color.$border-color; | ||
transition: border-color 0.25s; | ||
|
||
&:hover { | ||
border-color: color.$theme-primary-color; | ||
} | ||
} | ||
|
||
.link { | ||
height: 100%; | ||
width: 100%; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
} | ||
|
||
.img { | ||
display: block; | ||
|
||
@include media.respond-to('small') { | ||
width: 120px; | ||
height: 120px; | ||
} | ||
} |
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 BrandCard from './BrandCard' | ||
import Brand1 from '@/assets/images/brands/1-150x150.webp' | ||
|
||
const meta = { | ||
title: 'entities/BrandBlock', | ||
component: BrandCard, | ||
parameters: { | ||
layout: 'centered' | ||
} | ||
} as Meta<typeof BrandCard> | ||
|
||
export default meta | ||
type Story = StoryObj<typeof meta> | ||
|
||
export const Default: Story = { | ||
args: { | ||
card: { | ||
id: 1, | ||
name: 'UGG', | ||
slug: 'ugg', | ||
image: Brand1, | ||
is_prohibited: false, | ||
is_visible_on_main: true | ||
} | ||
} | ||
} |
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,40 @@ | ||
import { FC } from 'react' | ||
import { Routes } from '@/shared/config/routerConfig/routes' | ||
import { TBrand } from '@/models/BrandModel' | ||
import Link from '@/shared/ui/Link/Link' | ||
import Img from '@/ui/img' | ||
import BrandWithoutImage from '@/assets/images/brands/brand-without-image.webp' | ||
import { | ||
DEFAULT_WIDTH_FOR_BRANDCARD_IMG, | ||
DEFAULT_HEIGHT_FOR_BRANDCARD_IMG | ||
} from '@/entities/constants/constants' | ||
import styles from './BrandCard.module.scss' | ||
|
||
interface BrandCardProps { | ||
card: TBrand | ||
} | ||
|
||
/** | ||
* Компонент карточки бренда. Заполнение карточки происходит с применением метода map | ||
* @param {TBrand} card - массив для наполнения карточки бренда; | ||
*/ | ||
|
||
const BrandCard: FC<BrandCardProps> = ({ card }) => { | ||
return ( | ||
<li className={styles.brand}> | ||
<div className={styles.wrap}> | ||
<Link className={styles.link} to={`${Routes.BRANDS}/${card.slug}`}> | ||
<Img | ||
src={card.image || BrandWithoutImage} | ||
alt={card.name} | ||
width={card.width ?? DEFAULT_WIDTH_FOR_BRANDCARD_IMG} | ||
height={card.height ?? DEFAULT_HEIGHT_FOR_BRANDCARD_IMG} | ||
className={styles.img} | ||
/> | ||
</Link> | ||
</div> | ||
</li> | ||
) | ||
} | ||
|
||
export default BrandCard |
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,2 @@ | ||
export const DEFAULT_WIDTH_FOR_BRANDCARD_IMG: number = 150 | ||
export const DEFAULT_HEIGHT_FOR_BRANDCARD_IMG: number = 150 |
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 |
---|---|---|
@@ -1,39 +1,57 @@ | ||
import Brand1 from '@/assets/images/brands/1-150x150.webp' | ||
import Brand2 from '@/assets/images/brands/10-150x150.webp' | ||
import Brand3 from '@/assets/images/brands/3-150x150.webp' | ||
import Brand4 from '@/assets/images/brands/4-150x150.webp' | ||
import Brand5 from '@/assets/images/brands/6-150x150.webp' | ||
import Brand3 from '@/assets/images/brands/4-150x150.webp' | ||
import Brand4 from '@/assets/images/brands/6-150x150.webp' | ||
import Brand5 from '@/assets/images/brands/3-150x150.webp' | ||
import Brand6 from '@/assets/images/brands/9-150x150.webp' | ||
|
||
export const brandsData = [ | ||
{ | ||
id: 1, | ||
src: Brand1, | ||
alt: 'Изображение бренда' | ||
name: 'UGG', | ||
slug: 'ugg', | ||
image: Brand1, | ||
is_prohibited: false, | ||
is_visible_on_main: true | ||
}, | ||
{ | ||
id: 2, | ||
src: Brand2, | ||
alt: 'Изображение бренда' | ||
name: 'pols potten', | ||
slug: 'pols-potten', | ||
image: Brand2, | ||
is_prohibited: false, | ||
is_visible_on_main: true | ||
}, | ||
{ | ||
id: 3, | ||
src: Brand3, | ||
alt: 'Изображение бренда' | ||
name: 'Kartell', | ||
slug: 'kartell', | ||
image: Brand3, | ||
is_prohibited: false, | ||
is_visible_on_main: true | ||
}, | ||
{ | ||
id: 4, | ||
src: Brand4, | ||
alt: 'Изображение бренда' | ||
name: 'Tom Dixon.', | ||
slug: 'tom-dixon', | ||
image: Brand4, | ||
is_prohibited: false, | ||
is_visible_on_main: true | ||
}, | ||
{ | ||
id: 5, | ||
src: Brand5, | ||
alt: 'Изображение бренда' | ||
name: 'MISSIONI HOME', | ||
slug: 'missioni-home', | ||
image: Brand5, | ||
is_prohibited: false, | ||
is_visible_on_main: true | ||
}, | ||
{ | ||
id: 6, | ||
src: Brand6, | ||
alt: 'Изображение бренда' | ||
name: 'LSA International', | ||
slug: 'lsa-international', | ||
image: Brand6, | ||
is_prohibited: false, | ||
is_visible_on_main: true | ||
} | ||
] |
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 |
---|---|---|
@@ -1,7 +1,10 @@ | ||
export type TBrand = { | ||
id: number | ||
src: string | ||
alt: string | ||
name: string | ||
slug: string | ||
image: string | ||
is_prohibited: boolean | ||
is_visible_on_main: boolean | ||
width?: number | ||
height?: number | ||
} |
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,20 @@ | ||
import type { Meta, StoryObj } from '@storybook/react' | ||
import BrandBlock from './BrandBlock' | ||
import { brandsData } from '@/mockData/brandData' | ||
|
||
const meta = { | ||
title: 'widgets/BrandBlock', | ||
component: BrandBlock, | ||
parameters: { | ||
layout: 'centered' | ||
} | ||
} as Meta<typeof BrandBlock> | ||
|
||
export default meta | ||
type Story = StoryObj<typeof meta> | ||
|
||
export const Default: Story = { | ||
args: { | ||
card: brandsData | ||
} | ||
} |
Oops, something went wrong.